diff options
| author | yukang <moorekang@gmail.com> | 2022-09-18 15:35:21 +0800 |
|---|---|---|
| committer | yukang <moorekang@gmail.com> | 2022-12-03 22:41:12 +0800 |
| commit | fb004e9a95793b7672d55b2984d65d4ac00a3cfc (patch) | |
| tree | 033e66ea5bd1771498488df7520e37976531d7e3 /compiler/rustc_resolve/src/diagnostics.rs | |
| parent | 28a53cdb4695b71cb9ee39959df88542056479cd (diff) | |
| download | rust-fb004e9a95793b7672d55b2984d65d4ac00a3cfc.tar.gz rust-fb004e9a95793b7672d55b2984d65d4ac00a3cfc.zip | |
fix #101749, use . instead of :: when accessing a method of an object
Diffstat (limited to 'compiler/rustc_resolve/src/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index bc3a710e84b..f6b6cf3a94c 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -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) } } |
