rust/compiler
bors 8824d13161 Auto merge of #98831 - RalfJung:no-more-unsized-locals, r=oli-obk
interpret: remove support for unsized_locals

I added support for unsized_locals in https://github.com/rust-lang/rust/pull/59780 but the current implementation is a crude hack and IMO definitely not the right way to have unsized locals in MIR. It also [causes problems](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Missing.20Layout.20Check.20in.20.60interpret.2Foperand.2Ers.60.3F). and what codegen does is unsound and has been for years since clearly nobody cares (so I hope nobody actually relies on that implementation and I'll be happy if Miri ensures they do not). I think if we want to have unsized locals in Miri/MIR we should add them properly, either by having a `StorageLive` that takes metadata or by having an `alloca` that returns a pointer (making the ptr indirection explicit) or something like that.

So, this PR removes the `LocalValue::Unallocated` hack. It adds `Immediate::Uninit`, for several reasons:
- This lets us still do fairly little work in `push_stack_frame`, in particular we do not actually have to create any allocations.
- If/when I remove `ScalarMaybeUninit`, we will need something like this to have an "optimized" representation of uninitialized locals. Without this we'd have to put uninitialized integers into the heap!
- const-prop needs some way to indicate "I don't know the value of this local'; it used to use `LocalValue::Unallocated` for that, now it can use `Immediate::Uninit`.

There is still a fundamental difference between `LocalValue::Unallocated` and `Immediate::Uninit`: the latter is considered a regular local that you can read from and write to, it just has a more optimized representation when compared with an actual `Allocation` that is fully uninit. In contrast, `LocalValue::Unallocated`  had this really odd behavior where you would write to it but not read from it. (This is in fact what caused the problems mentioned above.)

While at it I also did two drive-by cleanups/improvements:
- In `pop_stack_frame`, do the return value copying and local deallocation while the frame is still on the stack. This leads to better error locations being reported. The old errors were [sometimes rather confusing](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Cron.20Job.20Failure.202022-06-24/near/287445522).
- Deduplicate `copy_op` and `copy_op_transmute`.

r? `@oli-obk`
2022-07-06 22:50:29 +00:00
..
rustc Rollup merge of #97385 - oli-obk:smir-tool-lib, r=pnkfelix 2022-06-14 07:47:24 +09:00
rustc_apfloat Update smallvec to 1.8.1. 2022-06-27 08:48:55 +10:00
rustc_arena Update smallvec to 1.8.1. 2022-06-27 08:48:55 +10:00
rustc_ast Update smallvec to 1.8.1. 2022-06-27 08:48:55 +10:00
rustc_ast_lowering Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
rustc_ast_passes Auto merge of #97842 - notriddle:notriddle/tuple-docs, r=jsha,GuillaumeGomez 2022-06-16 11:13:30 +00:00
rustc_ast_pretty Fix pretty printing of empty type bound lists in where-clause 2022-06-16 17:24:50 -07:00
rustc_attr Remove rustc_deprecated diagnostics 2022-06-14 19:46:13 -04:00
rustc_borrowck replace guess_head_span with def_span 2022-07-06 19:09:47 +09:00
rustc_builtin_macros Don't use match-destructuring for derived ops on structs. 2022-07-04 10:48:15 +10:00
rustc_codegen_cranelift Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
rustc_codegen_gcc Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
rustc_codegen_llvm Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
rustc_codegen_ssa Rollup merge of #96935 - thomcc:atomicptr-strict-prov, r=dtolnay 2022-07-06 20:43:23 +02:00
rustc_const_eval Auto merge of #98831 - RalfJung:no-more-unsized-locals, r=oli-obk 2022-07-06 22:50:29 +00:00
rustc_data_structures Auto merge of #98558 - nnethercote:smallvec-1.8.1, r=lqd 2022-06-29 09:11:29 +00:00
rustc_driver Fix bug in rustdoc -Whelp 2022-07-02 02:11:49 -05:00
rustc_error_codes Rollup merge of #97423 - m-ou-se:memory-ordering-intrinsics, r=tmiasko 2022-06-29 10:28:18 +05:30
rustc_error_messages lint: port asm labels diagnostics 2022-06-30 08:59:22 +01:00
rustc_errors errors: introduce DecorateLint 2022-07-05 16:00:20 +01:00
rustc_expand Auto merge of #98446 - nnethercote:derive-no-match-destructuring, r=scottmcm 2022-07-04 01:06:54 +00:00
rustc_feature Move/rename lazy::Sync{OnceCell,Lazy} to sync::{Once,Lazy}Lock 2022-06-16 19:54:42 +04:00
rustc_fs_util
rustc_graphviz Fully stabilize NLL 2022-06-03 17:16:41 -04:00
rustc_hir Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
rustc_hir_pretty clean up the borrowing in rustc_hir_pretty 2022-07-03 18:51:14 +02:00
rustc_incremental Auto merge of #98153 - nnethercote:fix-MissingDoc-quadratic-behaviour, r=cjgillot 2022-06-18 09:57:00 +00:00
rustc_index Update smallvec to 1.8.1. 2022-06-27 08:48:55 +10:00
rustc_infer replace guess_head_span with def_span 2022-07-06 19:09:47 +09:00
rustc_interface Auto merge of #98570 - SparrowLii:deadlock, r=cjgillot 2022-07-03 02:05:14 +00:00
rustc_lexer fix typo in comment 2022-06-28 19:59:09 +05:30
rustc_lint Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, r=cjgillot 2022-07-06 20:43:24 +02:00
rustc_lint_defs Auto merge of #97235 - nbdd0121:unwind, r=Amanieu 2022-07-02 14:06:27 +00:00
rustc_llvm llvm-wrapper: adapt for LLVMConstExtractValue removal 2022-06-30 12:47:34 +00:00
rustc_log clippy::complexity fixes 2022-05-26 13:14:24 +02:00
rustc_macros Rollup merge of #98884 - davidtwco:translation-on-lints-derive, r=oli-obk 2022-07-06 14:49:10 +05:30
rustc_metadata Auto merge of #97235 - nbdd0121:unwind, r=Amanieu 2022-07-02 14:06:27 +00:00
rustc_middle Auto merge of #98987 - GuillaumeGomez:rollup-bcy32bp, r=GuillaumeGomez 2022-07-06 20:09:41 +00:00
rustc_mir_build Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
rustc_mir_dataflow Rollup merge of #98944 - pierwill:flatset-docs, r=Dylan-DPC 2022-07-05 23:43:33 +02:00
rustc_mir_transform fix a strange ConstProp ICE 2022-07-06 14:11:44 -04:00
rustc_monomorphize Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
rustc_parse Auto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum 2022-07-03 06:55:50 +00:00
rustc_parse_format Make rustc_parse_format compile on stable 2022-05-03 11:26:58 +02:00
rustc_passes Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errors 2022-07-05 16:04:32 +05:30
rustc_plugin_impl remove currently unused deps 2022-06-13 22:20:51 +03:00
rustc_privacy Rollup merge of #98881 - cjgillot:q-def-kind, r=fee1-dead 2022-07-06 14:49:08 +05:30
rustc_query_impl Rollup merge of #98881 - cjgillot:q-def-kind, r=fee1-dead 2022-07-06 14:49:08 +05:30
rustc_query_system Auto merge of #98570 - SparrowLii:deadlock, r=cjgillot 2022-07-03 02:05:14 +00:00
rustc_resolve Auto merge of #98959 - cjgillot:late-bound-order, r=michaelwoerister 2022-07-06 17:38:48 +00:00
rustc_save_analysis Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
rustc_serialize Update smallvec to 1.8.1. 2022-06-27 08:48:55 +10:00
rustc_session incr.comp.: Make split-dwarf commandline options [TRACKED]. 2022-07-04 14:11:28 +02:00
rustc_smir Rustfmt 2022-06-02 10:29:00 +00:00
rustc_span errors: introduce DecorateLint 2022-07-05 16:00:20 +01:00
rustc_symbol_mangling Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
rustc_target rustc_target: Some more tests and fixes for linker arguments 2022-06-25 21:57:08 +03:00
rustc_trait_selection Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, r=cjgillot 2022-07-06 20:43:24 +02:00
rustc_traits Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
rustc_ty_utils Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
rustc_type_ir more rustc_pass_by_value 2022-07-04 09:40:58 +02:00
rustc_typeck replace guess_head_span with def_span 2022-07-06 19:09:47 +09:00