diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs index fdaebeaa93..0bf4fbdfbd 100644 --- a/crates/base-db/src/input.rs +++ b/crates/base-db/src/input.rs @@ -31,7 +31,7 @@ pub enum ProcMacroLoadingError { Disabled, FailedToBuild, ExpectedProcMacroArtifact, - MissingDylibPath(Box<[String]>), + MissingDylibPath, NotYetBuilt, NoProcMacros, ProcMacroSrvError(Box), @@ -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") diff --git a/crates/project-model/src/build_dependencies.rs b/crates/project-model/src/build_dependencies.rs index 9888984934..5bea74bed7 100644 --- a/crates/project-model/src/build_dependencies.rs +++ b/crates/project-model/src/build_dependencies.rs @@ -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, }; } }); diff --git a/crates/project-model/src/toolchain_info/rustc_cfg.rs b/crates/project-model/src/toolchain_info/rustc_cfg.rs index 6e06e88bf7..ab69c8e0e4 100644 --- a/crates/project-model/src/toolchain_info/rustc_cfg.rs +++ b/crates/project-model/src/toolchain_info/rustc_cfg.rs @@ -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]); diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index f53c0ae7dc..5b36e10fd6 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -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) } } }