Skip to content

Commit e91d5ca

Browse files
committed
Add test checking that Edition 2021 is suggested for .try_into() and fix other test
1 parent 3876753 commit e91d5ca

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/test/ui/rust-2021/future-prelude-collision-shadow.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ LL | fn try_into(self) -> Result<T, Self::Error>;
1515
| the method is available for `Rc<u8>` here
1616
|
1717
= help: items from traits can only be used if the trait is in scope
18+
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
1819
help: consider wrapping the receiver expression with the appropriate type
1920
|
2021
LL | let _: u32 = Box::new(3u8).try_into().unwrap();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Make sure that calling `.try_into()` in pre-2021 mentions Edition 2021 change
2+
// edition:2018
3+
4+
fn test() {
5+
let i: i16 = 0_i32.try_into().unwrap();
6+
//~^ ERROR no method named `try_into` found for type `i32` in the current scope
7+
//~| NOTE method not found in `i32`
8+
//~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
9+
}
10+
11+
fn main() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0599]: no method named `try_into` found for type `i32` in the current scope
2+
--> $DIR/suggest-tryinto-edition-change.rs:5:24
3+
|
4+
LL | let i: i16 = 0_i32.try_into().unwrap();
5+
| ^^^^^^^^ method not found in `i32`
6+
|
7+
::: $SRC_DIR/core/src/convert/mod.rs:LL:COL
8+
|
9+
LL | fn try_into(self) -> Result<T, Self::Error>;
10+
| -------- the method is available for `i32` here
11+
|
12+
= help: items from traits can only be used if the trait is in scope
13+
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
14+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
15+
|
16+
LL | use std::convert::TryInto;
17+
|
18+
19+
error: aborting due to previous error
20+
21+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)