rust/compiler
Matthias Krüger d73decdaad
Rollup merge of #128304 - Zalathar:thir-pat-display, r=Nadrieril
Isolate the diagnostic code that expects `thir::Pat` to be printable

Currently, `thir::Pat` implements `fmt::Display` (and `IntoDiagArg`) directly, for use by a few diagnostics.

That makes it tricky to experiment with alternate representations for THIR patterns, because the patterns currently need to be printable on their own. That immediately rules out possibilities like storing subpatterns as a `PatId` index into a central list (instead of the current directly-owned `Box<Pat>`).

This PR therefore takes an incremental step away from that obstacle, by removing `thir::Pat` from diagnostic structs in `rustc_pattern_analysis`, and hiding the pattern-printing process behind a single public `Pat::to_string` method. Doing so makes it easier to identify and update the code that wants to print patterns, and gives a place to pass in additional context in the future if necessary.

---

I'm currently not sure whether switching over to `PatId` is actually desirable or not, but I think this change makes sense on its own merits, by reducing the coupling between `thir::Pat` and the pattern-analysis error types.
2024-07-29 11:42:34 +02:00
..
rustc The rustc crate feature is called jemalloc 2024-07-15 13:01:20 -04:00
rustc_abi Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_arena Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ast Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ast_ir Use dep: for crate dependencies 2024-07-15 12:40:10 -04:00
rustc_ast_lowering Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ast_passes Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ast_pretty Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_attr Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_baked_icu_data Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_borrowck Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_builtin_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_codegen_cranelift Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_codegen_gcc Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_codegen_llvm Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_codegen_ssa Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_const_eval Rollup merge of #128277 - RalfJung:offset_from_wildcard, r=oli-obk 2024-07-29 11:42:34 +02:00
rustc_data_structures Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_driver Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_driver_impl Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_error_codes Rollup merge of #127853 - folkertdev:naked-function-error-messages, r=bjorn3 2024-07-28 08:57:16 +02:00
rustc_error_messages Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_errors Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_expand Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_feature Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_fluent_macro Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_fs_util Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_graphviz Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_hir Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_hir_analysis Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_hir_pretty Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_hir_typeck Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_incremental Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_index Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_index_macros Remove usage of specialization from newtype_index! 2024-06-30 16:42:53 +00:00
rustc_infer Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_interface Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_lexer Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_lint Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_lint_defs Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_llvm Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_log Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_metadata Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_middle Rollup merge of #128304 - Zalathar:thir-pat-display, r=Nadrieril 2024-07-29 11:42:34 +02:00
rustc_mir_build Rollup merge of #128304 - Zalathar:thir-pat-display, r=Nadrieril 2024-07-29 11:42:34 +02:00
rustc_mir_dataflow Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_mir_transform Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_monomorphize Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_next_trait_solver Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_parse Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_parse_format Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_passes Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_pattern_analysis Rollup merge of #128304 - Zalathar:thir-pat-display, r=Nadrieril 2024-07-29 11:42:34 +02:00
rustc_privacy Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_query_impl Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_query_system Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_resolve Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_sanitizers Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_serialize Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_session Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_smir Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_span Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_symbol_mangling Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_target Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_trait_selection Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_traits Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_transmute Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ty_utils Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_type_ir Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_type_ir_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
stable_mir Reformat use declarations. 2024-07-29 08:26:52 +10:00