-
-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: MaybeItemFn for better rust-analyzer experience #1086
Comments
I would prefer not to build this into syn. I consider the behavior that this is working around to be a rust-analyzer bug that needs to be fixed on their end. dtolnay/async-trait#178 has some related context. |
@dtolnay I could imagine a scenario where you have two attribute macros: #[uses_fn_signature]
#[bf2rust]
fn foo() {
[->+<]
} In this case, if A perhaps more realistic example would be one where In summary, parsing more than is strictly necessary is redundant work and makes the attribute more fragile. I think there's value in making good practices easier. |
Currently when an attribute macro parses a function body it will cause rust-analyzer's completion to stop working within the function.
This is because the code within the function will fail to parse, and then the attribute macro will just expand to a compile error.
To avoid this, attribute macros can use a custom type to only parse the function signature, and leave the function body as an opaque token-stream: Diggsey/sqlxmq@ea408f7#diff-5796541ab2132b1f9f5e924468f24b542a59297c91a7543be0a5702926b7d3ecR95-R131
A similar approach has also been used in other crates like tokio.
It would be convenient if
syn
could provide a type likeMaybeItemFn
.The text was updated successfully, but these errors were encountered: