Skip to content

rust-analyzer newly confused by endpoint macro #134

@jclulow

Description

@jclulow

Recently, the Rust Analyzer folks enabled (deeper?) processing of proc attribute macros, in: rust-lang/rust-analyzer#10366.

It seems that as of that commit, code completion inside endpoint functions (those wrapped by #[endpoint]) is a bit flaky. It will sometimes work once or twice, but then can eventually get confused and stops working altogether. This state seems to be sticky until you restart RA.

While I am not yet convinced RA is doing entirely the right thing here, it has been suggested in rust-lang/rust-analyzer#10498 that:

The problem is likely that the proc macro emits an error when the function is syntactically invalid. (What error message does rustc emit when faced with this incomplete code?) In that case, probably your only options are to either report this to the proc macro authors and wait for them to fix it, or to disable attribute macro expansion again.

Indeed, endpoint does emit an error when the function body is syntactically invalid -- but I'm not really sure what we should do instead? Should we be doing our best to construct what will be an invalid token stream and passing that back without error, unless the stream is so invalid that it is unrecognisable?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions