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/async-gen-move-suggestion.fixed35
-rw-r--r--tests/ui/async-await/async-gen-move-suggestion.rs35
-rw-r--r--tests/ui/async-await/async-gen-move-suggestion.stderr47
-rw-r--r--tests/ui/consts/const-blocks/const-block-in-array-size.rs5
-rw-r--r--tests/ui/impl-trait/in-trait/dont-probe-missing-item-name.rs12
-rw-r--r--tests/ui/impl-trait/in-trait/dont-probe-missing-item-name.stderr9
-rw-r--r--tests/ui/mir-dataflow/README.md9
7 files changed, 143 insertions, 9 deletions
diff --git a/tests/ui/async-await/async-gen-move-suggestion.fixed b/tests/ui/async-await/async-gen-move-suggestion.fixed
new file mode 100644
index 00000000000..d8020765528
--- /dev/null
+++ b/tests/ui/async-await/async-gen-move-suggestion.fixed
@@ -0,0 +1,35 @@
+// This is a regression test for <https://github.com/rust-lang/rust/issues/139839>.
+// It ensures that the "add `move` keyword" suggestion is valid.
+
+//@ run-rustfix
+//@ edition:2024
+
+#![feature(coroutines)]
+#![feature(gen_blocks)]
+#![feature(async_iterator)]
+
+use std::async_iter::AsyncIterator;
+
+#[allow(dead_code)]
+fn moved() -> impl AsyncIterator<Item = u32> {
+    let mut x = "foo".to_string();
+
+    async gen move { //~ ERROR
+        x.clear();
+        for x in 3..6 { yield x }
+    }
+}
+
+#[allow(dead_code)]
+fn check_with_whitespace_chars() -> impl AsyncIterator<Item = u32> {
+    let mut x = "foo".to_string();
+
+    async // Just to check that whitespace characters are correctly handled
+    gen move { //~^ ERROR
+        x.clear();
+        for x in 3..6 { yield x }
+    }
+}
+
+fn main() {
+}
diff --git a/tests/ui/async-await/async-gen-move-suggestion.rs b/tests/ui/async-await/async-gen-move-suggestion.rs
new file mode 100644
index 00000000000..825fb0fd189
--- /dev/null
+++ b/tests/ui/async-await/async-gen-move-suggestion.rs
@@ -0,0 +1,35 @@
+// This is a regression test for <https://github.com/rust-lang/rust/issues/139839>.
+// It ensures that the "add `move` keyword" suggestion is valid.
+
+//@ run-rustfix
+//@ edition:2024
+
+#![feature(coroutines)]
+#![feature(gen_blocks)]
+#![feature(async_iterator)]
+
+use std::async_iter::AsyncIterator;
+
+#[allow(dead_code)]
+fn moved() -> impl AsyncIterator<Item = u32> {
+    let mut x = "foo".to_string();
+
+    async gen { //~ ERROR
+        x.clear();
+        for x in 3..6 { yield x }
+    }
+}
+
+#[allow(dead_code)]
+fn check_with_whitespace_chars() -> impl AsyncIterator<Item = u32> {
+    let mut x = "foo".to_string();
+
+    async // Just to check that whitespace characters are correctly handled
+    gen { //~^ ERROR
+        x.clear();
+        for x in 3..6 { yield x }
+    }
+}
+
+fn main() {
+}
diff --git a/tests/ui/async-await/async-gen-move-suggestion.stderr b/tests/ui/async-await/async-gen-move-suggestion.stderr
new file mode 100644
index 00000000000..b8cdb8be7a4
--- /dev/null
+++ b/tests/ui/async-await/async-gen-move-suggestion.stderr
@@ -0,0 +1,47 @@
+error[E0373]: async gen block may outlive the current function, but it borrows `x`, which is owned by the current function
+  --> $DIR/async-gen-move-suggestion.rs:17:5
+   |
+LL |     async gen {
+   |     ^^^^^^^^^ may outlive borrowed value `x`
+LL |         x.clear();
+   |         - `x` is borrowed here
+   |
+note: async gen block is returned here
+  --> $DIR/async-gen-move-suggestion.rs:17:5
+   |
+LL | /     async gen {
+LL | |         x.clear();
+LL | |         for x in 3..6 { yield x }
+LL | |     }
+   | |_____^
+help: to force the async gen block to take ownership of `x` (and any other referenced variables), use the `move` keyword
+   |
+LL |     async gen move {
+   |               ++++
+
+error[E0373]: async gen block may outlive the current function, but it borrows `x`, which is owned by the current function
+  --> $DIR/async-gen-move-suggestion.rs:27:5
+   |
+LL | /     async // Just to check that whitespace characters are correctly handled
+LL | |     gen {
+   | |_______^ may outlive borrowed value `x`
+LL |           x.clear();
+   |           - `x` is borrowed here
+   |
+note: async gen block is returned here
+  --> $DIR/async-gen-move-suggestion.rs:27:5
+   |
+LL | /     async // Just to check that whitespace characters are correctly handled
+LL | |     gen {
+LL | |         x.clear();
+LL | |         for x in 3..6 { yield x }
+LL | |     }
+   | |_____^
+help: to force the async gen block to take ownership of `x` (and any other referenced variables), use the `move` keyword
+   |
+LL |     gen move {
+   |         ++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0373`.
diff --git a/tests/ui/consts/const-blocks/const-block-in-array-size.rs b/tests/ui/consts/const-blocks/const-block-in-array-size.rs
new file mode 100644
index 00000000000..ecab2432286
--- /dev/null
+++ b/tests/ui/consts/const-blocks/const-block-in-array-size.rs
@@ -0,0 +1,5 @@
+//@ check-pass
+
+type A = [u32; const { 2 }];
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name.rs b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name.rs
new file mode 100644
index 00000000000..450f41e209d
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name.rs
@@ -0,0 +1,12 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/139873>.
+
+// Test that we don't try to get the (nonexistent) name of the RPITIT in `Trait::foo`
+// when emitting an error for a missing associated item `Trait::Output`.
+
+trait Trait {
+    fn foo() -> impl Sized;
+    fn bar() -> Self::Output;
+    //~^ ERROR associated type `Output` not found for `Self`
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name.stderr b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name.stderr
new file mode 100644
index 00000000000..74e15785af1
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name.stderr
@@ -0,0 +1,9 @@
+error[E0220]: associated type `Output` not found for `Self`
+  --> $DIR/dont-probe-missing-item-name.rs:8:23
+   |
+LL |     fn bar() -> Self::Output;
+   |                       ^^^^^^ associated type `Output` not found
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0220`.
diff --git a/tests/ui/mir-dataflow/README.md b/tests/ui/mir-dataflow/README.md
index a3ab14b23c7..886020226d0 100644
--- a/tests/ui/mir-dataflow/README.md
+++ b/tests/ui/mir-dataflow/README.md
@@ -42,12 +42,3 @@ each generated output path.
    on *entry* to each block, as well as the gen- and kill-sets that
    were so-called "transfer functions" summarizing the effect of each
    basic block.
-
- * (In addition to the `borrowck_graphviz_postflow` attribute-key
-   noted above, there is also `borrowck_graphviz_preflow`; it has the
-   same interface and generates the same set of files, but it renders
-   the dataflow state after building the gen- and kill-sets but
-   *before* running the dataflow analysis itself, so each entry-set is
-   just the initial default state for that dataflow analysis. This is
-   less useful for understanding the error message output in these
-   tests.)