Skip to content

Commit faaec86

Browse files
bors[bot]Veykril
andauthored
Merge #11964
11964: internal: Show more project building errors to the user r=Veykril a=Veykril Something very fishy is going on with the `rustc_workspace` handling, which caused this bug to only manifest in the `std` library but not other library crate... So there is either a bug there or just the fact that we seem to add duplicate dependencies (I think this is what we are doing with this right?) might be tripping something up somewhere. cc https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Rust-analyzer.20use.20inside.20stdlib bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 5d25d24 + 24af94b commit faaec86

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

crates/hir_expand/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fn parse_macro_expansion(
263263
.collect::<Vec<_>>()
264264
.join("\n");
265265

266-
tracing::warn!(
266+
tracing::debug!(
267267
"fail on macro_parse: (reason: {:?} macro_call: {:#}) parents: {}",
268268
err,
269269
node.value,

crates/project_model/src/workspace.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ fn cargo_to_crate_graph(
663663
load,
664664
&mut crate_graph,
665665
&cfg_options,
666+
override_cfg,
666667
load_proc_macro,
667668
&mut pkg_to_lib_crate,
668669
&public_deps,
@@ -723,6 +724,7 @@ fn handle_rustc_crates(
723724
load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
724725
crate_graph: &mut CrateGraph,
725726
cfg_options: &CfgOptions,
727+
override_cfg: &CfgOverrides,
726728
load_proc_macro: &mut dyn FnMut(&str, &AbsPath) -> Vec<ProcMacro>,
727729
pkg_to_lib_crate: &mut FxHashMap<la_arena::Idx<crate::PackageData>, CrateId>,
728730
public_deps: &SysrootPublicDeps,
@@ -749,6 +751,28 @@ fn handle_rustc_crates(
749751
for dep in &rustc_workspace[pkg].dependencies {
750752
queue.push_back(dep.pkg);
751753
}
754+
755+
let mut cfg_options = cfg_options;
756+
let mut replaced_cfg_options;
757+
758+
let overrides = match override_cfg {
759+
CfgOverrides::Wildcard(cfg_diff) => Some(cfg_diff),
760+
CfgOverrides::Selective(cfg_overrides) => cfg_overrides.get(&cargo[pkg].name),
761+
};
762+
763+
if let Some(overrides) = overrides {
764+
// FIXME: this is sort of a hack to deal with #![cfg(not(test))] vanishing such as seen
765+
// in ed25519_dalek (#7243), and libcore (#9203) (although you only hit that one while
766+
// working on rust-lang/rust as that's the only time it appears outside sysroot).
767+
//
768+
// A more ideal solution might be to reanalyze crates based on where the cursor is and
769+
// figure out the set of cfgs that would have to apply to make it active.
770+
771+
replaced_cfg_options = cfg_options.clone();
772+
replaced_cfg_options.apply_diff(overrides.clone());
773+
cfg_options = &replaced_cfg_options;
774+
};
775+
752776
for &tgt in rustc_workspace[pkg].targets.iter() {
753777
if rustc_workspace[tgt].kind != TargetKind::Lib {
754778
continue;

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl GlobalState {
190190
// NOTE: don't count blocking select! call as a loop-turn time
191191
let _p = profile::span("GlobalState::handle_event");
192192

193-
tracing::info!("handle_event({:?})", event);
193+
tracing::debug!("handle_event({:?})", event);
194194
let task_queue_len = self.task_pool.handle.len();
195195
if task_queue_len > 0 {
196196
tracing::info!("task queue len: {}", task_queue_len);

0 commit comments

Comments
 (0)