Skip to content

Commit 81ab26c

Browse files
committed
Add tests for dependent defaults.
1 parent 75997d8 commit 81ab26c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/test/run-pass/defaults-well-formedness.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ struct IndividuallyBogus<T = i32, U = i32>(TwoParams<T, U>) where TwoParams<T, U
1919
// Clauses with non-defaulted params are not checked.
2020
struct NonDefaultedInClause<T, U = i32>(TwoParams<T, U>) where TwoParams<T, U>: Marker;
2121
struct DefaultedLhs<U, V=i32>(U, V) where V: Trait<U>;
22+
// Dependent defaults.
23+
struct Dependent<T: Copy, U = T>(T, U) where U: Copy;
2224

2325
fn main() {}

src/test/ui/type-check-defaults.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ trait Bar<V> {}
4747
impl Bar<String> for u32 { }
4848
impl Bar<i32> for String { }
4949

50+
// Dependent defaults.
51+
struct Dependent<T, U = T>(T, U) where U: Copy;
52+
//~^ the trait bound `T: std::marker::Copy` is not satisfied [E0277]
53+
5054
fn main() { }

src/test/ui/type-check-defaults.stderr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,14 @@ note: required by `Bar`
102102
46 | trait Bar<V> {}
103103
| ^^^^^^^^^^^^
104104

105-
error: aborting due to 10 previous errors
105+
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
106+
--> $DIR/type-check-defaults.rs:51:1
107+
|
108+
51 | struct Dependent<T, U = T>(T, U) where U: Copy;
109+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
110+
|
111+
= help: consider adding a `where T: std::marker::Copy` bound
112+
= note: required by `std::marker::Copy`
113+
114+
error: aborting due to 11 previous errors
106115

0 commit comments

Comments
 (0)