Rollup merge of #88578 - notriddle:notriddle/suggest-add-reference-to-for-loop-iter, r=nagisa

fix(rustc): suggest `items` be borrowed in `for i in items[x..]`

Fixes #87994
This commit is contained in:
Manish Goregaokar 2021-09-10 08:23:18 -07:00 committed by GitHub
commit 257f5adf0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 105 additions and 6 deletions

View file

@ -2,9 +2,12 @@ error[E0277]: the size for values of type `dyn Iterator<Item = &'a mut u8>` cann
--> $DIR/issue-20605.rs:2:17
|
LL | for item in *things { *item = 0 }
| ^^^^^^^ doesn't have a size known at compile-time
| ^^^^^^^
| |
| expected an implementor of trait `IntoIterator`
| help: consider mutably borrowing here: `&mut *things`
|
= help: the trait `Sized` is not implemented for `dyn Iterator<Item = &'a mut u8>`
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
= note: required because of the requirements on the impl of `IntoIterator` for `dyn Iterator<Item = &'a mut u8>`
note: required by `into_iter`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL