about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr4
-rw-r--r--src/test/ui/consts/const-fn-in-vec.stderr4
-rw-r--r--src/test/ui/loops/issue-82916.rs10
-rw-r--r--src/test/ui/loops/issue-82916.stderr23
4 files changed, 37 insertions, 4 deletions
diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr
index 303de078013..329c6cb2b12 100644
--- a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr
+++ b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr
@@ -7,8 +7,8 @@ LL |     let _: [Option<Bar>; 2] = [no_copy(); 2];
    = help: the following implementations were found:
              <Option<T> as Copy>
    = note: the `Copy` trait is required because the repeated element will be copied
-   = help: consider creating a new `const` item and initializing with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
-   = help: create an inline `const` block, see PR #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
+   = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
+   = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/consts/const-fn-in-vec.stderr b/src/test/ui/consts/const-fn-in-vec.stderr
index f9f184dfc06..f02cb4f1ff1 100644
--- a/src/test/ui/consts/const-fn-in-vec.stderr
+++ b/src/test/ui/consts/const-fn-in-vec.stderr
@@ -5,8 +5,8 @@ LL |     let strings: [String; 5] = [String::new(); 5];
    |                                ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
    |
    = note: the `Copy` trait is required because the repeated element will be copied
-   = help: consider creating a new `const` item and initializing with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
-   = help: create an inline `const` block, see PR #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
+   = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
+   = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/loops/issue-82916.rs b/src/test/ui/loops/issue-82916.rs
new file mode 100644
index 00000000000..8633ea1e8cb
--- /dev/null
+++ b/src/test/ui/loops/issue-82916.rs
@@ -0,0 +1,10 @@
+struct S(i32);
+
+fn foo(x: Vec<S>) {
+    for y in x {
+
+    }
+    let z = x; //~ ERROR use of moved value: `x`
+}
+
+fn main() {}
diff --git a/src/test/ui/loops/issue-82916.stderr b/src/test/ui/loops/issue-82916.stderr
new file mode 100644
index 00000000000..ad42cce71f6
--- /dev/null
+++ b/src/test/ui/loops/issue-82916.stderr
@@ -0,0 +1,23 @@
+error[E0382]: use of moved value: `x`
+  --> $DIR/issue-82916.rs:7:13
+   |
+LL | fn foo(x: Vec<S>) {
+   |        - move occurs because `x` has type `Vec<S>`, which does not implement the `Copy` trait
+LL |     for y in x {
+   |              -
+   |              |
+   |              `x` moved due to this implicit call to `.into_iter()`
+   |              help: consider borrowing to avoid moving into the for loop: `&x`
+...
+LL |     let z = x;
+   |             ^ value used here after move
+   |
+note: this function takes ownership of the receiver `self`, which moves `x`
+  --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
+   |
+LL |     fn into_iter(self) -> Self::IntoIter;
+   |                  ^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0382`.