Repository navigation
Conversation
|
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 |
|
|
|
haven't updated clippy yet. But I think I can do a perf run. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
destringlyfy lint infrastructure
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (3dcd667): comparison URL. Overall result: ❌✅ regressions and improvements - BENCHMARK(S) FAILEDBenchmarking 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 @bors rollup=never rustc-perf ❗ ❗ ❗ ❗ ❗
❗ ❗ ❗ ❗ ❗ Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
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.
CyclesResults (primary 2.2%, secondary 0.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 489.513s -> 489.49s (-0.00%) |
|
huh, any ideas why this might happenened in libc? |
it's one of the cases where a function takes |
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/clippy |
| #[derive(Copy, Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] | ||
| pub struct LintName { | ||
| /// The lint's tool name, if present. | ||
| pub tool: Option<Symbol>, |
There was a problem hiding this comment.
Imo it would make sense to leave this as Option<Ident>, so that you don't need to ads a separate LintCheck.tool_span field?
| /// produces multiple `LintCheck`s, one with a span pointing to `foo` | ||
| /// and another pointing to `bar`. | ||
| pub lint_span: Span, | ||
| pub lint_name: LintName, |
There was a problem hiding this comment.
Maybe put this inside LintName as well, as it seems pretty related?
This comment has been minimized.
This comment has been minimized.
No need to apologize, all reviews are welcome :) To answer your question w/r to spans: it would make comparing different And |
|
Also, possible followups:
|
|
@bors try @rust-timer queue |
I guess it'd be nice to have a wrapper like struct SpannedLintName {
tool: Option<Ident>,
name: Symbol,
/// The span of the complete lint name
span: Span,
}and use that inside |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (767dd6c): comparison URL. Overall result: ❌✅ regressions and improvements - please read: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 @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -1.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.6%, secondary 1.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 491.717s -> 488.128s (-0.73%) |
I don't think it'd help much at this time, we also won't need this if we move lint registration into the attribute parser. |
|
|
||
| impl LintName { | ||
| pub fn new(segments: impl Iterator<Item = Symbol>) -> LintName { | ||
| let segments = segments.collect::<Vec<_>>(); |
There was a problem hiding this comment.
Follow-up (unless you want to fix this immediately): Are we losing performance in this collect?
There was a problem hiding this comment.
its a bit vestigial (and it's easier to match on it), but i'll take a look
There was a problem hiding this comment.
I was thinking do it as a follow-up so we can independently measure a performance effect, and see if the change is worth it
| LintName { tool, name } | ||
| } | ||
|
|
||
| /// Panics if `lint` is empty. |
There was a problem hiding this comment.
I feel this comment is misleading if we only do this with debug_assertions
| LL - #[warn(clippy::dead_cod)] | ||
| LL + #[warn(dead_code)] | ||
| | | ||
| | ^^^^^^^^^^^^^^^^ help: did you mean: `dead_code` |
There was a problem hiding this comment.
I kinda prefer the old diagnostic here? Why did this change and how hard is this to undo?
| /// produces multiple `LintCheck`s, one with a span pointing to `foo` | ||
| /// and another pointing to `bar`. | ||
| pub lint_span: Span, | ||
| pub lint_name: LintName, |
There was a problem hiding this comment.
My dream solution would be to get anLintId here instead of syms.
I'm gonna do a quick experiment to see how realistic that is
There was a problem hiding this comment.
First exploration seems to show potential here, I think this should be possible! (with a few minor hacks)
I'm going to try this in depth tomorrow
There was a problem hiding this comment.
how realistic that is
there are some reasons to not do this:
- how do you represent a lint that doesn't exist, because e.g. the input is wrong or it belongs to a tool that isn't currently running
- you'd need to move Lint and LintId far down in the crate graph to do this
- it would be incompatible with implementing lint resolution for proc/decl macro lints, because we'd likely need to run queries to retrieve the lint information
There was a problem hiding this comment.
how do you represent a lint that doesn't exist, because e.g. the input is wrong or it belongs to a tool that isn't currently running
I think that could either stay in the HIR by name if it's useful, and if it's not useful removed entirely.
you'd need to move Lint and LintId far down in the crate graph to do this
rustc_attr_ir can depend directly on rustc_lint_defs. It already does transitively so it doesn't even worsen bootstrap times.
it would be incompatible with implementing lint resolution for proc/decl macro lints, because we'd likely need to run queries to retrieve the lint information
The only information we'd need is from the LintStore, which is available very early through the DynLintStore in Session
The only significant problem I've encountered so far is that LintIds are not encodable, so can't be part of the HIR. I was thinking to encode the index of the lint in LintStore::lints (field) instead.
There was a problem hiding this comment.
I got nerd-sniped too hard so this is part 1 of this approach: #164918
There was a problem hiding this comment.
Fwiw, I think our approaches are actually mostly compatible. It's still possible to introduce a LintName type and use it in most places that your PR does, and I think that would be good. It's just that it shouldn't be what's stored in the LintCheck type
There was a problem hiding this comment.
This PR also has better perf than #164918 (tho both are improvements) so doing both definitely makes sense
|
fwiw, what I want to experiment with next is to make |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| CheckLintNameResult::NoLint(suggestion) | ||
| } | ||
|
|
||
| fn check_tool_name_for_backwards_compat( |
There was a problem hiding this comment.
This code made:
legacy_numeric_constantswork asclippy::legacy_numeric_constants#[warn(DEAD_CODE)]would say that "in rustc" there is a lint nameddead_code
The fix was simply to delete it, with no other effects.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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. |
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:
r? @JonathanBrouwer