Skip to content

Attributes are parsed twice #143940

Open
Open
@JonathanBrouwer

Description

@JonathanBrouwer

All attributes, both using the old and new parsing infrastructure are currently parsed (at least) twice

  1. To do a few checks on the attribute, here: https://github.com/rust-lang/rust/blob/cccf075eba88363269e8589ebb8d40874cc542d8/compiler/rustc_parse/src/validate_attr.rs#L34C19-L34C29
  2. To lower the attribute, here:
    pub fn parse_attribute_list(

#[cfg] was one of the only attributes that was only parsed once. When we ported #[cfg] the the new parsing infrastructure (#143460), we sadly had to also parse it twice, losing around ~0.2% performance on some benchmarks.

This suggests that if we can merge these checks into the new attribute parser we can gain quite a bit of performance. We should do this.

cc @jdonszelmann

Metadata

Metadata

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions