Closed atamis closed 5 years ago
For reference, this is how the compiler responds to the same typo elsewhere.
fn main() {
println!("{:?}", Vec::<usize>>::new());
}
Compiling playground v0.0.1 (/playground)
error[E0423]: expected value, found struct `Vec`
--> src/main.rs:2:22
|
2 | println!("{:?}", Vec::<usize>>::new());
| ^^^^^^^^^^^^ did you mean `Vec { /* fields */ }`?
error[E0425]: cannot find function `new` in the crate root
--> src/main.rs:2:37
|
2 | println!("{:?}", Vec::<usize>>::new());
| ^^^ not found in the crate root
Just ran into this. Weird/confusing/unhelpful error message -- the real problem is an extra delimiter as you said.
The opposite problem should also be handled, probably as part of a separate PR: vec![1, 2, 3].into_iter().collect::<Vec<usize>())
Created https://github.com/rust-lang/rust/issues/57819 to track this case.
I typoed the angle brackets when attempting turbofish.
(Playground)
I expected to see this happen: To get an error indicating that I had an extra closing angle bracket after my turbofish, or that I had a mismatched delimiter.
Here is what happened instead:
Errors:
This error message refers to the case when you attempt to use turbofish on a struct field rather than a method or function, like
struct.field::<usize>
. However, this error message is confusing to users because, if you look at the end of the collect call, there are parentheses, and this looks like a correctly formed method call, which obscures the real error.