1
Fork 0

Rollup merge of #88497 - m-ou-se:prelude-collision-glob, r=nikomatsakis

Fix prelude collision suggestions for glob imported traits.

Fixes https://github.com/rust-lang/rust/issues/88471

cc `@nikomatsakis`
This commit is contained in:
Mara Bos 2021-08-31 10:41:28 +02:00 committed by GitHub
commit db44069482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 3 deletions

View file

@ -7,7 +7,7 @@ use rustc_hir as hir;
use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::{Adt, Ref, Ty};
use rustc_session::lint::builtin::RUST_2021_PRELUDE_COLLISIONS;
use rustc_span::symbol::kw::Underscore;
use rustc_span::symbol::kw::{Empty, Underscore};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use rustc_trait_selection::infer::InferCtxtExt;
@ -333,7 +333,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.filter_map(|item| if item.ident.name != Underscore { Some(item.ident) } else { None })
.next();
if let Some(any_id) = any_id {
return Some(format!("{}", any_id));
if any_id.name == Empty {
// Glob import, so just use its name.
return None;
} else {
return Some(format!("{}", any_id));
}
}
// All that is left is `_`! We need to use the full path. It doesn't matter which one we pick,