Skip to content

Commit cb336f1

Browse files
committed
Reverting switching test to no_std and adjust output after rebase.
1 parent e41ef36 commit cb336f1

File tree

3 files changed

+41
-31
lines changed

3 files changed

+41
-31
lines changed

compiler/rustc_resolve/src/diagnostics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,6 @@ crate fn show_candidates(
18231823
let instead = if instead { " instead" } else { "" };
18241824
let mut msg = format!("consider importing {} {}{}", determiner, kind, instead);
18251825

1826-
// Issue notes
18271826
for note in accessible_path_strings.iter().map(|cand| cand.3.as_ref()).flatten() {
18281827
err.note(note);
18291828
}

src/test/ui/suggestions/suggest-tryinto-edition-change.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@
22
// Edition 2021 change
33
// edition:2018
44

5-
// We mark this no_std to avoid emitting suggestions for both `std` and `core` traits. These were
6-
// inconsistently ordered between CI and at least one local build, causing test failures.
7-
#![no_std]
8-
#![crate_type = "lib"]
9-
10-
pub fn test() {
11-
let _i: Result<i16, _> = 0_i32.try_into();
5+
fn test() {
6+
let _i: i16 = 0_i32.try_into().unwrap();
127
//~^ ERROR no method named `try_into` found for type `i32` in the current scope
138
//~| NOTE method not found in `i32`
14-
//~| NOTE 'core::convert::TryInto' is included in the prelude starting in Edition 2021
9+
//~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
1510

16-
let _i: Result<i16, _> = TryFrom::try_from(0_i32);
11+
let _i: i16 = TryFrom::try_from(0_i32).unwrap();
1712
//~^ ERROR failed to resolve: use of undeclared type
1813
//~| NOTE not found in this scope
14+
//~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
1915
//~| NOTE 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
2016

21-
let _i: Result<i16, _> = TryInto::try_into(0_i32);
17+
let _i: i16 = TryInto::try_into(0_i32).unwrap();
2218
//~^ ERROR failed to resolve: use of undeclared type
2319
//~| NOTE not found in this scope
20+
//~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
2421
//~| NOTE 'core::convert::TryInto' is included in the prelude starting in Edition 2021
2522

26-
let _i: () = FromIterator::from_iter(core::iter::empty());
23+
let _v: Vec<_> = FromIterator::from_iter(&[1]);
2724
//~^ ERROR failed to resolve: use of undeclared type
25+
//~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
2826
//~| NOTE 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
2927
}
28+
29+
fn main() {
30+
test();
31+
}

src/test/ui/suggestions/suggest-tryinto-edition-change.stderr

+28-19
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,73 @@
11
error[E0433]: failed to resolve: use of undeclared type `TryFrom`
2-
--> $DIR/suggest-tryinto-edition-change.rs:16:30
2+
--> $DIR/suggest-tryinto-edition-change.rs:11:19
33
|
4-
LL | let _i: Result<i16, _> = TryFrom::try_from(0_i32);
5-
| ^^^^^^^ not found in this scope
4+
LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap();
5+
| ^^^^^^^ not found in this scope
66
|
7+
= note: 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
78
= note: 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
8-
help: consider importing this trait
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:21:30
17+
--> $DIR/suggest-tryinto-edition-change.rs:17:19
1518
|
16-
LL | let _i: Result<i16, _> = TryInto::try_into(0_i32);
17-
| ^^^^^^^ not found in this scope
19+
LL | let _i: i16 = TryInto::try_into(0_i32).unwrap();
20+
| ^^^^^^^ not found in this scope
1821
|
22+
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
1923
= note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021
20-
help: consider importing this trait
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:26:18
32+
--> $DIR/suggest-tryinto-edition-change.rs:23:22
2733
|
28-
LL | let _i: () = FromIterator::from_iter(core::iter::empty());
29-
| ^^^^^^^^^^^^
34+
LL | let _v: Vec<_> = FromIterator::from_iter(&[1]);
35+
| ^^^^^^^^^^^^
3036
|
3137
::: $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
3238
|
3339
LL | pub trait IntoIterator {
3440
| ---------------------- similarly named trait `IntoIterator` defined here
3541
|
42+
= note: 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
3643
= note: 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
3744
help: a trait with a similar name exists
3845
|
39-
LL | let _i: () = IntoIterator::from_iter(core::iter::empty());
40-
| ~~~~~~~~~~~~
41-
help: consider importing this trait
46+
LL | let _v: Vec<_> = IntoIterator::from_iter(&[1]);
47+
| ~~~~~~~~~~~~
48+
help: consider importing one of these items
4249
|
4350
LL | use core::iter::FromIterator;
4451
|
52+
LL | use std::iter::FromIterator;
53+
|
4554

4655
error[E0599]: no method named `try_into` found for type `i32` in the current scope
47-
--> $DIR/suggest-tryinto-edition-change.rs:11:36
56+
--> $DIR/suggest-tryinto-edition-change.rs:6:25
4857
|
49-
LL | let _i: Result<i16, _> = 0_i32.try_into();
50-
| ^^^^^^^^ method not found in `i32`
58+
LL | let _i: i16 = 0_i32.try_into().unwrap();
59+
| ^^^^^^^^ method not found in `i32`
5160
|
5261
::: $SRC_DIR/core/src/convert/mod.rs:LL:COL
5362
|
5463
LL | fn try_into(self) -> Result<T, Self::Error>;
5564
| -------- the method is available for `i32` here
5665
|
5766
= help: items from traits can only be used if the trait is in scope
58-
= note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021
67+
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
5968
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
6069
|
61-
LL | use core::convert::TryInto;
70+
LL | use std::convert::TryInto;
6271
|
6372

6473
error: aborting due to 4 previous errors

0 commit comments

Comments
 (0)