1 // test for https://github.com/rust-lang/rust/issues/86940
2 // run-rustfix
3 // edition:2018
4 // check-pass
5 #![warn(rust_2021_prelude_collisions)]
6 #![allow(dead_code)]
7 #![allow(unused_imports)]
8 
9 struct Generic<'a, U>(&'a U);
10 
11 trait MyFromIter {
from_iter(_: i32) -> Self12     fn from_iter(_: i32) -> Self;
13 }
14 
15 impl MyFromIter for Generic<'static, i32> {
from_iter(_: i32) -> Self16     fn from_iter(_: i32) -> Self {
17         todo!()
18     }
19 }
20 
21 impl std::iter::FromIterator<i32> for Generic<'static, i32> {
from_iter<T: IntoIterator<Item = i32>>(_: T) -> Self22     fn from_iter<T: IntoIterator<Item = i32>>(_: T) -> Self {
23         todo!()
24     }
25 }
26 
main()27 fn main() {
28     Generic::from_iter(1);
29     //~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
30     //~| this is accepted in the current edition (Rust 2018)
31     Generic::<'static, i32>::from_iter(1);
32     //~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
33     //~| this is accepted in the current edition (Rust 2018)
34     Generic::<'_, _>::from_iter(1);
35     //~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
36     //~| this is accepted in the current edition (Rust 2018)
37 }
38