rust/compiler
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
..
rustc Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_abi Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
rustc_arena Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_ast Revert "Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu" 2025-03-18 13:28:56 +01:00
rustc_ast_ir Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_ast_lowering Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_ast_passes expand: Leave traces when expanding cfg_attr attributes 2025-03-17 15:58:25 +03:00
rustc_ast_pretty Auto merge of #138515 - petrochenkov:cfgtrace, r=nnethercote 2025-03-20 19:24:48 +00:00
rustc_attr_data_structures Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu 2025-03-12 10:19:30 -07:00
rustc_attr_parsing Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_baked_icu_data Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_borrowck Rollup merge of #138384 - nnethercote:hir-ItemKind-idents, r=fmease 2025-03-17 22:49:04 +01:00
rustc_builtin_macros Allow builtin macros to be used more than once. 2025-03-19 14:12:47 +01:00
rustc_codegen_cranelift Remove implicit #[no_mangle] for #[rustc_std_internal_symbol] 2025-03-17 14:08:09 +00:00
rustc_codegen_gcc Remove implicit #[no_mangle] for #[rustc_std_internal_symbol] 2025-03-17 14:08:09 +00:00
rustc_codegen_llvm Rollup merge of #138674 - oli-obk:llvm-cleanups, r=compiler-errors 2025-03-19 08:17:19 +01:00
rustc_codegen_ssa Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_const_eval Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
rustc_data_structures Auto merge of #137011 - LuuuXXX:promote-ohos-with-host-tools, r=Amanieu 2025-03-16 18:42:18 +00:00
rustc_driver Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_driver_impl Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_error_codes Allow builtin macros to be used more than once. 2025-03-19 14:12:47 +01:00
rustc_error_messages Rollup merge of #138404 - bjorn3:sysroot_handling_cleanup, r=petrochenkov,jieyouxu 2025-03-13 11:28:35 +01:00
rustc_errors Do not suggest using -Zmacro-backtrace for builtin macros 2025-03-14 19:50:03 +00:00
rustc_expand Auto merge of #138515 - petrochenkov:cfgtrace, r=nnethercote 2025-03-20 19:24:48 +00:00
rustc_feature Auto merge of #138515 - petrochenkov:cfgtrace, r=nnethercote 2025-03-20 19:24:48 +00:00
rustc_fluent_macro Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_fs_util Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_graphviz Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_hashes Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hir Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
rustc_hir_analysis Remove existing AFIDT implementation 2025-03-18 17:35:26 +00:00
rustc_hir_pretty Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
rustc_hir_typeck Rollup merge of #138001 - meithecatte:privately-uninhabited, r=Nadrieril 2025-03-19 16:52:54 +01:00
rustc_incremental Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth 2025-03-13 01:37:26 +00:00
rustc_index Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
rustc_index_macros Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_infer Fold visit into ty 2025-03-15 06:34:36 +00:00
rustc_interface Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_lexer Revert "Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu" 2025-03-18 13:28:56 +01:00
rustc_lint Rollup merge of #138001 - meithecatte:privately-uninhabited, r=Nadrieril 2025-03-19 16:52:54 +01:00
rustc_lint_defs Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_llvm Auto merge of #137011 - LuuuXXX:promote-ohos-with-host-tools, r=Amanieu 2025-03-16 18:42:18 +00:00
rustc_log Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_macros Move codec module back into middle 2025-03-15 06:42:48 +00:00
rustc_metadata Auto merge of #137930 - nnethercote:use-Wunused-crate-dependencies, r=jieyouxu,Nadrieril 2025-03-20 04:20:13 +00:00
rustc_middle Auto merge of #133889 - compiler-errors:inh-unstable, r=Nadrieril 2025-03-20 14:31:34 +00:00
rustc_mir_build Auto merge of #137930 - nnethercote:use-Wunused-crate-dependencies, r=jieyouxu,Nadrieril 2025-03-20 04:20:13 +00:00
rustc_mir_dataflow Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_mir_transform Rollup merge of #138670 - compiler-errors:remove-afidt, r=oli-obk 2025-03-19 08:17:18 +01:00
rustc_monomorphize Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr 2025-03-12 17:27:43 +00:00
rustc_next_trait_solver Use {Decodable,Encodable}_NoContext in type_ir 2025-03-15 06:34:36 +00:00
rustc_parse Auto merge of #138515 - petrochenkov:cfgtrace, r=nnethercote 2025-03-20 19:24:48 +00:00
rustc_parse_format Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_passes Auto merge of #138515 - petrochenkov:cfgtrace, r=nnethercote 2025-03-20 19:24:48 +00:00
rustc_pattern_analysis Auto merge of #133889 - compiler-errors:inh-unstable, r=Nadrieril 2025-03-20 14:31:34 +00:00
rustc_privacy Auto merge of #138630 - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgr 2025-03-18 05:58:46 +00:00
rustc_query_impl Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_query_system Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_resolve Allow builtin macros to be used more than once. 2025-03-19 14:12:47 +01:00
rustc_sanitizers Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_serialize Convert rustc_serialize integration tests to unit tests. 2025-03-20 08:59:50 +11:00
rustc_session Auto merge of #122156 - Zoxc:side-effect-dep-node, r=oli-obk 2025-03-19 15:51:54 +00:00
rustc_smir Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_span expand: Leave traces when expanding cfg_attr attributes 2025-03-17 15:58:25 +03:00
rustc_symbol_mangling Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_target Rollup merge of #138608 - heiher:issue-116344, r=RalfJung 2025-03-17 22:49:07 +01:00
rustc_trait_selection Rollup merge of #138594 - oli-obk:no-select, r=lcnr 2025-03-19 16:52:57 +01:00
rustc_traits Rollup merge of #138394 - lcnr:yeet-variant, r=compiler-errors 2025-03-12 10:19:32 -07:00
rustc_transmute Add #[cfg(test)] for Transition in dfa 2025-03-18 07:17:16 +00:00
rustc_ty_utils Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_type_ir Suppress must_use in compiler and tools 2025-03-16 17:47:57 +00:00
rustc_type_ir_macros Fold visit into ty 2025-03-15 06:34:36 +00:00
stable_mir Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00