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

#[rust_analyzer::skip] attribute #7449

Open
lnicola opened this issue Jan 26, 2021 · 12 comments
Open

#[rust_analyzer::skip] attribute #7449

lnicola opened this issue Jan 26, 2021 · 12 comments
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@lnicola
Copy link
Member

lnicola commented Jan 26, 2021

Though an annotation like #[rustanalyzer::skip] would be nice for some fuctions we do not want to be analyzed.

Originally posted by @giftal in #4500 (comment)

@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Jan 26, 2021
@lnicola lnicola changed the title #[rustanalyzer::skip] attribute #[rust_analyzer::skip] attribute Jan 26, 2021
@lnicola
Copy link
Member Author

lnicola commented Jan 26, 2021

This could also be a #[cfg(not(rust-analyzer))], though it's less obvious.

As for the effect, I'm not sure. We'd like to skip that item or expression completely, but we still need to parse it to see where it ends. In the linked issue we run into a step limit in the parser.

@lnicola
Copy link
Member Author

lnicola commented Jan 26, 2021

Another option would be to move the problematic code to a different file and mark it as excluded, although that's still editor-dependent for now.

@giftal
Copy link

giftal commented Jan 26, 2021

Noted, thank you.

@jonas-schievink
Copy link
Contributor

Note that this requires upstream support in order to register rust_analyzer as a tool attribute namespace. A cfg would be easier to implement.

@jyn514
Copy link
Member

jyn514 commented Feb 1, 2021

Note that this requires upstream support in order to register rust_analyzer as a tool attribute namespace.

This would be useful as a general feature I think, other people have also asked for it: https://internals.rust-lang.org/t/pre-rfc-implementation-defined-lints/13870/10

@jyn514
Copy link
Member

jyn514 commented Apr 5, 2021

Note that this requires upstream support in order to register rust_analyzer as a tool attribute namespace. A cfg would be easier to implement.

You can do this on nightly with register_tool: rust-lang/rust#66079

@ChayimFriedman2
Copy link
Contributor

It may also apply to proc macros instead of (or in addition to) the current setting rust-analyzer.procMacro.ignored.

@bjorn3
Copy link
Member

bjorn3 commented Feb 27, 2022

I think rust-analyzer.procMacro.ignored is a more personal preference and thus shouldn't be dictated by the upstream (which an ignore in the actual source would do) I think. Some proc macros are only partially broken under rust-analyzer in which case some would like it enabled and others would like it disabled. In addition versions of rust-analyzer released after the crate was published may fix the proc macro.

@ChayimFriedman2
Copy link
Contributor

ChayimFriedman2 commented Feb 27, 2022

I think rust-analyzer.procMacro.ignored is a more personal preference and thus shouldn't be dictated by the upstream (which an ignore in the actual source would do) I think. Some proc macros are only partially broken under rust-analyzer in which case some would like it enabled and others would like it disabled. In addition versions of rust-analyzer released after the crate was published may fix the proc macro.

But there are macros that does not need expansion at all (e.g. tokio::main, at least until we'll emit an error for bare async fn main()), and expanding them is just redundant.

In a second thought, however, maybe all of those macros, even if should not be expanded today, should be in the future when we'll implement full diagnostics support.

@Veykril
Copy link
Member

Veykril commented Jan 10, 2025

#18907 implements such an attribute for bodies, that is functions / consts / statics for now. We do not make any stability promises wrt to the attribute for the time being though (although it is unlikely to change behavior or syntax in this case)

@jyn514
Copy link
Member

jyn514 commented Mar 22, 2025

#18907 implements such an attribute for bodies, that is functions / consts / statics for now. We do not make any stability promises wrt to the attribute for the time being though (although it is unlikely to change behavior or syntax in this case)

@Veykril i am confused: how do you expect people to add #[rust_analyzer::skip] to their source code? is the idea for each crate to add register_tool to the crate root?

(i would like to improve the situation around register_tool, i'm aware it's a pain. but i'm asking about how RA works today.)

@Veykril
Copy link
Member

Veykril commented Mar 22, 2025

rust_analyzer is special cased like rustfmt etc so the compiler just accepts it as is rust-lang/rust#125241

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

7 participants