summaryrefslogtreecommitdiffstats
path: root/src/test/ui/missing-trait-bounds
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/missing-trait-bounds
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/missing-trait-bounds')
-rw-r--r--src/test/ui/missing-trait-bounds/auxiliary/issue-69725.rs8
-rw-r--r--src/test/ui/missing-trait-bounds/issue-35677.fixed11
-rw-r--r--src/test/ui/missing-trait-bounds/issue-35677.rs11
-rw-r--r--src/test/ui/missing-trait-bounds/issue-35677.stderr17
-rw-r--r--src/test/ui/missing-trait-bounds/issue-69725.fixed13
-rw-r--r--src/test/ui/missing-trait-bounds/issue-69725.rs13
-rw-r--r--src/test/ui/missing-trait-bounds/issue-69725.stderr22
-rw-r--r--src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.fixed7
-rw-r--r--src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.rs7
-rw-r--r--src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.stderr16
-rw-r--r--src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.rs31
-rw-r--r--src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.stderr52
12 files changed, 208 insertions, 0 deletions
diff --git a/src/test/ui/missing-trait-bounds/auxiliary/issue-69725.rs b/src/test/ui/missing-trait-bounds/auxiliary/issue-69725.rs
new file mode 100644
index 000000000..13606e498
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/auxiliary/issue-69725.rs
@@ -0,0 +1,8 @@
+#[derive(Clone)]
+pub struct Struct<A>(A);
+
+impl<A> Struct<A> {
+ pub fn new() -> Self {
+ todo!()
+ }
+}
diff --git a/src/test/ui/missing-trait-bounds/issue-35677.fixed b/src/test/ui/missing-trait-bounds/issue-35677.fixed
new file mode 100644
index 000000000..08174d8d8
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/issue-35677.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+#![allow(dead_code)]
+use std::collections::HashSet;
+use std::hash::Hash;
+
+fn is_subset<T>(this: &HashSet<T>, other: &HashSet<T>) -> bool where T: Eq, T: Hash {
+ this.is_subset(other)
+ //~^ ERROR the method
+}
+
+fn main() {}
diff --git a/src/test/ui/missing-trait-bounds/issue-35677.rs b/src/test/ui/missing-trait-bounds/issue-35677.rs
new file mode 100644
index 000000000..2cb394386
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/issue-35677.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+#![allow(dead_code)]
+use std::collections::HashSet;
+use std::hash::Hash;
+
+fn is_subset<T>(this: &HashSet<T>, other: &HashSet<T>) -> bool {
+ this.is_subset(other)
+ //~^ ERROR the method
+}
+
+fn main() {}
diff --git a/src/test/ui/missing-trait-bounds/issue-35677.stderr b/src/test/ui/missing-trait-bounds/issue-35677.stderr
new file mode 100644
index 000000000..a2201b946
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/issue-35677.stderr
@@ -0,0 +1,17 @@
+error[E0599]: the method `is_subset` exists for reference `&HashSet<T>`, but its trait bounds were not satisfied
+ --> $DIR/issue-35677.rs:7:10
+ |
+LL | this.is_subset(other)
+ | ^^^^^^^^^ method cannot be called on `&HashSet<T>` due to unsatisfied trait bounds
+ |
+ = note: the following trait bounds were not satisfied:
+ `T: Eq`
+ `T: Hash`
+help: consider restricting the type parameters to satisfy the trait bounds
+ |
+LL | fn is_subset<T>(this: &HashSet<T>, other: &HashSet<T>) -> bool where T: Eq, T: Hash {
+ | ++++++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/missing-trait-bounds/issue-69725.fixed b/src/test/ui/missing-trait-bounds/issue-69725.fixed
new file mode 100644
index 000000000..d57badcfd
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/issue-69725.fixed
@@ -0,0 +1,13 @@
+// run-rustfix
+// aux-build:issue-69725.rs
+#![allow(dead_code)]
+
+extern crate issue_69725;
+use issue_69725::Struct;
+
+fn crash<A>() where A: Clone {
+ let _ = Struct::<A>::new().clone();
+ //~^ ERROR: the method
+}
+
+fn main() {}
diff --git a/src/test/ui/missing-trait-bounds/issue-69725.rs b/src/test/ui/missing-trait-bounds/issue-69725.rs
new file mode 100644
index 000000000..9c88969c5
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/issue-69725.rs
@@ -0,0 +1,13 @@
+// run-rustfix
+// aux-build:issue-69725.rs
+#![allow(dead_code)]
+
+extern crate issue_69725;
+use issue_69725::Struct;
+
+fn crash<A>() {
+ let _ = Struct::<A>::new().clone();
+ //~^ ERROR: the method
+}
+
+fn main() {}
diff --git a/src/test/ui/missing-trait-bounds/issue-69725.stderr b/src/test/ui/missing-trait-bounds/issue-69725.stderr
new file mode 100644
index 000000000..980d9dd16
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/issue-69725.stderr
@@ -0,0 +1,22 @@
+error[E0599]: the method `clone` exists for struct `Struct<A>`, but its trait bounds were not satisfied
+ --> $DIR/issue-69725.rs:9:32
+ |
+LL | let _ = Struct::<A>::new().clone();
+ | ^^^^^ method cannot be called on `Struct<A>` due to unsatisfied trait bounds
+ |
+ ::: $DIR/auxiliary/issue-69725.rs:2:1
+ |
+LL | pub struct Struct<A>(A);
+ | -------------------- doesn't satisfy `Struct<A>: Clone`
+ |
+ = note: the following trait bounds were not satisfied:
+ `A: Clone`
+ which is required by `Struct<A>: Clone`
+help: consider restricting the type parameter to satisfy the trait bound
+ |
+LL | fn crash<A>() where A: Clone {
+ | ++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.fixed b/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.fixed
new file mode 100644
index 000000000..6b24375e4
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.fixed
@@ -0,0 +1,7 @@
+// run-rustfix
+
+pub fn foo<T: std::cmp::PartialEq>(s: &[T], t: &[T]) {
+ let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `&[T]`
+}
+
+fn main() {}
diff --git a/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.rs b/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.rs
new file mode 100644
index 000000000..df47be070
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.rs
@@ -0,0 +1,7 @@
+// run-rustfix
+
+pub fn foo<T>(s: &[T], t: &[T]) {
+ let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `&[T]`
+}
+
+fn main() {}
diff --git a/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.stderr b/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.stderr
new file mode 100644
index 000000000..cde075501
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/missing-trait-bound-for-op.stderr
@@ -0,0 +1,16 @@
+error[E0369]: binary operation `==` cannot be applied to type `&[T]`
+ --> $DIR/missing-trait-bound-for-op.rs:4:15
+ |
+LL | let _ = s == t;
+ | - ^^ - &[T]
+ | |
+ | &[T]
+ |
+help: consider restricting type parameter `T`
+ |
+LL | pub fn foo<T: std::cmp::PartialEq>(s: &[T], t: &[T]) {
+ | +++++++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0369`.
diff --git a/src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.rs b/src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.rs
new file mode 100644
index 000000000..afd47f71c
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.rs
@@ -0,0 +1,31 @@
+#[derive(Default, PartialEq)]
+struct Foo<T> {
+ bar: Box<[T]>,
+}
+
+trait Bar {
+ fn foo(&self) {}
+}
+
+impl<T: Default + Bar> Bar for Foo<T> {}
+
+impl<T> Foo<T> {
+ fn bar(&self) {
+ self.foo();
+ //~^ ERROR the method
+ }
+}
+
+struct Fin<T> where T: Bar {
+ bar: Box<[T]>,
+}
+
+impl<T: Default + Bar> Bar for Fin<T> {}
+
+impl<T: Bar> Fin<T> {
+ fn bar(&self) {
+ self.foo();
+ //~^ ERROR the method
+ }
+}
+fn main() {}
diff --git a/src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.stderr b/src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.stderr
new file mode 100644
index 000000000..9e94aa2c7
--- /dev/null
+++ b/src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.stderr
@@ -0,0 +1,52 @@
+error[E0599]: the method `foo` exists for reference `&Foo<T>`, but its trait bounds were not satisfied
+ --> $DIR/missing-trait-bounds-for-method-call.rs:14:14
+ |
+LL | struct Foo<T> {
+ | ------------- doesn't satisfy `Foo<T>: Bar`
+...
+LL | self.foo();
+ | ^^^ method cannot be called on `&Foo<T>` due to unsatisfied trait bounds
+ |
+note: trait bound `T: Default` was not satisfied
+ --> $DIR/missing-trait-bounds-for-method-call.rs:10:9
+ |
+LL | impl<T: Default + Bar> Bar for Foo<T> {}
+ | ^^^^^^^ --- ------
+ | |
+ | unsatisfied trait bound introduced here
+note: trait bound `T: Bar` was not satisfied
+ --> $DIR/missing-trait-bounds-for-method-call.rs:10:19
+ |
+LL | impl<T: Default + Bar> Bar for Foo<T> {}
+ | ^^^ --- ------
+ | |
+ | unsatisfied trait bound introduced here
+help: consider restricting the type parameters to satisfy the trait bounds
+ |
+LL | struct Foo<T> where T: Bar, T: Default {
+ | ++++++++++++++++++++++++
+
+error[E0599]: the method `foo` exists for reference `&Fin<T>`, but its trait bounds were not satisfied
+ --> $DIR/missing-trait-bounds-for-method-call.rs:27:14
+ |
+LL | struct Fin<T> where T: Bar {
+ | ------------- doesn't satisfy `Fin<T>: Bar`
+...
+LL | self.foo();
+ | ^^^ method cannot be called on `&Fin<T>` due to unsatisfied trait bounds
+ |
+note: trait bound `T: Default` was not satisfied
+ --> $DIR/missing-trait-bounds-for-method-call.rs:23:9
+ |
+LL | impl<T: Default + Bar> Bar for Fin<T> {}
+ | ^^^^^^^ --- ------
+ | |
+ | unsatisfied trait bound introduced here
+help: consider restricting the type parameter to satisfy the trait bound
+ |
+LL | struct Fin<T> where T: Bar, T: Default {
+ | ++++++++++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0599`.