Skip to content

Commit ee560eb

Browse files
committed
Use visible_crates rather than crates for solving and diagnostics
For places where we don't want stdlib-private crates to be accessible, use `.visible_crates()` rather than `.crates()`. The current effect is that items in stdlib-private crates will no longer show up in diagnostics related to trait selection. Fixes: #135232
1 parent 401b2ad commit ee560eb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ impl<'tcx> TyCtxt<'tcx> {
20802080

20812081
pub fn all_traits(self) -> impl Iterator<Item = DefId> + 'tcx {
20822082
iter::once(LOCAL_CRATE)
2083-
.chain(self.crates(()).iter().copied())
2083+
.chain(self.visible_crates(()).iter().copied())
20842084
.flat_map(move |cnum| self.traits(cnum).iter().copied())
20852085
}
20862086

compiler/rustc_passes/src/diagnostic_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {
8080
let mut items = DiagnosticItems::default();
8181

8282
// Collect diagnostic items in other crates.
83-
for &cnum in tcx.crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)) {
83+
for &cnum in tcx.visible_crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)) {
8484
for (&name, &def_id) in &tcx.diagnostic_items(cnum).name_to_id {
8585
collect_item(tcx, &mut items, name, def_id);
8686
}

0 commit comments

Comments
 (0)