rust/compiler
bors 36e4f5d1fe Auto merge of #146096 - adwinwhite:handle_normalization_overflow_in_mono1, r=saethlin
Fix normalization overflow ICEs in monomorphization

Fixes rust-lang/rust#92004
Fixes rust-lang/rust#92470
Fixes rust-lang/rust#95134
Fixes rust-lang/rust#105275
Fixes rust-lang/rust#105937
Fixes rust-lang/rust#117696-2
Fixes rust-lang/rust#118590
Fixes rust-lang/rust#122823
Fixes rust-lang/rust#131342
Fixes rust-lang/rust#139659

## Analysis:
The causes of these issues are similar. They contain generic recursive functions that can be instantiated with different args infinitely at monomorphization stage.
Ideally this should be caught by the [`check_recursion_limit`](c0bb3b98bb/compiler/rustc_monomorphize/src/collector.rs (L468)) function. The reality is that normalization can reach recursion limit earlier than monomorphization's check because they calculate depths in different ways.
Since normalization is called everywhere, ICEs appear in different locations.

## Fix:
If we abort on overflow with `TypingMode::PostAnalysis` in the trait solver, it would also catch these errors.
The main challenge is providing good diagnostics for them. So it's quite natural to put the check right before these normalization happening.
I first tried to check the whole MIR body's normalization and `references_error`. (As elaborate_drop handles normalization failure by [returning `ty::Error`](c0bb3b98bb/compiler/rustc_mir_transform/src/elaborate_drop.rs (L514-L519)).)
It turns out that checking all `Local`s seems sufficient.
These types are gonna be normalized anyway. So with cache, these checks shouldn't be expensive.

This fixes these ICEs for both the next and old solver, though I'm not sure the change I made to the old solver is proper. Its overflow handling looks convoluted thus I didn't try to fix it more "upstream".
2025-10-13 00:20:10 +00:00
..
rustc Make llvm_enzyme a regular cargo feature 2025-09-15 15:31:56 +00:00
rustc_abi Rollup merge of #147134 - workingjubilee:remove-explicit-abialign-deref, r=Zalathar 2025-09-29 15:44:55 +10:00
rustc_arena some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_ast format: some small cleanup 2025-10-08 15:13:47 +00:00
rustc_ast_ir turn pointer width into an integer in target.json 2025-08-27 23:44:49 +02:00
rustc_ast_lowering Auto merge of #145882 - m-ou-se:format-args-extend-1-arg, r=petrochenkov 2025-09-26 04:34:09 +00:00
rustc_ast_passes Extract common logic for iterating over features 2025-10-02 21:43:14 +00:00
rustc_ast_pretty Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_attr_parsing Fix double error for #[no_mangle] on consts 2025-10-08 17:46:33 +02:00
rustc_baked_icu_data Use default locale fallback data 2025-08-28 09:48:54 +00:00
rustc_borrowck Auto merge of #142390 - cjgillot:mir-liveness, r=davidtwco 2025-10-12 13:00:04 +00:00
rustc_builtin_macros Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk 2025-10-09 18:43:26 +11:00
rustc_codegen_cranelift Auto merge of #145513 - beepster4096:erasedereftemps, r=saethlin,cjgillot 2025-10-12 02:34:20 +00:00
rustc_codegen_gcc codegen: Generate dbg_value for the ref statement 2025-10-02 14:55:51 +08:00
rustc_codegen_llvm Replace LLVMRustContextCreate with normal LLVM-C API calls 2025-10-10 15:45:40 +02:00
rustc_codegen_ssa Auto merge of #145513 - beepster4096:erasedereftemps, r=saethlin,cjgillot 2025-10-12 02:34:20 +00:00
rustc_const_eval Auto merge of #145513 - beepster4096:erasedereftemps, r=saethlin,cjgillot 2025-10-12 02:34:20 +00:00
rustc_data_structures avoid calling insert_presorted more than once 2025-09-10 08:40:12 +02:00
rustc_driver compiler: Add Windows resources to rustc-main and rustc_driver 2025-09-05 14:06:31 -04:00
rustc_driver_impl fixes for numerous clippy warnings 2025-09-19 20:56:07 +00:00
rustc_error_codes Rollup merge of #146585 - hkBst:indexing-1, r=jdonszelmann 2025-10-02 10:27:49 +02:00
rustc_error_messages Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_errors Rollup merge of #147354 - chenyukang:yukang-fix-147070-wrong-highlight-span, r=estebank 2025-10-07 07:04:17 +02:00
rustc_expand Rollup merge of #147395 - reddevilmidzy:refact-error-msg, r=Kivooeo,jackh726 2025-10-07 07:04:18 +02:00
rustc_feature Extract common logic for iterating over features 2025-10-02 21:43:14 +00:00
rustc_fluent_macro some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_fs_util Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_graphviz some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_hashes some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_hir support link modifier as-needed for raw-dylib-elf 2025-10-06 08:56:40 +08:00
rustc_hir_analysis Rollup merge of #147479 - folkertdev:cmse-refactor-warnings, r=davidtwco 2025-10-09 20:41:23 +02:00
rustc_hir_id rustc_hir_id: Add a comment explaining why the crate exists 2025-08-20 15:04:00 -07:00
rustc_hir_pretty Rollup merge of #146102 - fmease:rm-dead-eff-code-iii, r=fee1-dead 2025-09-02 17:08:58 +02:00
rustc_hir_typeck Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk 2025-10-09 18:43:26 +11:00
rustc_incremental Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_index Apply cfg(bootstrap) replacement 2025-09-26 19:09:23 -04:00
rustc_index_macros Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_infer rename select_where_possible and select_all_or_error 2025-10-07 23:02:23 +01:00
rustc_interface Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
rustc_lexer Fix a crash/mislex when more than one frontmatter closing possibility is considered 2025-09-22 15:10:41 -04:00
rustc_lint Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk 2025-10-09 18:43:26 +11:00
rustc_lint_defs clarify wording of match ergonomics diagnostics 2025-10-08 02:12:24 -07:00
rustc_llvm Rollup merge of #147604 - Kivooeo:tear-prev-pr, r=nnethercote 2025-10-12 19:07:48 +02:00
rustc_log some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_macros use declarative macro for #[derive(TryFromU32)] 2025-10-06 14:54:38 +00:00
rustc_metadata support link modifier as-needed for raw-dylib-elf 2025-10-06 08:56:40 +08:00
rustc_middle Auto merge of #146096 - adwinwhite:handle_normalization_overflow_in_mono1, r=saethlin 2025-10-13 00:20:10 +00:00
rustc_mir_build Auto merge of #142390 - cjgillot:mir-liveness, r=davidtwco 2025-10-12 13:00:04 +00:00
rustc_mir_dataflow Remove StatementKind::Deinit. 2025-10-10 12:57:24 +00:00
rustc_mir_transform Auto merge of #142390 - cjgillot:mir-liveness, r=davidtwco 2025-10-12 13:00:04 +00:00
rustc_monomorphize check normalization overflow in monomorphization 2025-10-12 06:59:10 +08:00
rustc_next_trait_solver Auto merge of #147138 - jackh726:split-canonical-bound, r=lcnr 2025-10-02 08:09:33 +00:00
rustc_parse Auto merge of #147360 - chenyukang:yukang-fix-assoc-eq-missing-term, r=nnethercote 2025-10-06 01:24:16 +00:00
rustc_parse_format Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_passes Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
rustc_pattern_analysis Rename various "concrete opaque type" terminology to say "hidden type" 2025-09-27 22:58:02 +01:00
rustc_privacy fix doc comments to be more standard 2025-09-26 09:25:56 +00:00
rustc_proc_macro Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_public Remove StatementKind::Deinit. 2025-10-10 12:57:24 +00:00
rustc_public_bridge Remove useless lifetime parameter. 2025-07-23 23:54:37 +00:00
rustc_query_impl fixup limit handling code 2025-09-08 15:07:12 -07:00
rustc_query_system Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk 2025-10-09 18:43:26 +11:00
rustc_resolve Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk 2025-10-09 18:43:26 +11:00
rustc_sanitizers Split Bound into Canonical and Bound 2025-09-30 12:58:28 -04:00
rustc_serialize Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_session support link modifier as-needed for raw-dylib-elf 2025-10-06 08:56:40 +08:00
rustc_span Auto merge of #145513 - beepster4096:erasedereftemps, r=saethlin,cjgillot 2025-10-12 02:34:20 +00:00
rustc_symbol_mangling Auto merge of #147138 - jackh726:split-canonical-bound, r=lcnr 2025-10-02 08:09:33 +00:00
rustc_target Rollup merge of #146522 - thejpster:promote-armv7a-none-eabihf, r=petrochenkov 2025-10-11 07:05:55 +08:00
rustc_thread_pool some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_trait_selection Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk 2025-10-09 18:43:26 +11:00
rustc_traits Auto merge of #146096 - adwinwhite:handle_normalization_overflow_in_mono1, r=saethlin 2025-10-13 00:20:10 +00:00
rustc_transmute prefer to use repeat_n over repeat and take 2025-10-09 01:24:55 +08:00
rustc_ty_utils rename select_where_possible and select_all_or_error 2025-10-07 23:02:23 +01:00
rustc_type_ir Rollup merge of #147251 - jackh726:global-cache-non-concurrent-change, r=lcnr 2025-10-04 17:11:12 +02:00
rustc_type_ir_macros some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_windows_rc [win] Use find-msvc-tools instead of cc to find the linker and rc on Windows 2025-09-19 12:00:30 -07:00