]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/suggest-tryinto-edition-change.rs
Add examples for `pointer::mask`
[rust.git] / src / test / ui / suggestions / suggest-tryinto-edition-change.rs
1 // Make sure that trying to access `TryInto`, `TryFrom`, `FromIterator` in pre-2021 mentions
2 // Edition 2021 change
3 // edition:2018
4
5 fn test() {
6     let _i: i16 = 0_i32.try_into().unwrap();
7     //~^ ERROR no method named `try_into` found for type `i32` in the current scope
8     //~| NOTE method not found in `i32`
9     //~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
10
11     let _i: i16 = TryFrom::try_from(0_i32).unwrap();
12     //~^ ERROR failed to resolve: use of undeclared type
13     //~| NOTE not found in this scope
14     //~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
15     //~| NOTE 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
16
17     let _i: i16 = TryInto::try_into(0_i32).unwrap();
18     //~^ ERROR failed to resolve: use of undeclared type
19     //~| NOTE not found in this scope
20     //~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
21     //~| NOTE 'core::convert::TryInto' is included in the prelude starting in Edition 2021
22
23     let _v: Vec<_> = FromIterator::from_iter(&[1]);
24     //~^ ERROR failed to resolve: use of undeclared type
25     //~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
26     //~| NOTE 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
27 }
28
29 fn main() {
30     test();
31 }