Improve test
This commit is contained in:
parent
1e3c020063
commit
d3be26d6a8
@ -1,3 +1,5 @@
|
||||
//! Tests the interaction of associated type defaults and specialization.
|
||||
|
||||
// compile-fail
|
||||
|
||||
#![feature(associated_type_defaults, specialization)]
|
||||
@ -16,6 +18,13 @@ fn make() -> u8 { 0 }
|
||||
//~^ ERROR method `make` has an incompatible type for trait
|
||||
}
|
||||
|
||||
struct A2<T>(T);
|
||||
// ...same, but in the method body
|
||||
default impl<T> Tr for A2<T> {
|
||||
fn make() -> Self::Ty { 0u8 }
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
struct B<T>(T);
|
||||
// Explicitly defaulting the type does the same.
|
||||
impl<T> Tr for B<T> {
|
||||
@ -25,6 +34,15 @@ fn make() -> bool { true }
|
||||
//~^ ERROR method `make` has an incompatible type for trait
|
||||
}
|
||||
|
||||
struct B2<T>(T);
|
||||
// ...same, but in the method body
|
||||
impl<T> Tr for B2<T> {
|
||||
default type Ty = bool;
|
||||
|
||||
fn make() -> Self::Ty { true }
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
struct C<T>(T);
|
||||
// Only the method is defaulted, so this is fine.
|
||||
impl<T> Tr for C<T> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0053]: method `make` has an incompatible type for trait
|
||||
--> $DIR/defaults-specialization.rs:15:18
|
||||
--> $DIR/defaults-specialization.rs:17:18
|
||||
|
|
||||
LL | fn make() -> Self::Ty;
|
||||
| -------- type in trait
|
||||
@ -11,7 +11,7 @@ LL | fn make() -> u8 { 0 }
|
||||
found type `fn() -> u8`
|
||||
|
||||
error[E0053]: method `make` has an incompatible type for trait
|
||||
--> $DIR/defaults-specialization.rs:24:18
|
||||
--> $DIR/defaults-specialization.rs:33:18
|
||||
|
|
||||
LL | fn make() -> Self::Ty;
|
||||
| -------- type in trait
|
||||
@ -22,6 +22,29 @@ LL | fn make() -> bool { true }
|
||||
= note: expected type `fn() -> <B<T> as Tr>::Ty`
|
||||
found type `fn() -> bool`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/defaults-specialization.rs:24:29
|
||||
|
|
||||
LL | fn make() -> Self::Ty { 0u8 }
|
||||
| -------- ^^^ expected associated type, found u8
|
||||
| |
|
||||
| expected `<A2<T> as Tr>::Ty` because of return type
|
||||
|
|
||||
= note: expected type `<A2<T> as Tr>::Ty`
|
||||
found type `u8`
|
||||
|
||||
For more information about this error, try `rustc --explain E0053`.
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/defaults-specialization.rs:42:29
|
||||
|
|
||||
LL | fn make() -> Self::Ty { true }
|
||||
| -------- ^^^^ expected associated type, found bool
|
||||
| |
|
||||
| expected `<B2<T> as Tr>::Ty` because of return type
|
||||
|
|
||||
= note: expected type `<B2<T> as Tr>::Ty`
|
||||
found type `bool`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0053, E0308.
|
||||
For more information about an error, try `rustc --explain E0053`.
|
||||
|
Loading…
Reference in New Issue
Block a user