rust/compiler
bors a0d98ff0e5 Auto merge of #132356 - jieyouxu:unsound-simplify_aggregate_to_copy, r=cjgillot,DianQK
Mark `simplify_aggregate_to_copy` mir-opt as unsound

Mark the `simplify_aggregate_to_copy` mir-opt added in #128299 as unsound as it seems to miscompile the MCVE reported in https://github.com/rust-lang/rust/issues/132353. The mir-opt can be re-enabled once this case is fixed.

```rs
fn pop_min(mut score2head: Vec<Option<usize>>) -> Option<usize> {
    loop {
        if let Some(col) = score2head[0] {
            score2head[0] = None;
            return Some(col);
        }
    }
}

fn main() {
    let min = pop_min(vec![Some(1)]);
    println!("min: {:?}", min);
    // panic happens here on beta in release mode
    // but not in debug mode
    min.unwrap();
}
```

This MCVE is included as a `run-pass` ui regression test in the first commit. I built the ui test with a nightly manually, and can reproduce the behavioral difference with `-C opt-level=0` and `-C opt-level=1`. Locally, this ui test will fail unless it was run on a compiler built with the second commit marking the mir-opt as unsound thus disabling it by default.

This PR **partially reverts** commit e7386b3, reversing changes made to 02b1be1. The mir-opt implementation is just marked as unsound but **not** reverted to make reland reviews easier. Test changes are **reverted if they were not pure additions**. Tests added by the original PR received `-Z unsound-mir-opts` compile-flags.

cc `@DianQK` `@cjgillot` (PR author and reviewer of #128299)
2024-10-31 15:29:14 +00:00
..
rustc
rustc_abi compiler: rustc_abi::Abi => BackendRepr 2024-10-29 14:56:00 -07:00
rustc_arena
rustc_ast fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
rustc_ast_ir
rustc_ast_lowering Encode cross-crate opaque type origin 2024-10-31 01:35:13 +00:00
rustc_ast_passes
rustc_ast_pretty fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
rustc_attr
rustc_baked_icu_data
rustc_borrowck Auto merge of #132301 - compiler-errors:adjust, r=lcnr 2024-10-31 10:17:49 +00:00
rustc_builtin_macros
rustc_codegen_cranelift cg_clif: rustc_abi::Abi => BackendRepr 2024-10-29 15:01:01 -07:00
rustc_codegen_gcc cg_gcc: rustc_abi::Abi => BackendRepr 2024-10-29 15:01:01 -07:00
rustc_codegen_llvm coverage: Avoid ICE when coverage_cx is unexpectedly unavailable 2024-10-31 21:25:43 +11:00
rustc_codegen_ssa Rollup merge of #132354 - koute:master, r=workingjubilee 2024-10-31 12:35:56 +01:00
rustc_const_eval Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errors 2024-10-30 14:01:37 -07:00
rustc_data_structures
rustc_driver
rustc_driver_impl fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
rustc_error_codes Reject generic self types. 2024-10-30 10:48:08 +00:00
rustc_error_messages
rustc_errors Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillot 2024-10-29 03:11:39 -07:00
rustc_expand Rollup merge of #132332 - nnethercote:use-token_descr-more, r=estebank 2024-10-30 06:40:36 +01:00
rustc_feature Rollup merge of #131984 - dingxiangfei2009:stabilize-if-let-rescope, r=traviscross,lcnr 2024-10-29 18:38:57 +01:00
rustc_fluent_macro
rustc_fs_util
rustc_graphviz
rustc_hir Encode cross-crate opaque type origin 2024-10-31 01:35:13 +00:00
rustc_hir_analysis Auto merge of #131186 - compiler-errors:precise-capturing-borrowck, r=estebank 2024-10-31 03:36:06 +00:00
rustc_hir_pretty Remap impl-trait lifetimes on HIR instead of AST lowering. 2024-10-30 16:18:50 +00:00
rustc_hir_typeck Auto merge of #132301 - compiler-errors:adjust, r=lcnr 2024-10-31 10:17:49 +00:00
rustc_incremental
rustc_index
rustc_index_macros
rustc_infer Encode cross-crate opaque type origin 2024-10-31 01:35:13 +00:00
rustc_interface fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
rustc_lexer
rustc_lint Auto merge of #132301 - compiler-errors:adjust, r=lcnr 2024-10-31 10:17:49 +00:00
rustc_lint_defs
rustc_llvm Rollup merge of #132342 - Zalathar:operand-bundle, r=workingjubilee 2024-10-30 06:40:38 +01:00
rustc_log
rustc_macros
rustc_metadata Auto merge of #131186 - compiler-errors:precise-capturing-borrowck, r=estebank 2024-10-31 03:36:06 +00:00
rustc_middle Auto merge of #132301 - compiler-errors:adjust, r=lcnr 2024-10-31 10:17:49 +00:00
rustc_mir_build Auto merge of #132301 - compiler-errors:adjust, r=lcnr 2024-10-31 10:17:49 +00:00
rustc_mir_dataflow Remove ValueAnalysis and ValueAnalysisWrapper. 2024-10-31 12:46:26 +11:00
rustc_mir_transform Auto merge of #132356 - jieyouxu:unsound-simplify_aggregate_to_copy, r=cjgillot,DianQK 2024-10-31 15:29:14 +00:00
rustc_monomorphize
rustc_next_trait_solver Merge HostPolarity and BoundConstness 2024-10-30 16:23:16 +00:00
rustc_parse Rollup merge of #132332 - nnethercote:use-token_descr-more, r=estebank 2024-10-30 06:40:36 +01:00
rustc_parse_format
rustc_passes Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errors 2024-10-30 14:01:37 -07:00
rustc_pattern_analysis
rustc_privacy Merge HostPolarity and BoundConstness 2024-10-30 16:23:16 +00:00
rustc_query_impl
rustc_query_system fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
rustc_resolve Review comments. 2024-10-30 16:20:49 +00:00
rustc_sanitizers
rustc_serialize
rustc_session fix libc call from i8 to u8 2024-10-30 09:17:44 -04:00
rustc_smir compiler: rustc_abi::Abi => BackendRepr 2024-10-29 14:56:00 -07:00
rustc_span Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillot 2024-10-29 03:11:39 -07:00
rustc_symbol_mangling
rustc_target Rollup merge of #132354 - koute:master, r=workingjubilee 2024-10-31 12:35:56 +01:00
rustc_trait_selection Auto merge of #132301 - compiler-errors:adjust, r=lcnr 2024-10-31 10:17:49 +00:00
rustc_traits TypingMode 🤔 2024-10-29 17:01:24 +01:00
rustc_transmute Rollup merge of #132255 - workingjubilee:layout-is-🏚️, r=compiler-errors 2024-10-28 10:18:50 -07:00
rustc_ty_utils Auto merge of #131186 - compiler-errors:precise-capturing-borrowck, r=estebank 2024-10-31 03:36:06 +00:00
rustc_type_ir Merge HostPolarity and BoundConstness 2024-10-30 16:23:16 +00:00
rustc_type_ir_macros
stable_mir