Closed
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.