rust/compiler
Matthias Krüger f9f97b661a
Rollup merge of #94305 - JakobDegen:dp-1, r=oli-obk
Remove an unnecessary restriction in `dest_prop`

I had asked about this [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Do.20unions.20have.20active.20fields.3F) but didn't receive a response, so putting up this PR that makes the change I think we can. If it turns out that this is wrong, hopefully I'll find out here. Reposting my Zulip comment:
> Not sure what channel to put this into, so using this as a fallback. The dest prop MIR opt has this comment:
>
> ```rust
> //!   Subtle case: If `dest` is a, or projects through a union, then we have to make sure that there
> //!   remains an assignment to it, since that sets the "active field" of the union. But if `src` is
> //!   a ZST, it might not be initialized, so there might not be any use of it before the assignment,
> //!   and performing the optimization would simply delete the assignment, leaving `dest`
> //!   uninitialized.
> ```
>
> In particular, the claim seems to be that we can't take
> ```
> x = ();
> y.field = x;
> ```
> where `y` is a union having `field: ()` as one of its variants, and optimize the entire thing away (assuming `x` is unused otherwise). As far as I know though, Rust unions don't have active fields. Is this comment correct and am I missing something? Is there a worry about this interacting poorly with FFI code/C unions/LTO or something?

This PR just removes that comment and the associated code. Also it fixes one unrelated comment that did not match the code it was commenting on.

r? rust-lang/mir-opt
2022-02-25 14:14:38 +01:00
..
rustc remove unused jemallocator crate 2022-01-28 16:56:05 +01:00
rustc_apfloat Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
rustc_arena Remove unused dep from rustc_arena 2022-02-02 17:37:14 +01:00
rustc_ast Rollup merge of #94316 - nnethercote:improve-string-literal-unescaping, r=petrochenkov 2022-02-24 21:42:18 +01:00
rustc_ast_lowering Remove in-band lifetimes 2022-02-24 18:50:33 -08:00
rustc_ast_passes Rollup merge of #94146 - est31:let_else, r=cjgillot 2022-02-20 00:37:34 +01:00
rustc_ast_pretty Pretty print ItemKind::Use in rustfmt style 2022-02-07 21:51:05 -08:00
rustc_attr Rollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkov 2022-02-24 21:42:13 +01:00
rustc_borrowck Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebank 2022-02-25 00:46:04 +00:00
rustc_builtin_macros Rollup merge of #92714 - yanganto:ignore-message, r=Mark-Simulacrum 2022-02-25 07:30:47 +01:00
rustc_codegen_cranelift Normalize main return type during mono item collection & codegen 2022-02-23 22:33:50 +01:00
rustc_codegen_gcc Auto merge of #94123 - bjorn3:cg_ssa_singleton_builder, r=tmiasko 2022-02-24 12:28:19 +00:00
rustc_codegen_llvm Auto merge of #94130 - erikdesjardins:partially, r=nikic 2022-02-25 05:44:33 +00:00
rustc_codegen_ssa Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebank 2022-02-25 00:46:04 +00:00
rustc_const_eval Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebank 2022-02-25 00:46:04 +00:00
rustc_data_structures Rollup merge of #94288 - Mark-Simulacrum:ser-opt, r=nnethercote 2022-02-24 07:48:09 +01:00
rustc_driver Rollup merge of #94146 - est31:let_else, r=cjgillot 2022-02-20 00:37:34 +01:00
rustc_error_codes Remove in-band lifetimes 2022-02-24 18:50:33 -08:00
rustc_errors Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebank 2022-02-25 00:46:04 +00:00
rustc_expand Rollup merge of #92714 - yanganto:ignore-message, r=Mark-Simulacrum 2022-02-25 07:30:47 +01:00
rustc_feature Remove in-band lifetimes 2022-02-24 18:50:33 -08:00
rustc_fs_util Migrate to 2021 2021-09-20 22:21:42 -04:00
rustc_graphviz eplace usages of vec![].into_iter with [].into_iter 2022-01-09 14:09:25 +11:00
rustc_hir Remove in-band lifetimes 2022-02-24 18:50:33 -08:00
rustc_hir_pretty resolve: Fix incorrect results of opt_def_kind query for some built-in macros 2022-02-24 22:54:36 +03:00
rustc_incremental Adopt let else in more places 2022-02-19 17:27:43 +01:00
rustc_index Fix test 2022-02-24 16:02:07 -05:00
rustc_infer Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillot 2022-02-25 14:14:35 +01:00
rustc_interface Auto merge of #94130 - erikdesjardins:partially, r=nikic 2022-02-25 05:44:33 +00:00
rustc_lexer Improve scan_escape. 2022-02-24 17:01:01 +11:00
rustc_lint Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebank 2022-02-25 00:46:04 +00:00
rustc_lint_defs Improve diagnostic of the unexpected_cfgs lint 2022-02-22 23:17:13 +01:00
rustc_llvm Rollup merge of #91675 - ivanloz:memtagsan, r=nagisa 2022-02-18 23:23:03 +01:00
rustc_log Make rustc_log doc test runnable 2022-01-03 22:31:56 -08:00
rustc_macros Auto merge of #93878 - Aaron1011:newtype-macro, r=cjgillot 2022-02-25 03:16:22 +00:00
rustc_metadata Rollup merge of #94252 - lcnr:def_kind-encoding, r=cjgillot 2022-02-25 14:14:37 +01:00
rustc_middle Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillot 2022-02-25 14:14:35 +01:00
rustc_mir_build rustc_errors: let DiagnosticBuilder::emit return a "guarantee of emission". 2022-02-23 06:38:52 +00:00
rustc_mir_dataflow Auto merge of #93984 - nnethercote:ChunkedBitSet, r=Mark-Simulacrum 2022-02-23 01:26:07 +00:00
rustc_mir_transform Rollup merge of #94305 - JakobDegen:dp-1, r=oli-obk 2022-02-25 14:14:38 +01:00
rustc_monomorphize Normalize main return type during mono item collection & codegen 2022-02-23 22:33:50 +01:00
rustc_parse rustc_errors: let DiagnosticBuilder::emit return a "guarantee of emission". 2022-02-23 06:38:52 +00:00
rustc_parse_format Correctly mark the span of captured arguments in format_args!() 2022-02-16 07:34:06 +00:00
rustc_passes Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebank 2022-02-25 00:46:04 +00:00
rustc_plugin_impl replace dynamic library module with libloading 2021-12-06 12:03:47 -05:00
rustc_privacy resolve: Fix incorrect results of opt_def_kind query for some built-in macros 2022-02-24 22:54:36 +03:00
rustc_query_impl Auto merge of #94066 - Mark-Simulacrum:factor-out-simple-def-kind, r=davidtwco 2022-02-21 03:36:55 +00:00
rustc_query_system rustc_errors: let DiagnosticBuilder::emit return a "guarantee of emission". 2022-02-23 06:38:52 +00:00
rustc_resolve Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillot 2022-02-25 14:14:35 +01:00
rustc_save_analysis resolve: Fix incorrect results of opt_def_kind query for some built-in macros 2022-02-24 22:54:36 +03:00
rustc_serialize Delete Decoder::read_unit 2022-02-22 18:14:51 -05:00
rustc_session Auto merge of #94130 - erikdesjardins:partially, r=nikic 2022-02-25 05:44:33 +00:00
rustc_span Rollup merge of #94169 - Amanieu:asm_stuff, r=nagisa 2022-02-22 12:16:28 +01:00
rustc_symbol_mangling Rename region_should_not_be_omitted to should_print_region 2022-02-23 08:58:36 +01:00
rustc_target riscv32imc_esp_espidf: set max_atomic_width to 64 2022-02-23 13:11:26 +00:00
rustc_trait_selection Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebank 2022-02-25 00:46:04 +00:00
rustc_traits use List<Ty<'tcx>> for tuples 2022-02-21 07:09:11 +01:00
rustc_ty_utils use List<Ty<'tcx>> for tuples 2022-02-21 07:09:11 +01:00
rustc_type_ir Inline UnifyKey::index and UnifyKey::from_index 2022-02-15 19:07:06 +01:00
rustc_typeck Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillot 2022-02-25 14:14:35 +01:00