Skip to content

destringlyfy lint infrastructure - #164607

Open
mejrs wants to merge 8 commits into
rust-lang:mainfrom
mejrs:lint_name
Open

mejrs wants to merge 8 commits into
rust-lang:mainfrom
mejrs:lint_name

Conversation

@mejrs

@mejrs mejrs commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

View all comments

Currently, lints are passed as strings and parsed/split/reformatted/compared/etc in many many places. It's not always clear whether that string includes the tool or not.

Instead, they are passed around as:

pub struct LintName {
    pub tool: Option<Symbol>,
    pub name: Symbol,
}

r? @JonathanBrouwer

@rustbot

rustbot commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 19, 2026
@rustbot

rustbot commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

JonathanBrouwer is currently at their maximum review capacity.
They may take a while to respond.

@mejrs

mejrs commented Oct 19, 2026 •

Copy link
Copy Markdown
Member Author

haven't updated clippy yet. But I think I can do a perf run.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 19, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 19, 2026
destringlyfy lint infrastructure
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 3dcd667 (3dcd66770271913d28347dd2820933e94b0f53a4)
Base parent: 07ea2af (07ea2af746e09a0e9e3ac9b39ee866bd9bf702a2)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (3dcd667): comparison URL.

Overall result: ❌✅ regressions and improvements - BENCHMARK(S) FAILED

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

❗ ❗ ❗ ❗ ❗
Warning ⚠️: The following benchmark(s) failed to build:

  • libc-0.2.172
  • Job failure

❗ ❗ ❗ ❗ ❗

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.2%, 0.5%] 5
Improvements ✅
(primary)
-0.4% [-1.3%, -0.1%] 45
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 2
All ❌✅ (primary) -0.4% [-1.3%, -0.1%] 45

Max RSS (memory usage)

Results (primary -1.0%, secondary -1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.1% [0.5%, 9.5%] 7
Improvements ✅
(primary)
-1.0% [-1.0%, -1.0%] 1
Improvements ✅
(secondary)
-5.5% [-8.3%, -3.2%] 8
All ❌✅ (primary) -1.0% [-1.0%, -1.0%] 1

Cycles

Results (primary 2.2%, secondary 0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.2% [2.2%, 2.2%] 1
Regressions ❌
(secondary)
3.1% [0.5%, 12.1%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-4.2%, -0.6%] 6
All ❌✅ (primary) 2.2% [2.2%, 2.2%] 1

Binary size

Results (primary -0.0%, secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 1
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 1
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 1

Bootstrap: 489.513s -> 489.49s (-0.00%)
Artifact size: 409.13 MiB -> 409.09 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 19, 2026
@Kivooeo

Kivooeo commented Oct 20, 2026

Copy link
Copy Markdown
Member

huh, any ideas why this might happenened in libc?

   thread 'rustc' (1970916) panicked at /rustc-dev/3dcd66770271913d28347dd2820933e94b0f53a4/compiler/rustc_lint/src/levels.rs:839:25:
    renamed lint does not exist: rustdoc::bare_urls

@mejrs

mejrs commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

huh, any ideas why this might happenened in libc?

   thread 'rustc' (1970916) panicked at /rustc-dev/3dcd66770271913d28347dd2820933e94b0f53a4/compiler/rustc_lint/src/levels.rs:839:25:
    renamed lint does not exist: rustdoc::bare_urls

it's one of the cases where a function takes (lint, tool) but in this case it's passed (rustdoc::bare_urls, None). i just didnt catch this one, it happened for clippy lints too.

@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Oct 20, 2026

@ada4a ada4a left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apologize the drive-by review. The idea seems very sensible, just some minor questions 👀

View changes since this review

Comment thread compiler/rustc_attr_ir/src/lint.rs Outdated
Comment thread compiler/rustc_attr_ir/src/lint.rs
@rust-log-analyzer

This comment has been minimized.

@mejrs

mejrs commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Please apologize the drive-by review. The idea seems very sensible, just some minor questions 👀

No need to apologize, all reviews are welcome :)

To answer your question w/r to spans: it would make comparing different LintNames complicated, because lint names with equal values but different spans will compare unequal.

And Span: !Ord, so this would require manual Ord impls, and I'd rather not go there...

@mejrs

mejrs commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Also, possible followups:

  • clippy has it's own LintName, it could use this one instead
  • store all the builtin lints as symbols rather than string literals. just pre-interning them may also matter for perf.

@mejrs

mejrs commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

CheckLintNameResult::NoLint(suggestion)
}

fn check_tool_name_for_backwards_compat(

@mejrs mejrs Oct 25, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code made:

  • legacy_numeric_constants work as clippy::legacy_numeric_constants
  • #[warn(DEAD_CODE)] would say that "in rustc" there is a lint named dead_code

The fix was simply to delete it, with no other effects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it ok to remove this? This is a behavior change right?
@rustbot author

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is only for when clippy is running, this should be fine then

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@mejrs

mejrs commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 26, 2026

@JonathanBrouwer JonathanBrouwer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 361557a has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 29, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors rollup=iffy
Making a rollup of perf sensitive prs

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 30, 2026
destringlyfy lint infrastructure

Currently, lints are passed as strings and parsed/split/reformatted/compared/etc in many many places. It's not always clear whether that string includes the tool or not.

Instead, they are passed around as:
```rust
pub struct LintName {
    pub tool: Option<Symbol>,
    pub name: Symbol,
}
```

r? @JonathanBrouwer

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants