summaryrefslogtreecommitdiffstats
path: root/tests/ui/trait-bounds
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /tests/ui/trait-bounds
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/trait-bounds')
-rw-r--r--tests/ui/trait-bounds/enum-unit-variant-trait-bound.rs6
-rw-r--r--tests/ui/trait-bounds/enum-unit-variant-trait-bound.stderr13
-rw-r--r--tests/ui/trait-bounds/issue-82038.rs9
-rw-r--r--tests/ui/trait-bounds/issue-82038.stderr15
4 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/trait-bounds/enum-unit-variant-trait-bound.rs b/tests/ui/trait-bounds/enum-unit-variant-trait-bound.rs
new file mode 100644
index 000000000..91525bc90
--- /dev/null
+++ b/tests/ui/trait-bounds/enum-unit-variant-trait-bound.rs
@@ -0,0 +1,6 @@
+// Regression test for one part of issue #105306.
+
+fn main() {
+ let _ = Option::<[u8]>::None;
+ //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+}
diff --git a/tests/ui/trait-bounds/enum-unit-variant-trait-bound.stderr b/tests/ui/trait-bounds/enum-unit-variant-trait-bound.stderr
new file mode 100644
index 000000000..32f6b00b2
--- /dev/null
+++ b/tests/ui/trait-bounds/enum-unit-variant-trait-bound.stderr
@@ -0,0 +1,13 @@
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+ --> $DIR/enum-unit-variant-trait-bound.rs:4:22
+ |
+LL | let _ = Option::<[u8]>::None;
+ | ^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `[u8]`
+note: required by a bound in `None`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/trait-bounds/issue-82038.rs b/tests/ui/trait-bounds/issue-82038.rs
new file mode 100644
index 000000000..11de714fa
--- /dev/null
+++ b/tests/ui/trait-bounds/issue-82038.rs
@@ -0,0 +1,9 @@
+// Failed bound `bool: Foo` must not point at the `Self: Clone` line
+
+trait Foo {
+ fn my_method() where Self: Clone;
+}
+
+fn main() {
+ <bool as Foo>::my_method(); //~ERROR [E0277]
+}
diff --git a/tests/ui/trait-bounds/issue-82038.stderr b/tests/ui/trait-bounds/issue-82038.stderr
new file mode 100644
index 000000000..30bb4a0a8
--- /dev/null
+++ b/tests/ui/trait-bounds/issue-82038.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `bool: Foo` is not satisfied
+ --> $DIR/issue-82038.rs:8:6
+ |
+LL | <bool as Foo>::my_method();
+ | ^^^^ the trait `Foo` is not implemented for `bool`
+ |
+help: this trait has no implementations, consider adding one
+ --> $DIR/issue-82038.rs:3:1
+ |
+LL | trait Foo {
+ | ^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.