-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTT-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
Consider this code (playpen):
struct S;
impl S { pub hello_method(&self) { println!("Hello"); } }
fn main() { S.hello_method(); }
It yields this error today:
rustc 1.17.0-nightly (a17e5e294 2017-02-20)
error: can't qualify macro invocation with `pub`
--> <anon>:2:10
|
2 | impl S { pub hello_method(&self) { println!("Hello"); } }
| ^^^
|
= help: try adjusting the macro to put `pub` inside the invocation
error: expected one of `!` or `::`, found `(`
--> <anon>:2:26
|
2 | impl S { pub hello_method(&self) { println!("Hello"); } }
| ^
error: aborting due to previous error
In this case, the actual error is that the user left out the keyword after the visibility to indicate which kind of item they are trying to define here.
Our parser should be able to do a better job here. At the very least, if there is no trailing !
, then instead of assuming that the input was a macro invocation, it should instead assume it was some item definition that is missing its keyword.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTT-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.