Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions tools/rust_analyzer/aquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn consolidate_crate_specs(crate_specs: Vec<CrateSpec>) -> anyhow::Result<BT
// generated crate-spec in both the fastbuild and opt-exec configuration.
// Prefer proc macro paths with an opt-exec component in the path.
if let Some(dylib_path) = spec.proc_macro_dylib_path.as_ref() {
const OPT_PATH_COMPONENT: &str = "-opt-exec-";
const OPT_PATH_COMPONENT: &str = "-opt-exec";
if dylib_path.contains(OPT_PATH_COMPONENT) {
existing.proc_macro_dylib_path.replace(dylib_path.clone());
}
Expand Down Expand Up @@ -508,7 +508,7 @@ mod test {

#[test]
fn consolidate_proc_macro_prefer_exec() {
// proc macro crates should prefer the -opt-exec- path which is always generated
// proc macro crates should prefer the -opt-exec path which is always generated
// during builds where it is used, while the fastbuild version would only be built
// when explicitly building that target.
let crate_specs = vec![
Expand Down Expand Up @@ -580,6 +580,71 @@ mod test {
}
}

#[test]
fn consolidate_proc_macro_prefer_unsuffixed_exec() {
let crate_specs = vec![
CrateSpec {
aliases: BTreeMap::new(),
crate_id: "ID-myproc_macro.rs".into(),
display_name: "myproc_macro".into(),
edition: "2018".into(),
root_module: "myproc_macro.rs".into(),
is_workspace_member: true,
deps: BTreeSet::new(),
proc_macro_dylib_path: None,
source: None,
cfg: vec!["test".into(), "debug_assertions".into()],
env: BTreeMap::new(),
target: "wasm32-unknown-unknown".into(),
crate_type: CrateType::ProcMacro,
is_test: false,
build: None,
},
CrateSpec {
aliases: BTreeMap::new(),
crate_id: "ID-myproc_macro.rs".into(),
display_name: "myproc_macro".into(),
edition: "2018".into(),
root_module: "myproc_macro.rs".into(),
is_workspace_member: true,
deps: BTreeSet::new(),
proc_macro_dylib_path: Some(
"bazel-out/k8-opt-exec/bin/myproc_macro/libmyproc_macro-12345.so".into(),
),
source: None,
cfg: vec!["test".into(), "debug_assertions".into()],
env: BTreeMap::new(),
target: "x86_64-unknown-linux-gnu".into(),
crate_type: CrateType::ProcMacro,
is_test: false,
build: None,
},
];

assert_eq!(
consolidate_crate_specs(crate_specs).unwrap(),
BTreeSet::from([CrateSpec {
aliases: BTreeMap::new(),
crate_id: "ID-myproc_macro.rs".into(),
display_name: "myproc_macro".into(),
edition: "2018".into(),
root_module: "myproc_macro.rs".into(),
is_workspace_member: true,
deps: BTreeSet::new(),
proc_macro_dylib_path: Some(
"bazel-out/k8-opt-exec/bin/myproc_macro/libmyproc_macro-12345.so".into(),
),
source: None,
cfg: vec!["test".into(), "debug_assertions".into()],
env: BTreeMap::new(),
target: "wasm32-unknown-unknown".into(),
crate_type: CrateType::ProcMacro,
is_test: false,
build: None,
}])
);
}

#[test]
fn consolidate_spec_with_aliases() {
let crate_specs = vec![
Expand Down
Loading