File tree 4 files changed +106
-0
lines changed
src/test/ui/type-alias-impl-trait
4 files changed +106
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Regression test for #90400,
2
+ // taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836
3
+
4
+ #![ feature( generic_associated_types) ]
5
+ #![ feature( type_alias_impl_trait) ]
6
+
7
+ trait Bar {
8
+ fn bar ( & self ) ;
9
+ }
10
+
11
+ trait Foo {
12
+ type FooFn < B > : FnOnce ( ) ;
13
+
14
+ fn foo < B : Bar > ( & self , bar : B ) -> Self :: FooFn < B > ;
15
+ }
16
+
17
+ struct MyFoo ;
18
+
19
+ impl Foo for MyFoo {
20
+ type FooFn < B > = impl FnOnce ( ) ;
21
+
22
+ fn foo < B : Bar > ( & self , bar : B ) -> Self :: FooFn < B > {
23
+ move || bar. bar ( ) //~ ERROR: the trait bound `B: Bar` is not satisfied
24
+ }
25
+ }
26
+
27
+ fn main ( ) {
28
+ let boom: <MyFoo as Foo >:: FooFn < u32 > = unsafe { core:: mem:: zeroed ( ) } ;
29
+ boom ( ) ;
30
+ }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `B: Bar` is not satisfied
2
+ --> $DIR/issue-90400-1.rs:23:9
3
+ |
4
+ LL | move || bar.bar()
5
+ | ^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `B`
6
+ |
7
+ note: required by a bound in `<MyFoo as Foo>::foo`
8
+ --> $DIR/issue-90400-1.rs:22:15
9
+ |
10
+ LL | fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> {
11
+ | ^^^ required by this bound in `<MyFoo as Foo>::foo`
12
+ help: consider restricting type parameter `B`
13
+ |
14
+ LL | type FooFn<B: Bar> = impl FnOnce();
15
+ | +++++
16
+
17
+ error: aborting due to previous error
18
+
19
+ For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
1
+ // Regression test for #90400,
2
+ // taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836
3
+
4
+ #![ feature( generic_associated_types) ]
5
+ #![ feature( type_alias_impl_trait) ]
6
+
7
+ trait Bar {
8
+ fn bar ( & self ) ;
9
+ }
10
+
11
+ trait Baz {
12
+ fn baz ( & self ) ;
13
+ }
14
+
15
+ trait Foo {
16
+ type FooFn < B > : Baz ;
17
+
18
+ fn foo < B : Bar > ( & self , bar : B ) -> Self :: FooFn < B > ;
19
+ }
20
+
21
+ struct MyFoo ;
22
+ impl Foo for MyFoo {
23
+ type FooFn < B > = impl Baz ;
24
+
25
+ fn foo < B : Bar > ( & self , bar : B ) -> Self :: FooFn < B > {
26
+ MyBaz ( bar) //~ ERROR: the trait bound `B: Bar` is not satisfied
27
+ }
28
+ }
29
+
30
+ struct MyBaz < B : Bar > ( B ) ;
31
+ impl < B : Bar > Baz for MyBaz < B > {
32
+ fn baz ( & self ) { }
33
+ }
34
+
35
+ fn main ( ) {
36
+ let boom: <MyFoo as Foo >:: FooFn < u32 > = unsafe { core:: mem:: zeroed ( ) } ;
37
+ boom. baz ( ) ;
38
+ }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `B: Bar` is not satisfied
2
+ --> $DIR/issue-90400-2.rs:26:9
3
+ |
4
+ LL | MyBaz(bar)
5
+ | ^^^^^^^^^^ the trait `Bar` is not implemented for `B`
6
+ |
7
+ note: required because of the requirements on the impl of `Baz` for `MyBaz<B>`
8
+ --> $DIR/issue-90400-2.rs:31:14
9
+ |
10
+ LL | impl<B: Bar> Baz for MyBaz<B> {
11
+ | ^^^ ^^^^^^^^
12
+ help: consider restricting type parameter `B`
13
+ |
14
+ LL | type FooFn<B: Bar> = impl Baz;
15
+ | +++++
16
+
17
+ error: aborting due to previous error
18
+
19
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments