From 26478c81fd3152eb0d272209dc02cdacfcb22aba Mon Sep 17 00:00:00 2001 From: Henry Boisdequin <65845077+henryboisdequin@users.noreply.github.com> Date: Tue, 9 Mar 2021 20:12:47 +0530 Subject: Don't show note if `span` is `DUMMY_SP` --- src/test/ui/loops/issue-82916.rs | 10 ++++++++++ src/test/ui/loops/issue-82916.stderr | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/test/ui/loops/issue-82916.rs create mode 100644 src/test/ui/loops/issue-82916.stderr (limited to 'src') 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) { + 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) { + | - move occurs because `x` has type `Vec`, 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`. -- cgit 1.4.1-3-g733a5