fix #101749, use . instead of :: when accessing a method of an object

This commit is contained in:
yukang 2022-09-18 15:35:21 +08:00
parent 28a53cdb46
commit fb004e9a95
15 changed files with 218 additions and 66 deletions

View file

@ -1840,13 +1840,16 @@ impl<'a> Resolver<'a> {
(format!("use of undeclared type `{}`", ident), suggestion)
} else {
let suggestion = if ident.name == sym::alloc {
Some((
let mut suggestion = None;
if ident.name == sym::alloc {
suggestion = Some((
vec![],
String::from("add `extern crate alloc` to use the `alloc` crate"),
Applicability::MaybeIncorrect,
))
} else {
}
suggestion = suggestion.or_else(|| {
self.find_similarly_named_module_or_crate(ident.name, &parent_scope.module).map(
|sugg| {
(
@ -1856,7 +1859,7 @@ impl<'a> Resolver<'a> {
)
},
)
};
});
(format!("use of undeclared crate or module `{}`", ident), suggestion)
}
}