]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-impl-trait/issue-90400-2.rs
Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm
[rust.git] / tests / ui / type-alias-impl-trait / issue-90400-2.rs
1 // Regression test for #90400,
2 // taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836
3
4 #![feature(type_alias_impl_trait)]
5
6 trait Bar {
7     fn bar(&self);
8 }
9
10 trait Baz {
11     fn baz(&self);
12 }
13
14 trait Foo {
15     type FooFn<B>: Baz;
16
17     fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B>;
18 }
19
20 struct MyFoo;
21 impl Foo for MyFoo {
22     type FooFn<B> = impl Baz;
23
24     fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> {
25         MyBaz(bar) //~ ERROR: the trait bound `B: Bar` is not satisfied
26     }
27 }
28
29 struct MyBaz<B: Bar>(B);
30 impl<B: Bar> Baz for MyBaz<B> {
31     fn baz(&self) {}
32 }
33
34 fn main() {
35     let boom: <MyFoo as Foo>::FooFn<u32> = unsafe { core::mem::zeroed() };
36     boom.baz();
37 }