diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:42 +0000 |
commit | cec1877e180393eba0f6ddb0cf97bf3a791631c7 (patch) | |
tree | 47b4dac2a9dd9a40c30c251b4d4a72d7ccf77e9f /tests/ui/suggestions/issue-102972.stderr | |
parent | Adding debian version 1.74.1+dfsg1-1. (diff) | |
download | rustc-cec1877e180393eba0f6ddb0cf97bf3a791631c7.tar.xz rustc-cec1877e180393eba0f6ddb0cf97bf3a791631c7.zip |
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/suggestions/issue-102972.stderr')
-rw-r--r-- | tests/ui/suggestions/issue-102972.stderr | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/tests/ui/suggestions/issue-102972.stderr b/tests/ui/suggestions/issue-102972.stderr index 3303d6bbc..4b0d3b96f 100644 --- a/tests/ui/suggestions/issue-102972.stderr +++ b/tests/ui/suggestions/issue-102972.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `chars` as mutable more than once at a time - --> $DIR/issue-102972.rs:4:9 + --> $DIR/issue-102972.rs:6:9 | LL | for _c in chars.by_ref() { | -------------- @@ -8,9 +8,17 @@ LL | for _c in chars.by_ref() { | first borrow later used here LL | chars.next(); | ^^^^^ second mutable borrow occurs here + | + = note: a for loop advances the iterator for you, the result is stored in `_c` +help: if you want to call `next` on a iterator within the loop, consider using `while let` + | +LL ~ let iter = chars.by_ref(); +LL ~ while let Some(_c) = iter.next() { +LL ~ iter.next(); + | error[E0382]: borrow of moved value: `iter` - --> $DIR/issue-102972.rs:12:9 + --> $DIR/issue-102972.rs:14:9 | LL | let mut iter = v.iter(); | -------- move occurs because `iter` has type `std::slice::Iter<'_, i32>`, which does not implement the `Copy` trait @@ -19,10 +27,52 @@ LL | for _i in iter { LL | iter.next(); | ^^^^ value borrowed here after move | + = note: a for loop advances the iterator for you, the result is stored in `_i` note: `into_iter` takes ownership of the receiver `self`, which moves `iter` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL +help: if you want to call `next` on a iterator within the loop, consider using `while let` + | +LL | while let Some(_i) = iter.next() { + | ~~~~~~~~~~~~~~~ ~~~ +++++++ + +error[E0499]: cannot borrow `i` as mutable more than once at a time + --> $DIR/issue-102972.rs:22:9 + | +LL | for () in i.by_ref() { + | ---------- + | | + | first mutable borrow occurs here + | first borrow later used here +LL | i.next(); + | ^ second mutable borrow occurs here + | + = note: a for loop advances the iterator for you, the result is stored in its pattern +help: if you want to call `next` on a iterator within the loop, consider using `while let` + | +LL ~ let iter = i.by_ref(); +LL ~ while let Some(()) = iter.next() { +LL ~ iter.next(); + | + +error[E0382]: borrow of moved value: `iter` + --> $DIR/issue-102972.rs:30:9 + | +LL | let mut iter = v.iter(); + | -------- move occurs because `iter` has type `std::slice::Iter<'_, ()>`, which does not implement the `Copy` trait +LL | for () in iter { + | ---- `iter` moved due to this implicit call to `.into_iter()` +LL | iter.next(); + | ^^^^ value borrowed here after move + | + = note: a for loop advances the iterator for you, the result is stored in its pattern +note: `into_iter` takes ownership of the receiver `self`, which moves `iter` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL +help: if you want to call `next` on a iterator within the loop, consider using `while let` + | +LL | while let Some(()) = iter.next() { + | ~~~~~~~~~~~~~~~ ~~~ +++++++ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0382, E0499. For more information about an error, try `rustc --explain E0382`. |