summaryrefslogtreecommitdiffstats
path: root/src/test/ui/argument-suggestions/invalid_arguments.rs
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/argument-suggestions/invalid_arguments.rs
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/argument-suggestions/invalid_arguments.rs')
-rw-r--r--src/test/ui/argument-suggestions/invalid_arguments.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/ui/argument-suggestions/invalid_arguments.rs b/src/test/ui/argument-suggestions/invalid_arguments.rs
new file mode 100644
index 000000000..53fbdd4b5
--- /dev/null
+++ b/src/test/ui/argument-suggestions/invalid_arguments.rs
@@ -0,0 +1,43 @@
+// More nuanced test cases for invalid arguments #65853
+
+struct X {}
+
+fn one_arg(_a: i32) {}
+fn two_arg_same(_a: i32, _b: i32) {}
+fn two_arg_diff(_a: i32, _b: f32) {}
+fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
+fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
+
+fn main() {
+ // Providing an incorrect argument for a single parameter function
+ one_arg(1.0); //~ ERROR mismatched types
+
+ // Providing one or two invalid arguments to a two parameter function
+ two_arg_same(1, ""); //~ ERROR mismatched types
+ two_arg_same("", 1); //~ ERROR mismatched types
+ two_arg_same("", ""); //~ ERROR arguments to this function are incorrect
+ two_arg_diff(1, ""); //~ ERROR mismatched types
+ two_arg_diff("", 1.0); //~ ERROR mismatched types
+ two_arg_diff("", ""); //~ ERROR arguments to this function are incorrect
+
+ // Providing invalid arguments to a three parameter function
+ three_arg_diff(X{}, 1.0, ""); //~ ERROR mismatched types
+ three_arg_diff(1, X {}, ""); //~ ERROR mismatched types
+ three_arg_diff(1, 1.0, X {}); //~ ERROR mismatched types
+
+ three_arg_diff(X {}, X {}, ""); //~ ERROR arguments to this function are incorrect
+ three_arg_diff(X {}, 1.0, X {}); //~ ERROR arguments to this function are incorrect
+ three_arg_diff(1, X {}, X {}); //~ ERROR arguments to this function are incorrect
+
+ three_arg_diff(X {}, X {}, X {}); //~ ERROR arguments to this function are incorrect
+
+ three_arg_repeat(X {}, 1, ""); //~ ERROR mismatched types
+ three_arg_repeat(1, X {}, ""); //~ ERROR mismatched types
+ three_arg_repeat(1, 1, X {}); //~ ERROR mismatched types
+
+ three_arg_repeat(X {}, X {}, ""); //~ ERROR arguments to this function are incorrect
+ three_arg_repeat(X {}, 1, X {}); //~ ERROR arguments to this function are incorrect
+ three_arg_repeat(1, X {}, X{}); //~ ERROR arguments to this function are incorrect
+
+ three_arg_repeat(X {}, X {}, X {}); //~ ERROR arguments to this function are incorrect
+}