diff options
Diffstat (limited to 'tests/ui/unsized')
-rw-r--r-- | tests/ui/unsized/maybe-bounds-where.rs | 4 | ||||
-rw-r--r-- | tests/ui/unsized/maybe-bounds-where.stderr | 16 | ||||
-rw-r--r-- | tests/ui/unsized/unsize-coerce-multiple-adt-params.rs | 29 | ||||
-rw-r--r-- | tests/ui/unsized/unsized-trait-impl-self-type.rs | 1 | ||||
-rw-r--r-- | tests/ui/unsized/unsized-trait-impl-self-type.stderr | 14 | ||||
-rw-r--r-- | tests/ui/unsized/unsized-trait-impl-trait-arg.rs | 1 | ||||
-rw-r--r-- | tests/ui/unsized/unsized-trait-impl-trait-arg.stderr | 14 | ||||
-rw-r--r-- | tests/ui/unsized/unsized7.rs | 1 | ||||
-rw-r--r-- | tests/ui/unsized/unsized7.stderr | 14 |
9 files changed, 78 insertions, 16 deletions
diff --git a/tests/ui/unsized/maybe-bounds-where.rs b/tests/ui/unsized/maybe-bounds-where.rs index d7af0c424..7e82a3eb4 100644 --- a/tests/ui/unsized/maybe-bounds-where.rs +++ b/tests/ui/unsized/maybe-bounds-where.rs @@ -11,11 +11,11 @@ trait Trait<'a> {} struct S4<T>(T) where for<'a> T: ?Trait<'a>; //~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared -//~| WARN default bound relaxed for a type parameter +//~| WARN relaxing a default bound only does something for `?Sized` struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; //~^ ERROR type parameter has more than one relaxed default bound -//~| WARN default bound relaxed for a type parameter +//~| WARN relaxing a default bound only does something for `?Sized` impl<T> S1<T> { fn f() where T: ?Sized {} diff --git a/tests/ui/unsized/maybe-bounds-where.stderr b/tests/ui/unsized/maybe-bounds-where.stderr index 39bc1b88e..683bd387b 100644 --- a/tests/ui/unsized/maybe-bounds-where.stderr +++ b/tests/ui/unsized/maybe-bounds-where.stderr @@ -28,23 +28,23 @@ error: `?Trait` bounds are only permitted at the point where a type parameter is LL | fn f() where T: ?Sized {} | ^^^^^^ -warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported - --> $DIR/maybe-bounds-where.rs:12:11 +warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default + --> $DIR/maybe-bounds-where.rs:12:34 | LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>; - | ^ + | ^^^^^^^^^^ error[E0203]: type parameter has more than one relaxed default bound, only one is supported - --> $DIR/maybe-bounds-where.rs:16:11 + --> $DIR/maybe-bounds-where.rs:16:33 | LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; - | ^ + | ^^^^^^^^^^^^^^^ ^^^^^^ -warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported - --> $DIR/maybe-bounds-where.rs:16:11 +warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default + --> $DIR/maybe-bounds-where.rs:16:33 | LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; - | ^ + | ^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors; 2 warnings emitted diff --git a/tests/ui/unsized/unsize-coerce-multiple-adt-params.rs b/tests/ui/unsized/unsize-coerce-multiple-adt-params.rs new file mode 100644 index 000000000..eba341ff2 --- /dev/null +++ b/tests/ui/unsized/unsize-coerce-multiple-adt-params.rs @@ -0,0 +1,29 @@ +// check-pass + +struct Foo<T, U> +where + (T, U): Trait, +{ + f: <(T, U) as Trait>::Assoc, +} + +trait Trait { + type Assoc: ?Sized; +} + +struct Count<const N: usize>; + +impl<const N: usize> Trait for (i32, Count<N>) { + type Assoc = [(); N]; +} + +impl<'a> Trait for (u32, ()) { + type Assoc = [()]; +} + +// Test that we can unsize several trait params in creative ways. +fn unsize<const N: usize>(x: &Foo<i32, Count<N>>) -> &Foo<u32, ()> { + x +} + +fn main() {} diff --git a/tests/ui/unsized/unsized-trait-impl-self-type.rs b/tests/ui/unsized/unsized-trait-impl-self-type.rs index df571a833..603c0a221 100644 --- a/tests/ui/unsized/unsized-trait-impl-self-type.rs +++ b/tests/ui/unsized/unsized-trait-impl-self-type.rs @@ -9,6 +9,7 @@ struct S5<Y>(Y); impl<X: ?Sized> T3<X> for S5<X> { //~^ ERROR the size for values of type + //~| ERROR not all trait items implemented } fn main() { } diff --git a/tests/ui/unsized/unsized-trait-impl-self-type.stderr b/tests/ui/unsized/unsized-trait-impl-self-type.stderr index 4955d463f..5bc8dc590 100644 --- a/tests/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/tests/ui/unsized/unsized-trait-impl-self-type.stderr @@ -24,6 +24,16 @@ LL - impl<X: ?Sized> T3<X> for S5<X> { LL + impl<X> T3<X> for S5<X> { | -error: aborting due to previous error +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/unsized-trait-impl-self-type.rs:10:1 + | +LL | fn foo(&self, z: &Z); + | --------------------- `foo` from trait +... +LL | impl<X: ?Sized> T3<X> for S5<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0046, E0277. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/unsized/unsized-trait-impl-trait-arg.rs b/tests/ui/unsized/unsized-trait-impl-trait-arg.rs index 96e7e371f..e7602b175 100644 --- a/tests/ui/unsized/unsized-trait-impl-trait-arg.rs +++ b/tests/ui/unsized/unsized-trait-impl-trait-arg.rs @@ -7,6 +7,7 @@ trait T2<Z> { struct S4<Y: ?Sized>(Box<Y>); impl<X: ?Sized> T2<X> for S4<X> { //~^ ERROR the size for values of type + //~| ERROR not all trait items implemented } fn main() { } diff --git a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr index 8761c293a..e9353d2bb 100644 --- a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -21,6 +21,16 @@ help: consider relaxing the implicit `Sized` restriction LL | trait T2<Z: ?Sized> { | ++++++++ -error: aborting due to previous error +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/unsized-trait-impl-trait-arg.rs:8:1 + | +LL | fn foo(&self, z: Z); + | -------------------- `foo` from trait +... +LL | impl<X: ?Sized> T2<X> for S4<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0046, E0277. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/unsized/unsized7.rs b/tests/ui/unsized/unsized7.rs index 422a78481..63e015c28 100644 --- a/tests/ui/unsized/unsized7.rs +++ b/tests/ui/unsized/unsized7.rs @@ -11,6 +11,7 @@ trait T1<Z: T> { struct S3<Y: ?Sized>(Box<Y>); impl<X: ?Sized + T> T1<X> for S3<X> { //~^ ERROR the size for values of type + //~| ERROR not all trait items implemented } fn main() { } diff --git a/tests/ui/unsized/unsized7.stderr b/tests/ui/unsized/unsized7.stderr index c313a2724..2edde1596 100644 --- a/tests/ui/unsized/unsized7.stderr +++ b/tests/ui/unsized/unsized7.stderr @@ -21,6 +21,16 @@ help: consider relaxing the implicit `Sized` restriction LL | trait T1<Z: T + ?Sized> { | ++++++++ -error: aborting due to previous error +error[E0046]: not all trait items implemented, missing: `dummy` + --> $DIR/unsized7.rs:12:1 + | +LL | fn dummy(&self) -> Z; + | --------------------- `dummy` from trait +... +LL | impl<X: ?Sized + T> T1<X> for S3<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `dummy` in implementation + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0046, E0277. +For more information about an error, try `rustc --explain E0046`. |