about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/object-safety/assoc_const_bounds.rs13
-rw-r--r--tests/ui/object-safety/assoc_const_bounds.stderr15
-rw-r--r--tests/ui/object-safety/assoc_const_bounds_sized.rs9
-rw-r--r--tests/ui/object-safety/assoc_const_bounds_sized.stderr15
-rw-r--r--tests/ui/object-safety/assoc_type_bounds.rs13
-rw-r--r--tests/ui/object-safety/assoc_type_bounds.stderr21
-rw-r--r--tests/ui/object-safety/assoc_type_bounds2.rs13
-rw-r--r--tests/ui/object-safety/assoc_type_bounds2.stderr21
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_sized.rs9
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_sized.stderr12
10 files changed, 141 insertions, 0 deletions
diff --git a/tests/ui/object-safety/assoc_const_bounds.rs b/tests/ui/object-safety/assoc_const_bounds.rs
new file mode 100644
index 00000000000..94b1f63165b
--- /dev/null
+++ b/tests/ui/object-safety/assoc_const_bounds.rs
@@ -0,0 +1,13 @@
+trait Foo<T> {
+    const BAR: bool
+        where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where`
+            Self: Sized;
+}
+
+trait Cake {}
+impl Cake for () {}
+
+fn foo(_: &dyn Foo<()>) {}
+fn bar(_: &dyn Foo<i32>) {}
+
+fn main() {}
diff --git a/tests/ui/object-safety/assoc_const_bounds.stderr b/tests/ui/object-safety/assoc_const_bounds.stderr
new file mode 100644
index 00000000000..09bc11e178a
--- /dev/null
+++ b/tests/ui/object-safety/assoc_const_bounds.stderr
@@ -0,0 +1,15 @@
+error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where`
+  --> $DIR/assoc_const_bounds.rs:3:9
+   |
+LL | trait Foo<T> {
+   |              - while parsing this item list starting here
+LL |     const BAR: bool
+   |                    - expected one of 7 possible tokens
+LL |         where
+   |         ^^^^^ unexpected token
+LL |             Self: Sized;
+LL | }
+   | - the item list ends here
+
+error: aborting due to previous error
+
diff --git a/tests/ui/object-safety/assoc_const_bounds_sized.rs b/tests/ui/object-safety/assoc_const_bounds_sized.rs
new file mode 100644
index 00000000000..2a76e5dce2b
--- /dev/null
+++ b/tests/ui/object-safety/assoc_const_bounds_sized.rs
@@ -0,0 +1,9 @@
+trait Foo {
+    const BAR: bool
+        where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where`
+            Self: Sized;
+}
+
+fn foo(_: &dyn Foo) {}
+
+fn main() {}
diff --git a/tests/ui/object-safety/assoc_const_bounds_sized.stderr b/tests/ui/object-safety/assoc_const_bounds_sized.stderr
new file mode 100644
index 00000000000..e1f57f67795
--- /dev/null
+++ b/tests/ui/object-safety/assoc_const_bounds_sized.stderr
@@ -0,0 +1,15 @@
+error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where`
+  --> $DIR/assoc_const_bounds_sized.rs:3:9
+   |
+LL | trait Foo {
+   |           - while parsing this item list starting here
+LL |     const BAR: bool
+   |                    - expected one of 7 possible tokens
+LL |         where
+   |         ^^^^^ unexpected token
+LL |             Self: Sized;
+LL | }
+   | - the item list ends here
+
+error: aborting due to previous error
+
diff --git a/tests/ui/object-safety/assoc_type_bounds.rs b/tests/ui/object-safety/assoc_type_bounds.rs
new file mode 100644
index 00000000000..9abf7939c43
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds.rs
@@ -0,0 +1,13 @@
+trait Foo<T> {
+    type Bar
+    where
+        T: Cake;
+}
+
+trait Cake {}
+impl Cake for () {}
+
+fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
+fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
+
+fn main() {}
diff --git a/tests/ui/object-safety/assoc_type_bounds.stderr b/tests/ui/object-safety/assoc_type_bounds.stderr
new file mode 100644
index 00000000000..a1396dc3ad4
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds.stderr
@@ -0,0 +1,21 @@
+error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+  --> $DIR/assoc_type_bounds.rs:10:16
+   |
+LL |     type Bar
+   |     -------- `Bar` defined here
+...
+LL | fn foo(_: &dyn Foo<()>) {}
+   |                ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>`
+
+error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+  --> $DIR/assoc_type_bounds.rs:11:16
+   |
+LL |     type Bar
+   |     -------- `Bar` defined here
+...
+LL | fn bar(_: &dyn Foo<i32>) {}
+   |                ^^^^^^^^ help: specify the associated type: `Foo<i32, Bar = Type>`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0191`.
diff --git a/tests/ui/object-safety/assoc_type_bounds2.rs b/tests/ui/object-safety/assoc_type_bounds2.rs
new file mode 100644
index 00000000000..0112123fd42
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds2.rs
@@ -0,0 +1,13 @@
+trait Foo<T> {
+    type Bar
+    where
+        Self: Foo<()>;
+}
+
+trait Cake {}
+impl Cake for () {}
+
+fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
+fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
+
+fn main() {}
diff --git a/tests/ui/object-safety/assoc_type_bounds2.stderr b/tests/ui/object-safety/assoc_type_bounds2.stderr
new file mode 100644
index 00000000000..7a3c0e02d48
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds2.stderr
@@ -0,0 +1,21 @@
+error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+  --> $DIR/assoc_type_bounds2.rs:10:16
+   |
+LL |     type Bar
+   |     -------- `Bar` defined here
+...
+LL | fn foo(_: &dyn Foo<()>) {}
+   |                ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>`
+
+error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+  --> $DIR/assoc_type_bounds2.rs:11:16
+   |
+LL |     type Bar
+   |     -------- `Bar` defined here
+...
+LL | fn bar(_: &dyn Foo<i32>) {}
+   |                ^^^^^^^^ help: specify the associated type: `Foo<i32, Bar = Type>`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0191`.
diff --git a/tests/ui/object-safety/assoc_type_bounds_sized.rs b/tests/ui/object-safety/assoc_type_bounds_sized.rs
new file mode 100644
index 00000000000..61ad3cf9dc6
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds_sized.rs
@@ -0,0 +1,9 @@
+trait Foo {
+    type Bar
+    where
+        Self: Sized;
+}
+
+fn foo(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
+
+fn main() {}
diff --git a/tests/ui/object-safety/assoc_type_bounds_sized.stderr b/tests/ui/object-safety/assoc_type_bounds_sized.stderr
new file mode 100644
index 00000000000..49d624f9b1d
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds_sized.stderr
@@ -0,0 +1,12 @@
+error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+  --> $DIR/assoc_type_bounds_sized.rs:7:16
+   |
+LL |     type Bar
+   |     -------- `Bar` defined here
+...
+LL | fn foo(_: &dyn Foo) {}
+   |                ^^^ help: specify the associated type: `Foo<Bar = Type>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0191`.