Skip to content

Commit 6b09fbf

Browse files
committed
fix: Consider all produced artifacts for proc-macro dylib search
1 parent afee071 commit 6b09fbf

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

crates/base-db/src/input.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub enum ProcMacroLoadingError {
3131
Disabled,
3232
FailedToBuild,
3333
ExpectedProcMacroArtifact,
34-
MissingDylibPath(Box<[String]>),
34+
MissingDylibPath,
3535
NotYetBuilt,
3636
NoProcMacros,
3737
ProcMacroSrvError(Box<str>),
@@ -42,7 +42,7 @@ impl ProcMacroLoadingError {
4242
ProcMacroLoadingError::Disabled | ProcMacroLoadingError::NotYetBuilt => false,
4343
ProcMacroLoadingError::ExpectedProcMacroArtifact
4444
| ProcMacroLoadingError::FailedToBuild
45-
| ProcMacroLoadingError::MissingDylibPath(_)
45+
| ProcMacroLoadingError::MissingDylibPath
4646
| ProcMacroLoadingError::NoProcMacros
4747
| ProcMacroLoadingError::ProcMacroSrvError(_) => true,
4848
}
@@ -58,19 +58,12 @@ impl fmt::Display for ProcMacroLoadingError {
5858
}
5959
ProcMacroLoadingError::Disabled => write!(f, "proc-macro expansion is disabled"),
6060
ProcMacroLoadingError::FailedToBuild => write!(f, "proc-macro failed to build"),
61-
ProcMacroLoadingError::MissingDylibPath(candidates) if candidates.is_empty() => {
61+
ProcMacroLoadingError::MissingDylibPath => {
6262
write!(
6363
f,
6464
"proc-macro crate built but the dylib path is missing, this indicates a problem with your build system."
6565
)
6666
}
67-
ProcMacroLoadingError::MissingDylibPath(candidates) => {
68-
write!(
69-
f,
70-
"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: {}",
71-
candidates.join(", ")
72-
)
73-
}
7467
ProcMacroLoadingError::NotYetBuilt => write!(f, "proc-macro not yet built"),
7568
ProcMacroLoadingError::NoProcMacros => {
7669
write!(f, "proc macro library has no proc macros")

crates/project-model/src/build_dependencies.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct WorkspaceBuildScripts {
3535
#[derive(Debug, Clone, Default, PartialEq, Eq)]
3636
pub enum ProcMacroDylibPath {
3737
Path(AbsPathBuf),
38-
DylibNotFound(Box<[Utf8PathBuf]>),
38+
DylibNotFound,
3939
NotProcMacro,
4040
#[default]
4141
NotBuilt,
@@ -251,7 +251,7 @@ impl WorkspaceBuildScripts {
251251
}) {
252252
match proc_macro_dylibs.iter().find(|(name, _)| *name == package.name) {
253253
Some((_, path)) => ProcMacroDylibPath::Path(path.clone()),
254-
_ => ProcMacroDylibPath::DylibNotFound(Box::default()),
254+
_ => ProcMacroDylibPath::DylibNotFound,
255255
}
256256
} else {
257257
ProcMacroDylibPath::NotProcMacro
@@ -386,17 +386,19 @@ impl WorkspaceBuildScripts {
386386
if data.proc_macro_dylib_path == ProcMacroDylibPath::NotBuilt {
387387
data.proc_macro_dylib_path = ProcMacroDylibPath::NotProcMacro;
388388
}
389-
if message.target.kind.contains(&cargo_metadata::TargetKind::ProcMacro)
389+
if !matches!(data.proc_macro_dylib_path, ProcMacroDylibPath::Path(_))
390+
&& message
391+
.target
392+
.kind
393+
.contains(&cargo_metadata::TargetKind::ProcMacro)
390394
{
391395
data.proc_macro_dylib_path =
392396
match message.filenames.iter().find(|file| is_dylib(file)) {
393397
Some(filename) => {
394398
let filename = AbsPath::assert(filename);
395399
ProcMacroDylibPath::Path(filename.to_owned())
396400
}
397-
None => ProcMacroDylibPath::DylibNotFound(
398-
message.filenames.clone().into_boxed_slice(),
399-
),
401+
None => ProcMacroDylibPath::DylibNotFound,
400402
};
401403
}
402404
});

crates/project-model/src/toolchain_info/rustc_cfg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn rustc_print_cfg(
6565
let (sysroot, current_dir) = match config {
6666
QueryConfig::Cargo(sysroot, cargo_toml, _) => {
6767
let mut cmd = sysroot.tool(Tool::Cargo, cargo_toml.parent(), extra_env);
68+
cmd.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly");
6869
cmd.args(["rustc", "-Z", "unstable-options"]).args(RUSTC_ARGS);
6970
if let Some(target) = target {
7071
cmd.args(["--target", target]);

crates/project-model/src/workspace.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,18 +1639,16 @@ fn add_target_crate_root(
16391639
match proc_macro_dylib_path {
16401640
ProcMacroDylibPath::Path(path) => Ok((cargo_name.to_owned(), path.clone())),
16411641
ProcMacroDylibPath::NotBuilt => Err(ProcMacroLoadingError::NotYetBuilt),
1642-
ProcMacroDylibPath::NotProcMacro | ProcMacroDylibPath::DylibNotFound(_)
1642+
ProcMacroDylibPath::NotProcMacro | ProcMacroDylibPath::DylibNotFound
16431643
if has_errors =>
16441644
{
16451645
Err(ProcMacroLoadingError::FailedToBuild)
16461646
}
16471647
ProcMacroDylibPath::NotProcMacro => {
16481648
Err(ProcMacroLoadingError::ExpectedProcMacroArtifact)
16491649
}
1650-
ProcMacroDylibPath::DylibNotFound(candidates) => {
1651-
Err(ProcMacroLoadingError::MissingDylibPath(
1652-
candidates.iter().map(ToString::to_string).collect(),
1653-
))
1650+
ProcMacroDylibPath::DylibNotFound => {
1651+
Err(ProcMacroLoadingError::MissingDylibPath)
16541652
}
16551653
}
16561654
}

0 commit comments

Comments
 (0)