adjust smart_resolve_partial_mod_path_errors

This commit is contained in:
yukang 2023-07-07 10:19:30 +08:00
parent 9763472e2b
commit 37b40e592a
5 changed files with 48 additions and 2 deletions

View File

@ -335,8 +335,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
following_seg: Option<&Segment>,
) -> Vec<ImportSuggestion> {
if let Some(segment) = prefix_path.last() &&
let Some(following_seg) = following_seg &&
prefix_path.len() == 1
let Some(following_seg) = following_seg
{
let candidates = self.r.lookup_import_candidates(
segment.ident,

View File

@ -13,6 +13,15 @@ LL | let _: u8 = ::core::default::Default();
| ^^^^ maybe a missing crate `core`?
|
= help: consider adding `extern crate core` to use the `core` crate
help: consider importing this module
|
LL + use std::default;
|
help: if you import `default`, refer to it directly
|
LL - let _: u8 = ::core::default::Default();
LL + let _: u8 = default::Default();
|
error: aborting due to 2 previous errors

View File

@ -24,6 +24,9 @@ LL | fn f() { my_core::mem::drop(0); }
LL | a!();
| ---- in this macro invocation
|
= help: consider importing one of these items:
std::mem
core::mem
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
@ -31,6 +34,18 @@ error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
|
LL | fn f() { my_core::mem::drop(0); }
| ^^^^^^^ use of undeclared crate or module `my_core`
|
help: consider importing one of these items
|
LL + use core::mem;
|
LL + use std::mem;
|
help: if you import `mem`, refer to it directly
|
LL - fn f() { my_core::mem::drop(0); }
LL + fn f() { mem::drop(0); }
|
error: aborting due to 4 previous errors

View File

@ -24,6 +24,8 @@ LL | fn f() { my_core::mem::drop(0); }
LL | a!();
| ---- in this macro invocation
|
= help: consider importing this module:
my_core::mem
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
@ -31,6 +33,16 @@ error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
|
LL | fn f() { my_core::mem::drop(0); }
| ^^^^^^^ use of undeclared crate or module `my_core`
|
help: consider importing this module
|
LL + use my_core::mem;
|
help: if you import `mem`, refer to it directly
|
LL - fn f() { my_core::mem::drop(0); }
LL + fn f() { mem::drop(0); }
|
error: aborting due to 4 previous errors

View File

@ -30,6 +30,17 @@ help: there is a crate or module with a similar name
|
LL | bar: std::cell::Cell<bool>
| ~~~
help: consider importing one of these items
|
LL + use core::cell;
|
LL + use std::cell;
|
help: if you import `cell`, refer to it directly
|
LL - bar: st::cell::Cell<bool>
LL + bar: cell::Cell<bool>
|
error[E0433]: failed to resolve: use of undeclared crate or module `bar`
--> $DIR/crate-or-module-typo.rs:6:20