-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=5bb0aaa179979e54df877b3aafe9f507
use std::fmt::Display;
fn pretty_list(v: &Vec<impl Display>){
print!("{}", v[0]);
for item in v[1..] {
print!(", {}", item);
}
}
fn main(){
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.
jyn514
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.