diff options
| author | Jakob Degen <jakob@degen.com> | 2021-10-24 21:09:52 -0400 |
|---|---|---|
| committer | Jakob Degen <jakob@degen.com> | 2021-10-26 22:17:01 -0400 |
| commit | e91d5ca197b966b841c4e49c921215a69f9d9c19 (patch) | |
| tree | 209fd00a81bb50d07b1db61c1ca4eb16ec35dcc6 /src | |
| parent | 387675366868e19fe1a9542afa2738b8f9ca23de (diff) | |
| download | rust-e91d5ca197b966b841c4e49c921215a69f9d9c19.tar.gz rust-e91d5ca197b966b841c4e49c921215a69f9d9c19.zip | |
Add test checking that Edition 2021 is suggested for .try_into() and fix other test
Diffstat (limited to 'src')
3 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/rust-2021/future-prelude-collision-shadow.stderr b/src/test/ui/rust-2021/future-prelude-collision-shadow.stderr index e4662b430dc..d945b4c94ca 100644 --- a/src/test/ui/rust-2021/future-prelude-collision-shadow.stderr +++ b/src/test/ui/rust-2021/future-prelude-collision-shadow.stderr @@ -15,6 +15,7 @@ LL | fn try_into(self) -> Result<T, Self::Error>; | the method is available for `Rc<u8>` here | = help: items from traits can only be used if the trait is in scope + = note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021 help: consider wrapping the receiver expression with the appropriate type | LL | let _: u32 = Box::new(3u8).try_into().unwrap(); diff --git a/src/test/ui/suggestions/suggest-tryinto-edition-change.rs b/src/test/ui/suggestions/suggest-tryinto-edition-change.rs new file mode 100644 index 00000000000..f60ef587cfa --- /dev/null +++ b/src/test/ui/suggestions/suggest-tryinto-edition-change.rs @@ -0,0 +1,11 @@ +// Make sure that calling `.try_into()` in pre-2021 mentions Edition 2021 change +// edition:2018 + +fn test() { + let i: i16 = 0_i32.try_into().unwrap(); + //~^ ERROR no method named `try_into` found for type `i32` in the current scope + //~| NOTE method not found in `i32` + //~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021 +} + +fn main() {} diff --git a/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr b/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr new file mode 100644 index 00000000000..7915937023c --- /dev/null +++ b/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr @@ -0,0 +1,21 @@ +error[E0599]: no method named `try_into` found for type `i32` in the current scope + --> $DIR/suggest-tryinto-edition-change.rs:5:24 + | +LL | let i: i16 = 0_i32.try_into().unwrap(); + | ^^^^^^^^ method not found in `i32` + | + ::: $SRC_DIR/core/src/convert/mod.rs:LL:COL + | +LL | fn try_into(self) -> Result<T, Self::Error>; + | -------- the method is available for `i32` here + | + = help: items from traits can only be used if the trait is in scope + = note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021 +help: the following trait is implemented but not in scope; perhaps add a `use` for it: + | +LL | use std::convert::TryInto; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. |
