]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rust-2021/future-prelude-collision-turbofish.rs
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
[rust.git] / src / test / ui / rust-2021 / future-prelude-collision-turbofish.rs
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
8 trait 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
15 impl<T> AnnotatableTryInto for T where T: From<u8> {}
16
17 fn main() -> Result<(), &'static str> {
18     let x: u64 = 1;
19     x.try_into::<usize>().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     x.try_into::<usize>().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 }