mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-05 11:33:04 +00:00
Add test checking that Edition 2021 is suggested for .try_into() and fix other test
This commit is contained in:
parent
3876753668
commit
e91d5ca197
@ -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();
|
||||
|
11
src/test/ui/suggestions/suggest-tryinto-edition-change.rs
Normal file
11
src/test/ui/suggestions/suggest-tryinto-edition-change.rs
Normal file
@ -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() {}
|
@ -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`.
|
Loading…
Reference in New Issue
Block a user