about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.rs10
-rw-r--r--tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.stderr23
-rw-r--r--tests/ui/did_you_mean/issue-105225-named-args.rs10
-rw-r--r--tests/ui/did_you_mean/issue-105225-named-args.stderr22
-rw-r--r--tests/ui/did_you_mean/issue-105225.fixed21
-rw-r--r--tests/ui/did_you_mean/issue-105225.rs21
-rw-r--r--tests/ui/did_you_mean/issue-105225.stderr72
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs7
8 files changed, 186 insertions, 0 deletions
diff --git a/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.rs b/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.rs
new file mode 100644
index 00000000000..ced4434a7a7
--- /dev/null
+++ b/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.rs
@@ -0,0 +1,10 @@
+// check-fail
+// edition:2021
+
+// test for issue-114912 - debug ice: attempted to add with overflow
+
+async fn main() {
+    //~^ ERROR `main` function is not allowed to be `async`
+    [0usize; 0xffff_ffff_ffff_ffff].await;
+    //~^ ERROR `[usize; usize::MAX]` is not a future
+}
diff --git a/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.stderr b/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.stderr
new file mode 100644
index 00000000000..8c9d06c79ca
--- /dev/null
+++ b/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.stderr
@@ -0,0 +1,23 @@
+error[E0277]: `[usize; usize::MAX]` is not a future
+  --> $DIR/debug-ice-attempted-to-add-with-overflow.rs:8:37
+   |
+LL |     [0usize; 0xffff_ffff_ffff_ffff].await;
+   |                                    -^^^^^
+   |                                    ||
+   |                                    |`[usize; usize::MAX]` is not a future
+   |                                    help: remove the `.await`
+   |
+   = help: the trait `Future` is not implemented for `[usize; usize::MAX]`
+   = note: [usize; usize::MAX] must be a future or must implement `IntoFuture` to be awaited
+   = note: required for `[usize; usize::MAX]` to implement `IntoFuture`
+
+error[E0752]: `main` function is not allowed to be `async`
+  --> $DIR/debug-ice-attempted-to-add-with-overflow.rs:6:1
+   |
+LL | async fn main() {
+   | ^^^^^^^^^^^^^^^ `main` function is not allowed to be `async`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0277, E0752.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/did_you_mean/issue-105225-named-args.rs b/tests/ui/did_you_mean/issue-105225-named-args.rs
new file mode 100644
index 00000000000..38e81776576
--- /dev/null
+++ b/tests/ui/did_you_mean/issue-105225-named-args.rs
@@ -0,0 +1,10 @@
+fn main() {
+    let x = "x";
+    let y = "y";
+
+    println!("{x}", x, x = y);
+    //~^ ERROR: redundant argument
+
+    println!("{x}", x = y, x = y);
+    //~^ ERROR: duplicate argument named `x`
+}
diff --git a/tests/ui/did_you_mean/issue-105225-named-args.stderr b/tests/ui/did_you_mean/issue-105225-named-args.stderr
new file mode 100644
index 00000000000..72204102ef6
--- /dev/null
+++ b/tests/ui/did_you_mean/issue-105225-named-args.stderr
@@ -0,0 +1,22 @@
+error: redundant argument
+  --> $DIR/issue-105225-named-args.rs:5:21
+   |
+LL |     println!("{x}", x, x = y);
+   |                     ^
+   |
+note: the formatting specifier is referencing the binding already
+  --> $DIR/issue-105225-named-args.rs:5:16
+   |
+LL |     println!("{x}", x, x = y);
+   |                ^
+
+error: duplicate argument named `x`
+  --> $DIR/issue-105225-named-args.rs:8:28
+   |
+LL |     println!("{x}", x = y, x = y);
+   |                     -      ^ duplicate argument
+   |                     |
+   |                     previously here
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/did_you_mean/issue-105225.fixed b/tests/ui/did_you_mean/issue-105225.fixed
new file mode 100644
index 00000000000..f756be615a1
--- /dev/null
+++ b/tests/ui/did_you_mean/issue-105225.fixed
@@ -0,0 +1,21 @@
+// run-rustfix
+
+fn main() {
+    let x = "x";
+    let y = "y";
+
+    println!("{x}", );
+    //~^ ERROR: redundant argument
+
+    println!("{x} {}", x, );
+    //~^ ERROR: redundant argument
+
+    println!("{} {x}", x, );
+    //~^ ERROR: redundant argument
+
+    println!("{x} {y}", );
+    //~^ ERROR: redundant arguments
+
+    println!("{} {} {x} {y} {}", x, x, x, );
+    //~^ ERROR: redundant arguments
+}
diff --git a/tests/ui/did_you_mean/issue-105225.rs b/tests/ui/did_you_mean/issue-105225.rs
new file mode 100644
index 00000000000..91cdf0eb28f
--- /dev/null
+++ b/tests/ui/did_you_mean/issue-105225.rs
@@ -0,0 +1,21 @@
+// run-rustfix
+
+fn main() {
+    let x = "x";
+    let y = "y";
+
+    println!("{x}", x);
+    //~^ ERROR: redundant argument
+
+    println!("{x} {}", x, x);
+    //~^ ERROR: redundant argument
+
+    println!("{} {x}", x, x);
+    //~^ ERROR: redundant argument
+
+    println!("{x} {y}", x, y);
+    //~^ ERROR: redundant arguments
+
+    println!("{} {} {x} {y} {}", x, x, x, y, y);
+    //~^ ERROR: redundant arguments
+}
diff --git a/tests/ui/did_you_mean/issue-105225.stderr b/tests/ui/did_you_mean/issue-105225.stderr
new file mode 100644
index 00000000000..5fb46222bee
--- /dev/null
+++ b/tests/ui/did_you_mean/issue-105225.stderr
@@ -0,0 +1,72 @@
+error: redundant argument
+  --> $DIR/issue-105225.rs:7:21
+   |
+LL |     println!("{x}", x);
+   |                     ^ help: this can be removed
+   |
+note: the formatting specifier is referencing the binding already
+  --> $DIR/issue-105225.rs:7:16
+   |
+LL |     println!("{x}", x);
+   |                ^
+
+error: redundant argument
+  --> $DIR/issue-105225.rs:10:27
+   |
+LL |     println!("{x} {}", x, x);
+   |                           ^ help: this can be removed
+   |
+note: the formatting specifier is referencing the binding already
+  --> $DIR/issue-105225.rs:10:16
+   |
+LL |     println!("{x} {}", x, x);
+   |                ^
+
+error: redundant argument
+  --> $DIR/issue-105225.rs:13:27
+   |
+LL |     println!("{} {x}", x, x);
+   |                           ^ help: this can be removed
+   |
+note: the formatting specifier is referencing the binding already
+  --> $DIR/issue-105225.rs:13:19
+   |
+LL |     println!("{} {x}", x, x);
+   |                   ^
+
+error: redundant arguments
+  --> $DIR/issue-105225.rs:16:25
+   |
+LL |     println!("{x} {y}", x, y);
+   |                         ^  ^
+   |
+note: the formatting specifiers are referencing the bindings already
+  --> $DIR/issue-105225.rs:16:16
+   |
+LL |     println!("{x} {y}", x, y);
+   |                ^   ^
+help: this can be removed
+   |
+LL -     println!("{x} {y}", x, y);
+LL +     println!("{x} {y}", );
+   |
+
+error: redundant arguments
+  --> $DIR/issue-105225.rs:19:43
+   |
+LL |     println!("{} {} {x} {y} {}", x, x, x, y, y);
+   |                                           ^  ^
+   |
+note: the formatting specifiers are referencing the bindings already
+  --> $DIR/issue-105225.rs:19:26
+   |
+LL |     println!("{} {} {x} {y} {}", x, x, x, y, y);
+   |                          ^
+help: this can be removed
+   |
+LL -     println!("{} {} {x} {y} {}", x, x, x, y, y);
+LL +     println!("{} {} {x} {y} {}", x, x, x, );
+   |
+
+error: aborting due to 5 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs
index ecfeb3f9b98..e0a6051a81f 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs
@@ -251,3 +251,10 @@ fn main() {
 pub fn takes_non_exhaustive(_: NonExhaustiveEnum) {
     let _closure = |_: NonExhaustiveEnum| {};
 }
+
+// ICE #117033
+enum Void {}
+#[deny(non_exhaustive_omitted_patterns)]
+pub fn void(v: Void) -> ! {
+    match v {}
+}