test: add case for mutating iterator
Note that this incorrectly suggests a shared borrow, but at least we know it's happening.
This commit is contained in:
parent
f23003dff1
commit
d6ff916c2f
2 changed files with 44 additions and 1 deletions
|
@ -4,4 +4,13 @@ fn main() {
|
|||
//~^ ERROR [i32]` is not an iterator [E0277]
|
||||
//~^^ ERROR known at compilation time
|
||||
}
|
||||
struct K {
|
||||
n: i32,
|
||||
}
|
||||
let mut v2 = vec![K { n: 1 }, K { n: 1 }, K { n: 1 }];
|
||||
for i2 in v2[1..] {
|
||||
//~^ ERROR [K]` is not an iterator [E0277]
|
||||
//~^^ ERROR known at compilation time
|
||||
i2.n = 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,40 @@ note: required by `into_iter`
|
|||
LL | fn into_iter(self) -> Self::IntoIter;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0277]: the size for values of type `[K]` cannot be known at compilation time
|
||||
--> $DIR/slice-issue-87994.rs:11:13
|
||||
|
|
||||
LL | for i2 in v2[1..] {
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| expected an implementor of trait `IntoIterator`
|
||||
| help: consider borrowing here: `&v2[1..]`
|
||||
|
|
||||
= note: the trait bound `[K]: IntoIterator` is not satisfied
|
||||
= note: required because of the requirements on the impl of `IntoIterator` for `[K]`
|
||||
note: required by `into_iter`
|
||||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
||||
|
|
||||
LL | fn into_iter(self) -> Self::IntoIter;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `[K]` is not an iterator
|
||||
--> $DIR/slice-issue-87994.rs:11:13
|
||||
|
|
||||
LL | for i2 in v2[1..] {
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| expected an implementor of trait `IntoIterator`
|
||||
| help: consider borrowing here: `&v2[1..]`
|
||||
|
|
||||
= note: the trait bound `[K]: IntoIterator` is not satisfied
|
||||
= note: required because of the requirements on the impl of `IntoIterator` for `[K]`
|
||||
note: required by `into_iter`
|
||||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
||||
|
|
||||
LL | fn into_iter(self) -> Self::IntoIter;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue