summaryrefslogtreecommitdiffstats
path: root/tests/ui/trait-bounds
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:42 +0000
commitcec1877e180393eba0f6ddb0cf97bf3a791631c7 (patch)
tree47b4dac2a9dd9a40c30c251b4d4a72d7ccf77e9f /tests/ui/trait-bounds
parentAdding debian version 1.74.1+dfsg1-1. (diff)
downloadrustc-cec1877e180393eba0f6ddb0cf97bf3a791631c7.tar.xz
rustc-cec1877e180393eba0f6ddb0cf97bf3a791631c7.zip
Merging upstream version 1.75.0+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/impl-bound-with-references-error.stderr7
-rw-r--r--tests/ui/trait-bounds/mismatch-fn-trait.stderr20
-rw-r--r--tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.fixed11
-rw-r--r--tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.rs11
-rw-r--r--tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.stderr20
5 files changed, 57 insertions, 12 deletions
diff --git a/tests/ui/trait-bounds/impl-bound-with-references-error.stderr b/tests/ui/trait-bounds/impl-bound-with-references-error.stderr
index b114d295d..63280b861 100644
--- a/tests/ui/trait-bounds/impl-bound-with-references-error.stderr
+++ b/tests/ui/trait-bounds/impl-bound-with-references-error.stderr
@@ -12,8 +12,11 @@ LL + use std::borrow::Cow;
error[E0119]: conflicting implementations of trait `From<LabelText>` for type `LabelText`
--> $DIR/impl-bound-with-references-error.rs:9:1
|
-LL | impl<T> From<T> for LabelText
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | / impl<T> From<T> for LabelText
+LL | |
+LL | | where
+LL | | T: Into<Cow<'static, str>>,
+ | |_______________________________^
|
= note: conflicting implementation in crate `core`:
- impl<T> From<T> for T;
diff --git a/tests/ui/trait-bounds/mismatch-fn-trait.stderr b/tests/ui/trait-bounds/mismatch-fn-trait.stderr
index 961e6d88f..519aa9ea3 100644
--- a/tests/ui/trait-bounds/mismatch-fn-trait.stderr
+++ b/tests/ui/trait-bounds/mismatch-fn-trait.stderr
@@ -1,8 +1,8 @@
-error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnMut(u32)`
+error[E0277]: expected a `FnMut(i32)` closure, found `impl FnMut(u32)`
--> $DIR/mismatch-fn-trait.rs:4:10
|
LL | take(f)
- | ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnMut(u32)`
+ | ---- ^ expected an `FnMut(i32)` closure, found `impl FnMut(u32)`
| |
| required by a bound introduced by this call
|
@@ -14,11 +14,11 @@ note: required by a bound in `take`
LL | fn take(_f: impl FnMut(i32)) {}
| ^^^^^^^^^^ required by this bound in `take`
-error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnMut(i32, i32)`
+error[E0277]: expected a `FnMut(i32)` closure, found `impl FnMut(i32, i32)`
--> $DIR/mismatch-fn-trait.rs:9:10
|
LL | take(f)
- | ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnMut(i32, i32)`
+ | ---- ^ expected an `FnMut(i32)` closure, found `impl FnMut(i32, i32)`
| |
| required by a bound introduced by this call
|
@@ -29,11 +29,11 @@ note: required by a bound in `take`
LL | fn take(_f: impl FnMut(i32)) {}
| ^^^^^^^^^^ required by this bound in `take`
-error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnMut()`
+error[E0277]: expected a `FnMut(i32)` closure, found `impl FnMut()`
--> $DIR/mismatch-fn-trait.rs:14:10
|
LL | take(f)
- | ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnMut()`
+ | ---- ^ expected an `FnMut(i32)` closure, found `impl FnMut()`
| |
| required by a bound introduced by this call
|
@@ -44,11 +44,11 @@ note: required by a bound in `take`
LL | fn take(_f: impl FnMut(i32)) {}
| ^^^^^^^^^^ required by this bound in `take`
-error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnOnce(i32)`
+error[E0277]: expected a `FnMut(i32)` closure, found `impl FnOnce(i32)`
--> $DIR/mismatch-fn-trait.rs:19:10
|
LL | take(f)
- | ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnOnce(i32)`
+ | ---- ^ expected an `FnMut(i32)` closure, found `impl FnOnce(i32)`
| |
| required by a bound introduced by this call
|
@@ -59,11 +59,11 @@ note: required by a bound in `take`
LL | fn take(_f: impl FnMut(i32)) {}
| ^^^^^^^^^^ required by this bound in `take`
-error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnOnce(u32)`
+error[E0277]: expected a `FnMut(i32)` closure, found `impl FnOnce(u32)`
--> $DIR/mismatch-fn-trait.rs:24:10
|
LL | take(f)
- | ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnOnce(u32)`
+ | ---- ^ expected an `FnMut(i32)` closure, found `impl FnOnce(u32)`
| |
| required by a bound introduced by this call
|
diff --git a/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.fixed b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.fixed
new file mode 100644
index 000000000..b3f5ad52d
--- /dev/null
+++ b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+pub trait MyTrait {
+ type T;
+
+ fn bar(self) -> Self::T;
+}
+
+pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B {
+ return a.bar(); //~ ERROR mismatched types
+}
+fn main() {}
diff --git a/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.rs b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.rs
new file mode 100644
index 000000000..213abda77
--- /dev/null
+++ b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+pub trait MyTrait {
+ type T;
+
+ fn bar(self) -> Self::T;
+}
+
+pub fn foo<A: MyTrait, B>(a: A) -> B {
+ return a.bar(); //~ ERROR mismatched types
+}
+fn main() {}
diff --git a/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.stderr b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.stderr
new file mode 100644
index 000000000..61132efc4
--- /dev/null
+++ b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.stderr
@@ -0,0 +1,20 @@
+error[E0308]: mismatched types
+ --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12
+ |
+LL | pub fn foo<A: MyTrait, B>(a: A) -> B {
+ | - - expected `B` because of return type
+ | |
+ | expected this type parameter
+LL | return a.bar();
+ | ^^^^^^^ expected type parameter `B`, found associated type
+ |
+ = note: expected type parameter `B`
+ found associated type `<A as MyTrait>::T`
+help: consider further restricting this bound
+ |
+LL | pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B {
+ | +++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.