mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-25 11:17:13 +00:00
fix: Consider all produced artifacts for proc-macro dylib search
This commit is contained in:
parent
afee0710e1
commit
6b09fbf881
@ -31,7 +31,7 @@ pub enum ProcMacroLoadingError {
|
||||
Disabled,
|
||||
FailedToBuild,
|
||||
ExpectedProcMacroArtifact,
|
||||
MissingDylibPath(Box<[String]>),
|
||||
MissingDylibPath,
|
||||
NotYetBuilt,
|
||||
NoProcMacros,
|
||||
ProcMacroSrvError(Box<str>),
|
||||
@ -42,7 +42,7 @@ impl ProcMacroLoadingError {
|
||||
ProcMacroLoadingError::Disabled | ProcMacroLoadingError::NotYetBuilt => false,
|
||||
ProcMacroLoadingError::ExpectedProcMacroArtifact
|
||||
| ProcMacroLoadingError::FailedToBuild
|
||||
| ProcMacroLoadingError::MissingDylibPath(_)
|
||||
| ProcMacroLoadingError::MissingDylibPath
|
||||
| ProcMacroLoadingError::NoProcMacros
|
||||
| ProcMacroLoadingError::ProcMacroSrvError(_) => true,
|
||||
}
|
||||
@ -58,19 +58,12 @@ impl fmt::Display for ProcMacroLoadingError {
|
||||
}
|
||||
ProcMacroLoadingError::Disabled => write!(f, "proc-macro expansion is disabled"),
|
||||
ProcMacroLoadingError::FailedToBuild => write!(f, "proc-macro failed to build"),
|
||||
ProcMacroLoadingError::MissingDylibPath(candidates) if candidates.is_empty() => {
|
||||
ProcMacroLoadingError::MissingDylibPath => {
|
||||
write!(
|
||||
f,
|
||||
"proc-macro crate built but the dylib path is missing, this indicates a problem with your build system."
|
||||
)
|
||||
}
|
||||
ProcMacroLoadingError::MissingDylibPath(candidates) => {
|
||||
write!(
|
||||
f,
|
||||
"proc-macro crate built but the dylib path is missing, this indicates a problem with your build system. Candidates not considered due to not having a dynamic library extension: {}",
|
||||
candidates.join(", ")
|
||||
)
|
||||
}
|
||||
ProcMacroLoadingError::NotYetBuilt => write!(f, "proc-macro not yet built"),
|
||||
ProcMacroLoadingError::NoProcMacros => {
|
||||
write!(f, "proc macro library has no proc macros")
|
||||
|
@ -35,7 +35,7 @@ pub struct WorkspaceBuildScripts {
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub enum ProcMacroDylibPath {
|
||||
Path(AbsPathBuf),
|
||||
DylibNotFound(Box<[Utf8PathBuf]>),
|
||||
DylibNotFound,
|
||||
NotProcMacro,
|
||||
#[default]
|
||||
NotBuilt,
|
||||
@ -251,7 +251,7 @@ impl WorkspaceBuildScripts {
|
||||
}) {
|
||||
match proc_macro_dylibs.iter().find(|(name, _)| *name == package.name) {
|
||||
Some((_, path)) => ProcMacroDylibPath::Path(path.clone()),
|
||||
_ => ProcMacroDylibPath::DylibNotFound(Box::default()),
|
||||
_ => ProcMacroDylibPath::DylibNotFound,
|
||||
}
|
||||
} else {
|
||||
ProcMacroDylibPath::NotProcMacro
|
||||
@ -386,7 +386,11 @@ impl WorkspaceBuildScripts {
|
||||
if data.proc_macro_dylib_path == ProcMacroDylibPath::NotBuilt {
|
||||
data.proc_macro_dylib_path = ProcMacroDylibPath::NotProcMacro;
|
||||
}
|
||||
if message.target.kind.contains(&cargo_metadata::TargetKind::ProcMacro)
|
||||
if !matches!(data.proc_macro_dylib_path, ProcMacroDylibPath::Path(_))
|
||||
&& message
|
||||
.target
|
||||
.kind
|
||||
.contains(&cargo_metadata::TargetKind::ProcMacro)
|
||||
{
|
||||
data.proc_macro_dylib_path =
|
||||
match message.filenames.iter().find(|file| is_dylib(file)) {
|
||||
@ -394,9 +398,7 @@ impl WorkspaceBuildScripts {
|
||||
let filename = AbsPath::assert(filename);
|
||||
ProcMacroDylibPath::Path(filename.to_owned())
|
||||
}
|
||||
None => ProcMacroDylibPath::DylibNotFound(
|
||||
message.filenames.clone().into_boxed_slice(),
|
||||
),
|
||||
None => ProcMacroDylibPath::DylibNotFound,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -65,6 +65,7 @@ fn rustc_print_cfg(
|
||||
let (sysroot, current_dir) = match config {
|
||||
QueryConfig::Cargo(sysroot, cargo_toml, _) => {
|
||||
let mut cmd = sysroot.tool(Tool::Cargo, cargo_toml.parent(), extra_env);
|
||||
cmd.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly");
|
||||
cmd.args(["rustc", "-Z", "unstable-options"]).args(RUSTC_ARGS);
|
||||
if let Some(target) = target {
|
||||
cmd.args(["--target", target]);
|
||||
|
@ -1639,7 +1639,7 @@ fn add_target_crate_root(
|
||||
match proc_macro_dylib_path {
|
||||
ProcMacroDylibPath::Path(path) => Ok((cargo_name.to_owned(), path.clone())),
|
||||
ProcMacroDylibPath::NotBuilt => Err(ProcMacroLoadingError::NotYetBuilt),
|
||||
ProcMacroDylibPath::NotProcMacro | ProcMacroDylibPath::DylibNotFound(_)
|
||||
ProcMacroDylibPath::NotProcMacro | ProcMacroDylibPath::DylibNotFound
|
||||
if has_errors =>
|
||||
{
|
||||
Err(ProcMacroLoadingError::FailedToBuild)
|
||||
@ -1647,10 +1647,8 @@ fn add_target_crate_root(
|
||||
ProcMacroDylibPath::NotProcMacro => {
|
||||
Err(ProcMacroLoadingError::ExpectedProcMacroArtifact)
|
||||
}
|
||||
ProcMacroDylibPath::DylibNotFound(candidates) => {
|
||||
Err(ProcMacroLoadingError::MissingDylibPath(
|
||||
candidates.iter().map(ToString::to_string).collect(),
|
||||
))
|
||||
ProcMacroDylibPath::DylibNotFound => {
|
||||
Err(ProcMacroLoadingError::MissingDylibPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user