Skip to content

Confusing error message: "can't qualify macro invocation with pub" when a inherent method lacks "fn" #38911

Closed
@ExpHP

Description

@ExpHP

Both stable 1.14 and nightly 2017-01-06.
playpen

struct A {}

impl A {
    pub get(self) {}
}

(Edit: Above example is fixed as of 1.20.0, but free functions are affected.)

rustc 1.14.0 (e8a012324 2016-12-16)
error: can't qualify macro invocation with `pub`
 --> <anon>:4:5
  |
4 |     pub get(self) {}
  |     ^^^
  |
  = help: try adjusting the macro to put `pub` inside the invocation

error: expected one of `!` or `::`, found `(`
 --> <anon>:4:12
  |
4 |     pub get(self) {}
  |            ^

error: aborting due to previous error

while the actual issue is that the definition of get is missing the fn keyword.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions