Add tests for dependent defaults.

This commit is contained in:
leonardo.yvens 2018-02-05 21:51:58 -02:00
parent 75997d85c5
commit 81ab26c99a
3 changed files with 16 additions and 1 deletions

View File

@ -19,5 +19,7 @@ struct IndividuallyBogus<T = i32, U = i32>(TwoParams<T, U>) where TwoParams<T, U
// Clauses with non-defaulted params are not checked.
struct NonDefaultedInClause<T, U = i32>(TwoParams<T, U>) where TwoParams<T, U>: Marker;
struct DefaultedLhs<U, V=i32>(U, V) where V: Trait<U>;
// Dependent defaults.
struct Dependent<T: Copy, U = T>(T, U) where U: Copy;
fn main() {}

View File

@ -47,4 +47,8 @@ trait Bar<V> {}
impl Bar<String> for u32 { }
impl Bar<i32> for String { }
// Dependent defaults.
struct Dependent<T, U = T>(T, U) where U: Copy;
//~^ the trait bound `T: std::marker::Copy` is not satisfied [E0277]
fn main() { }

View File

@ -102,5 +102,14 @@ note: required by `Bar`
46 | trait Bar<V> {}
| ^^^^^^^^^^^^
error: aborting due to 10 previous errors
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/type-check-defaults.rs:51:1
|
51 | struct Dependent<T, U = T>(T, U) where U: Copy;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
|
= help: consider adding a `where T: std::marker::Copy` bound
= note: required by `std::marker::Copy`
error: aborting due to 11 previous errors