File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed
src/test/ui/associated-types Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ // compile-fail
2
+
3
+ #![ feature( associated_type_defaults) ]
4
+
5
+ // Tests that a trait with one defaulted and one non-defaulted assoc. type behaves properly.
6
+
7
+ trait Trait {
8
+ type Foo = u8 ;
9
+ type Bar ;
10
+ }
11
+
12
+ // `Bar` must be specified
13
+ impl Trait for ( ) { }
14
+ //~^ error: not all trait items implemented, missing: `Bar`
15
+
16
+ impl Trait for bool {
17
+ //~^ error: not all trait items implemented, missing: `Bar`
18
+ type Foo = ( ) ;
19
+ }
20
+
21
+ impl Trait for u8 {
22
+ type Bar = ( ) ;
23
+ }
24
+
25
+ impl Trait for u16 {
26
+ type Foo = String ;
27
+ type Bar = bool ;
28
+ }
29
+
30
+ fn main ( ) {
31
+ let _: <u8 as Trait >:: Foo = 0u8 ;
32
+ let _: <u8 as Trait >:: Bar = ( ) ;
33
+
34
+ let _: <u16 as Trait >:: Foo = String :: new ( ) ;
35
+ let _: <u16 as Trait >:: Bar = true ;
36
+ }
Original file line number Diff line number Diff line change
1
+ error[E0046]: not all trait items implemented, missing: `Bar`
2
+ --> $DIR/defaults-mixed.rs:13:1
3
+ |
4
+ LL | type Bar;
5
+ | --------- `Bar` from trait
6
+ ...
7
+ LL | impl Trait for () {}
8
+ | ^^^^^^^^^^^^^^^^^ missing `Bar` in implementation
9
+
10
+ error[E0046]: not all trait items implemented, missing: `Bar`
11
+ --> $DIR/defaults-mixed.rs:16:1
12
+ |
13
+ LL | type Bar;
14
+ | --------- `Bar` from trait
15
+ ...
16
+ LL | impl Trait for bool {
17
+ | ^^^^^^^^^^^^^^^^^^^ missing `Bar` in implementation
18
+
19
+ error: aborting due to 2 previous errors
20
+
21
+ For more information about this error, try `rustc --explain E0046`.
You can’t perform that action at this time.
0 commit comments