This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed
tests/ui/type-alias-impl-trait Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 1+ error[E0308]: mismatched types
2+ --> $DIR/itiat-allow-nested-closures.rs:21:22
3+ |
4+ LL | type Assoc = impl Sized;
5+ | ---------- the found opaque type
6+ ...
7+ LL | let _: i32 = closure();
8+ | --- ^^^^^^^^^ expected `i32`, found opaque type
9+ | |
10+ | expected due to this
11+
12+ error[E0308]: mismatched types
13+ --> $DIR/itiat-allow-nested-closures.rs:22:9
14+ |
15+ LL | fn bar() -> Self::Assoc {
16+ | ----------- expected `()` because of return type
17+ ...
18+ LL | 1i32
19+ | ^^^^ expected `()`, found `i32`
20+
21+ error: aborting due to 2 previous errors
22+
23+ For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change 1+ #![ feature( impl_trait_in_assoc_type) ]
2+
3+ // revisions: ok bad
4+ // [ok] check-pass
5+
6+ trait Foo {
7+ type Assoc ;
8+ fn bar ( ) -> Self :: Assoc ;
9+ }
10+
11+ impl Foo for ( ) {
12+ type Assoc = impl Sized ;
13+ fn bar ( ) -> Self :: Assoc {
14+ let closure = || -> Self :: Assoc {
15+ #[ cfg( ok) ]
16+ let x: Self :: Assoc = 42_i32 ;
17+ #[ cfg( bad) ]
18+ let x: Self :: Assoc = ( ) ;
19+ x
20+ } ;
21+ let _: i32 = closure ( ) ; //[bad]~ ERROR mismatched types
22+ 1i32 //[bad]~ ERROR mismatched types
23+ }
24+ }
25+
26+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ #![ feature( impl_trait_in_assoc_type) ]
2+
3+ trait Foo {
4+ type Assoc ;
5+ fn bar ( ) -> Self :: Assoc ;
6+ }
7+
8+ impl Foo for ( ) {
9+ type Assoc = impl Sized ;
10+ fn bar ( ) -> Self :: Assoc {
11+ fn foo ( ) -> <( ) as Foo >:: Assoc {
12+ let x: <( ) as Foo >:: Assoc = 42_i32 ; //~ ERROR mismatched types
13+ x
14+ } ;
15+ let _: i32 = foo ( ) ;
16+ 1i32
17+ }
18+ }
19+
20+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0308]: mismatched types
2+ --> $DIR/itiat-forbid-nested-items.rs:12:41
3+ |
4+ LL | type Assoc = impl Sized;
5+ | ---------- the expected opaque type
6+ ...
7+ LL | let x: <() as Foo>::Assoc = 42_i32;
8+ | ------------------ ^^^^^^ expected opaque type, found `i32`
9+ | |
10+ | expected due to this
11+ |
12+ = note: expected opaque type `<() as Foo>::Assoc`
13+ found type `i32`
14+ note: this item must have the opaque type in its signature in order to be able to register hidden types
15+ --> $DIR/itiat-forbid-nested-items.rs:11:12
16+ |
17+ LL | fn foo() -> <() as Foo>::Assoc {
18+ | ^^^
19+
20+ error: aborting due to 1 previous error
21+
22+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments