1// See https://github.com/rust-lang/rust/issues/88442 2// run-rustfix 3// edition:2018 4// check-pass 5#![allow(unused)] 6#![warn(rust_2021_prelude_collisions)] 7 8trait AnnotatableTryInto { 9 fn try_into<T>(self) -> Result<T, Self::Error> 10 where Self: std::convert::TryInto<T> { 11 std::convert::TryInto::try_into(self) 12 } 13} 14 15impl<T> AnnotatableTryInto for T where T: From<u8> {} 16 17fn main() -> Result<(), &'static str> { 18 let x: u64 = 1; 19 AnnotatableTryInto::try_into::<usize>(x).or(Err("foo"))?.checked_sub(1); 20 //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 21 //~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! 22 23 AnnotatableTryInto::try_into::<usize>(x).or(Err("foo"))?; 24 //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021 25 //~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! 26 27 Ok(()) 28} 29