]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rust-2021/future-prelude-collision-unneeded.rs
Rollup merge of #99479 - Enselic:import-can-be-without-id, r=camelid
[rust.git] / src / test / ui / rust-2021 / future-prelude-collision-unneeded.rs
1 // edition:2018
2 // check-pass
3 #![allow(unused)]
4 #![deny(rust_2021_prelude_collisions)]
5
6 struct S;
7
8 impl S {
9     fn try_into(self) -> S {
10         S
11     }
12 }
13
14 struct X;
15
16 trait Hey {
17     fn from_iter(_: i32) -> Self;
18 }
19
20 impl Hey for X {
21     fn from_iter(_: i32) -> Self {
22         X
23     }
24 }
25
26 struct Y<T>(T);
27
28 impl Hey for Y<i32> {
29     fn from_iter(_: i32) -> Self {
30         Y(0)
31     }
32 }
33
34 struct Z<T>(T);
35
36 impl Hey for Z<i32> {
37     fn from_iter(_: i32) -> Self {
38         Z(0)
39     }
40 }
41
42 impl std::iter::FromIterator<u32> for Z<u32> {
43     fn from_iter<T: IntoIterator<Item = u32>>(_: T) -> Self {
44         todo!()
45     }
46 }
47
48 fn main() {
49     // See https://github.com/rust-lang/rust/issues/86633
50     let s = S;
51     let s2 = s.try_into();
52
53     // Check that we do not issue suggestions for types that do not implement `FromIter`.
54     //
55     // See https://github.com/rust-lang/rust/issues/86902
56     X::from_iter(1);
57     Y::from_iter(1);
58     Y::<i32>::from_iter(1);
59     Z::<i32>::from_iter(1);
60 }