From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/mir/issue-75053.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/ui/mir/issue-75053.rs (limited to 'tests/ui/mir/issue-75053.rs') diff --git a/tests/ui/mir/issue-75053.rs b/tests/ui/mir/issue-75053.rs new file mode 100644 index 000000000..cb56eaa0b --- /dev/null +++ b/tests/ui/mir/issue-75053.rs @@ -0,0 +1,49 @@ +// compile-flags: -Z mir-opt-level=3 + +#![feature(type_alias_impl_trait, rustc_attrs)] + +use std::marker::PhantomData; + +trait MyIndex { + type O; + fn my_index(self) -> Self::O; +} +trait MyFrom: Sized { + type Error; + fn my_from(value: T) -> Result; +} + +trait F {} +impl F for () {} +type DummyT = impl F; +fn _dummy_t() -> DummyT {} + +struct Phantom1(PhantomData); +struct Phantom2(PhantomData); +struct Scope(Phantom2>); + +impl Scope { + fn new() -> Self { + unimplemented!() + } +} + +impl MyFrom> for Phantom1 { + type Error = (); + fn my_from(_: Phantom2) -> Result { + unimplemented!() + } +} + +impl>>, U> MyIndex> for Scope { + type O = T; + fn my_index(self) -> Self::O { + MyFrom::my_from(self.0).ok().unwrap() + } +} + +#[rustc_error] +fn main() { + //~^ ERROR + let _pos: Phantom1> = Scope::new().my_index(); +} -- cgit v1.2.3