From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/type-alias-impl-trait/issue-90400-2.rs | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/ui/type-alias-impl-trait/issue-90400-2.rs (limited to 'tests/ui/type-alias-impl-trait/issue-90400-2.rs') diff --git a/tests/ui/type-alias-impl-trait/issue-90400-2.rs b/tests/ui/type-alias-impl-trait/issue-90400-2.rs new file mode 100644 index 000000000..4c6e893c1 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/issue-90400-2.rs @@ -0,0 +1,37 @@ +// Regression test for #90400, +// taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836 + +#![feature(type_alias_impl_trait)] + +trait Bar { + fn bar(&self); +} + +trait Baz { + fn baz(&self); +} + +trait Foo { + type FooFn: Baz; + + fn foo(&self, bar: B) -> Self::FooFn; +} + +struct MyFoo; +impl Foo for MyFoo { + type FooFn = impl Baz; + + fn foo(&self, bar: B) -> Self::FooFn { + MyBaz(bar) //~ ERROR: the trait bound `B: Bar` is not satisfied + } +} + +struct MyBaz(B); +impl Baz for MyBaz { + fn baz(&self) {} +} + +fn main() { + let boom: ::FooFn = unsafe { core::mem::zeroed() }; + boom.baz(); +} -- cgit v1.2.3