Auto merge of #135278 - tgross35:ignore-std-dep-crates, r=SparrowLii
Exclude dependencies of `std` for diagnostics Currently crates in the sysroot can show up in diagnostic suggestions, such as in https://github.com/rust-lang/rust/issues/135232. To prevent this, duplicate `all_traits` into `visible_traits` which only shows traits in non-private crates. Setting `#![feature(rustc_private)]` overrides this and makes items in private crates visible as well, since `rustc_private` enables use of `std`'s private dependencies. This may be reviewed per-commit. Fixes: https://github.com/rust-lang/rust/issues/135232
This commit is contained in:
commit
8c39ce5b4f
11 changed files with 225 additions and 44 deletions
|
@ -79,8 +79,14 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {
|
|||
// Initialize the collector.
|
||||
let mut items = DiagnosticItems::default();
|
||||
|
||||
// Collect diagnostic items in other crates.
|
||||
for &cnum in tcx.crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)) {
|
||||
// Collect diagnostic items in visible crates.
|
||||
for cnum in tcx
|
||||
.crates(())
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|cnum| tcx.is_user_visible_dep(*cnum))
|
||||
.chain(std::iter::once(LOCAL_CRATE))
|
||||
{
|
||||
for (&name, &def_id) in &tcx.diagnostic_items(cnum).name_to_id {
|
||||
collect_item(tcx, &mut items, name, def_id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue