rust/compiler/rustc_builtin_macros/src
Jacob Pratt d3c9908a8a
Rollup merge of #145747 - joshtriplett:builtin-diag-dyn, r=jdonszelmann
Refactor lint buffering to avoid requiring a giant enum

Lint buffering currently relies on a giant enum `BuiltinLintDiag` containing all the lints that might potentially get buffered. In addition to being an unwieldy enum in a central crate, this also makes `rustc_lint_defs` a build bottleneck: it depends on various types from various crates (with a steady pressure to add more), and many crates depend on it.

Having all of these variants in a separate crate also prevents detecting when a variant becomes unused, which we can do with a dedicated type defined and used in the same crate.

Refactor this to use a dyn trait, to allow using `LintDiagnostic` types directly.

Because the existing `BuiltinLintDiag` requires some additional types in order to decorate some variants, which are only available later in `rustc_lint`, use an enum `DecorateDiagCompat` to handle both the `dyn LintDiagnostic` case and the `BuiltinLintDiag` case.

---

With the infrastructure in place, use it to migrate three of the enum variants to use `LintDiagnostic` directly, as a proof of concept and to demonstrate that the net result is a reduction in code size and a removal of a boilerplate-heavy layer of indirection.

Also remove an unused `BuiltinLintDiag` variant.
2025-08-22 22:00:59 -04:00
..
assert remove P 2025-08-09 15:47:01 +08:00
deriving Avoid using () in derive(From) output. 2025-08-19 18:16:57 +10:00
format_foreign Rustfmt 2025-02-08 22:12:13 +00:00
alloc_error_handler.rs remove P 2025-08-09 15:47:01 +08:00
asm.rs remove P 2025-08-09 15:47:01 +08:00
assert.rs Change the desugaring of assert! for better error output 2025-08-12 16:30:48 +00:00
autodiff.rs Remove inlining for autodiff handling 2025-08-14 16:30:16 +00:00
cfg.rs Speed up Parser::expected_token_types. 2024-12-19 16:05:41 +11:00
cfg_accessible.rs Move validate_attr to rustc_attr_parsing 2025-08-22 08:37:19 +02:00
cfg_eval.rs remove P 2025-08-09 15:47:01 +08:00
cfg_select.rs update cfg_select! documentation 2025-07-14 22:29:28 +02:00
cmdline_attrs.rs Improve -Z crate-attr diagnostics 2025-04-13 16:46:02 -04:00
compile_error.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
concat.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
concat_bytes.rs remove P 2025-08-09 15:47:01 +08:00
contracts.rs Fix imports, remove attrs for unused_* 2025-02-10 20:15:30 +00:00
define_opaque.rs Test define opaques in extern items 2025-03-25 16:44:59 +00:00
derive.rs Move validate_attr to rustc_attr_parsing 2025-08-22 08:37:19 +02:00
edition_panic.rs remove P 2025-08-09 15:47:01 +08:00
env.rs Remove AstDeref. 2025-05-10 08:58:47 +10:00
errors.rs Implement #[derive(From)] 2025-08-15 12:07:15 +02:00
format.rs Refactor lint buffering to avoid requiring a giant enum 2025-08-22 01:59:56 -07:00
format_foreign.rs remove P 2025-08-09 15:47:01 +08:00
global_allocator.rs remove P 2025-08-09 15:47:01 +08:00
iter.rs remove P 2025-08-09 15:47:01 +08:00
lib.rs Rollup merge of #145429 - bjorn3:codegen_fn_attrs_improvements, r=jdonszelmann 2025-08-19 19:45:31 +08:00
log_syntax.rs Adjust some pubs. 2024-04-26 13:29:20 +10:00
pattern_type.rs remove P 2025-08-09 15:47:01 +08:00
proc_macro_harness.rs Remove the old target checking logic 2025-08-14 18:18:42 +02:00
source_util.rs remove P 2025-08-09 15:47:01 +08:00
standard_library_imports.rs expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
test.rs remove P 2025-08-09 15:47:01 +08:00
test_harness.rs Prevent impossible combinations in ast::ModKind. 2025-08-19 21:57:31 +10:00
trace_macros.rs Rollup merge of #134161 - nnethercote:overhaul-token-cursors, r=spastorino 2024-12-18 22:56:53 +08:00
util.rs Move validate_attr to rustc_attr_parsing 2025-08-22 08:37:19 +02:00