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 9struct Generic<'a, U>(&'a U); 10 11trait MyFromIter { 12 fn from_iter(_: i32) -> Self; 13} 14 15impl MyFromIter for Generic<'static, i32> { 16 fn from_iter(_: i32) -> Self { 17 todo!() 18 } 19} 20 21impl std::iter::FromIterator<i32> for Generic<'static, i32> { 22 fn from_iter<T: IntoIterator<Item = i32>>(_: T) -> Self { 23 todo!() 24 } 25} 26 27fn main() { 28 <Generic<'_, _> as MyFromIter>::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> as MyFromIter>::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::<'_, _> as MyFromIter>::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