Skip to content

Commit 284c174

Browse files
committed
Auto merge of rust-lang#14419 - Veykril:proc-ids, r=Veykril
fix: Fix proc-macro paths using incorrect CrateId's for `rust-project.json` workspaces
2 parents b99d5eb + b03a218 commit 284c174

File tree

2 files changed

+36
-38
lines changed

2 files changed

+36
-38
lines changed

crates/hir-def/src/body/lower.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,9 @@ impl ExprCollector<'_> {
10831083
.collect(),
10841084
}
10851085
}
1086-
// FIXME: rustfmt removes this label if it is a block and not a loop
1087-
ast::Pat::LiteralPat(lit) => 'b: loop {
1088-
break if let Some(ast_lit) = lit.literal() {
1086+
#[rustfmt::skip] // https://github.com/rust-lang/rustfmt/issues/5676
1087+
ast::Pat::LiteralPat(lit) => 'b: {
1088+
if let Some(ast_lit) = lit.literal() {
10891089
let mut hir_lit: Literal = ast_lit.kind().into();
10901090
if lit.minus_token().is_some() {
10911091
let Some(h) = hir_lit.negate() else {
@@ -1099,7 +1099,7 @@ impl ExprCollector<'_> {
10991099
Pat::Lit(expr_id)
11001100
} else {
11011101
Pat::Missing
1102-
};
1102+
}
11031103
},
11041104
ast::Pat::RestPat(_) => {
11051105
// `RestPat` requires special handling and should not be mapped

crates/project-model/src/workspace.rs

+32-34
Original file line numberDiff line numberDiff line change
@@ -704,15 +704,7 @@ fn project_json_to_crate_graph(
704704
})
705705
.map(|(crate_id, krate, file_id)| {
706706
let env = krate.env.clone().into_iter().collect();
707-
if let Some(path) = krate.proc_macro_dylib_path.clone() {
708-
proc_macros.insert(
709-
crate_id,
710-
Some((
711-
krate.display_name.as_ref().map(|it| it.canonical_name().to_owned()),
712-
path,
713-
)),
714-
);
715-
}
707+
716708
let target_cfgs = match krate.target.as_deref() {
717709
Some(target) => cfg_cache
718710
.entry(target)
@@ -722,31 +714,37 @@ fn project_json_to_crate_graph(
722714

723715
let mut cfg_options = CfgOptions::default();
724716
cfg_options.extend(target_cfgs.iter().chain(krate.cfg.iter()).cloned());
725-
(
726-
crate_id,
727-
crate_graph.add_crate_root(
728-
file_id,
729-
krate.edition,
730-
krate.display_name.clone(),
731-
krate.version.clone(),
732-
cfg_options.clone(),
733-
cfg_options,
734-
env,
735-
krate.is_proc_macro,
736-
if krate.display_name.is_some() {
737-
CrateOrigin::CratesIo {
738-
repo: krate.repository.clone(),
739-
name: krate
740-
.display_name
741-
.clone()
742-
.map(|n| n.canonical_name().to_string()),
743-
}
744-
} else {
745-
CrateOrigin::CratesIo { repo: None, name: None }
746-
},
747-
target_layout.clone(),
748-
),
749-
)
717+
let crate_graph_crate_id = crate_graph.add_crate_root(
718+
file_id,
719+
krate.edition,
720+
krate.display_name.clone(),
721+
krate.version.clone(),
722+
cfg_options.clone(),
723+
cfg_options,
724+
env,
725+
krate.is_proc_macro,
726+
if krate.display_name.is_some() {
727+
CrateOrigin::CratesIo {
728+
repo: krate.repository.clone(),
729+
name: krate.display_name.clone().map(|n| n.canonical_name().to_string()),
730+
}
731+
} else {
732+
CrateOrigin::CratesIo { repo: None, name: None }
733+
},
734+
target_layout.clone(),
735+
);
736+
if krate.is_proc_macro {
737+
if let Some(path) = krate.proc_macro_dylib_path.clone() {
738+
proc_macros.insert(
739+
crate_graph_crate_id,
740+
Some((
741+
krate.display_name.as_ref().map(|it| it.canonical_name().to_owned()),
742+
path,
743+
)),
744+
);
745+
}
746+
}
747+
(crate_id, crate_graph_crate_id)
750748
})
751749
.collect();
752750

0 commit comments

Comments
 (0)