You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggest items be borrowed in for i in items[x..] #87994
use std::fmt::Display;fnpretty_list(v:&Vec<implDisplay>){print!("{}", v[0]);for item in v[1..]{print!(", {}", item);}}fnmain(){let data = vec![0,1,2,3,4,5,6,7,8,9];pretty_list(&data);}
The current output is:
error[E0277]: the size for values of type `[impl Display]` cannot be known at compilation time
--> src/main.rs:5:17
|
5 | for item in v[1..] {
| ^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[impl Display]`
= note: required because of the requirements on the impl of `IntoIterator` for `[impl Display]`
= note: required by `into_iter`
error[E0277]: `[impl Display]` is not an iterator
--> src/main.rs:5:17
|
5 | for item in v[1..] {
| ^^^^^^ `[impl Display]` is not an iterator
|
= help: the trait `Iterator` is not implemented for `[impl Display]`
= note: required because of the requirements on the impl of `IntoIterator` for `[impl Display]`
= note: required by `into_iter`
error: aborting due to 2 previous errors
Ideally, the output should note that &v[1..] is a possible solution to these errors.
Activity
Nicholas-Baron commentedon Aug 13, 2021
@rustbot label: +D-newcomer-roadblock.
fix(rustc): suggest `items` be borrowed in `for i in items[x..]`
Rollup merge of rust-lang#88578 - notriddle:notriddle/suggest-add-ref…
Rollup merge of rust-lang#88578 - notriddle:notriddle/suggest-add-ref…