You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In short this is a problem with how syn and attributes using syn implement failure, as these crates tend to just discard the entire attributed item on a parsing failure, replacing it with a compile_error! invocation. This has the side effect that when typing inside an item, a user may momentarily create invalid syntax causing the item to be fully discarded resulting in loss of IDE features as the item now effectively does not exist in the file until this syntax error has been fixed.
Describe the solution you'd like
A simple solution to this problem is to change the attributes such that when they error, they re-emit the original item with the compile_error! invocation, that way IDEs will still see the item even if the attribute fails causing IDE features to continue to function.
Sidenote: This will fix the general problem, but if the attribute introduces new usable items inside the item they will of course not always be visible in completions with just this fix. An ideal fix would be to make the attribute do parsing with recovery in such cases if required.
Additional context
This is becoming a bigger problem now as Rust-Analyzer enabled attribute expansion by default starting this week.
Note that rust-analyzer currently does not resolve tokio's macros unless tokio-macros has been added to the rust-analyzer.cargo.unsetTest list due to the #[cfg(not(test))] // Work around for rust-lang/rust#62127 workarounds.
Is your feature request related to a problem? Please describe.
In short this is a problem with how syn and attributes using syn implement failure, as these crates tend to just discard the entire attributed item on a parsing failure, replacing it with a
compile_error!
invocation. This has the side effect that when typing inside an item, a user may momentarily create invalid syntax causing the item to be fully discarded resulting in loss of IDE features as the item now effectively does not exist in the file until this syntax error has been fixed.Describe the solution you'd like
A simple solution to this problem is to change the attributes such that when they error, they re-emit the original item with the
compile_error!
invocation, that way IDEs will still see the item even if the attribute fails causing IDE features to continue to function.Sidenote: This will fix the general problem, but if the attribute introduces new usable items inside the item they will of course not always be visible in completions with just this fix. An ideal fix would be to make the attribute do parsing with recovery in such cases if required.
Additional context
This is becoming a bigger problem now as Rust-Analyzer enabled attribute expansion by default starting this week.
Note that rust-analyzer currently does not resolve tokio's macros unless
tokio-macros
has been added to therust-analyzer.cargo.unsetTest
list due to the#[cfg(not(test))] // Work around for rust-lang/rust#62127
workarounds.See a relevant RA issue rust-lang/rust-analyzer#10468
The text was updated successfully, but these errors were encountered: