]> git.lizzy.rs Git - rust.git/commitdiff
Add tests for dependent defaults.
authorleonardo.yvens <leoyvens@gmail.com>
Mon, 5 Feb 2018 23:51:58 +0000 (21:51 -0200)
committerleonardo.yvens <leoyvens@gmail.com>
Wed, 28 Feb 2018 15:33:15 +0000 (12:33 -0300)
src/test/run-pass/defaults-well-formedness.rs
src/test/ui/type-check-defaults.rs
src/test/ui/type-check-defaults.stderr

index 6a7b1c51ccd285cf9f28733b10a21f2b07905d37..60e78e29afd8bda3cac7b1c1e7dc2404d3218ba9 100644 (file)
@@ -19,5 +19,7 @@ impl Marker for TwoParams<i32, i32> {}
 // 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() {}
index ff3fb44bb264e8362d4298b60cdd13ac5fe17fb4..d57b39464806ac98ad97e8d02c8ff125c5ce4ac8 100644 (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() { }
index 412a7966f0aac4791471efc2678ca351a5be9c0d..032e80cdb14855e200c2c7a4ef79bd6195a01d20 100644 (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