File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ //! This test checks that associated types only need to be
2+ //! mentioned in trait objects, if they don't require `Self: Sized`.
3+
14// check-pass
25
36trait Foo {
@@ -8,4 +11,14 @@ trait Foo {
811
912fn foo ( _: & dyn Foo ) { }
1013
14+ trait Other : Sized { }
15+
16+ trait Boo {
17+ type Assoc
18+ where
19+ Self : Other ;
20+ }
21+
22+ fn boo ( _: & dyn Boo ) { }
23+
1124fn main ( ) { }
Original file line number Diff line number Diff line change 1+ //! This test checks that even if some associated types have
2+ //! `where Self: Sized` bounds, those without still need to be
3+ //! mentioned in trait objects.
4+
5+ trait Foo {
6+ type Bar
7+ where
8+ Self : Sized ;
9+ type Bop ;
10+ }
11+
12+ fn foo ( _: & dyn Foo ) { }
13+ //~^ ERROR the value of the associated type `Bop` (from trait `Foo`) must be specified
14+
15+ trait Bar {
16+ type Bop ;
17+ type Bar
18+ where
19+ Self : Sized ;
20+ }
21+
22+ fn bar ( _: & dyn Bar ) { }
23+ //~^ ERROR the value of the associated type `Bop` (from trait `Bar`) must be specified
24+
25+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0191]: the value of the associated type `Bop` (from trait `Foo`) must be specified
2+ --> $DIR/assoc_type_bounds_sized_others.rs:12:16
3+ |
4+ LL | type Bop;
5+ | -------- `Bop` defined here
6+ ...
7+ LL | fn foo(_: &dyn Foo) {}
8+ | ^^^ help: specify the associated type: `Foo<Bop = Type>`
9+
10+ error[E0191]: the value of the associated type `Bop` (from trait `Bar`) must be specified
11+ --> $DIR/assoc_type_bounds_sized_others.rs:22:16
12+ |
13+ LL | type Bop;
14+ | -------- `Bop` defined here
15+ ...
16+ LL | fn bar(_: &dyn Bar) {}
17+ | ^^^ help: specify the associated type: `Bar<Bop = Type>`
18+
19+ error: aborting due to 2 previous errors
20+
21+ For more information about this error, try `rustc --explain E0191`.
You can’t perform that action at this time.
0 commit comments