98332c108b
The current message for "`->` used for field access" is the following: ```rust error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `->` --> src/main.rs:2:6 | 2 | a->b; | ^^ expected one of 8 possible tokens ``` (playground link[1]) This PR tries to address this by adding a dedicated error message and recovery. The proposed error message is: ``` error: `->` used for field access or method call --> ./tiny_test.rs:2:6 | 2 | a->b; | ^^ help: try using `.` instead | = help: the `.` operator will dereference the value if needed ``` (feel free to bikeshed it as much as necessary) [1]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7f8b6f4433aa7866124123575456f54e Signed-off-by: Sasha Pourcelot <sasha.pourcelot@protonmail.com>
17 lines
462 B
Rust
17 lines
462 B
Rust
fn bar() -> String {
|
|
#[cfg]
|
|
[1, 2, 3].iter() //~ ERROR expected `;`, found `#`
|
|
#[feature]
|
|
attr::fn bar() -> String { //~ ERROR expected identifier, found keyword `fn`
|
|
//~^ ERROR expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `{`
|
|
//~| ERROR expected `;`, found `bar`
|
|
//~| ERROR `->` used for field access or method call
|
|
#[attr]
|
|
[1, 2, 3].iter().map().collect::<String>()
|
|
#[attr]
|
|
|
|
}()
|
|
}
|
|
|
|
fn main() { }
|