Skip to content
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

No auto-completion inside fn (& attribute proc-macro) #10520

Closed
cynecx opened this issue Oct 11, 2021 · 6 comments
Closed

No auto-completion inside fn (& attribute proc-macro) #10520

cynecx opened this issue Oct 11, 2021 · 6 comments

Comments

@cynecx
Copy link
Contributor

cynecx commented Oct 11, 2021

use tracing::instrument;

#[instrument]
fn testy() {
    let x = Vec::new();
    x.<|> // no auto completions here
}
[dependencies]
tracing = { version = "0.1.29", features = ["attributes"] }

rust-analyzer: 1e9ecb9 (master)

rust-analyzer should be able to trigger auto-completions at that position even with an attribute proc-macro at fn level (hover information works though).

image

@Veykril
Copy link
Member

Veykril commented Oct 11, 2021

This is due to tracing::instrument using syn to parse the item which replaces the entire item with a compile_error invocation on parsing failure(which happens in this case because x. is not a valid expressions), https:/tokio-rs/tracing/blob/2f6fcb0fabff541d14b0fe3a5211b8f472fec4cb/tracing-attributes/src/lib.rs#L265-L266
See #10468

@cynecx
Copy link
Contributor Author

cynecx commented Oct 11, 2021

See #10468

I see, that's unfortunate. Thought/Idea: Perhaps we could "catch" a compile_error invocation and just don't expand the attribute proc-macro at all as a recovery mechanism?

@Veykril
Copy link
Member

Veykril commented Oct 11, 2021

We need to expand it to see the compile_error though, so I don't think that is easily doable but maybe someone can prove me wrong.

For the meantime I opened tokio-rs/tracing#1633

@Veykril
Copy link
Member

Veykril commented Oct 11, 2021

Note you can get aroun this for the time being by disabling attribute expansion for your project again(we enabled it by default last week).

@lnicola
Copy link
Member

lnicola commented Oct 17, 2021

@cynecx's tracing fix in tokio-rs/tracing#1634 just got merged.

@cynecx
Copy link
Contributor Author

cynecx commented Oct 17, 2021

Thanks for all your input :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants