diff options
| author | bors <bors@rust-lang.org> | 2023-03-27 15:17:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-03-27 15:17:47 +0000 |
| commit | 284c1741d6536be6e7d4d4d252c424b90d6f1e45 (patch) | |
| tree | be92fa7eb2afd22bf43ca19a35bd1d57fcefc74a | |
| parent | b99d5eb97315faca04a33bae40bd2fb809ba9d46 (diff) | |
| parent | b03a218b573511d15fd5b398a5c1db1509ab8d59 (diff) | |
| download | rust-284c1741d6536be6e7d4d4d252c424b90d6f1e45.tar.gz rust-284c1741d6536be6e7d4d4d252c424b90d6f1e45.zip | |
Auto merge of #14419 - Veykril:proc-ids, r=Veykril
fix: Fix proc-macro paths using incorrect CrateId's for `rust-project.json` workspaces
| -rw-r--r-- | crates/hir-def/src/body/lower.rs | 8 | ||||
| -rw-r--r-- | crates/project-model/src/workspace.rs | 66 |
2 files changed, 36 insertions, 38 deletions
diff --git a/crates/hir-def/src/body/lower.rs b/crates/hir-def/src/body/lower.rs index 3fb3e4f68dd..886d71ebeda 100644 --- a/crates/hir-def/src/body/lower.rs +++ b/crates/hir-def/src/body/lower.rs @@ -1083,9 +1083,9 @@ impl ExprCollector<'_> { .collect(), } } - // FIXME: rustfmt removes this label if it is a block and not a loop - ast::Pat::LiteralPat(lit) => 'b: loop { - break if let Some(ast_lit) = lit.literal() { + #[rustfmt::skip] // https://github.com/rust-lang/rustfmt/issues/5676 + ast::Pat::LiteralPat(lit) => 'b: { + if let Some(ast_lit) = lit.literal() { let mut hir_lit: Literal = ast_lit.kind().into(); if lit.minus_token().is_some() { let Some(h) = hir_lit.negate() else { @@ -1099,7 +1099,7 @@ impl ExprCollector<'_> { Pat::Lit(expr_id) } else { Pat::Missing - }; + } }, ast::Pat::RestPat(_) => { // `RestPat` requires special handling and should not be mapped diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index fa966f70aa4..916447fdffa 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -704,15 +704,7 @@ fn project_json_to_crate_graph( }) .map(|(crate_id, krate, file_id)| { let env = krate.env.clone().into_iter().collect(); - if let Some(path) = krate.proc_macro_dylib_path.clone() { - proc_macros.insert( - crate_id, - Some(( - krate.display_name.as_ref().map(|it| it.canonical_name().to_owned()), - path, - )), - ); - } + let target_cfgs = match krate.target.as_deref() { Some(target) => cfg_cache .entry(target) @@ -722,31 +714,37 @@ fn project_json_to_crate_graph( let mut cfg_options = CfgOptions::default(); cfg_options.extend(target_cfgs.iter().chain(krate.cfg.iter()).cloned()); - ( - crate_id, - crate_graph.add_crate_root( - file_id, - krate.edition, - krate.display_name.clone(), - krate.version.clone(), - cfg_options.clone(), - cfg_options, - env, - krate.is_proc_macro, - if krate.display_name.is_some() { - CrateOrigin::CratesIo { - repo: krate.repository.clone(), - name: krate - .display_name - .clone() - .map(|n| n.canonical_name().to_string()), - } - } else { - CrateOrigin::CratesIo { repo: None, name: None } - }, - target_layout.clone(), - ), - ) + let crate_graph_crate_id = crate_graph.add_crate_root( + file_id, + krate.edition, + krate.display_name.clone(), + krate.version.clone(), + cfg_options.clone(), + cfg_options, + env, + krate.is_proc_macro, + if krate.display_name.is_some() { + CrateOrigin::CratesIo { + repo: krate.repository.clone(), + name: krate.display_name.clone().map(|n| n.canonical_name().to_string()), + } + } else { + CrateOrigin::CratesIo { repo: None, name: None } + }, + target_layout.clone(), + ); + if krate.is_proc_macro { + if let Some(path) = krate.proc_macro_dylib_path.clone() { + proc_macros.insert( + crate_graph_crate_id, + Some(( + krate.display_name.as_ref().map(|it| it.canonical_name().to_owned()), + path, + )), + ); + } + } + (crate_id, crate_graph_crate_id) }) .collect(); |
