about summary refs log tree commit diff
diff options
context:
space:
mode:
authorleonardo.yvens <leoyvens@gmail.com>2018-02-05 21:51:58 -0200
committerleonardo.yvens <leoyvens@gmail.com>2018-02-28 12:33:15 -0300
commit81ab26c99a4775c613ff30e18fe0ee01661a635e (patch)
tree0c19dfd55aca3b6b47e1eac9380e715379038f05
parent75997d85c50b3c489f6a0bf0e388c86ad7a839e4 (diff)
downloadrust-81ab26c99a4775c613ff30e18fe0ee01661a635e.tar.gz
rust-81ab26c99a4775c613ff30e18fe0ee01661a635e.zip
Add tests for dependent defaults.
-rw-r--r--src/test/run-pass/defaults-well-formedness.rs2
-rw-r--r--src/test/ui/type-check-defaults.rs4
-rw-r--r--src/test/ui/type-check-defaults.stderr11
3 files changed, 16 insertions, 1 deletions
diff --git a/src/test/run-pass/defaults-well-formedness.rs b/src/test/run-pass/defaults-well-formedness.rs
index 6a7b1c51ccd..60e78e29afd 100644
--- a/src/test/run-pass/defaults-well-formedness.rs
+++ b/src/test/run-pass/defaults-well-formedness.rs
@@ -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() {}
diff --git a/src/test/ui/type-check-defaults.rs b/src/test/ui/type-check-defaults.rs
index ff3fb44bb26..d57b3946480 100644
--- a/src/test/ui/type-check-defaults.rs
+++ b/src/test/ui/type-check-defaults.rs
@@ -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() { }
diff --git a/src/test/ui/type-check-defaults.stderr b/src/test/ui/type-check-defaults.stderr
index 412a7966f0a..032e80cdb14 100644
--- a/src/test/ui/type-check-defaults.stderr
+++ b/src/test/ui/type-check-defaults.stderr
@@ -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