summaryrefslogtreecommitdiffstats
path: root/src/test/ui/argument-suggestions
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /src/test/ui/argument-suggestions
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/argument-suggestions')
-rw-r--r--src/test/ui/argument-suggestions/formal-and-expected-differ.rs25
-rw-r--r--src/test/ui/argument-suggestions/formal-and-expected-differ.stderr30
2 files changed, 55 insertions, 0 deletions
diff --git a/src/test/ui/argument-suggestions/formal-and-expected-differ.rs b/src/test/ui/argument-suggestions/formal-and-expected-differ.rs
new file mode 100644
index 000000000..5e3b55ca5
--- /dev/null
+++ b/src/test/ui/argument-suggestions/formal-and-expected-differ.rs
@@ -0,0 +1,25 @@
+pub trait Foo {
+ type T;
+}
+
+impl Foo for i32 {
+ type T = f32;
+}
+
+pub struct U<T1, T2>(T1, S<T2>)
+where
+ T1: Foo<T = T2>;
+
+pub struct S<T>(T);
+
+fn main() {
+ // The error message here isn't great -- it has to do with the fact that the
+ // `expected_inputs_for_expected_output` deduced inputs differs from the inputs
+ // that we infer from the constraints of the signature.
+ //
+ // I am not really sure what the best way of presenting this error message is,
+ // since right now it just suggests changing `3u32` <=> `3f32` back and forth.
+ let _: U<_, u32> = U(1, S(3u32));
+ //~^ ERROR mismatched types
+ //~| ERROR mismatched types
+}
diff --git a/src/test/ui/argument-suggestions/formal-and-expected-differ.stderr b/src/test/ui/argument-suggestions/formal-and-expected-differ.stderr
new file mode 100644
index 000000000..905875b52
--- /dev/null
+++ b/src/test/ui/argument-suggestions/formal-and-expected-differ.stderr
@@ -0,0 +1,30 @@
+error[E0308]: mismatched types
+ --> $DIR/formal-and-expected-differ.rs:22:29
+ |
+LL | let _: U<_, u32> = U(1, S(3u32));
+ | - ^^^^^^^ expected `f32`, found `u32`
+ | |
+ | arguments to this struct are incorrect
+ |
+ = note: expected struct `S<f32>`
+ found struct `S<u32>`
+note: tuple struct defined here
+ --> $DIR/formal-and-expected-differ.rs:9:12
+ |
+LL | pub struct U<T1, T2>(T1, S<T2>)
+ | ^
+
+error[E0308]: mismatched types
+ --> $DIR/formal-and-expected-differ.rs:22:24
+ |
+LL | let _: U<_, u32> = U(1, S(3u32));
+ | --------- ^^^^^^^^^^^^^ expected `u32`, found `f32`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `U<_, u32>`
+ found struct `U<i32, f32>`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.