]> git.proxmox.com Git - rustc.git/blame - src/test/ui/suggestions/suggest-tryinto-edition-change.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / suggestions / suggest-tryinto-edition-change.rs
CommitLineData
3c0e092e
XL
1// Make sure that trying to access `TryInto`, `TryFrom`, `FromIterator` in pre-2021 mentions
2// Edition 2021 change
3// edition:2018
4
5fn 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
487cf647 13 //~| NOTE use of undeclared type
3c0e092e
XL
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
487cf647 19 //~| NOTE use of undeclared type
3c0e092e
XL
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
487cf647 25 //~| NOTE use of undeclared type
3c0e092e
XL
26 //~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
27 //~| NOTE 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
28}
29
30fn main() {
31 test();
32}