rust-lang / rust-lang/rust

Reduce the size of check_attrs.rs and move as much as possible into the attribute parsers.

Open
#153,101 30 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-AST A-attributes C-cleanup E-help-wanted E-medium E-mentor E-tedious T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

View all comments

As part of the attribute parser rework initiative, i'd be nice to reduce the size of check_attrs.rs and move as much of the code into the attribute parsers themselves. This is part of #131229.

Mentor: @JonathanBrouwer

There is quite a lot of different checks in check_attrs.rs, and the goal is to move as much as possible to the respective attribute parsers. A lot of things are not currently moveable because the right information is not available in the attribute parsers, and making this information available is difficult

All checks:

  • check_stability: easy (claimed by @josetorrs) https://github.com/rust-lang/rust/pull/154015
  • check_align: easy (claimed by @JayanAXHF) https://github.com/rust-lang/rust/pull/153189
  • check_custom_mir: easy (claimed by @JayanAXHF) #154126
  • check_doc_attrs: 1, 3 (partially easy, for example moving the features check for rustc_logo is possible)
  • check_inline: 1, 3
  • check_loop_match: 1
  • check_const_continue: 1
  • check_macro_only_attr: 2
  • check_rustc_allow_const_fn_unstable: 1
  • check_deprecated: 1
  • check_target_feature: 2 (done by @obeis) https://github.com/rust-lang/rust/pull/158313
  • check_object_lifetime_default 1
  • check_rustc_pub_transparent: 2, 3 (claimed by @obeis) https://github.com/rust-lang/rust/pull/158496
  • check_naked: 1
  • check_track_caller: 1,2
  • check_non_exhaustive: 1
  • check_ffi_pure: 2 (done by @obeis) https://github.com/rust-lang/rust/pull/158361
  • check_may_dangle: 1
  • check_sanitize: 3
  • check_link: 1
  • check_macro_export: 1
  • check_rustc_legacy_const_generics: 1
  • check_proc_macro: fundamentally impossible, requires type information
  • check_eii_impl: 1
  • check_rustc_must_implement_one_of: 1
  • check_do_not_recommend: 1
  • check_diagnostic_on_unimplemented: 1
  • check_diagnostic_on_const: 1
  • check_diagnostic_on_move: 1

Legend:

  1. Requires detailed target information: Requires a way for the target checking to know more about the target than currently available to the attribute parsers. Ideally, we should pass information from either the AST or the HIR down, not sure which is easier.
  2. Requires other attrs: These checks check the presence or absence of other attributes. We need to find a nice way to represent this. (claimed by @rperier)
  3. The allowed targets depend on the arguments passed to the attribute, we need to find a way to allow target checking to depend on arguments

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading check_attrs.rs and the attribute parser code involved in one of the unchecked checks, using the attribute parser rework in #131229 for context. Identify which validation can move without unavailable target or type information; done means the selected check is moved while preserving its behavior and the remaining checklist is updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.