Skip to content

Commit 1d72508

Browse files
committed
fix tests
1 parent c74121e commit 1d72508

18 files changed

+127
-40
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,19 +1391,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13911391
crate_path.push(ast::PathSegment::path_root(rustc_span::DUMMY_SP));
13921392
}
13931393
crate_path.push(ast::PathSegment::from_ident(ident));
1394-
let suggest_imports = self.lookup_import_candidates_from_module(
1394+
1395+
suggestions.extend(self.lookup_import_candidates_from_module(
13951396
lookup_ident,
13961397
namespace,
13971398
parent_scope,
13981399
crate_root,
13991400
crate_path,
14001401
&filter_fn,
1401-
);
1402-
for item in suggest_imports {
1403-
if suggestions.iter().all(|sugg| sugg.did != item.did) {
1404-
suggestions.push(item);
1405-
}
1406-
}
1402+
));
14071403
}
14081404
}
14091405
}

tests/run-make/extern-alias/Makefile

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/run-make/extern-alias/main.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ LL | fn f() { my_core::mem::drop(0); }
2424
LL | a!();
2525
| ---- in this macro invocation
2626
|
27-
= help: consider importing this module:
27+
= help: consider importing one of these items:
2828
core::mem
29+
std::mem
2930
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
3031

3132
error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
@@ -34,10 +35,12 @@ error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
3435
LL | fn f() { my_core::mem::drop(0); }
3536
| ^^^^^^^ use of undeclared crate or module `my_core`
3637
|
37-
help: consider importing this module
38+
help: consider importing one of these items
3839
|
3940
LL + use core::mem;
4041
|
42+
LL + use std::mem;
43+
|
4144
help: if you import `mem`, refer to it directly
4245
|
4346
LL - fn f() { my_core::mem::drop(0); }

tests/ui/imports/issue-121168-2.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ edition: 2018
2+
//@ compile-flags: --extern issue_121168_extern
3+
//@ aux-build: issue-121168-extern.rs
4+
5+
extern crate issue_121168_extern as nice_crate_name;
6+
7+
fn use_foo_from_another_crate_without_importing_it_first() {
8+
//use nice_crate_name::Foo;
9+
let _: Foo<i32> = todo!(); //~ ERROR cannot find type `Foo` in this scope
10+
}
11+
12+
fn main() {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0412]: cannot find type `Foo` in this scope
2+
--> $DIR/issue-121168-2.rs:9:12
3+
|
4+
LL | let _: Foo<i32> = todo!();
5+
| ^^^ not found in this scope
6+
|
7+
help: consider importing one of these items
8+
|
9+
LL + use crate::nice_crate_name::Foo;
10+
|
11+
LL + use issue_121168_extern::Foo;
12+
|
13+
14+
error: aborting due to 1 previous error
15+
16+
For more information about this error, try `rustc --explain E0412`.

tests/ui/imports/issue-121168-3.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ edition: 2015
2+
//@ compile-flags: --extern issue_121168_extern
3+
//@ aux-build: issue-121168-extern.rs
4+
5+
extern crate issue_121168_extern as nice_crate_name;
6+
7+
fn use_foo_from_another_crate_without_importing_it_first() {
8+
//use nice_crate_name::Foo;
9+
let _: Foo<i32> = todo!(); //~ ERROR cannot find type `Foo` in this scope
10+
}
11+
12+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0412]: cannot find type `Foo` in this scope
2+
--> $DIR/issue-121168-3.rs:9:12
3+
|
4+
LL | let _: Foo<i32> = todo!();
5+
| ^^^ not found in this scope
6+
|
7+
help: consider importing this struct
8+
|
9+
LL + use nice_crate_name::Foo;
10+
|
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0412`.

tests/ui/imports/issue-121168.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ edition: 2021
2+
//@ compile-flags: --extern issue_121168_extern
3+
//@ aux-build: issue-121168-extern.rs
4+
5+
extern crate issue_121168_extern as nice_crate_name;
6+
7+
fn use_foo_from_another_crate_without_importing_it_first() {
8+
//use nice_crate_name::Foo;
9+
let _: Foo<i32> = todo!(); //~ ERROR cannot find type `Foo` in this scope
10+
}
11+
12+
fn main() {}

tests/ui/imports/issue-121168.stderr

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0412]: cannot find type `Foo` in this scope
2+
--> $DIR/issue-121168.rs:9:12
3+
|
4+
LL | let _: Foo<i32> = todo!();
5+
| ^^^ not found in this scope
6+
|
7+
help: consider importing one of these items
8+
|
9+
LL + use crate::nice_crate_name::Foo;
10+
|
11+
LL + use issue_121168_extern::Foo;
12+
|
13+
14+
error: aborting due to 1 previous error
15+
16+
For more information about this error, try `rustc --explain E0412`.

tests/ui/imports/issue-56125.stderr

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ help: consider importing one of these items instead
88
|
99
LL | use ::issue_56125::issue_56125;
1010
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
11+
LL | use ::issue_56125::last_segment::issue_56125;
12+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13+
LL | use ::issue_56125::non_last_segment::non_last_segment::issue_56125;
14+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1115
LL | use crate::m3::last_segment::issue_56125;
1216
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13-
LL | use crate::m3::non_last_segment::non_last_segment::issue_56125;
14-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17+
and 1 other candidate
1518

1619
error[E0659]: `issue_56125` is ambiguous
1720
--> $DIR/issue-56125.rs:6:9

tests/ui/mir/issue-106062.stderr

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ error[E0573]: expected type, found variant `Ok`
22
--> $DIR/issue-106062.rs:15:64
33
|
44
LL | async fn connection_handler(handler: impl Sized) -> Result<Ok, std::io::Error> {
5-
| ^^
6-
| |
7-
| not a type
8-
| help: try using the variant's enum: `core::result::Result`
5+
| ^^ not a type
6+
|
7+
help: try using the variant's enum
8+
|
9+
LL | async fn connection_handler(handler: impl Sized) -> Result<core::result::Result, std::io::Error> {
10+
| ~~~~~~~~~~~~~~~~~~~~
11+
LL | async fn connection_handler(handler: impl Sized) -> Result<std::result::Result, std::io::Error> {
12+
| ~~~~~~~~~~~~~~~~~~~
913

1014
error: aborting due to 1 previous error
1115

tests/ui/suggestions/core-std-import-order-issue-83564.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// For some reason, Rust 2018 or higher is required to reproduce the bug.
55

66
fn main() {
7-
//~^ HELP consider importing this type alias
7+
//~^ HELP consider importing one of these items
88
let _x = NonZeroU32::new(5).unwrap();
99
//~^ ERROR failed to resolve: use of undeclared type `NonZeroU32`
1010
}

tests/ui/suggestions/core-std-import-order-issue-83564.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ error[E0433]: failed to resolve: use of undeclared type `NonZeroU32`
44
LL | let _x = NonZeroU32::new(5).unwrap();
55
| ^^^^^^^^^^ use of undeclared type `NonZeroU32`
66
|
7-
help: consider importing this type alias
7+
help: consider importing one of these items
88
|
99
LL + use core::num::NonZeroU32;
1010
|
11+
LL + use std::num::NonZeroU32;
12+
|
1113

1214
error: aborting due to 1 previous error
1315

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ help: there is a crate or module with a similar name
3030
|
3131
LL | bar: std::cell::Cell<bool>
3232
| ~~~
33-
help: consider importing this module
33+
help: consider importing one of these items
3434
|
3535
LL + use core::cell;
3636
|
37+
LL + use std::cell;
38+
|
3739
help: if you import `cell`, refer to it directly
3840
|
3941
LL - bar: st::cell::Cell<bool>

tests/ui/suggestions/suggest-tryinto-edition-change.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ fn test() {
1111
let _i: i16 = TryFrom::try_from(0_i32).unwrap();
1212
//~^ ERROR failed to resolve: use of undeclared type
1313
//~| NOTE use of undeclared type
14+
//~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
1415
//~| NOTE 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
1516

1617
let _i: i16 = TryInto::try_into(0_i32).unwrap();
1718
//~^ ERROR failed to resolve: use of undeclared type
1819
//~| NOTE use of undeclared type
20+
//~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
1921
//~| NOTE 'core::convert::TryInto' is included in the prelude starting in Edition 2021
2022

2123
let _v: Vec<_> = FromIterator::from_iter(&[1]);
2224
//~^ ERROR failed to resolve: use of undeclared type
2325
//~| NOTE use of undeclared type
26+
//~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
2427
//~| NOTE 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
2528
}
2629

tests/ui/suggestions/suggest-tryinto-edition-change.stderr

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,47 @@ LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap();
55
| ^^^^^^^ use of undeclared type `TryFrom`
66
|
77
= note: 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
8-
help: consider importing this trait
8+
= note: 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
9+
help: consider importing one of these items
910
|
1011
LL + use core::convert::TryFrom;
1112
|
13+
LL + use std::convert::TryFrom;
14+
|
1215

1316
error[E0433]: failed to resolve: use of undeclared type `TryInto`
14-
--> $DIR/suggest-tryinto-edition-change.rs:16:19
17+
--> $DIR/suggest-tryinto-edition-change.rs:17:19
1518
|
1619
LL | let _i: i16 = TryInto::try_into(0_i32).unwrap();
1720
| ^^^^^^^ use of undeclared type `TryInto`
1821
|
1922
= note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021
20-
help: consider importing this trait
23+
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
24+
help: consider importing one of these items
2125
|
2226
LL + use core::convert::TryInto;
2327
|
28+
LL + use std::convert::TryInto;
29+
|
2430

2531
error[E0433]: failed to resolve: use of undeclared type `FromIterator`
26-
--> $DIR/suggest-tryinto-edition-change.rs:21:22
32+
--> $DIR/suggest-tryinto-edition-change.rs:23:22
2733
|
2834
LL | let _v: Vec<_> = FromIterator::from_iter(&[1]);
2935
| ^^^^^^^^^^^^ use of undeclared type `FromIterator`
3036
|
3137
= note: 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
38+
= note: 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
3239
help: a trait with a similar name exists
3340
|
3441
LL | let _v: Vec<_> = IntoIterator::from_iter(&[1]);
3542
| ~~~~~~~~~~~~
36-
help: consider importing this trait
43+
help: consider importing one of these items
3744
|
3845
LL + use core::iter::FromIterator;
3946
|
47+
LL + use std::iter::FromIterator;
48+
|
4049

4150
error[E0599]: no method named `try_into` found for type `i32` in the current scope
4251
--> $DIR/suggest-tryinto-edition-change.rs:6:25

0 commit comments

Comments
 (0)