suggestion for typoed crate or module
avoid suggesting the same name sort candidates fix a message use `opt_def_id` instead of `def_id` move `find_similarly_named_module_or_crate` to rustc_resolve/src/diagnostics.rs
This commit is contained in:
parent
d7539a6af0
commit
f819e6d59c
5 changed files with 109 additions and 1 deletions
|
@ -2555,7 +2555,22 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
(format!("use of undeclared type `{}`", ident), suggestion)
|
||||
} else {
|
||||
(format!("use of undeclared crate or module `{}`", ident), None)
|
||||
(
|
||||
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())],
|
||||
String::from(
|
||||
"there is a crate or module with a similar name",
|
||||
),
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
}),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
let parent = path[i - 1].ident.name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue