Skip to content

Commit 45c1218

Browse files
committed
fix tests
1 parent dab9160 commit 45c1218

11 files changed

+159
-36
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ 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 {
338+
let Some(following_seg) = following_seg
339+
{
339340
let candidates = self.r.lookup_import_candidates(
340341
segment.ident,
341342
Namespace::TypeNS,
@@ -1803,7 +1804,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
18031804
if let Some(following_seg) = following_seg {
18041805
names.retain(|suggestion| match suggestion.res {
18051806
Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, _) => {
1806-
// this is not totally accurate, but mostly works
1807+
// FIXME: this is not totally accurate, but mostly works
18071808
suggestion.candidate != following_seg.ident.name
18081809
}
18091810
Res::Def(DefKind::Mod, def_id) => self.r.get_module(def_id).map_or_else(

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// edition:2018
2+
#![feature(decl_macro)]
3+
4+
macro a() {
5+
extern crate core as my_core;
6+
mod v {
7+
// Early resolution.
8+
use my_core; //~ ERROR unresolved import `my_core`
9+
}
10+
mod u {
11+
// Late resolution.
12+
fn f() { my_core::mem::drop(0); }
13+
//~^ ERROR failed to resolve: use of undeclared crate or module `my_core`
14+
}
15+
}
16+
17+
a!();
18+
19+
mod v {
20+
// Early resolution.
21+
use my_core; //~ ERROR unresolved import `my_core`
22+
}
23+
mod u {
24+
// Late resolution.
25+
fn f() { my_core::mem::drop(0); }
26+
//~^ ERROR failed to resolve: use of undeclared crate or module `my_core`
27+
}
28+
29+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error[E0432]: unresolved import `my_core`
2+
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:21:9
3+
|
4+
LL | use my_core;
5+
| ^^^^^^^ no external crate `my_core`
6+
7+
error[E0432]: unresolved import `my_core`
8+
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:8:13
9+
|
10+
LL | use my_core;
11+
| ^^^^^^^ no external crate `my_core`
12+
...
13+
LL | a!();
14+
| ---- in this macro invocation
15+
|
16+
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
19+
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:12:18
20+
|
21+
LL | fn f() { my_core::mem::drop(0); }
22+
| ^^^^^^^ use of undeclared crate or module `my_core`
23+
...
24+
LL | a!();
25+
| ---- in this macro invocation
26+
|
27+
= help: consider importing one of these items:
28+
std::mem
29+
core::mem
30+
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
31+
32+
error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
33+
--> $DIR/extern-prelude-from-opaque-fail-2018.rs:25:14
34+
|
35+
LL | fn f() { my_core::mem::drop(0); }
36+
| ^^^^^^^ 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+
|
49+
50+
error: aborting due to 4 previous errors
51+
52+
Some errors have detailed explanations: E0432, E0433.
53+
For more information about an error, try `rustc --explain E0432`.

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

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// edition:2015
12
#![feature(decl_macro)]
23

34
macro a() {

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

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0432]: unresolved import `my_core`
2-
--> $DIR/extern-prelude-from-opaque-fail.rs:20:9
2+
--> $DIR/extern-prelude-from-opaque-fail.rs:21:9
33
|
44
LL | use my_core;
55
| ^^^^^^^ no `my_core` in the root
66

77
error[E0432]: unresolved import `my_core`
8-
--> $DIR/extern-prelude-from-opaque-fail.rs:7:13
8+
--> $DIR/extern-prelude-from-opaque-fail.rs:8:13
99
|
1010
LL | use my_core;
1111
| ^^^^^^^ no `my_core` in the root
@@ -16,21 +16,33 @@ LL | a!();
1616
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
1717

1818
error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
19-
--> $DIR/extern-prelude-from-opaque-fail.rs:11:18
19+
--> $DIR/extern-prelude-from-opaque-fail.rs:12:18
2020
|
2121
LL | fn f() { my_core::mem::drop(0); }
2222
| ^^^^^^^ use of undeclared crate or module `my_core`
2323
...
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`
30-
--> $DIR/extern-prelude-from-opaque-fail.rs:24:14
32+
--> $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/macros/builtin-prelude-no-accidents.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `vec`
2626
LL | type B = vec::Vec<u8>;
2727
| ^^^ use of undeclared crate or module `vec`
2828
|
29-
help: a struct with a similar name exists
30-
|
31-
LL | type B = Vec::Vec<u8>;
32-
| ~~~
3329
help: consider importing this module
3430
|
3531
LL + use std::vec;

tests/ui/resolve/112590-2.fixed

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// run-rustfix
2+
use std::vec;
3+
4+
use std::sync::atomic::AtomicBool;
5+
6+
fn main() {
7+
let _t: Vec<i32> = Vec::new(); //~ ERROR failed to resolve
8+
type _B = vec::Vec::<u8>; //~ ERROR failed to resolve
9+
let _t = AtomicBool::new(true); //~ ERROR failed to resolve
10+
}

tests/ui/resolve/112590-2.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
// run-rustfix
12
fn main() {
2-
let _t = vec::new(); //~ ERROR failed to resolve
3-
type B = vec::Vec::<u8>; //~ ERROR failed to resolve
4-
let _t = std::sync_error::atomic::AtomicBool; //~ ERROR failed to resolve
3+
let _t: Vec<i32> = vec::new(); //~ ERROR failed to resolve
4+
type _B = vec::Vec::<u8>; //~ ERROR failed to resolve
5+
let _t = std::sync_error::atomic::AtomicBool::new(true); //~ ERROR failed to resolve
56
}

tests/ui/resolve/112590-2.stderr

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
error[E0433]: failed to resolve: use of undeclared crate or module `vec`
2-
--> $DIR/112590-2.rs:3:14
2+
--> $DIR/112590-2.rs:4:15
33
|
4-
LL | type B = vec::Vec::<u8>;
5-
| ^^^ use of undeclared crate or module `vec`
4+
LL | type _B = vec::Vec::<u8>;
5+
| ^^^ use of undeclared crate or module `vec`
66
|
77
help: consider importing this module
88
|
99
LL + use std::vec;
1010
|
1111

1212
error[E0433]: failed to resolve: could not find `sync_error` in `std`
13-
--> $DIR/112590-2.rs:4:19
13+
--> $DIR/112590-2.rs:5:19
1414
|
15-
LL | let _t = std::sync_error::atomic::AtomicBool;
15+
LL | let _t = std::sync_error::atomic::AtomicBool::new(true);
1616
| ^^^^^^^^^^ could not find `sync_error` in `std`
1717
|
18-
help: consider importing this module
18+
help: consider importing this struct
1919
|
20-
LL + use std::sync::atomic;
20+
LL + use std::sync::atomic::AtomicBool;
2121
|
22-
help: if you import `atomic`, refer to it directly
22+
help: if you import `AtomicBool`, refer to it directly
2323
|
24-
LL - let _t = std::sync_error::atomic::AtomicBool;
25-
LL + let _t = atomic::AtomicBool;
24+
LL - let _t = std::sync_error::atomic::AtomicBool::new(true);
25+
LL + let _t = AtomicBool::new(true);
2626
|
2727

2828
error[E0433]: failed to resolve: use of undeclared crate or module `vec`
29-
--> $DIR/112590-2.rs:2:14
29+
--> $DIR/112590-2.rs:3:24
3030
|
31-
LL | let _t = vec::new();
32-
| ^^^
33-
| |
34-
| use of undeclared crate or module `vec`
35-
| help: a struct with a similar name exists (notice the capitalization): `Vec`
31+
LL | let _t: Vec<i32> = vec::new();
32+
| ^^^
33+
| |
34+
| use of undeclared crate or module `vec`
35+
| help: a struct with a similar name exists (notice the capitalization): `Vec`
3636

3737
error: aborting due to 3 previous errors
3838

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

+18-7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ help: there is a crate or module with a similar name
2020
LL | use bar::bar;
2121
| ~~~
2222

23+
error[E0433]: failed to resolve: use of undeclared crate or module `bar`
24+
--> $DIR/crate-or-module-typo.rs:6:20
25+
|
26+
LL | pub fn bar() { bar::baz(); }
27+
| ^^^ use of undeclared crate or module `bar`
28+
|
29+
help: consider importing this module
30+
|
31+
LL + use crate::bar;
32+
|
33+
2334
error[E0433]: failed to resolve: use of undeclared crate or module `st`
2435
--> $DIR/crate-or-module-typo.rs:14:10
2536
|
@@ -30,16 +41,16 @@ help: there is a crate or module with a similar name
3041
|
3142
LL | bar: std::cell::Cell<bool>
3243
| ~~~
33-
34-
error[E0433]: failed to resolve: use of undeclared crate or module `bar`
35-
--> $DIR/crate-or-module-typo.rs:6:20
44+
help: consider importing one of these items
3645
|
37-
LL | pub fn bar() { bar::baz(); }
38-
| ^^^ use of undeclared crate or module `bar`
46+
LL + use core::cell;
3947
|
40-
help: consider importing this module
48+
LL + use std::cell;
4149
|
42-
LL + use crate::bar;
50+
help: if you import `cell`, refer to it directly
51+
|
52+
LL - bar: st::cell::Cell<bool>
53+
LL + bar: cell::Cell<bool>
4354
|
4455

4556
error: aborting due to 4 previous errors

0 commit comments

Comments
 (0)