rust/compiler
Dylan DPC f7d8f5b1e1
Rollup merge of #96162 - RalfJung:mark-uninit, r=oli-obk
interpret: Fix writing uninit to an allocation

When calling `mark_init`, we need to also be mindful of what happens with the relocations! Specifically, when we de-init memory, we need to clear relocations in that range as well or else strange things will happen (and printing will not show the de-init, since relocations take precedence there).

Fixes https://github.com/rust-lang/miri/issues/2068.

Here's the Miri testcase that this fixes (requires `-Zmiri-disable-validation`):
```rust
use std::mem::MaybeUninit;

fn main() { unsafe {
    let mut x = MaybeUninit::<i64>::uninit();
    // Put in a ptr.
    x.as_mut_ptr().cast::<&i32>().write_unaligned(&0);
    // Overwrite parts of that pointer with 'uninit' through a Scalar.
    let ptr = x.as_mut_ptr().cast::<i32>();
    *ptr = MaybeUninit::uninit().assume_init();
    // Reading this back should hence work fine.
    let _c = *ptr;
} }
```
Previously this failed with
```
error: unsupported operation: unable to turn pointer into raw bytes
  --> ../miri/uninit.rs:11:14
   |
11 |     let _c = *ptr;
   |              ^^^^ unable to turn pointer into raw bytes
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support

   = note: inside `main` at ../miri/uninit.rs:11:14
```
2022-04-19 22:57:42 +02:00
..
rustc Propagate parallel_compiler feature through rustc crates. Turned off feature gives change of builded crates: 238 -> 224. 2022-03-28 08:41:12 +03:00
rustc_apfloat Addressed comments by @compiler-errors and @bjorn3 2022-03-30 17:04:46 -04:00
rustc_arena mark FIXMES for all the places found that are probably offset_from 2022-03-29 20:18:28 -04:00
rustc_ast Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkov 2022-04-17 12:56:19 +00:00
rustc_ast_lowering Lint elided lifetimes in path on the AST. 2022-04-17 11:03:34 +02:00
rustc_ast_passes Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkov 2022-04-17 12:56:19 +00:00
rustc_ast_pretty Rollup merge of #94985 - dtolnay:constattr, r=pnkfelix 2022-04-16 19:42:00 +02:00
rustc_attr Rollup merge of #94948 - jhpratt:rustc_deprecated, r=Dylan-DPC 2022-03-20 09:14:59 +01:00
rustc_borrowck Lint elided lifetimes in path on the AST. 2022-04-17 11:03:34 +02:00
rustc_builtin_macros Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisa 2022-04-16 04:46:01 +00:00
rustc_codegen_cranelift Add new Deinit statement kind 2022-04-11 08:55:03 -04:00
rustc_codegen_gcc Rollup merge of #95740 - Amanieu:kreg0, r=nagisa 2022-04-19 22:57:39 +02:00
rustc_codegen_llvm Rollup merge of #95740 - Amanieu:kreg0, r=nagisa 2022-04-19 22:57:39 +02:00
rustc_codegen_ssa Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov 2022-04-19 14:43:21 +02:00
rustc_const_eval add caution to some comments 2022-04-17 19:32:13 -04:00
rustc_data_structures Auto merge of #95899 - petrochenkov:modchild2, r=cjgillot 2022-04-16 22:04:10 +00:00
rustc_driver errors: lazily load fallback fluent bundle 2022-04-13 02:44:59 +01:00
rustc_error_codes rework error messages for incorrect inherent impls 2022-03-30 11:23:58 +02:00
rustc_error_messages Rollup merge of #96029 - IsakNyberg:error-messages-fix, r=Dylan-DPC 2022-04-19 22:57:41 +02:00
rustc_errors Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwco 2022-04-19 14:43:17 +02:00
rustc_expand Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnr 2022-04-16 14:25:56 +02:00
rustc_feature Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwco 2022-04-15 20:50:43 +02:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov 2022-04-19 14:43:21 +02:00
rustc_hir_pretty Reimplement lowering of sym operands for asm! so that it also works with global_asm! 2022-04-14 15:32:03 +01:00
rustc_incremental Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot 2022-04-17 08:06:53 +00:00
rustc_index Spellchecking compiler comments 2022-03-30 15:14:15 -04:00
rustc_infer Auto merge of #96020 - martingms:optimize-relate_substs, r=nnethercote 2022-04-19 10:53:53 +00:00
rustc_interface Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot 2022-04-17 08:06:53 +00:00
rustc_lexer Reduce max hash in raw strings from u16 to u8 2022-03-23 22:13:55 +01:00
rustc_lint Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwco 2022-04-19 14:43:17 +02:00
rustc_lint_defs Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwco 2022-04-19 14:43:17 +02:00
rustc_llvm Add codegen for global_asm! sym operands 2022-04-15 14:36:30 +01:00
rustc_log
rustc_macros couple of clippy::complexity fixes 2022-04-13 22:51:34 +02:00
rustc_metadata Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov 2022-04-19 14:43:21 +02:00
rustc_middle Rollup merge of #96162 - RalfJung:mark-uninit, r=oli-obk 2022-04-19 22:57:42 +02:00
rustc_mir_build Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnr 2022-04-16 14:25:56 +02:00
rustc_mir_dataflow Add new MutatatingUseContexts for deinit and SetDiscriminant 2022-04-11 09:26:26 -04:00
rustc_mir_transform couple of clippy::complexity fixes 2022-04-13 22:51:34 +02:00
rustc_monomorphize Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov 2022-04-19 14:43:21 +02:00
rustc_parse Rollup merge of #95346 - Aaron1011:stablize-const-extern-fn, r=pnkfelix 2022-04-17 00:07:23 +02:00
rustc_parse_format Spellchecking compiler comments 2022-03-30 15:14:15 -04:00
rustc_passes Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov 2022-04-19 14:43:21 +02:00
rustc_plugin_impl
rustc_privacy do use ty::Const in patterns and abstract consts 2022-04-02 12:20:59 +02:00
rustc_query_impl Stop using CRATE_DEF_INDEX. 2022-04-17 12:14:42 +02:00
rustc_query_system Remove NodeIdHashingMode. 2022-04-12 19:59:32 +02:00
rustc_resolve Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov 2022-04-19 14:43:21 +02:00
rustc_save_analysis remove find_use_placement 2022-03-31 17:20:03 -04:00
rustc_serialize errors: implement fallback diagnostic translation 2022-04-05 07:01:02 +01:00
rustc_session Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwco 2022-04-19 14:43:17 +02:00
rustc_span Rollup merge of #95740 - Amanieu:kreg0, r=nagisa 2022-04-19 22:57:39 +02:00
rustc_symbol_mangling Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot 2022-04-17 08:06:53 +00:00
rustc_target Rollup merge of #95740 - Amanieu:kreg0, r=nagisa 2022-04-19 22:57:39 +02:00
rustc_trait_selection Rollup merge of #94493 - oribenshir:feature/ISSUE-78543_async_fn_in_foreign_crate_diag_2, r=davidtwco 2022-04-19 14:43:15 +02:00
rustc_traits Remove opaque type obligation and just register opaque types as they are encountered. 2022-03-28 16:57:45 +00:00
rustc_ty_utils Avoid accessing HIR from MIR queries. 2022-04-10 13:08:36 +02:00
rustc_type_ir Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk" 2022-03-28 16:27:14 +00:00
rustc_typeck Rollup merge of #96122 - TaKO8Ki:fix-invalid-error-for-suggestion-to-add-slice-in-pattern-matching, r=nagisa 2022-04-19 14:43:20 +02:00