add a suggestion about undeclared alloc
module
This commit is contained in:
parent
ff0e14829e
commit
acb9f9ba38
4 changed files with 39 additions and 9 deletions
|
@ -2523,19 +2523,29 @@ impl<'a> Resolver<'a> {
|
|||
} else {
|
||||
(
|
||||
format!("use of undeclared crate or module `{}`", ident),
|
||||
self.find_similarly_named_module_or_crate(
|
||||
ident.name,
|
||||
&parent_scope.module,
|
||||
)
|
||||
.map(|sugg| {
|
||||
(
|
||||
vec![(ident.span, sugg.to_string())],
|
||||
if ident.name == sym::alloc {
|
||||
Some((
|
||||
vec![],
|
||||
String::from(
|
||||
"there is a crate or module with a similar name",
|
||||
"add `extern crate alloc` to use the builtin `alloc` module",
|
||||
),
|
||||
Applicability::MaybeIncorrect,
|
||||
))
|
||||
} else {
|
||||
self.find_similarly_named_module_or_crate(
|
||||
ident.name,
|
||||
&parent_scope.module,
|
||||
)
|
||||
}),
|
||||
.map(|sugg| {
|
||||
(
|
||||
vec![(ident.span, sugg.to_string())],
|
||||
String::from(
|
||||
"there is a crate or module with a similar name",
|
||||
),
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue