1
Fork 0
rust/compiler/rustc_passes/src
bors 78948ac259 Auto merge of #138515 - petrochenkov:cfgtrace, r=nnethercote
expand: Leave traces when expanding `cfg_attr` attributes

Currently `cfg_trace` just disappears during expansion, but after this PR `#[cfg_attr(some tokens)]` will leave a `#[cfg_attr_trace(some tokens)]` attribute instead of itself in AST after expansion (the new attribute is built-in and inert, its inner tokens are the same as in the original attribute).
This trace attribute can then be used by lints or other diagnostics, #133823 has some examples.

Tokens in these trace attributes are set to an empty token stream, so the traces are non-existent for proc macros and cannot affect any user-observable behavior.
This is also a weakness, because if a proc macro processes some code with the trace attributes, they will be lost, so the traces are best effort rather than precise.

The next step is to do the same thing with `cfg` attributes (`#[cfg(TRUE)]` currently remains in both AST and tokens after expanding, it should be replaced with a trace instead).

The idea belongs to `@estebank.`
2025-03-20 19:24:48 +00:00
..
liveness compiler: Use size_of from the prelude instead of imported 2025-03-07 13:37:04 -08:00
abi_test.rs compiler: die immediately instead of handling unknown target codegen 2025-02-10 11:04:31 -08:00
check_attr.rs Auto merge of #138515 - petrochenkov:cfgtrace, r=nnethercote 2025-03-20 19:24:48 +00:00
dead.rs Rollup merge of #138384 - nnethercote:hir-ItemKind-idents, r=fmease 2025-03-17 22:49:04 +01:00
debugger_visualizer.rs Use SourceMap to load debugger visualizer files 2024-12-08 18:57:04 +00:00
diagnostic_items.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
entry.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
errors.rs Implment #[cfg] and #[cfg_attr] in where clauses 2025-03-01 22:02:46 +08:00
hir_id_validator.rs Adjust Map's to_string functionality. 2025-03-12 08:30:03 +11:00
input_stats.rs Rollup merge of #138040 - thaliaarchi:use-prelude-size-of.compiler, r=compiler-errors 2025-03-09 10:34:49 +01:00
lang_items.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
layout_test.rs Teach structured errors to display short Ty 2025-02-25 16:56:03 +00:00
lib.rs Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
lib_features.rs Introduce new-style attribute parsers for several attributes 2025-02-24 14:31:17 +01:00
liveness.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
loops.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
naked_functions.rs Implement .use keyword as an alias of clone 2025-03-06 17:58:32 -03:00
reachable.rs Auto merge of #138630 - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgr 2025-03-18 05:58:46 +00:00
stability.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
upvars.rs Move methods from Map to TyCtxt, part 2. 2025-02-18 10:17:44 +11:00
weak_lang_items.rs Add support for wasm exception handling to Emscripten target 2025-01-06 10:29:54 +01:00