rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.31k stars 1.62k forks source link

minor: Remove impossible function pointer qualifiers from grammar #18514

Closed Giga-Bowser closed 6 days ago

Giga-Bowser commented 6 days ago

Rust doesn't support const or async function pointers, nor does our parser.

lnicola commented 6 days ago

We might want to parse these so we can offer diagnostics like rustc: "error: an fn pointer type cannot be async".

Giga-Bowser commented 6 days ago

That diagnostic is offered as it stands, with an accompanying assist, although with a lot of cruft afterwards. We could probably just eat the tokens to fix this. Is there a reason to emit a proper error from the parser rather than relying on the diagnostic from rustc? image

lnicola commented 6 days ago

I like to disable check and rely on the native r-a diagnostics. They're (arguably) faster, and get displayed on-the-fly, not just when saving the file.

Ideally, we would be able to reuse the rustc diagnostic. Not going to happen, but we do have a couple of them implemented.

Giga-Bowser commented 6 days ago

Whoops, of course I pushed that right before seeing your reply. I'll eventually make a new PR to generate a proper rust-analyzer diagnostic for this. For now, I'll just close this and handle this stuff there.