Skip to content

Commit 080e703

Browse files
authored
Merge pull request #21484 from Veykril/push-uoxwkwottnqn
fix: Do not show sysroot dependencies in symbol search
2 parents 54dd939 + fcdcf05 commit 080e703

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

crates/base-db/src/input.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ pub enum LangCrateOrigin {
221221
ProcMacro,
222222
Std,
223223
Test,
224+
Dependency,
224225
Other,
225226
}
226227

@@ -245,7 +246,7 @@ impl fmt::Display for LangCrateOrigin {
245246
LangCrateOrigin::ProcMacro => "proc_macro",
246247
LangCrateOrigin::Std => "std",
247248
LangCrateOrigin::Test => "test",
248-
LangCrateOrigin::Other => "other",
249+
LangCrateOrigin::Other | LangCrateOrigin::Dependency => "other",
249250
};
250251
f.write_str(text)
251252
}

crates/ide-db/src/symbol_index.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use std::{
2727
ops::ControlFlow,
2828
};
2929

30-
use base_db::{LibraryRoots, LocalRoots, RootQueryDb, SourceRootId};
30+
use base_db::{CrateOrigin, LangCrateOrigin, LibraryRoots, LocalRoots, RootQueryDb, SourceRootId};
3131
use fst::{Automaton, Streamer, raw::IndexedValue};
3232
use hir::{
3333
Crate, Module,
@@ -446,6 +446,12 @@ impl<'db> SymbolIndex<'db> {
446446
{
447447
continue;
448448
}
449+
if let CrateOrigin::Lang(LangCrateOrigin::Dependency | LangCrateOrigin::Other) =
450+
krate.origin(db)
451+
{
452+
// don't show dependencies of the sysroot
453+
continue;
454+
}
449455
collector.push_crate_root(krate);
450456
}
451457

crates/project-model/src/workspace.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,8 @@ fn project_json_to_crate_graph(
11611161
name: Some(name.canonical_name().to_owned()),
11621162
}
11631163
}
1164+
} else if is_sysroot {
1165+
CrateOrigin::Lang(LangCrateOrigin::Dependency)
11641166
} else {
11651167
CrateOrigin::Local { repo: None, name: None }
11661168
},
@@ -1294,6 +1296,8 @@ fn cargo_to_crate_graph(
12941296
name: Some(Symbol::intern(&pkg_data.name)),
12951297
}
12961298
}
1299+
} else if cargo.is_sysroot() {
1300+
CrateOrigin::Lang(LangCrateOrigin::Dependency)
12971301
} else {
12981302
CrateOrigin::Library {
12991303
repo: pkg_data.repository.clone(),
@@ -1717,7 +1721,7 @@ fn extend_crate_graph_with_sysroot(
17171721
!matches!(lang_crate, LangCrateOrigin::Test | LangCrateOrigin::Alloc),
17181722
)),
17191723
LangCrateOrigin::ProcMacro => libproc_macro = Some(cid),
1720-
LangCrateOrigin::Other => (),
1724+
LangCrateOrigin::Other | LangCrateOrigin::Dependency => (),
17211725
}
17221726
}
17231727
}

0 commit comments

Comments
 (0)