summaryrefslogtreecommitdiffstats
path: root/src/test/ui/mismatched_types
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:21 +0000
commit4e8199b572f2035b7749cba276ece3a26630d23e (patch)
treef09feeed6a0fe39d027b1908aa63ea6b35e4b631 /src/test/ui/mismatched_types
parentAdding upstream version 1.66.0+dfsg1. (diff)
downloadrustc-4e8199b572f2035b7749cba276ece3a26630d23e.tar.xz
rustc-4e8199b572f2035b7749cba276ece3a26630d23e.zip
Adding upstream version 1.67.1+dfsg1.upstream/1.67.1+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/mismatched_types')
-rw-r--r--src/test/ui/mismatched_types/binops.stderr13
-rw-r--r--src/test/ui/mismatched_types/overloaded-calls-bad.rs19
-rw-r--r--src/test/ui/mismatched_types/overloaded-calls-bad.stderr22
-rw-r--r--src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs4
4 files changed, 38 insertions, 20 deletions
diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr
index 3de652d87..3585587ed 100644
--- a/src/test/ui/mismatched_types/binops.stderr
+++ b/src/test/ui/mismatched_types/binops.stderr
@@ -24,15 +24,10 @@ LL | 2 as usize - Some(1);
|
= help: the trait `Sub<Option<{integer}>>` is not implemented for `usize`
= help: the following other types implement trait `Sub<Rhs>`:
- <&'a f32 as Sub<f32>>
- <&'a f64 as Sub<f64>>
- <&'a i128 as Sub<i128>>
- <&'a i16 as Sub<i16>>
- <&'a i32 as Sub<i32>>
- <&'a i64 as Sub<i64>>
- <&'a i8 as Sub<i8>>
- <&'a isize as Sub<isize>>
- and 48 others
+ <&'a usize as Sub<usize>>
+ <&usize as Sub<&usize>>
+ <usize as Sub<&usize>>
+ <usize as Sub>
error[E0277]: cannot multiply `{integer}` by `()`
--> $DIR/binops.rs:4:7
diff --git a/src/test/ui/mismatched_types/overloaded-calls-bad.rs b/src/test/ui/mismatched_types/overloaded-calls-bad.rs
index 902a6ec81..232cd2ba8 100644
--- a/src/test/ui/mismatched_types/overloaded-calls-bad.rs
+++ b/src/test/ui/mismatched_types/overloaded-calls-bad.rs
@@ -20,14 +20,23 @@ impl FnOnce<(isize,)> for S {
}
}
+struct F;
+
+impl FnOnce<(i32,)> for F {
+ type Output = ();
+
+ extern "rust-call" fn call_once(self, args: (i32,)) -> Self::Output {}
+}
+
fn main() {
- let mut s = S {
- x: 3,
- y: 3,
- };
- let ans = s("what"); //~ ERROR mismatched types
+ let mut s = S { x: 3, y: 3 };
+ let ans = s("what");
+ //~^ ERROR mismatched types
let ans = s();
//~^ ERROR this function takes 1 argument but 0 arguments were supplied
let ans = s("burma", "shave");
//~^ ERROR this function takes 1 argument but 2 arguments were supplied
+
+ F("");
+ //~^ ERROR mismatched types
}
diff --git a/src/test/ui/mismatched_types/overloaded-calls-bad.stderr b/src/test/ui/mismatched_types/overloaded-calls-bad.stderr
index fb3597aa8..3a895acbd 100644
--- a/src/test/ui/mismatched_types/overloaded-calls-bad.stderr
+++ b/src/test/ui/mismatched_types/overloaded-calls-bad.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/overloaded-calls-bad.rs:28:17
+ --> $DIR/overloaded-calls-bad.rs:33:17
|
LL | let ans = s("what");
| - ^^^^^^ expected `isize`, found `&str`
@@ -13,7 +13,7 @@ LL | impl FnMut<(isize,)> for S {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0057]: this function takes 1 argument but 0 arguments were supplied
- --> $DIR/overloaded-calls-bad.rs:29:15
+ --> $DIR/overloaded-calls-bad.rs:35:15
|
LL | let ans = s();
| ^-- an argument of type `isize` is missing
@@ -29,7 +29,7 @@ LL | let ans = s(/* isize */);
| ~~~~~~~~~~~~~
error[E0057]: this function takes 1 argument but 2 arguments were supplied
- --> $DIR/overloaded-calls-bad.rs:31:15
+ --> $DIR/overloaded-calls-bad.rs:37:15
|
LL | let ans = s("burma", "shave");
| ^ ------- ------- argument of type `&'static str` unexpected
@@ -46,7 +46,21 @@ help: remove the extra argument
LL | let ans = s(/* isize */);
| ~~~~~~~~~~~~~
-error: aborting due to 3 previous errors
+error[E0308]: mismatched types
+ --> $DIR/overloaded-calls-bad.rs:40:7
+ |
+LL | F("");
+ | - ^^ expected `i32`, found `&str`
+ | |
+ | arguments to this struct are incorrect
+ |
+note: implementation defined here
+ --> $DIR/overloaded-calls-bad.rs:25:1
+ |
+LL | impl FnOnce<(i32,)> for F {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
Some errors have detailed explanations: E0057, E0308.
For more information about an error, try `rustc --explain E0057`.
diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs
index 8dbe3472e..307104e47 100644
--- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs
+++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs
@@ -1,8 +1,8 @@
-#![feature(unboxed_closures)]
+#![feature(unboxed_closures,tuple_trait)]
use std::ops::FnMut;
-fn to_fn_mut<A, F: FnMut<A>>(f: F) -> F { f }
+fn to_fn_mut<A:std::marker::Tuple, F:FnMut<A>>(f: F) -> F { f }
fn call_it<F: FnMut(isize, isize) -> isize>(y: isize, mut f: F) -> isize {
//~^ NOTE required by this bound in `call_it`