Skip to content

Conversation

@fmease
Copy link
Member

@fmease fmease commented Oct 13, 2025

Follow-up to #145881 and #145747.

I originally wanted to migrate most if not the entire rest of the early buffered lints. However, when trying to migrate the buffered lints used by check-cfg I encountered a roadblock. Namely, it depends on TyCtxt (well, Option<TyCtxt>) which makes it quite hard to migrate (see also #147634 (comment), #147634 (comment) & #149215).

So for now, I won't migrate it (maybe #149215 will find a solution), nor will I migrate the rest since it's quite tedious to migrate these. I'll leave them for future me.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 13, 2025
@rust-log-analyzer

This comment has been minimized.

@Urgau
Copy link
Member

Urgau commented Oct 13, 2025

  • Complete check-cfg migration if feasible or drop it for now (it's nasty due to it requiring a TyCtxt)

Yeah, and it's even more complex as check-cfg lints are emitted from both rustc & rustdoc, which do not operate at the same time, rustc is at expansion time, while rustdoc is after expansion (and therefore has direct access to a TyCtxt).

@fmease
Copy link
Member Author

fmease commented Oct 13, 2025

The thing is, while currently only the post-expansion lint pass gets passed a TyCtxt (since your PR), in theory the pre-expansion lint pass has access to the TyCtxt, too, because both run inside create_and_enter_global_ctxt and TyCtxt::crate_name is already fed for the local crate (and I'm pretty sure decoding from metadata for foreign DefIds should also work inside the pre-expansion pass).

We can easily pass the TyCtxt to the pre-expansion pass that gets run on the root source file (crate root + inline modules) but the problem I was struggling with was passing the TyCtxt to the pre-expansion passes that get run for out-of-line/file modules because this happens in rustc_expand when expanding ModKind::Unloadeds where we only have access to an ExtCtxt1 and a dyn LintStoreExpand but I'm not sure if it's sound (wrt. thread-local storage and query caching and maybe some other hidden assumptions2) to (make rustc_expand depend on rustc_middle and) store a TyCtxt inside ExtCtxt esp. once we parallelize things (CC #145354). That's where I gave up but I should probably just ping the relevant people.

Not being able to name TyCtxt inside rustc_attr_parsing shouldn't that huge of a problem, I'll just create a new proxy trait EarlyTyCtxt that defines crate_name similar to the LintEmitter and HirTyCtxt shenanigans we already have to do.

Footnotes

  1. I still don't know what the Ext stands for. If it really does stand for extended then I must say that's a really non-descriptive name ^^'

  2. I really don't know what I'm talking about here btw. I know that both TyCtxt and ExtCtxt are !Send and !Sync so maybe everything is sufficiently locked down already?

@fmease
Copy link
Member Author

fmease commented Oct 13, 2025

We can easily pass the TyCtxt to the pre-expansion pass

And I know we don't do that right now (we use Option<TyCtxt> as you know) but since I'm already trying to clean things up I was attempting to make TyCtxt unconditionally available to check-cfg. I don't remember if dropping that requirement I've imposed on myself makes the migration easier or not because we probably need to parametrize things over some proxy TyCtxt trait regardless.

@bors

This comment was marked as resolved.

@fmease fmease force-pushed the mv-var-to-dyn-buf-lints-next branch from a944814 to 3bce608 Compare November 30, 2025 17:30
@fmease fmease changed the title [WIP] Move even more early buffered lints to dyn lint diagnostics Move even more early buffered lints to dyn lint diagnostics Nov 30, 2025
@fmease
Copy link
Member Author

fmease commented Nov 30, 2025

Fully dropped the check-cfg migration due to the reasons above. Maybe #149215 will fix the TyCtxt issue for me in some way. Moreover, I won't migrate any other early lints in this PR since this process is quite tedious & I need to be in the right mood to do it. I'll leave that for more follow-up PRs.

@fmease fmease marked this pull request as ready for review November 30, 2025 17:41
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 30, 2025
@fmease
Copy link
Member Author

fmease commented Nov 30, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 30, 2025
Move even more early buffered lints to dyn lint diagnostics
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 30, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Nov 30, 2025

☀️ Try build successful (CI)
Build commit: cb75625 (cb756251a1b5963834143557fd6b220741a300f7, parent: f40a70d2bcd830a4f1f8c7ca1a7f93f1d9d703d6)

@rust-timer

This comment has been minimized.

@fmease fmease force-pushed the mv-var-to-dyn-buf-lints-next branch from 3bce608 to b1bf1e5 Compare November 30, 2025 20:01
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cb75625): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

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

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.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
-0.5% [-0.8%, -0.0%] 14
All ❌✅ (primary) -0.1% [-0.1%, -0.1%] 1

Max RSS (memory usage)

Results (primary 3.3%, secondary -4.1%)

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

mean range count
Regressions ❌
(primary)
3.3% [3.3%, 3.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-8.1%, -1.4%] 11
All ❌✅ (primary) 3.3% [3.3%, 3.3%] 1

Cycles

Results (secondary -3.3%)

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
Improvements ✅
(secondary)
-3.3% [-3.7%, -3.1%] 5
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 469.915s -> 468.944s (-0.21%)
Artifact size: 386.98 MiB -> 386.93 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 30, 2025
@jdonszelmann
Copy link
Contributor

cc: @JonathanBrouwer you were also running into the cfg lint issue recently weren't you? take a look at this pr

@jdonszelmann
Copy link
Contributor

I hate all the proxy traits but I guess it will be the way to do it... what's here looks good. The lints that are migrated look good. @fmease if you know more about error codes on lints, lmk, otherwise r=me

@JonathanBrouwer
Copy link
Contributor

JonathanBrouwer commented Dec 1, 2025

@jdonszelmann Yeah the linked PR #149215 is my PR :p

The problem blocking that PR is that attribute lints have their own enum (AttributeLindKind), and the emitting code of that also doesn't have access to TyCtxt. One fix I attempted (but not fully succeeded in yet) for that PR is to actually move all of the AttributeLindKind variants from there into BuiltinLintDiag. But that won't help you with the problem in this PR I'm afraid.

@jdonszelmann
Copy link
Contributor

@rustbot author

@rustbot rustbot added 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-review Status: Awaiting review from the assignee but also interested parties. labels Dec 1, 2025
@fmease
Copy link
Member Author

fmease commented Dec 1, 2025

I didn't even link to the dropped commit even though most of the comments in this PR are concerned with it. So for reference / "posterity" (will probably get pruned at some point): fmease@c97e79f.

@fmease fmease force-pushed the mv-var-to-dyn-buf-lints-next branch from b1bf1e5 to 109e5e5 Compare December 1, 2025 15:32
@fmease
Copy link
Member Author

fmease commented Dec 1, 2025

@bors r=jdonszelmann

@bors
Copy link
Collaborator

bors commented Dec 1, 2025

📌 Commit 109e5e5 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors 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 Dec 1, 2025
@bors
Copy link
Collaborator

bors commented Dec 2, 2025

⌛ Testing commit 109e5e5 with merge 47cd712...

@bjorn3
Copy link
Member

bjorn3 commented Dec 2, 2025

I still don't know what the Ext stands for. If it really does stand for extended then I must say that's a really non-descriptive name ^^

Probably extension as in syntax extension, the precursor to proc macros. It is the context object passed to syntax extension implementations. Eg https://doc.rust-lang.org/1.26.0/nightly-rustc/syntax/ext/base/trait.TTMacroExpander.html

@bors
Copy link
Collaborator

bors commented Dec 2, 2025

☀️ Test successful - checks-actions
Approved by: jdonszelmann
Pushing 47cd712 to main...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 2, 2025
@bors bors merged commit 47cd712 into rust-lang:main Dec 2, 2025
12 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Dec 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 63b1db0 (parent) -> 47cd712 (this PR)

Test differences

Show 242 test diffs

Stage 0

  • errors::verify_resolve_anonymous_lifetime_non_gat_report_error_47: [missing] -> pass (J1)
  • errors::verify_resolve_arguments_macro_use_not_allowed_43: [missing] -> pass (J1)
  • errors::verify_resolve_attributes_starting_with_rustc_are_reserved_54: [missing] -> pass (J1)
  • errors::verify_resolve_cannot_find_builtin_macro_with_name_57: [missing] -> pass (J1)
  • errors::verify_resolve_cannot_glob_import_possible_crates_36: pass -> [missing] (J1)
  • errors::verify_resolve_cannot_glob_import_possible_crates_37: [missing] -> pass (J1)
  • errors::verify_resolve_cannot_use_through_an_import_55: [missing] -> pass (J1)
  • errors::verify_resolve_explicit_anonymous_lifetime_report_error_48: [missing] -> pass (J1)
  • errors::verify_resolve_extern_crate_self_requires_renaming_38: pass -> [missing] (J1)
  • errors::verify_resolve_extern_crate_self_requires_renaming_39: [missing] -> pass (J1)
  • errors::verify_resolve_generic_arguments_in_macro_path_52: pass -> [missing] (J1)
  • errors::verify_resolve_imported_macro_not_found_40: pass -> [missing] (J1)
  • errors::verify_resolve_legacy_derive_helpers_60: pass -> [missing] (J1)
  • errors::verify_resolve_macro_expanded_extern_crate_cannot_shadow_extern_arguments_45: [missing] -> pass (J1)
  • errors::verify_resolve_macro_rule_never_used_69: [missing] -> pass (J1)
  • errors::verify_resolve_macro_use_deprecated_65: pass -> [missing] (J1)
  • errors::verify_resolve_macro_use_name_already_in_use_39: pass -> [missing] (J1)
  • errors::verify_resolve_name_reserved_in_attribute_namespace_56: [missing] -> pass (J1)
  • errors::verify_resolve_out_of_scope_macro_calls_71: [missing] -> pass (J1)
  • errors::verify_resolve_private_extern_crate_reexport_36: [missing] -> pass (J1)
  • errors::verify_resolve_redundant_import_visibility_72: [missing] -> pass (J1)
  • errors::verify_resolve_reexport_private_dependency_63: [missing] -> pass (J1)
  • errors::verify_resolve_static_lifetime_is_reserved_49: pass -> [missing] (J1)
  • errors::verify_resolve_tool_only_accepts_identifiers_58: pass -> [missing] (J1)
  • errors::verify_resolve_trait_impl_mismatch_60: [missing] -> pass (J1)
  • errors::verify_resolve_underscore_lifetime_is_reserved_49: [missing] -> pass (J1)
  • errors::verify_resolve_unnamed_crate_root_import_43: pass -> [missing] (J1)
  • errors::verify_resolve_unnamed_crate_root_import_44: [missing] -> pass (J1)
  • errors::verify_resolve_unused_extern_crate_61: pass -> [missing] (J1)
  • errors::verify_resolve_unused_macro_use_64: pass -> [missing] (J1)
  • errors::verify_resolve_variable_is_not_bound_in_all_patterns_50: pass -> [missing] (J1)
  • errors::verify_resolve_variable_is_not_bound_in_all_patterns_51: [missing] -> pass (J1)
  • lints::verify_lint_ambiguous_glob_reexport_119: pass -> [missing] (J1)
  • lints::verify_lint_associated_const_elided_lifetime_117: [missing] -> pass (J1)
  • lints::verify_lint_associated_const_elided_lifetime_122: pass -> [missing] (J1)
  • lints::verify_lint_hidden_glob_reexport_115: [missing] -> pass (J1)
  • lints::verify_lint_hidden_glob_reexport_120: pass -> [missing] (J1)
  • lints::verify_lint_ill_formed_attribute_input_109: [missing] -> pass (J1)
  • lints::verify_lint_macro_is_private_109: pass -> [missing] (J1)
  • lints::verify_lint_private_extern_crate_reexport_108: pass -> [missing] (J1)
  • lints::verify_lint_raw_prefix_115: pass -> [missing] (J1)
  • lints::verify_lint_redundant_import_visibility_123: pass -> [missing] (J1)
  • lints::verify_lint_reserved_multihash_127: pass -> [missing] (J1)
  • lints::verify_lint_reserved_prefix_110: [missing] -> pass (J1)
  • lints::verify_lint_reserved_string_119: [missing] -> pass (J1)
  • lints::verify_lint_unqualified_local_imports_125: pass -> [missing] (J1)
  • lints::verify_lint_unused_lifetime_116: pass -> [missing] (J1)
  • lints::verify_lint_unused_macro_definition_110: pass -> [missing] (J1)

Stage 1

  • errors::verify_resolve_anonymous_lifetime_non_gat_report_error_47: [missing] -> pass (J0)
  • errors::verify_resolve_arguments_macro_use_not_allowed_43: [missing] -> pass (J0)
  • errors::verify_resolve_attributes_starting_with_rustc_are_reserved_53: pass -> [missing] (J0)
  • errors::verify_resolve_cannot_find_builtin_macro_with_name_57: [missing] -> pass (J0)
  • errors::verify_resolve_cannot_glob_import_possible_crates_36: pass -> [missing] (J0)
  • errors::verify_resolve_cannot_glob_import_possible_crates_37: [missing] -> pass (J0)
  • errors::verify_resolve_explicit_anonymous_lifetime_report_error_47: pass -> [missing] (J0)
  • errors::verify_resolve_explicit_anonymous_lifetime_report_error_48: [missing] -> pass (J0)
  • errors::verify_resolve_extern_crate_not_idiomatic_70: [missing] -> pass (J0)
  • errors::verify_resolve_extern_crate_self_requires_renaming_38: pass -> [missing] (J0)
  • errors::verify_resolve_extern_crate_self_requires_renaming_39: [missing] -> pass (J0)
  • errors::verify_resolve_is_private_51: pass -> [missing] (J0)
  • errors::verify_resolve_is_private_52: [missing] -> pass (J0)
  • errors::verify_resolve_lending_iterator_report_error_46: [missing] -> pass (J0)
  • errors::verify_resolve_macro_expanded_extern_crate_cannot_shadow_extern_arguments_44: pass -> [missing] (J0)
  • errors::verify_resolve_macro_expanded_extern_crate_cannot_shadow_extern_arguments_45: [missing] -> pass (J0)
  • errors::verify_resolve_macro_extern_deprecated_42: [missing] -> pass (J0)
  • errors::verify_resolve_macro_use_deprecated_65: pass -> [missing] (J0)
  • errors::verify_resolve_macro_use_name_already_in_use_39: pass -> [missing] (J0)
  • errors::verify_resolve_macro_use_name_already_in_use_40: [missing] -> pass (J0)
  • errors::verify_resolve_name_reserved_in_attribute_namespace_55: pass -> [missing] (J0)
  • errors::verify_resolve_name_reserved_in_attribute_namespace_56: [missing] -> pass (J0)
  • errors::verify_resolve_out_of_scope_macro_calls_71: [missing] -> pass (J0)
  • errors::verify_resolve_private_extern_crate_reexport_36: [missing] -> pass (J0)
  • errors::verify_resolve_reexport_private_dependency_63: [missing] -> pass (J0)
  • errors::verify_resolve_static_lifetime_is_reserved_50: [missing] -> pass (J0)
  • errors::verify_resolve_trait_impl_mismatch_59: pass -> [missing] (J0)
  • errors::verify_resolve_trait_impl_mismatch_60: [missing] -> pass (J0)
  • errors::verify_resolve_unnamed_crate_root_import_43: pass -> [missing] (J0)
  • errors::verify_resolve_unused_extern_crate_61: pass -> [missing] (J0)
  • errors::verify_resolve_unused_label_63: pass -> [missing] (J0)
  • errors::verify_resolve_variable_is_not_bound_in_all_patterns_51: [missing] -> pass (J0)
  • lints::verify_lint_ambiguous_glob_reexport_119: pass -> [missing] (J0)
  • lints::verify_lint_associated_const_elided_lifetime_122: pass -> [missing] (J0)
  • lints::verify_lint_extern_crate_not_idiomatic_118: pass -> [missing] (J0)
  • lints::verify_lint_hidden_glob_reexport_115: [missing] -> pass (J0)
  • lints::verify_lint_ill_formed_attribute_input_109: [missing] -> pass (J0)
  • lints::verify_lint_named_argument_used_positionally_117: pass -> [missing] (J0)
  • lints::verify_lint_private_extern_crate_reexport_108: pass -> [missing] (J0)
  • lints::verify_lint_redundant_import_visibility_123: pass -> [missing] (J0)
  • lints::verify_lint_reserved_multihash_120: [missing] -> pass (J0)
  • lints::verify_lint_reserved_multihash_127: pass -> [missing] (J0)
  • lints::verify_lint_reserved_prefix_110: [missing] -> pass (J0)
  • lints::verify_lint_reserved_string_119: [missing] -> pass (J0)
  • lints::verify_lint_unnecessary_qualification_116: [missing] -> pass (J0)
  • lints::verify_lint_unnecessary_qualification_121: pass -> [missing] (J0)
  • lints::verify_lint_unused_crate_dependency_108: [missing] -> pass (J0)
  • lints::verify_lint_unused_crate_dependency_112: pass -> [missing] (J0)
  • lints::verify_lint_unused_lifetime_112: [missing] -> pass (J0)
  • lints::verify_lint_unused_lifetime_116: pass -> [missing] (J0)
  • lints::verify_lint_unused_macro_definition_110: pass -> [missing] (J0)
  • transmute::verify_lint_undefined_transmute_128: pass -> [missing] (J0)

(and 104 additional test diffs)

Additionally, 38 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 47cd7120d9b4e1b64eb27c87522a07888197fae8 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-sparcv9-solaris: 5081.2s -> 8649.7s (+70.2%)
  2. dist-x86_64-solaris: 5350.8s -> 8682.5s (+62.3%)
  3. dist-powerpc64le-linux-gnu: 5200.4s -> 7441.8s (+43.1%)
  4. dist-x86_64-netbsd: 4774.3s -> 6361.0s (+33.2%)
  5. dist-riscv64-linux: 4919.1s -> 6503.8s (+32.2%)
  6. dist-powerpc-linux: 4957.7s -> 6502.8s (+31.2%)
  7. dist-armv7-linux: 5068.5s -> 6556.5s (+29.4%)
  8. dist-s390x-linux: 4778.0s -> 6161.4s (+29.0%)
  9. dist-x86_64-apple: 6453.8s -> 8143.0s (+26.2%)
  10. dist-armhf-linux: 4943.6s -> 6140.3s (+24.2%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@fmease fmease deleted the mv-var-to-dyn-buf-lints-next branch December 2, 2025 11:05
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (47cd712): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.9%, -0.1%] 13
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -3.8%)

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
Improvements ✅
(secondary)
-3.8% [-7.9%, -1.2%] 12
All ❌✅ (primary) - - 0

Cycles

Results (secondary -2.7%)

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)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.7% [-5.2%, -4.3%] 3
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 468.853s -> 469.029s (0.04%)
Artifact size: 386.75 MiB -> 386.77 MiB (0.00%)

@rustbot rustbot added the perf-regression Performance regression. label Dec 2, 2025
@Mark-Simulacrum Mark-Simulacrum added the perf-regression-triaged The performance regression has been triaged. label Dec 3, 2025
@Mark-Simulacrum
Copy link
Member

Only a single secondary run regressed (ucd) so while it doesn't look spurious I don't think it merits investigation, especially coupled with some improvements. Marking as triaged.

jhpratt added a commit to jhpratt/rust that referenced this pull request Dec 6, 2025
…nszelmann

Move attribute lints to `rustc_lint`

This PR changes two things:
- This decouples the `AttributeLintKind` from the `Lint` it is emitted in. `cx.emit_lint` now takes both as an argument, rather than inferring the `Lint` from the `AttributeLintKind`. This is nice because:
  - It allows us to remove `AttributeLintKind::InvalidMacroExportArguments`
  - It allows us to move the choice between `USELESS_DEPRECATED` and `UNUSED_ATTRIBUTES` out of the lint emitting code
  - It allows the next change:
- This moves `AttributeLintKind` to `rustc_lint_defs`, and the decorating code to `rustc_lint`. This is nice because:
  - It allows attribute lint decorating code to access the TypeCtxt, which unblocks rust-lang#149215
  - It might allow most early buffered attribute lints to become dyn lint diagnostics in the future, as in rust-lang#147634
  - It deduplicates `IllFormedAttributeInput`

This PR does not change observable output of the compiler, as can be seen by no uitests being affected.

r? `@jdonszelmann`
rust-timer added a commit that referenced this pull request Dec 6, 2025
Rollup merge of #149662 - JonathanBrouwer:lint-rework, r=jdonszelmann

Move attribute lints to `rustc_lint`

This PR changes two things:
- This decouples the `AttributeLintKind` from the `Lint` it is emitted in. `cx.emit_lint` now takes both as an argument, rather than inferring the `Lint` from the `AttributeLintKind`. This is nice because:
  - It allows us to remove `AttributeLintKind::InvalidMacroExportArguments`
  - It allows us to move the choice between `USELESS_DEPRECATED` and `UNUSED_ATTRIBUTES` out of the lint emitting code
  - It allows the next change:
- This moves `AttributeLintKind` to `rustc_lint_defs`, and the decorating code to `rustc_lint`. This is nice because:
  - It allows attribute lint decorating code to access the TypeCtxt, which unblocks #149215
  - It might allow most early buffered attribute lints to become dyn lint diagnostics in the future, as in #147634
  - It deduplicates `IllFormedAttributeInput`

This PR does not change observable output of the compiler, as can be seen by no uitests being affected.

r? `@jdonszelmann`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

10 participants