rust-lang / rust-lang/rust-analyzer
`#[rust_analyzer::*]` tool and lint attributes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
NOTE: Implementation of some of these has started but we do not make any stability guarantees about these attributes for now, so they may change over time.
This serves as a general bag of ideas around possible future r-a/ide tool attributes (we have this attribute now https://github.com/rust-lang/rust/pull/125241)
#[rust_analyzer::skip]: cc https://github.com/rust-analyzer/rust-analyzer/issues/7449#[rust_analyzer::macro::expands_to(kind0, kind1, ...)]where kind can be anything a macro is allowed to expand to likeitem,expr,pat, ... This annotation's sole purpose would be to aid completions by allowing us to filter out macros that aren't applicable.#[rust_analyzer::crate_prelude]marks a crate's prelude, aids fly-import completions and auto-import features by allowing (via a config) to avoid or prefer crate preludes for imports.#[rust_analyzer::rust_fixture_params(param_name1, ...)]: specify parameters of a function that are to be highlighting injected, alternatively mark the parameters with attributes directly, but that might become rather unwieldy -> https://github.com/rust-lang/rust-analyzer/pull/18906#[rust_analyzer::macro::expansion_type(path::to::type)]: https://github.com/rust-analyzer/rust-analyzer/issues/10913#[rust_analyzer::unsafe_macro]: https://www.reddit.com/r/rust/comments/vftkrm/unsafe_code_highlighting_with_rustanalyzer/icy0jlv/#[rust_analyzer::render_as_impl_trait]: annotation for types to render them asimpl Trait, like we do by default forstdtypes that implementIterator#[rust_analyzer::color(args)]: https://github.com/rust-lang/rust-analyzer/issues/13122#[rust_analyzer::resolve_hint(path::to::something): Will make r-a attempt to resolve the given path, useful for macros to output to so that tokens they full consume can be remapped to a resolving path.#[rust_analyzer::runnable(command arg arg ....)): Will make r-a recognize this as a runnable action (likefn main()or#[test] fn test), putting a runnable lens on top that executes the command with the given args#[rust_analyzer::macro_expansion_token_limit(10000)]: Sets the expansion token limit for the crate or annotated macro call#[rust_analyzer::enum_happy_variant]: Annotate variants to handle them likeSomeorOkfor assist purposes, https://github.com/rust-lang/rust-analyzer/blob/d6d735e6f20ef78b16a79886fe28bd69cf059504/crates/ide-db/src/ty_filter.rs
Note: names are of course bikesheddable
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin by reviewing the existing attribute from rust-lang/rust#125241 and the linked rust-analyzer issues, then inspect crates/ide-db/src/ty_filter.rs for the enum-variant assist behavior. This issue is a broad list of proposals, so completion would require selecting one attribute, defining its scope and behavior, and adding the relevant implementation and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100