Skip to content

Commit 51e4fba

Browse files
committed
Fix prelude collision suggestions for glob imported traits.
1 parent 13edc17 commit 51e4fba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/rustc_typeck/src/check/method/prelude2021.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir as hir;
77
use rustc_middle::ty::subst::InternalSubsts;
88
use rustc_middle::ty::{Adt, Ref, Ty};
99
use rustc_session::lint::builtin::RUST_2021_PRELUDE_COLLISIONS;
10-
use rustc_span::symbol::kw::Underscore;
10+
use rustc_span::symbol::kw::{Empty, Underscore};
1111
use rustc_span::symbol::{sym, Ident};
1212
use rustc_span::Span;
1313
use rustc_trait_selection::infer::InferCtxtExt;
@@ -322,7 +322,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
322322
.filter_map(|item| if item.ident.name != Underscore { Some(item.ident) } else { None })
323323
.next();
324324
if let Some(any_id) = any_id {
325-
return Some(format!("{}", any_id));
325+
if any_id.name == Empty {
326+
// Glob import, so just use its name.
327+
return None;
328+
} else {
329+
return Some(format!("{}", any_id));
330+
}
326331
}
327332

328333
// All that is left is `_`! We need to use the full path. It doesn't matter which one we pick,

0 commit comments

Comments
 (0)