rust/tests/ui/codegen
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
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
equal-pointers-unequal Adjust test to still show miscompile 2025-08-20 19:08:16 +02:00
normalization-overflow check normalization overflow in monomorphization 2025-10-12 06:59:10 +08:00
alias-uninit-value.rs Adjust alias-uninit-value.rs 2024-12-10 11:20:19 +08:00
assign-expr-unit-type.rs Move assign-assign.rs to tests/ui/codegen/assign-expr-unit-type.rs 2024-12-08 15:32:04 +08:00
cfguard-run.rs Move tests from /ui directory 2025-04-29 18:19:26 +02:00
const-bool-bitcast.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
duplicated-path-in-error.gnu.stderr tests: Fix duplicated-path-in-error fail with musl 2025-07-14 18:37:49 +02:00
duplicated-path-in-error.musl.stderr tests: Fix duplicated-path-in-error fail with musl 2025-07-14 18:37:49 +02:00
duplicated-path-in-error.rs tests: Fix duplicated-path-in-error fail with musl 2025-07-14 18:37:49 +02:00
dynamic-size-of-prefix-correctly-36278.rs Rehome tests/ui/issues/ tests [1/?] 2025-07-24 17:01:44 -04:00
empty-static-libs-issue-108825.rs don't uppercase error messages 2025-09-03 15:24:49 +02:00
emscripten-llvm-crash-regression-66308.rs Add test batch 4 2025-10-11 21:59:51 -04:00
freeze-on-polymorphic-projection.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
freeze-on-polymorphic-projection.stderr Check freeze with right param-env 2023-04-16 23:09:57 +00:00
i128-shift-overflow-check-76042.rs Rehome tests/ui/issues/ tests [5/?] 2025-08-17 13:01:02 -04:00
indirect-nocapture.rs Use captures(address) instead of captures(none) for indirect args 2025-08-26 16:16:23 +02:00
init-large-type.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
issue-16602-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-16602-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-16602-3.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-27859.rs Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
issue-28950.rs compiletest: Add a //@ needs-threads directive 2024-03-06 12:35:07 -08:00
issue-55976.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-63787.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-64401.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-79865-llvm-miscompile.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-82833-slice-miscompile.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
issue-82859-slice-miscompile.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-88043-bb-does-not-have-terminator.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-97708.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-99551.rs remove feature(trait_upcasting) from tests and bless them 2025-02-06 23:44:23 +01:00
issue-101585-128bit-repeat.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
llvm-args-invalid-flag.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
llvm-args-invalid-flag.stderr moved tests 2025-07-01 23:33:59 +05:00
llvm-miscompile-metadata-invalidation-36023.rs Rehome tests/ui/issues/ tests [2/?] 2025-08-02 15:29:16 -04:00
llvm-pr32379.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
matrix-row-swap-54462.rs Add test batch 2 2025-08-27 15:06:05 -04:00
maximal-hir-to-mir-coverage-flag.rs cleaned up some tests 2025-06-30 12:45:47 +05:00
mismatched-data-layout.json fix target-pointer-width in tests 2025-08-27 23:44:49 +02:00
mismatched-data-layouts.rs Use serde for target spec json deserialize 2025-07-21 19:32:44 +02:00
mismatched-data-layouts.stderr Use serde for target spec json deserialize 2025-07-21 19:32:44 +02:00
mono-impossible-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
mono-impossible-drop.rs Fix ProvenVia for global where clauses 2025-04-05 16:23:25 +00:00
mono-impossible.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
mono-item-collector-default-impl-58375.rs Add test batch 3 2025-09-12 14:45:12 -04:00
mono-respects-abi-alignment.rs cleaned up some tests 2025-06-30 11:23:01 +05:00
msvc-opt-level-z-no-corruption.rs cleaned up some tests 2025-06-30 11:23:01 +05:00
nested-enum-match-optimization-15793.rs comments 2025-08-09 16:27:20 +05:00
no-mangle-on-internal-lang-items.rs error when using no_mangle on language items 2025-04-30 14:54:10 +03:00
no-mangle-on-internal-lang-items.stderr error when using no_mangle on language items 2025-04-30 14:54:10 +03:00
no-mangle-on-panic-handler.rs error when using no_mangle on language items 2025-04-30 14:54:10 +03:00
no-mangle-on-panic-handler.stderr error when using no_mangle on language items 2025-04-30 14:54:10 +03:00
output-slot-init-vs-noninit.rs cleaned up some tests 2025-07-05 03:46:08 +05:00
overflow-during-mono.rs Use tcx.short_string() in more diagnostics 2025-08-07 21:18:00 +00:00
overflow-during-mono.stderr Use tcx.short_string() in more diagnostics 2025-08-07 21:18:00 +00:00
ref-dyn-trait-in-structs-and-enums.rs Cleaned up 4 tests in tests/ui/issues 2025-04-19 01:10:26 -06:00
remark-flag-functionality.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
rvalue-mut-ref-box-drop.rs cleaned up some tests 2025-06-04 17:48:50 +05:00
shift-right-operand-mutation.rs cleaned up some tests 2025-07-05 03:46:08 +05:00
sret-aliasing-rules.rs cleaned up some tests 2025-07-05 03:46:08 +05:00
StackColoring-not-blowup-stack-issue-40883.rs Add ignore-backends annotations in failing GCC backend ui tests 2025-07-23 13:48:04 +02:00
static-array-comparison-7012.rs Add test batch 1 2025-08-27 00:23:26 -04:00
sub-principals-in-codegen.rs Relax a debug assertion in codegen 2024-09-30 12:18:02 -04:00
subtyping-enforces-type-equality.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
subtyping-impacts-selection-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
subtyping-impacts-selection-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
target-cpus.rs Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
target-cpus.stdout Add ui test of LLVM print-from-C++ changes 2023-07-20 11:04:31 -07:00
unsupported-static-initializer-in-const-array.rs LLVM error with unsupported expression in static initializer for const pointer in array on macOS 2025-08-01 18:01:21 +01:00
virtual-function-elimination.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00