1
Fork 0

diagnostics: Differentiate between edition meanings of ::foo in resolve diagnostics (for bare ::foo)

This commit is contained in:
Manish Goregaokar 2021-03-07 13:53:45 -08:00
parent 66ec64ccf3
commit ac7f9ccb6f
8 changed files with 72 additions and 8 deletions

View file

@ -2450,10 +2450,16 @@ impl<'a> Resolver<'a> {
}
} else {
let parent = path[i - 1].ident.name;
let parent = if parent == kw::PathRoot {
"crate root".to_owned()
} else {
format!("`{}`", parent)
let parent = match parent {
// ::foo is mounted at the crate root for 2015, and is the extern
// prelude for 2018+
kw::PathRoot if self.session.edition() > Edition::Edition2015 => {
"the list of imported crates".to_owned()
}
kw::PathRoot | kw::Crate => "the crate root".to_owned(),
_ => {
format!("`{}`", parent)
}
};
let mut msg = format!("could not find `{}` in {}", ident, parent);