Closed
Description
This came up in #rust today and I couldn't find any similar A-diagnostics issues. A simple example is:
use std::vec::Vec;
fn main() {
let x: Vec::with_capacity(10);
}
This correctly fails with a compiler error, since it's using :
for type ascription where it meant to use =
for initialization. But our current error message makes it sound like the problem is near 10
, instead of near the :
.
error: expected type, found `10`
--> src/main.rs:4:31
|
4 | let x: Vec::with_capacity(10);
| ^^
error: expected one of `!`, `+`, `->`, `::`, `;`, or `=`, found `)`
--> src/main.rs:4:33
|
4 | let x: Vec::with_capacity(10);
| ^ expected one of `!`, `+`, `->`, `::`, `;`, or `=` here
error: aborting due to previous error(s)
Ideally the message would be "expected type, found Vec::with_capacity(10)
".