rust/compiler
Matthias Krüger 434232f7b2
Rollup merge of #118426 - aDotInTheVoid:const-wat, r=compiler-errors,cjgillot
ConstProp: Correctly remove const if unknown value assigned to it.

Closes #118328

The problematic sequence of MIR is:

```rust
          _1 = const 0_usize;
          _1 = const _; // This is an associated constant we can't know before monomorphization.
          _0 = _1;
```

1. When `ConstProp::visit_assign` happens on `_1 = const 0_usize;`, it records that `0x0usize` is the value for `_1`.
2. Next `visit_assign` happens on `_1 = const _;`. Because the rvalue `.has_param()`, it can't be const evaled.
3. Finaly, `visit_assign` happens on `_0 = _1;`. Here it would think the value of `_1` was `0x0usize` from step 1.

The solution is to remove consts when checking the RValue fails, as they may have contained values that should now be invalidated, as that local was overwritten.

This should probably be back-ported to beta. Stable is more iffy, as it's gone unidentified since 1.70, so I only think it's worthwhile if there's another reason for a 1.74.1 release anyway.
2023-11-29 12:34:50 +01:00
..
rustc
rustc_abi Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
rustc_arena
rustc_ast Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_ast_lowering Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_ast_passes Add never_patterns feature gate 2023-11-29 03:58:29 +01:00
rustc_ast_pretty Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_attr Detect and reject malformed repr(Rust) hints 2023-11-27 12:29:21 +01:00
rustc_baked_icu_data
rustc_borrowck Fix a typo in a format_args! note 2023-11-28 17:12:20 -08:00
rustc_builtin_macros unwrap return Option value, as it always returns Some for some fns 2023-11-28 14:52:21 +03:00
rustc_codegen_cranelift Auto merge of #118279 - bjorn3:sync_cg_clif-2023-11-25, r=bjorn3 2023-11-25 13:08:29 +00:00
rustc_codegen_gcc Use rustc_fluent_macro::fluent_messages! directly. 2023-11-26 08:38:40 +11:00
rustc_codegen_llvm Auto merge of #117947 - Dirbaio:drop-llvm-15, r=cuviper 2023-11-27 21:54:03 +00:00
rustc_codegen_ssa Rollup merge of #118378 - cormacrelf:bugfix/linker-plugin-lto-wasm, r=petrochenkov 2023-11-28 16:09:55 +01:00
rustc_const_eval rustc: hir().local_def_id_to_hir_id() -> tcx.local_def_id_to_hir_id() cleanup 2023-11-26 12:41:21 +03:00
rustc_data_structures Avoid an unnecessary by_ref. 2023-11-28 14:32:40 +11:00
rustc_driver
rustc_driver_impl Turn write_dep_info into a regular function 2023-11-26 18:02:47 +00:00
rustc_error_codes Yeet E0744 2023-11-28 20:40:38 +00:00
rustc_error_messages Remove rustc_error_messages/messages.ftl. 2023-11-26 08:37:27 +11:00
rustc_errors Use rustc_fluent_macro::fluent_messages! directly. 2023-11-26 08:38:40 +11:00
rustc_expand Use rustc_fluent_macro::fluent_messages! directly. 2023-11-26 08:38:40 +11:00
rustc_feature Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_fluent_macro Add a useful comment. 2023-11-26 08:38:02 +11:00
rustc_fs_util
rustc_graphviz remove unused pub fn 2023-11-23 14:11:02 +03:00
rustc_hir Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_hir_analysis Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_hir_pretty Add never_patterns feature gate 2023-11-29 03:58:29 +01:00
rustc_hir_typeck Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_incremental Auto merge of #117301 - saethlin:finish-rmeta-encoding, r=WaffleLapkin 2023-11-26 14:43:02 +00:00
rustc_index Replace no_ord_impl with orderable. 2023-11-22 18:38:17 +11:00
rustc_index_macros Put backticks around some attributes in doc comments. 2023-11-27 09:37:01 +11:00
rustc_infer Rollup merge of #118269 - compiler-errors:poly, r=wesleywiser 2023-11-29 04:23:22 +01:00
rustc_interface resolve: Feed the def_kind query immediately on DefId creation 2023-11-28 15:39:31 +03:00
rustc_lexer
rustc_lint Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_lint_defs Remove --check-cfg checking of --cfg args 2023-11-18 12:21:58 +01:00
rustc_llvm Auto merge of #117947 - Dirbaio:drop-llvm-15, r=cuviper 2023-11-27 21:54:03 +00:00
rustc_log
rustc_macros Unify HashStable implementations 2023-11-21 05:49:45 +00:00
rustc_metadata Auto merge of #118319 - GuillaumeGomez:rollup-vte50yq, r=GuillaumeGomez 2023-11-26 16:42:32 +00:00
rustc_middle Rollup merge of #118333 - eduardosm:print-missing-target-features, r=est31 2023-11-29 12:34:50 +01:00
rustc_mir_build Rollup merge of #118333 - eduardosm:print-missing-target-features, r=est31 2023-11-29 12:34:50 +01:00
rustc_mir_dataflow Rollup merge of #118288 - compiler-errors:is_some_and, r=lqd,dtolnay 2023-11-25 17:23:34 -05:00
rustc_mir_transform Rollup merge of #118426 - aDotInTheVoid:const-wat, r=compiler-errors,cjgillot 2023-11-29 12:34:50 +01:00
rustc_monomorphize merge DefKind::Coroutine into DefKind::Closure 2023-11-26 21:05:08 +08:00
rustc_parse Rollup merge of #118191 - estebank:let-chain-typo, r=compiler-errors 2023-11-29 12:34:48 +01:00
rustc_parse_format
rustc_passes Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_privacy Rollup merge of #118311 - bvanjoi:merge_coroutinue_into_closure, r=petrochenkov 2023-11-26 15:44:54 +01:00
rustc_query_impl QueryContext: rename try_collect_active_jobs -> collect_active_jobs and change it's return type from Option<QueryMap> to QueryMap 2023-11-27 18:13:15 +03:00
rustc_query_system Auto merge of #118348 - Mark-Simulacrum:feature-code-size, r=compiler-errors 2023-11-29 02:45:36 +00:00
rustc_resolve Rollup merge of #118342 - compiler-errors:macro-generic-bang, r=estebank 2023-11-29 04:23:28 +01:00
rustc_serialize Call FileEncoder::finish in rmeta encoding 2023-11-22 22:49:22 -05:00
rustc_session Serialize OutputFilenames into rmeta file 2023-11-26 18:02:42 +00:00
rustc_smir Rollup merge of #118172 - ouz-a:improve_emit_stable1, r=celinval 2023-11-27 19:06:47 -05:00
rustc_span Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
rustc_symbol_mangling merge DefKind::Coroutine into DefKind::Closure 2023-11-26 21:05:08 +08:00
rustc_target Auto merge of #117947 - Dirbaio:drop-llvm-15, r=cuviper 2023-11-27 21:54:03 +00:00
rustc_trait_selection Auto merge of #117200 - rmehri01:repeated_help, r=WaffleLapkin 2023-11-27 19:37:35 +00:00
rustc_traits Auto merge of #118120 - compiler-errors:closure-kind, r=lcnr 2023-11-22 21:09:01 +00:00
rustc_transmute Update itertools to 0.11. 2023-11-22 08:13:21 +11:00
rustc_ty_utils resolve: Feed the def_kind query immediately on DefId creation 2023-11-28 15:39:31 +03:00
rustc_type_ir Auto merge of #118120 - compiler-errors:closure-kind, r=lcnr 2023-11-22 21:09:01 +00:00
stable_mir Rollup merge of #118172 - ouz-a:improve_emit_stable1, r=celinval 2023-11-27 19:06:47 -05:00