Skip to content

Commit 37b40e5

Browse files
committed
adjust smart_resolve_partial_mod_path_errors
1 parent 9763472 commit 37b40e5

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
335335
following_seg: Option<&Segment>,
336336
) -> Vec<ImportSuggestion> {
337337
if let Some(segment) = prefix_path.last() &&
338-
let Some(following_seg) = following_seg &&
339-
prefix_path.len() == 1
338+
let Some(following_seg) = following_seg
340339
{
341340
let candidates = self.r.lookup_import_candidates(
342341
segment.ident,

tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ LL | let _: u8 = ::core::default::Default();
1313
| ^^^^ maybe a missing crate `core`?
1414
|
1515
= help: consider adding `extern crate core` to use the `core` crate
16+
help: consider importing this module
17+
|
18+
LL + use std::default;
19+
|
20+
help: if you import `default`, refer to it directly
21+
|
22+
LL - let _: u8 = ::core::default::Default();
23+
LL + let _: u8 = default::Default();
24+
|
1625

1726
error: aborting due to 2 previous errors
1827

tests/ui/hygiene/extern-prelude-from-opaque-fail-2018.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,28 @@ LL | fn f() { my_core::mem::drop(0); }
2424
LL | a!();
2525
| ---- in this macro invocation
2626
|
27+
= help: consider importing one of these items:
28+
std::mem
29+
core::mem
2730
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
2831

2932
error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
3033
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:25:14
3134
|
3235
LL | fn f() { my_core::mem::drop(0); }
3336
| ^^^^^^^ use of undeclared crate or module `my_core`
37+
|
38+
help: consider importing one of these items
39+
|
40+
LL + use core::mem;
41+
|
42+
LL + use std::mem;
43+
|
44+
help: if you import `mem`, refer to it directly
45+
|
46+
LL - fn f() { my_core::mem::drop(0); }
47+
LL + fn f() { mem::drop(0); }
48+
|
3449

3550
error: aborting due to 4 previous errors
3651

tests/ui/hygiene/extern-prelude-from-opaque-fail.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,25 @@ LL | fn f() { my_core::mem::drop(0); }
2424
LL | a!();
2525
| ---- in this macro invocation
2626
|
27+
= help: consider importing this module:
28+
my_core::mem
2729
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
2830

2931
error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
3032
--> $DIR/extern-prelude-from-opaque-fail.rs:25:14
3133
|
3234
LL | fn f() { my_core::mem::drop(0); }
3335
| ^^^^^^^ use of undeclared crate or module `my_core`
36+
|
37+
help: consider importing this module
38+
|
39+
LL + use my_core::mem;
40+
|
41+
help: if you import `mem`, refer to it directly
42+
|
43+
LL - fn f() { my_core::mem::drop(0); }
44+
LL + fn f() { mem::drop(0); }
45+
|
3446

3547
error: aborting due to 4 previous errors
3648

tests/ui/suggestions/crate-or-module-typo.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ help: there is a crate or module with a similar name
3030
|
3131
LL | bar: std::cell::Cell<bool>
3232
| ~~~
33+
help: consider importing one of these items
34+
|
35+
LL + use core::cell;
36+
|
37+
LL + use std::cell;
38+
|
39+
help: if you import `cell`, refer to it directly
40+
|
41+
LL - bar: st::cell::Cell<bool>
42+
LL + bar: cell::Cell<bool>
43+
|
3344

3445
error[E0433]: failed to resolve: use of undeclared crate or module `bar`
3546
--> $DIR/crate-or-module-typo.rs:6:20

0 commit comments

Comments
 (0)