diff options
| author | Henry Boisdequin <65845077+henryboisdequin@users.noreply.github.com> | 2021-03-09 20:12:47 +0530 |
|---|---|---|
| committer | Henry Boisdequin <65845077+henryboisdequin@users.noreply.github.com> | 2021-03-12 06:18:33 +0530 |
| commit | 26478c81fd3152eb0d272209dc02cdacfcb22aba (patch) | |
| tree | 02da80f47a2d62ffb5831ce8a17f68ff509f4cdb /src/test | |
| parent | bba2bac9fe6a4c72aff5c5ad10616d7ca7d169c1 (diff) | |
| download | rust-26478c81fd3152eb0d272209dc02cdacfcb22aba.tar.gz rust-26478c81fd3152eb0d272209dc02cdacfcb22aba.zip | |
Don't show note if `span` is `DUMMY_SP`
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/loops/issue-82916.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/loops/issue-82916.stderr | 23 |
2 files changed, 33 insertions, 0 deletions
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`. |
