-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make early lints translatable #124417
Make early lints translatable #124417
Conversation
Some changes occurred in check-cfg diagnostics cc @Urgau
cc @davidtwco, @compiler-errors, @TaKO8Ki Some changes occurred in tests/ui/check-cfg cc @Urgau |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #124424) made this pull request unmergeable. Please resolve the merge conflicts. |
362f064
to
4edd58f
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #124558) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @davidtwco I'm going on vacation for two weeks |
4edd58f
to
eb5690a
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #124228) made this pull request unmergeable. Please resolve the merge conflicts. |
Are there any blockers left apart from a rebase? Edit: Ah, it seems like the patch to fluent-rs was only merged but not released yet. |
Yep, I can also patch those |
eb5690a
to
c2d5646
Compare
Rebased, and the use case for Would appreciate a review on this soon, rebasing this is getting quite tiring. |
Apologies for the delay in my reviewing, had a busy couple weeks, will let @fmease handle this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot. this is great work!
I've added a lot of review comments for things that are secondary or preexisting even. You don't need to address them in this PR, they can be fixed in follow-up PRs (by you or my me). Basically drive-by commentary.
I g2g rn unfortunately but I'd like to see emit_buffered_lint
being made non-generic as noted in one of my comments. You should be able to pick out what is relevant and what isn't. In a few hours, I will be back again and can push it into the merge queue with a high priority
@@ -18,3 +23,9 @@ impl Display for RustcVersion { | |||
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch) | |||
} | |||
} | |||
|
|||
impl IntoDiagArg for RustcVersion { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I've started reviewing this PR only a few seconds ago, so later commits may answer this)
How often is RustcVersion
used inside diagnostic structs/enums? If it's just once or twice for example, I wonder if such an impl is warranted. Happy to be convinced otherwise.
I mean we probably display values of hundreds (?) of distinct types right now I think but that doesn't mean we should impl IntoDiagArg
for them. We do a lot of manual .to_string()
s when constructing diag structs and use String
which seems fine by me.
| SubdiagnosticKind::NoteOnce | ||
| SubdiagnosticKind::Help | ||
| SubdiagnosticKind::HelpOnce | ||
| SubdiagnosticKind::Warn => { | ||
let inner = info.ty.inner_type(); | ||
if type_matches_path(inner, &["rustc_span", "Span"]) | ||
|| type_matches_path(inner, &["rustc_span", "MultiSpan"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(preexisting) Oh, this doesn't account for rustc_errors::MultiSpan
(pub reexport) and rustc_error_messages::MultiSpan
(def site). Anyway, should be fixed at some other point.
@@ -395,13 +466,24 @@ lint_map_unit_fn = `Iterator::map` call that discard the iterator's values | |||
.map_label = after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items | |||
.suggestion = you might have meant to use `Iterator::for_each` | |||
|
|||
lint_metavariable_still_repeating = variable '{$name}' is still repeating at this depth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(preexisting) backticks instead of single quotes, not blocking
mod tests; | ||
|
||
pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Diag<'_, ()>) { | ||
pub(super) fn emit_buffered_lint<C: LintContext + ?Sized>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rewrite you method in such a way that it's not generic? The body of this function is massive and currently, due to monomorphization, it gets duplicated per C
(i.e., twice, once for EarlyContext
, once for LateContext
). While the optimizer and linker are able to throw out duplicate code in some cases, it's obviously not always possible. Furthermore, it's more work for LLVM and the linker (therefore, we have the experimental -Zpolymorphize
, however it's still far from usable)
You might need to go back to the approach on master or sth. similar to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, actually, this function is only instantiated once for EarlyContext
- I honestly don't know why I made it generic in the first place, it compiles fine if I just make it take an EarlyContext
?
Edit: ah, right, I moved it out of trait LintContext
into EarlyContext
, since that's the only type it was actually being called on. Could there be any third-party consumers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could there be any third-party consumers?
Clippy (src/tools/clippy
, rust-lang/rust-clippy) uses rustc_lint::{LintContext, EarlyContext, LateContext}
extensively but it doesn't seem to use buffer_lint
@bors p=1 prone to bitrotting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to address the most pressing concern (making emit_buffered_lint
not generic), but I got most of the rest done.
PROC_MACRO_BACK_COMPAT, | ||
item.ident.span, | ||
ast::CRATE_NODE_ID, | ||
BuiltinLintDiag::ProcMacroBackCompat { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if other crates might be added here in the future (there were more in the past), so I went for the possibly overkill solution.
c2d5646
to
92749e6
Compare
Finished benchmarking commit (791adf7): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary 2.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 2.4%, secondary 2.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 671.076s -> 670.302s (-0.12%) |
Some sizeable perf regressions. Is that expected? |
No, it's not expected. I think I know what's going wrong. Sending a fix shortly. |
No, not really - would be interesting to know if this is just for lints that are actually emitted or even for ones that get silenced. |
@Xiretza I think we no longer decorate the lint |
[perf] Delay construction of early lint diag structs cc rust-lang#124417 (comment) r? ghost
[perf] Delay construction of early lint diag structs cc rust-lang#124417 (comment) r? ghost
[perf] Delay construction of early lint diag structs cc rust-lang#124417 (comment) r? ghost
In #125410 I was able to
Anyways, Xiretza and/or I can conduct some more perf experiments after #125410 has been merged. I should be able to squeeze this into my schedule. |
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from rust-lang#124417 (comment). See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from rust-lang/rust#124417 (comment). See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from rust-lang/rust#124417 (comment). See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
…diags, r=Nadrieril Spruce up the diagnostics of some early lints Implement the various "*(note to myself) in a follow-up PR we should turn parts of this message into a subdiagnostic (help msg or even struct sugg)*" drive-by comments I left in rust-lang#124417 during my review. For context, before rust-lang#124417, only a few early lints touched/decorated/customized their diagnostic because the former API made it a bit awkward. Likely because of that, things that should've been subdiagnostics were just crammed into the primary message. This PR rectifies this.
…diags, r=Nadrieril Spruce up the diagnostics of some early lints Implement the various "*(note to myself) in a follow-up PR we should turn parts of this message into a subdiagnostic (help msg or even struct sugg)*" drive-by comments I left in rust-lang#124417 during my review. For context, before rust-lang#124417, only a few early lints touched/decorated/customized their diagnostic because the former API made it a bit awkward. Likely because of that, things that should've been subdiagnostics were just crammed into the primary message. This PR rectifies this.
Rollup merge of rust-lang#125913 - fmease:early-lints-spruce-up-some-diags, r=Nadrieril Spruce up the diagnostics of some early lints Implement the various "*(note to myself) in a follow-up PR we should turn parts of this message into a subdiagnostic (help msg or even struct sugg)*" drive-by comments I left in rust-lang#124417 during my review. For context, before rust-lang#124417, only a few early lints touched/decorated/customized their diagnostic because the former API made it a bit awkward. Likely because of that, things that should've been subdiagnostics were just crammed into the primary message. This PR rectifies this.
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from rust-lang/rust#124417 (comment). See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from rust-lang/rust#124417 (comment). See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
Requires projectfluent/fluent-rs#353.5134a04r? diagnostics