summaryrefslogtreecommitdiffstats
path: root/tests/ui/associated-type-bounds
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/associated-type-bounds')
-rw-r--r--tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs14
-rw-r--r--tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr8
-rw-r--r--tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs13
-rw-r--r--tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr8
-rw-r--r--tests/ui/associated-type-bounds/elision.stderr6
-rw-r--r--tests/ui/associated-type-bounds/inside-adt.rs22
-rw-r--r--tests/ui/associated-type-bounds/inside-adt.stderr105
-rw-r--r--tests/ui/associated-type-bounds/issue-71443-1.stderr2
8 files changed, 71 insertions, 107 deletions
diff --git a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs
new file mode 100644
index 000000000..8cab1f66c
--- /dev/null
+++ b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs
@@ -0,0 +1,14 @@
+#![feature(associated_type_bounds)]
+
+trait B {
+ type AssocType;
+}
+
+fn f()
+where
+ dyn for<'j> B<AssocType: 'j>:,
+ //~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+{
+}
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr
new file mode 100644
index 000000000..6fa266d23
--- /dev/null
+++ b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr
@@ -0,0 +1,8 @@
+error: associated type bounds are only allowed in where clauses and function signatures, not in bounds
+ --> $DIR/bad-universal-in-dyn-in-where-clause.rs:9:19
+ |
+LL | dyn for<'j> B<AssocType: 'j>:,
+ | ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs
new file mode 100644
index 000000000..1d5d181ef
--- /dev/null
+++ b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs
@@ -0,0 +1,13 @@
+#![feature(associated_type_bounds)]
+
+trait Trait {
+ type Item;
+}
+
+trait Trait2 {}
+
+// It's not possible to insert a universal `impl Trait` here!
+impl dyn Trait<Item: Trait2> {}
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr
new file mode 100644
index 000000000..8b66627d5
--- /dev/null
+++ b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr
@@ -0,0 +1,8 @@
+error: associated type bounds are only allowed in where clauses and function signatures, not in impl headers
+ --> $DIR/bad-universal-in-impl-sig.rs:10:16
+ |
+LL | impl dyn Trait<Item: Trait2> {}
+ | ^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/associated-type-bounds/elision.stderr b/tests/ui/associated-type-bounds/elision.stderr
index ea3024627..cc10bbcc0 100644
--- a/tests/ui/associated-type-bounds/elision.stderr
+++ b/tests/ui/associated-type-bounds/elision.stderr
@@ -14,12 +14,12 @@ error[E0308]: mismatched types
--> $DIR/elision.rs:5:79
|
LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() }
- | ----------------------------- -------------- ^^^^^^^^ expected `&()`, found type parameter `impl Iterator<Item = &'_ ()>`
+ | ----------------------------- -------------- ^^^^^^^^ expected `Option<&()>`, found `Option<impl Iterator<Item = &'_ ()>>`
| | |
- | | expected `Option<&'static ()>` because of return type
+ | | expected `Option<&()>` because of return type
| this type parameter
|
- = note: expected enum `Option<&'static ()>`
+ = note: expected enum `Option<&()>`
found enum `Option<impl Iterator<Item = &'_ ()>>`
error: aborting due to 2 previous errors
diff --git a/tests/ui/associated-type-bounds/inside-adt.rs b/tests/ui/associated-type-bounds/inside-adt.rs
index 8eb8c44bb..057966941 100644
--- a/tests/ui/associated-type-bounds/inside-adt.rs
+++ b/tests/ui/associated-type-bounds/inside-adt.rs
@@ -3,28 +3,24 @@
use std::mem::ManuallyDrop;
struct S1 { f: dyn Iterator<Item: Copy> }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
struct S2 { f: Box<dyn Iterator<Item: Copy>> }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
struct S3 { f: dyn Iterator<Item: 'static> }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
enum E1 { V(dyn Iterator<Item: Copy>) }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
-//~| ERROR the size for values of type `(dyn Iterator<Item = impl Copy> + 'static)`
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
enum E2 { V(Box<dyn Iterator<Item: Copy>>) }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
enum E3 { V(dyn Iterator<Item: 'static>) }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
-//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
-//~| ERROR the size for values of type `(dyn Iterator<Item = impl Copy> + 'static)`
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
union U2 { f: ManuallyDrop<Box<dyn Iterator<Item: Copy>>> }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> }
-//~^ ERROR associated type bounds are not allowed within structs, enums, or unions
-//~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
+//~^ ERROR associated type bounds are only allowed in where clauses and function signatures
fn main() {}
diff --git a/tests/ui/associated-type-bounds/inside-adt.stderr b/tests/ui/associated-type-bounds/inside-adt.stderr
index dbfcfa580..f848bd798 100644
--- a/tests/ui/associated-type-bounds/inside-adt.stderr
+++ b/tests/ui/associated-type-bounds/inside-adt.stderr
@@ -1,131 +1,56 @@
-error: associated type bounds are not allowed within structs, enums, or unions
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
--> $DIR/inside-adt.rs:5:29
|
LL | struct S1 { f: dyn Iterator<Item: Copy> }
| ^^^^^^^^^^
-error: associated type bounds are not allowed within structs, enums, or unions
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
--> $DIR/inside-adt.rs:7:33
|
LL | struct S2 { f: Box<dyn Iterator<Item: Copy>> }
| ^^^^^^^^^^
-error: associated type bounds are not allowed within structs, enums, or unions
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
--> $DIR/inside-adt.rs:9:29
|
LL | struct S3 { f: dyn Iterator<Item: 'static> }
| ^^^^^^^^^^^^^
-error: associated type bounds are not allowed within structs, enums, or unions
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
--> $DIR/inside-adt.rs:12:26
|
LL | enum E1 { V(dyn Iterator<Item: Copy>) }
| ^^^^^^^^^^
-error: associated type bounds are not allowed within structs, enums, or unions
- --> $DIR/inside-adt.rs:15:30
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+ --> $DIR/inside-adt.rs:14:30
|
LL | enum E2 { V(Box<dyn Iterator<Item: Copy>>) }
| ^^^^^^^^^^
-error: associated type bounds are not allowed within structs, enums, or unions
- --> $DIR/inside-adt.rs:17:26
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+ --> $DIR/inside-adt.rs:16:26
|
LL | enum E3 { V(dyn Iterator<Item: 'static>) }
| ^^^^^^^^^^^^^
-error: associated type bounds are not allowed within structs, enums, or unions
- --> $DIR/inside-adt.rs:21:41
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+ --> $DIR/inside-adt.rs:19:41
|
LL | union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> }
| ^^^^^^^^^^
-error: associated type bounds are not allowed within structs, enums, or unions
- --> $DIR/inside-adt.rs:24:45
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+ --> $DIR/inside-adt.rs:21:45
|
LL | union U2 { f: ManuallyDrop<Box<dyn Iterator<Item: Copy>>> }
| ^^^^^^^^^^
-error: associated type bounds are not allowed within structs, enums, or unions
- --> $DIR/inside-adt.rs:26:41
+error: associated type bounds are only allowed in where clauses and function signatures, not in field types
+ --> $DIR/inside-adt.rs:23:41
|
LL | union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> }
| ^^^^^^^^^^^^^
-error[E0277]: the size for values of type `(dyn Iterator<Item = impl Copy> + 'static)` cannot be known at compilation time
- --> $DIR/inside-adt.rs:12:13
- |
-LL | enum E1 { V(dyn Iterator<Item: Copy>) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Copy> + 'static)`
- = note: no field of an enum variant may have a dynamically sized type
- = help: change the field's type to have a statically known size
-help: borrowed types always have a statically known size
- |
-LL | enum E1 { V(&dyn Iterator<Item: Copy>) }
- | +
-help: the `Box` type always has a statically known size and allocates its contents in the heap
- |
-LL | enum E1 { V(Box<dyn Iterator<Item: Copy>>) }
- | ++++ +
-
-error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)` cannot be known at compilation time
- --> $DIR/inside-adt.rs:17:13
- |
-LL | enum E3 { V(dyn Iterator<Item: 'static>) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
- = note: no field of an enum variant may have a dynamically sized type
- = help: change the field's type to have a statically known size
-help: borrowed types always have a statically known size
- |
-LL | enum E3 { V(&dyn Iterator<Item: 'static>) }
- | +
-help: the `Box` type always has a statically known size and allocates its contents in the heap
- |
-LL | enum E3 { V(Box<dyn Iterator<Item: 'static>>) }
- | ++++ +
-
-error[E0277]: the size for values of type `(dyn Iterator<Item = impl Copy> + 'static)` cannot be known at compilation time
- --> $DIR/inside-adt.rs:21:15
- |
-LL | union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: within `ManuallyDrop<(dyn Iterator<Item = impl Copy> + 'static)>`, the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Copy> + 'static)`
- = note: required because it appears within the type `ManuallyDrop<(dyn Iterator<Item = impl Copy> + 'static)>`
- = note: no field of a union may have a dynamically sized type
- = help: change the field's type to have a statically known size
-help: borrowed types always have a statically known size
- |
-LL | union U1 { f: &ManuallyDrop<dyn Iterator<Item: Copy>> }
- | +
-help: the `Box` type always has a statically known size and allocates its contents in the heap
- |
-LL | union U1 { f: Box<ManuallyDrop<dyn Iterator<Item: Copy>>> }
- | ++++ +
-
-error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized + 'static> + 'static)` cannot be known at compilation time
- --> $DIR/inside-adt.rs:26:15
- |
-LL | union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: within `ManuallyDrop<(dyn Iterator<Item = impl Sized + 'static> + 'static)>`, the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
- = note: required because it appears within the type `ManuallyDrop<(dyn Iterator<Item = impl Sized + 'static> + 'static)>`
- = note: no field of a union may have a dynamically sized type
- = help: change the field's type to have a statically known size
-help: borrowed types always have a statically known size
- |
-LL | union U3 { f: &ManuallyDrop<dyn Iterator<Item: 'static>> }
- | +
-help: the `Box` type always has a statically known size and allocates its contents in the heap
- |
-LL | union U3 { f: Box<ManuallyDrop<dyn Iterator<Item: 'static>>> }
- | ++++ +
-
-error: aborting due to 13 previous errors
+error: aborting due to 9 previous errors
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/associated-type-bounds/issue-71443-1.stderr b/tests/ui/associated-type-bounds/issue-71443-1.stderr
index a9459ee74..15cc9646b 100644
--- a/tests/ui/associated-type-bounds/issue-71443-1.stderr
+++ b/tests/ui/associated-type-bounds/issue-71443-1.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | fn hello<F: for<'a> Iterator<Item: 'a>>() {
| - help: try adding a return type: `-> Incorrect`
LL | Incorrect
- | ^^^^^^^^^ expected `()`, found struct `Incorrect`
+ | ^^^^^^^^^ expected `()`, found `Incorrect`
error: aborting due to previous error