]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #70913 - eddyb:rc-arc-diagnostic-items, r=matthewjasper
authorMazdak Farrokhzad <twingoow@gmail.com>
Fri, 10 Apr 2020 10:48:45 +0000 (12:48 +0200)
committerGitHub <noreply@github.com>
Fri, 10 Apr 2020 10:48:45 +0000 (12:48 +0200)
Replace "rc"/"arc" lang items with Rc/Arc diagnostic items.

`Rc`/`Arc` should have no special semantics, so it seems appropriate for them to not be lang items.

r? @matthewjasper

320 files changed:
src/ci/scripts/symlink-build-dir.sh
src/doc/rustc/src/lints/levels.md
src/doc/rustdoc/src/documentation-tests.md
src/liballoc/collections/btree/map.rs
src/liballoc/collections/btree/set.rs
src/liballoc/collections/vec_deque.rs
src/liballoc/slice.rs
src/liballoc/tests/string.rs
src/liballoc/tests/vec.rs
src/liballoc/tests/vec_deque.rs
src/libcore/iter/adapters/chain.rs
src/librustc_ast_lowering/item.rs
src/librustc_ast_lowering/lib.rs
src/librustc_codegen_llvm/callee.rs
src/librustc_codegen_llvm/mono_item.rs
src/librustc_codegen_ssa/back/link.rs
src/librustc_codegen_ssa/back/linker.rs
src/librustc_error_codes/error_codes.rs
src/librustc_error_codes/error_codes/E0507.md
src/librustc_error_codes/error_codes/E0510.md
src/librustc_error_codes/error_codes/E0738.md [deleted file]
src/librustc_hir/definitions.rs
src/librustc_infer/infer/canonical/canonicalizer.rs
src/librustc_infer/infer/resolve.rs
src/librustc_lint/unused.rs
src/librustc_middle/mir/cache.rs
src/librustc_middle/ty/context.rs
src/librustc_middle/ty/erase_regions.rs
src/librustc_middle/ty/flags.rs
src/librustc_middle/ty/fold.rs
src/librustc_middle/ty/instance.rs
src/librustc_middle/ty/layout.rs
src/librustc_middle/ty/mod.rs
src/librustc_middle/ty/relate.rs
src/librustc_middle/ty/sty.rs
src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
src/librustc_mir/borrow_check/region_infer/mod.rs
src/librustc_mir/dataflow/impls/storage_liveness.rs
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/lib.rs
src/librustc_mir/transform/generator.rs
src/librustc_mir/util/borrowck_errors.rs
src/librustc_mir/util/mod.rs
src/librustc_mir/util/storage.rs [new file with mode: 0644]
src/librustc_mir_build/build/mod.rs
src/librustc_mir_build/lints.rs
src/librustc_passes/check_attr.rs
src/librustc_passes/region.rs
src/librustc_privacy/lib.rs
src/librustc_query_system/dep_graph/graph.rs
src/librustc_query_system/query/plumbing.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/late.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/macros.rs
src/librustc_session/config.rs
src/librustc_trait_selection/infer.rs
src/librustc_trait_selection/traits/mod.rs
src/librustc_trait_selection/traits/select.rs
src/librustc_trait_selection/traits/wf.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/wfcheck.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/lib.rs
src/librustc_typeck/variance/constraints.rs
src/librustdoc/clean/mod.rs
src/librustdoc/clean/types.rs
src/librustdoc/html/render.rs
src/librustdoc/html/sources.rs
src/libstd/os/mod.rs
src/libstd/sys/hermit/ext/ffi.rs [new file with mode: 0644]
src/libstd/sys/hermit/ext/mod.rs [new file with mode: 0644]
src/libstd/sys/hermit/mod.rs
src/libstd/sys/windows/mod.rs
src/libstd/thread/local.rs
src/test/mir-opt/README.md
src/test/mir-opt/address-of.rs
src/test/mir-opt/address-of/rustc.address_of_reborrow.SimplifyCfg-initial.after.mir [new file with mode: 0644]
src/test/mir-opt/address-of/rustc.borrow_and_cast.SimplifyCfg-initial.after.mir [new file with mode: 0644]
src/test/mir-opt/array-index-is-temporary.rs
src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/box_expr.rs
src/test/mir-opt/box_expr/rustc.main.ElaborateDrops.before.mir [new file with mode: 0644]
src/test/mir-opt/byte_slice.rs
src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/combine_array_len.rs
src/test/mir-opt/combine_array_len/32bit/rustc.norm2.InstCombine.diff [new file with mode: 0644]
src/test/mir-opt/combine_array_len/64bit/rustc.norm2.InstCombine.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/aggregate.rs
src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/array_index.rs
src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/boxes.rs
src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/checked_add.rs
src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs
src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/control-flow-simplification.rs
src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir [new file with mode: 0644]
src/test/mir-opt/const_prop/discriminant.rs
src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/indirect.rs
src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/issue-66971.rs
src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/issue-67019.rs
src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/optimizes_into_variable.rs
src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir [new file with mode: 0644]
src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir [new file with mode: 0644]
src/test/mir-opt/const_prop/read_immutable_static.rs
src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/ref_deref.rs
src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/ref_deref_project.rs
src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/reify_fn_ptr.rs
src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/repeat.rs
src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/return_place.rs
src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir [new file with mode: 0644]
src/test/mir-opt/const_prop/slice_len.rs
src/test/mir-opt/const_prop/slice_len/32bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/slice_len/64bit/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/switch_int.rs
src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff [new file with mode: 0644]
src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff [new file with mode: 0644]
src/test/mir-opt/copy_propagation.rs
src/test/mir-opt/copy_propagation/rustc.test.CopyPropagation.diff [new file with mode: 0644]
src/test/mir-opt/copy_propagation_arg.rs
src/test/mir-opt/copy_propagation_arg/rustc.arg_src.CopyPropagation.diff [new file with mode: 0644]
src/test/mir-opt/copy_propagation_arg/rustc.bar.CopyPropagation.diff [new file with mode: 0644]
src/test/mir-opt/copy_propagation_arg/rustc.baz.CopyPropagation.diff [new file with mode: 0644]
src/test/mir-opt/copy_propagation_arg/rustc.foo.CopyPropagation.diff [new file with mode: 0644]
src/test/mir-opt/deaggregator_test.rs
src/test/mir-opt/deaggregator_test/rustc.bar.Deaggregator.diff [new file with mode: 0644]
src/test/mir-opt/deaggregator_test_enum.rs
src/test/mir-opt/deaggregator_test_enum/rustc.bar.Deaggregator.diff [new file with mode: 0644]
src/test/mir-opt/deaggregator_test_enum_2.rs
src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff [new file with mode: 0644]
src/test/mir-opt/deaggregator_test_multiple.rs
src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff [new file with mode: 0644]
src/test/mir-opt/exponential-or.rs
src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir [new file with mode: 0644]
src/test/mir-opt/generator-drop-cleanup.rs
src/test/mir-opt/generator-drop-cleanup/rustc.main-{{closure}}.generator_drop.0.mir [new file with mode: 0644]
src/test/mir-opt/generator-storage-dead-unwind.rs
src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir [new file with mode: 0644]
src/test/mir-opt/generator-tiny.rs
src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir [new file with mode: 0644]
src/test/mir-opt/graphviz.rs
src/test/mir-opt/graphviz/rustc.main.mir_map.0.dot [new file with mode: 0644]
src/test/mir-opt/inline/inline-any-operand.rs
src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir [new file with mode: 0644]
src/test/mir-opt/inline/inline-closure-borrows-arg.rs
src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir [new file with mode: 0644]
src/test/mir-opt/inline/inline-closure-captures.rs
src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir [new file with mode: 0644]
src/test/mir-opt/inline/inline-closure.rs
src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir [new file with mode: 0644]
src/test/mir-opt/inline/inline-into-box-place.rs
src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff [new file with mode: 0644]
src/test/mir-opt/inline/inline-retag.rs
src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir [new file with mode: 0644]
src/test/mir-opt/inline/inline-specialization.rs
src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff [new file with mode: 0644]
src/test/mir-opt/inline/inline-trait-method.rs
src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir [new file with mode: 0644]
src/test/mir-opt/inline/inline-trait-method_2.rs
src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir [new file with mode: 0644]
src/test/mir-opt/issue-38669.rs
src/test/mir-opt/issue-38669/rustc.main.SimplifyCfg-initial.after.mir [new file with mode: 0644]
src/test/mir-opt/issue-41110.rs
src/test/mir-opt/issue-41110/rustc.main.ElaborateDrops.after.mir [new file with mode: 0644]
src/test/mir-opt/issue-41110/rustc.test.ElaborateDrops.after.mir [new file with mode: 0644]
src/test/mir-opt/issue-41697.rs
src/test/mir-opt/issue-41697/32bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir [new file with mode: 0644]
src/test/mir-opt/issue-41697/64bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir [new file with mode: 0644]
src/test/mir-opt/issue-41888.rs
src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir [new file with mode: 0644]
src/test/mir-opt/issue-49232.rs
src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/issue-62289.rs
src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir [new file with mode: 0644]
src/test/mir-opt/loop_test.rs
src/test/mir-opt/loop_test/rustc.main.SimplifyCfg-qualify-consts.after.mir [new file with mode: 0644]
src/test/mir-opt/match-arm-scopes.rs
src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir [new file with mode: 0644]
src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir [new file with mode: 0644]
src/test/mir-opt/match_false_edges.rs
src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir [new file with mode: 0644]
src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir [new file with mode: 0644]
src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir [new file with mode: 0644]
src/test/mir-opt/match_test.rs
src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir [new file with mode: 0644]
src/test/mir-opt/nll/named-lifetimes-basic.rs
src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir [new file with mode: 0644]
src/test/mir-opt/nll/region-subtyping-basic.rs
src/test/mir-opt/nll/region-subtyping-basic/32bit/rustc.main.nll.0.mir [new file with mode: 0644]
src/test/mir-opt/nll/region-subtyping-basic/64bit/rustc.main.nll.0.mir [new file with mode: 0644]
src/test/mir-opt/no-drop-for-inactive-variant.rs
src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/no-spurious-drop-after-call.rs
src/test/mir-opt/no-spurious-drop-after-call/rustc.main.ElaborateDrops.before.mir [new file with mode: 0644]
src/test/mir-opt/packed-struct-drop-aligned.rs
src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/remove_fake_borrows.rs
src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff [new file with mode: 0644]
src/test/mir-opt/retag.rs
src/test/mir-opt/retag/rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/retag/rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir [new file with mode: 0644]
src/test/mir-opt/retag/rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/retag/rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/retain-never-const.rs
src/test/mir-opt/retain-never-const/rustc.no_codegen.PreCodegen.after.mir [new file with mode: 0644]
src/test/mir-opt/simple-match.rs
src/test/mir-opt/simple-match/32bit/rustc.match_bool.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/simple-match/64bit/rustc.match_bool.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/simplify-arm-identity.rs
src/test/mir-opt/simplify-arm-identity/rustc.main.SimplifyArmIdentity.diff [new file with mode: 0644]
src/test/mir-opt/simplify-locals-removes-unused-consts.rs
src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff [new file with mode: 0644]
src/test/mir-opt/simplify_cfg.rs
src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-early-opt.diff [new file with mode: 0644]
src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-initial.diff [new file with mode: 0644]
src/test/mir-opt/simplify_if.rs
src/test/mir-opt/simplify_if/rustc.main.SimplifyBranches-after-const-prop.diff [new file with mode: 0644]
src/test/mir-opt/simplify_match.rs
src/test/mir-opt/simplify_match/rustc.main.SimplifyBranches-after-copy-prop.diff [new file with mode: 0644]
src/test/mir-opt/simplify_try.rs
src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff [new file with mode: 0644]
src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir [new file with mode: 0644]
src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir [new file with mode: 0644]
src/test/mir-opt/slice-drop-shim.rs
src/test/mir-opt/slice-drop-shim/32bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir [new file with mode: 0644]
src/test/mir-opt/slice-drop-shim/64bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir [new file with mode: 0644]
src/test/mir-opt/storage_live_dead_in_statics.rs
src/test/mir-opt/storage_live_dead_in_statics/rustc.XXX.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/storage_ranges.rs
src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir [new file with mode: 0644]
src/test/mir-opt/uniform_array_move_out.rs
src/test/mir-opt/uniform_array_move_out/rustc.move_out_by_subslice.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/uniform_array_move_out/rustc.move_out_from_end.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/uninhabited-enum.rs
src/test/mir-opt/uninhabited-enum/rustc.process_never.SimplifyLocals.after.mir [new file with mode: 0644]
src/test/mir-opt/uninhabited-enum/rustc.process_void.SimplifyLocals.after.mir [new file with mode: 0644]
src/test/mir-opt/uninhabited_enum_branching.rs
src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir [new file with mode: 0644]
src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff [new file with mode: 0644]
src/test/mir-opt/unreachable.rs
src/test/mir-opt/unreachable/rustc.main.UnreachablePropagation.diff [new file with mode: 0644]
src/test/mir-opt/unreachable_asm.rs
src/test/mir-opt/unreachable_asm/rustc.main.UnreachablePropagation.diff [new file with mode: 0644]
src/test/mir-opt/unreachable_asm_2.rs
src/test/mir-opt/unreachable_asm_2/rustc.main.UnreachablePropagation.diff [new file with mode: 0644]
src/test/mir-opt/unreachable_diverging.rs
src/test/mir-opt/unreachable_diverging/rustc.main.UnreachablePropagation.diff [new file with mode: 0644]
src/test/mir-opt/unusual-item-types.rs
src/test/mir-opt/unusual-item-types/32bit/rustc.E-V-{{constant}}.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/unusual-item-types/32bit/rustc.Test-X-{{constructor}}.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/unusual-item-types/32bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir [new file with mode: 0644]
src/test/mir-opt/unusual-item-types/32bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/unusual-item-types/64bit/rustc.E-V-{{constant}}.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/unusual-item-types/64bit/rustc.Test-X-{{constructor}}.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/unusual-item-types/64bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir [new file with mode: 0644]
src/test/mir-opt/unusual-item-types/64bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir [new file with mode: 0644]
src/test/mir-opt/while-storage.rs
src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir [new file with mode: 0644]
src/test/rustdoc/auxiliary/external-macro-src.rs [new file with mode: 0644]
src/test/rustdoc/external-macro-src.rs [new file with mode: 0644]
src/test/rustdoc/issue-26606.rs
src/test/rustdoc/thread-local-src.rs [new file with mode: 0644]
src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.rs [new file with mode: 0644]
src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.stderr [new file with mode: 0644]
src/test/ui/async-await/async-borrowck-escaping-block-error.fixed
src/test/ui/async-await/async-borrowck-escaping-block-error.rs
src/test/ui/async-await/async-borrowck-escaping-block-error.stderr
src/test/ui/async-await/async-borrowck-escaping-closure-error.rs
src/test/ui/async-await/issues/issue-69307-nested.rs [new file with mode: 0644]
src/test/ui/async-await/issues/issue-69307.rs [new file with mode: 0644]
src/test/ui/const-generics/issue-61522-array-len-succ.rs [new file with mode: 0644]
src/test/ui/const-generics/issue-61522-array-len-succ.stderr [new file with mode: 0644]
src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs [new file with mode: 0644]
src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr [new file with mode: 0644]
src/test/ui/impl-trait/does-not-live-long-enough.rs
src/test/ui/impl-trait/does-not-live-long-enough.stderr
src/test/ui/issues/issue-29181.rs
src/test/ui/issues/issue-29181.stderr
src/test/ui/lint/lint-unconditional-recursion.rs
src/test/ui/lint/unused_braces.rs
src/test/ui/lint/unused_braces.stderr
src/test/ui/lint/unused_braces_borrow.rs [new file with mode: 0644]
src/test/ui/lint/unused_braces_borrow.stderr [new file with mode: 0644]
src/test/ui/lint/unused_parens_borrow.rs [deleted file]
src/test/ui/lint/unused_parens_borrow.stderr [deleted file]
src/test/ui/privacy/privacy-ns1.stderr
src/test/ui/rfc-2091-track-caller/error-extern-fn.rs [deleted file]
src/test/ui/rfc-2091-track-caller/error-extern-fn.stderr [deleted file]
src/test/ui/rfc-2091-track-caller/error-with-naked.rs
src/test/ui/rfc-2091-track-caller/error-with-naked.stderr
src/test/ui/rfc-2091-track-caller/track-caller-ffi.rs [new file with mode: 0644]
src/test/ui/suggestions/no-extern-crate-in-type.stderr
src/tools/cargo
src/tools/clippy
src/tools/compiletest/src/runtest.rs
src/tools/miri

index c77059c00ac2a583b95b932bf9fe357203c17de9..50178b9c33ed46eb783c2fd788ec92aba1a84bf6 100755 (executable)
@@ -24,4 +24,10 @@ elif isLinux && isGitHubActions; then
     mv "${current_dir}" /mnt/more-space/workspace
     ln -s /mnt/more-space/workspace "${current_dir}"
     cd "${current_dir}"
+
+    # Move the Docker data directory to /mnt
+    sudo systemctl stop docker.service
+    sudo mv /var/lib/docker /mnt/docker
+    sudo ln -s /mnt/docker /var/lib/docker
+    sudo systemctl start docker.service
 fi
index 3cfe2f698f3e01cf9a55afa67d3132d56aad52e1..64cbbbb003585fee465012f1115e831bb775d26c 100644 (file)
@@ -170,7 +170,7 @@ The order of these command line arguments is taken into account. The following a
 $ rustc lib.rs --crate-type=lib -D unused-variables -A unused-variables
 ```
 
-You can make use of this behavior by overriding the level of one specific lint out of a group of lints. The following example denies all the lints in the `unused` group, but explicitly allows the `unused-variables` lint in that group:
+You can make use of this behavior by overriding the level of one specific lint out of a group of lints. The following example denies all the lints in the `unused` group, but explicitly allows the `unused-variables` lint in that group (forbid still trumps everything regardless of ordering):
 
 ```bash
 $ rustc lib.rs --crate-type=lib -D unused -A unused-variables
index 78181156e250f50cbfabf2e9e67ff49b9e230c6e..efadae1c5fb9d078f95828120999800f0084ceea 100644 (file)
@@ -352,9 +352,9 @@ are added.
 /// ```
 ```
 
-`edition2018` tells `rustdoc` that the code sample should be compiled the 2018
-edition of Rust. Similarly, you can specify `edition2015` to compile the code
-with the 2015 edition.
+`edition2018` tells `rustdoc` that the code sample should be compiled using
+the 2018 edition of Rust. Similarly, you can specify `edition2015` to compile
+the code with the 2015 edition.
 
 ## Syntax reference
 
index 70968964f476e1b821631a4c56e237d006998a6f..fc7e91ce47b52e9114cbd076065bcfc6ba32ada3 100644 (file)
@@ -653,11 +653,7 @@ pub fn get_key_value<Q: ?Sized>(&self, k: &Q) -> Option<(&K, &V)>
     /// assert_eq!(map.first_key_value(), Some((&1, &"b")));
     /// ```
     #[unstable(feature = "map_first_last", issue = "62924")]
-    pub fn first_key_value<T: ?Sized>(&self) -> Option<(&K, &V)>
-    where
-        T: Ord,
-        K: Borrow<T>,
-    {
+    pub fn first_key_value(&self) -> Option<(&K, &V)> {
         let front = self.root.as_ref()?.as_ref().first_leaf_edge();
         front.right_kv().ok().map(Handle::into_kv)
     }
@@ -667,8 +663,6 @@ pub fn first_key_value<T: ?Sized>(&self) -> Option<(&K, &V)>
     ///
     /// # Examples
     ///
-    /// Contrived way to `clear` a map:
-    ///
     /// ```
     /// #![feature(map_first_last)]
     /// use std::collections::BTreeMap;
@@ -676,27 +670,47 @@ pub fn first_key_value<T: ?Sized>(&self) -> Option<(&K, &V)>
     /// let mut map = BTreeMap::new();
     /// map.insert(1, "a");
     /// map.insert(2, "b");
-    /// while let Some(entry) = map.first_entry() {
-    ///     let (key, val) = entry.remove_entry();
-    ///     assert!(!map.contains_key(&key));
+    /// if let Some(mut entry) = map.first_entry() {
+    ///     if *entry.key() > 0 {
+    ///         entry.insert("first");
+    ///     }
     /// }
+    /// assert_eq!(*map.get(&1).unwrap(), "first");
+    /// assert_eq!(*map.get(&2).unwrap(), "b");
     /// ```
     #[unstable(feature = "map_first_last", issue = "62924")]
-    pub fn first_entry<T: ?Sized>(&mut self) -> Option<OccupiedEntry<'_, K, V>>
-    where
-        T: Ord,
-        K: Borrow<T>,
-    {
+    pub fn first_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> {
         let front = self.root.as_mut()?.as_mut().first_leaf_edge();
-        if let Ok(kv) = front.right_kv() {
-            Some(OccupiedEntry {
-                handle: kv.forget_node_type(),
-                length: &mut self.length,
-                _marker: PhantomData,
-            })
-        } else {
-            None
-        }
+        let kv = front.right_kv().ok()?;
+        Some(OccupiedEntry {
+            handle: kv.forget_node_type(),
+            length: &mut self.length,
+            _marker: PhantomData,
+        })
+    }
+
+    /// Removes and returns the first element in the map.
+    /// The key of this element is the minimum key that was in the map.
+    ///
+    /// # Examples
+    ///
+    /// Draining elements in ascending order, while keeping a usable map each iteration.
+    ///
+    /// ```
+    /// #![feature(map_first_last)]
+    /// use std::collections::BTreeMap;
+    ///
+    /// let mut map = BTreeMap::new();
+    /// map.insert(1, "a");
+    /// map.insert(2, "b");
+    /// while let Some((key, _val)) = map.pop_first() {
+    ///     assert!(map.iter().all(|(k, _v)| *k > key));
+    /// }
+    /// assert!(map.is_empty());
+    /// ```
+    #[unstable(feature = "map_first_last", issue = "62924")]
+    pub fn pop_first(&mut self) -> Option<(K, V)> {
+        self.first_entry().map(|entry| entry.remove_entry())
     }
 
     /// Returns the last key-value pair in the map.
@@ -716,11 +730,7 @@ pub fn first_entry<T: ?Sized>(&mut self) -> Option<OccupiedEntry<'_, K, V>>
     /// assert_eq!(map.last_key_value(), Some((&2, &"a")));
     /// ```
     #[unstable(feature = "map_first_last", issue = "62924")]
-    pub fn last_key_value<T: ?Sized>(&self) -> Option<(&K, &V)>
-    where
-        T: Ord,
-        K: Borrow<T>,
-    {
+    pub fn last_key_value(&self) -> Option<(&K, &V)> {
         let back = self.root.as_ref()?.as_ref().last_leaf_edge();
         back.left_kv().ok().map(Handle::into_kv)
     }
@@ -730,8 +740,6 @@ pub fn last_key_value<T: ?Sized>(&self) -> Option<(&K, &V)>
     ///
     /// # Examples
     ///
-    /// Contrived way to `clear` a map:
-    ///
     /// ```
     /// #![feature(map_first_last)]
     /// use std::collections::BTreeMap;
@@ -739,27 +747,47 @@ pub fn last_key_value<T: ?Sized>(&self) -> Option<(&K, &V)>
     /// let mut map = BTreeMap::new();
     /// map.insert(1, "a");
     /// map.insert(2, "b");
-    /// while let Some(entry) = map.last_entry() {
-    ///     let (key, val) = entry.remove_entry();
-    ///     assert!(!map.contains_key(&key));
+    /// if let Some(mut entry) = map.last_entry() {
+    ///     if *entry.key() > 0 {
+    ///         entry.insert("last");
+    ///     }
     /// }
+    /// assert_eq!(*map.get(&1).unwrap(), "a");
+    /// assert_eq!(*map.get(&2).unwrap(), "last");
     /// ```
     #[unstable(feature = "map_first_last", issue = "62924")]
-    pub fn last_entry<T: ?Sized>(&mut self) -> Option<OccupiedEntry<'_, K, V>>
-    where
-        T: Ord,
-        K: Borrow<T>,
-    {
+    pub fn last_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> {
         let back = self.root.as_mut()?.as_mut().last_leaf_edge();
-        if let Ok(kv) = back.left_kv() {
-            Some(OccupiedEntry {
-                handle: kv.forget_node_type(),
-                length: &mut self.length,
-                _marker: PhantomData,
-            })
-        } else {
-            None
-        }
+        let kv = back.left_kv().ok()?;
+        Some(OccupiedEntry {
+            handle: kv.forget_node_type(),
+            length: &mut self.length,
+            _marker: PhantomData,
+        })
+    }
+
+    /// Removes and returns the last element in the map.
+    /// The key of this element is the maximum key that was in the map.
+    ///
+    /// # Examples
+    ///
+    /// Draining elements in descending order, while keeping a usable map each iteration.
+    ///
+    /// ```
+    /// #![feature(map_first_last)]
+    /// use std::collections::BTreeMap;
+    ///
+    /// let mut map = BTreeMap::new();
+    /// map.insert(1, "a");
+    /// map.insert(2, "b");
+    /// while let Some((key, _val)) = map.pop_last() {
+    ///     assert!(map.iter().all(|(k, _v)| *k < key));
+    /// }
+    /// assert!(map.is_empty());
+    /// ```
+    #[unstable(feature = "map_first_last", issue = "62924")]
+    pub fn pop_last(&mut self) -> Option<(K, V)> {
+        self.last_entry().map(|entry| entry.remove_entry())
     }
 
     /// Returns `true` if the map contains a value for the specified key.
@@ -1699,28 +1727,22 @@ fn clone(&self) -> Self {
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
 pub struct DrainFilter<'a, K, V, F>
 where
-    K: 'a + Ord, // This Ord bound should be removed before stabilization.
+    K: 'a,
     V: 'a,
     F: 'a + FnMut(&K, &mut V) -> bool,
 {
     pred: F,
     inner: DrainFilterInner<'a, K, V>,
 }
-pub(super) struct DrainFilterInner<'a, K, V>
-where
-    K: 'a + Ord,
-    V: 'a,
-{
+pub(super) struct DrainFilterInner<'a, K: 'a, V: 'a> {
     length: &'a mut usize,
     cur_leaf_edge: Option<Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>>,
 }
 
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
-impl<'a, K, V, F> Drop for DrainFilter<'a, K, V, F>
+impl<K, V, F> Drop for DrainFilter<'_, K, V, F>
 where
-    K: 'a + Ord,
-    V: 'a,
-    F: 'a + FnMut(&K, &mut V) -> bool,
+    F: FnMut(&K, &mut V) -> bool,
 {
     fn drop(&mut self) {
         self.for_each(drop);
@@ -1728,11 +1750,11 @@ fn drop(&mut self) {
 }
 
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
-impl<'a, K, V, F> fmt::Debug for DrainFilter<'a, K, V, F>
+impl<K, V, F> fmt::Debug for DrainFilter<'_, K, V, F>
 where
-    K: 'a + fmt::Debug + Ord,
-    V: 'a + fmt::Debug,
-    F: 'a + FnMut(&K, &mut V) -> bool,
+    K: fmt::Debug,
+    V: fmt::Debug,
+    F: FnMut(&K, &mut V) -> bool,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_tuple("DrainFilter").field(&self.inner.peek()).finish()
@@ -1740,11 +1762,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 }
 
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
-impl<'a, K, V, F> Iterator for DrainFilter<'a, K, V, F>
+impl<K, V, F> Iterator for DrainFilter<'_, K, V, F>
 where
-    K: 'a + Ord,
-    V: 'a,
-    F: 'a + FnMut(&K, &mut V) -> bool,
+    F: FnMut(&K, &mut V) -> bool,
 {
     type Item = (K, V);
 
@@ -1757,11 +1777,7 @@ fn size_hint(&self) -> (usize, Option<usize>) {
     }
 }
 
-impl<'a, K, V> DrainFilterInner<'a, K, V>
-where
-    K: 'a + Ord,
-    V: 'a,
-{
+impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> {
     /// Allow Debug implementations to predict the next element.
     pub(super) fn peek(&self) -> Option<(&K, &V)> {
         let edge = self.cur_leaf_edge.as_ref()?;
@@ -1800,12 +1816,7 @@ pub(super) fn size_hint(&self) -> (usize, Option<usize>) {
 }
 
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
-impl<K, V, F> FusedIterator for DrainFilter<'_, K, V, F>
-where
-    K: Ord,
-    F: FnMut(&K, &mut V) -> bool,
-{
-}
+impl<K, V, F> FusedIterator for DrainFilter<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool {}
 
 #[stable(feature = "btree_range", since = "1.17.0")]
 impl<'a, K, V> Iterator for Range<'a, K, V> {
index 0b02223def4f85dc76c4b894e2cd5c94d222f69a..9bf483f269f6e6785913dd199619def693dc69e6 100644 (file)
@@ -1094,7 +1094,7 @@ fn into_iter(self) -> Iter<'a, T> {
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
 pub struct DrainFilter<'a, T, F>
 where
-    T: 'a + Ord,
+    T: 'a,
     F: 'a + FnMut(&T) -> bool,
 {
     pred: F,
@@ -1102,10 +1102,9 @@ pub struct DrainFilter<'a, T, F>
 }
 
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
-impl<'a, T, F> Drop for DrainFilter<'a, T, F>
+impl<T, F> Drop for DrainFilter<'_, T, F>
 where
-    T: 'a + Ord,
-    F: 'a + FnMut(&T) -> bool,
+    F: FnMut(&T) -> bool,
 {
     fn drop(&mut self) {
         self.for_each(drop);
@@ -1113,10 +1112,10 @@ fn drop(&mut self) {
 }
 
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
-impl<'a, T, F> fmt::Debug for DrainFilter<'a, T, F>
+impl<T, F> fmt::Debug for DrainFilter<'_, T, F>
 where
-    T: 'a + Ord + fmt::Debug,
-    F: 'a + FnMut(&T) -> bool,
+    T: fmt::Debug,
+    F: FnMut(&T) -> bool,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_tuple("DrainFilter").field(&self.inner.peek().map(|(k, _)| k)).finish()
@@ -1124,10 +1123,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 }
 
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
-impl<'a, 'f, T, F> Iterator for DrainFilter<'a, T, F>
+impl<'a, T, F> Iterator for DrainFilter<'_, T, F>
 where
-    T: 'a + Ord,
-    F: 'a + 'f + FnMut(&T) -> bool,
+    F: 'a + FnMut(&T) -> bool,
 {
     type Item = T;
 
@@ -1143,12 +1141,7 @@ fn size_hint(&self) -> (usize, Option<usize>) {
 }
 
 #[unstable(feature = "btree_drain_filter", issue = "70530")]
-impl<'a, T, F> FusedIterator for DrainFilter<'a, T, F>
-where
-    T: 'a + Ord,
-    F: 'a + FnMut(&T) -> bool,
-{
-}
+impl<T, F> FusedIterator for DrainFilter<'_, T, F> where F: FnMut(&T) -> bool {}
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Ord> Extend<T> for BTreeSet<T> {
index c17a37c7bae12f0fa268f2a2afe3a32692955ded..0ed9773630e24b8716f56dc62ca9e67113131865 100644 (file)
@@ -2104,7 +2104,7 @@ pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut() -> T) {
     ///     assert_eq!(slice, &[3, 2, 1] as &[_]);
     /// }
     /// ```
-    #[unstable(feature = "deque_make_contiguous", issue = "none")]
+    #[unstable(feature = "deque_make_contiguous", issue = "70929")]
     pub fn make_contiguous(&mut self) -> &mut [T] {
         if self.is_contiguous() {
             let tail = self.tail;
index cd750d2558035f8ace5078b10cb5f10f70d6dfc0..4ae7532d992b9b18098bd4d1176f3bd58395b73e 100644 (file)
@@ -140,6 +140,7 @@ mod hack {
     use crate::string::ToString;
     use crate::vec::Vec;
 
+    #[inline]
     pub fn into_vec<T>(b: Box<[T]>) -> Vec<T> {
         unsafe {
             let len = b.len();
index 6e2a5abe90d7006dc1ba93bf9fd579293f0c2ab1..9ea020d2d19f4a6349b3b21920e1e3a2b341f3e5 100644 (file)
@@ -555,6 +555,7 @@ fn test_reserve_exact() {
 
 #[test]
 #[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
+#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
 fn test_try_reserve() {
     // These are the interesting cases:
     // * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
@@ -644,6 +645,7 @@ fn test_try_reserve() {
 
 #[test]
 #[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
+#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
 fn test_try_reserve_exact() {
     // This is exactly the same as test_try_reserve with the method changed.
     // See that test for comments.
index b63d81796f9d2eb7b46f9889cb106927efedd41d..3d76324f7e880767f0a7be6aef82303d7d6c12a5 100644 (file)
@@ -1137,6 +1137,7 @@ fn test_reserve_exact() {
 
 #[test]
 #[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
+#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
 fn test_try_reserve() {
     // These are the interesting cases:
     // * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
@@ -1254,6 +1255,7 @@ fn test_try_reserve() {
 
 #[test]
 #[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
+#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
 fn test_try_reserve_exact() {
     // This is exactly the same as test_try_reserve with the method changed.
     // See that test for comments.
index c287d56fa5353dceab5f32b09355f51c23c817c6..c4b6a36bb05412234a5c5aaf8cb0558b3277a68e 100644 (file)
@@ -1134,6 +1134,7 @@ fn test_reserve_exact_2() {
 
 #[test]
 #[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
+#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
 fn test_try_reserve() {
     // These are the interesting cases:
     // * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
@@ -1248,6 +1249,7 @@ fn test_try_reserve() {
 
 #[test]
 #[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
+#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
 fn test_try_reserve_exact() {
     // This is exactly the same as test_try_reserve with the method changed.
     // See that test for comments.
index 3611a1aadaddba0492cd9a776cbe322310108896..2dd405ced20e1577bdbe77ea7a86927a076b0862 100644 (file)
@@ -1,8 +1,7 @@
+use crate::iter::{DoubleEndedIterator, FusedIterator, Iterator, TrustedLen};
 use crate::ops::Try;
 use crate::usize;
 
-use super::super::{DoubleEndedIterator, FusedIterator, Iterator, TrustedLen};
-
 /// An iterator that links two iterators together, in a chain.
 ///
 /// This `struct` is created by the [`chain`] method on [`Iterator`]. See its
 #[must_use = "iterators are lazy and do nothing unless consumed"]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Chain<A, B> {
-    a: A,
-    b: B,
-    state: ChainState,
+    // These are "fused" with `Option` so we don't need separate state to track which part is
+    // already exhausted, and we may also get niche layout for `None`. We don't use the real `Fuse`
+    // adapter because its specialization for `FusedIterator` unconditionally descends into the
+    // iterator, and that could be expensive to keep revisiting stuff like nested chains. It also
+    // hurts compiler performance to add more iterator layers to `Chain`.
+    a: Option<A>,
+    b: Option<B>,
 }
 impl<A, B> Chain<A, B> {
     pub(in super::super) fn new(a: A, b: B) -> Chain<A, B> {
-        Chain { a, b, state: ChainState::Both }
+        Chain { a: Some(a), b: Some(b) }
     }
 }
 
-// The iterator protocol specifies that iteration ends with the return value
-// `None` from `.next()` (or `.next_back()`) and it is unspecified what
-// further calls return. The chain adaptor must account for this since it uses
-// two subiterators.
-//
-//  It uses three states:
-//
-//  - Both: `a` and `b` are remaining
-//  - Front: `a` remaining
-//  - Back: `b` remaining
-//
-//  The fourth state (neither iterator is remaining) only occurs after Chain has
-//  returned None once, so we don't need to store this state.
-#[derive(Clone, Debug)]
-enum ChainState {
-    // both front and back iterator are remaining
-    Both,
-    // only front is remaining
-    Front,
-    // only back is remaining
-    Back,
+/// Fuse the iterator if the expression is `None`.
+macro_rules! fuse {
+    ($self:ident . $iter:ident . $($call:tt)+) => {
+        match $self.$iter {
+            Some(ref mut iter) => match iter.$($call)+ {
+                None => {
+                    $self.$iter = None;
+                    None
+                }
+                item => item,
+            },
+            None => None,
+        }
+    };
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -57,88 +53,68 @@ impl<A, B> Iterator for Chain<A, B>
 
     #[inline]
     fn next(&mut self) -> Option<A::Item> {
-        match self.state {
-            ChainState::Both => match self.a.next() {
-                elt @ Some(..) => elt,
-                None => {
-                    self.state = ChainState::Back;
-                    self.b.next()
-                }
-            },
-            ChainState::Front => self.a.next(),
-            ChainState::Back => self.b.next(),
+        match fuse!(self.a.next()) {
+            None => fuse!(self.b.next()),
+            item => item,
         }
     }
 
     #[inline]
     #[rustc_inherit_overflow_checks]
     fn count(self) -> usize {
-        match self.state {
-            ChainState::Both => self.a.count() + self.b.count(),
-            ChainState::Front => self.a.count(),
-            ChainState::Back => self.b.count(),
-        }
+        let a_count = match self.a {
+            Some(a) => a.count(),
+            None => 0,
+        };
+        let b_count = match self.b {
+            Some(b) => b.count(),
+            None => 0,
+        };
+        a_count + b_count
     }
 
-    fn try_fold<Acc, F, R>(&mut self, init: Acc, mut f: F) -> R
+    fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R
     where
         Self: Sized,
         F: FnMut(Acc, Self::Item) -> R,
         R: Try<Ok = Acc>,
     {
-        let mut accum = init;
-        match self.state {
-            ChainState::Both | ChainState::Front => {
-                accum = self.a.try_fold(accum, &mut f)?;
-                if let ChainState::Both = self.state {
-                    self.state = ChainState::Back;
-                }
-            }
-            _ => {}
+        if let Some(ref mut a) = self.a {
+            acc = a.try_fold(acc, &mut f)?;
+            self.a = None;
         }
-        if let ChainState::Back = self.state {
-            accum = self.b.try_fold(accum, &mut f)?;
+        if let Some(ref mut b) = self.b {
+            acc = b.try_fold(acc, f)?;
+            self.b = None;
         }
-        Try::from_ok(accum)
+        Try::from_ok(acc)
     }
 
-    fn fold<Acc, F>(self, init: Acc, mut f: F) -> Acc
+    fn fold<Acc, F>(self, mut acc: Acc, mut f: F) -> Acc
     where
         F: FnMut(Acc, Self::Item) -> Acc,
     {
-        let mut accum = init;
-        match self.state {
-            ChainState::Both | ChainState::Front => {
-                accum = self.a.fold(accum, &mut f);
-            }
-            _ => {}
+        if let Some(a) = self.a {
+            acc = a.fold(acc, &mut f);
         }
-        match self.state {
-            ChainState::Both | ChainState::Back => {
-                accum = self.b.fold(accum, &mut f);
-            }
-            _ => {}
+        if let Some(b) = self.b {
+            acc = b.fold(acc, f);
         }
-        accum
+        acc
     }
 
     #[inline]
     fn nth(&mut self, mut n: usize) -> Option<A::Item> {
-        match self.state {
-            ChainState::Both | ChainState::Front => {
-                for x in self.a.by_ref() {
-                    if n == 0 {
-                        return Some(x);
-                    }
-                    n -= 1;
-                }
-                if let ChainState::Both = self.state {
-                    self.state = ChainState::Back;
+        if let Some(ref mut a) = self.a {
+            while let Some(x) = a.next() {
+                if n == 0 {
+                    return Some(x);
                 }
+                n -= 1;
             }
-            ChainState::Back => {}
+            self.a = None;
         }
-        if let ChainState::Back = self.state { self.b.nth(n) } else { None }
+        fuse!(self.b.nth(n))
     }
 
     #[inline]
@@ -146,39 +122,32 @@ fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item>
     where
         P: FnMut(&Self::Item) -> bool,
     {
-        match self.state {
-            ChainState::Both => match self.a.find(&mut predicate) {
-                None => {
-                    self.state = ChainState::Back;
-                    self.b.find(predicate)
-                }
-                v => v,
-            },
-            ChainState::Front => self.a.find(predicate),
-            ChainState::Back => self.b.find(predicate),
+        match fuse!(self.a.find(&mut predicate)) {
+            None => fuse!(self.b.find(predicate)),
+            item => item,
         }
     }
 
     #[inline]
     fn last(self) -> Option<A::Item> {
-        match self.state {
-            ChainState::Both => {
-                // Must exhaust a before b.
-                let a_last = self.a.last();
-                let b_last = self.b.last();
-                b_last.or(a_last)
-            }
-            ChainState::Front => self.a.last(),
-            ChainState::Back => self.b.last(),
-        }
+        // Must exhaust a before b.
+        let a_last = match self.a {
+            Some(a) => a.last(),
+            None => None,
+        };
+        let b_last = match self.b {
+            Some(b) => b.last(),
+            None => None,
+        };
+        b_last.or(a_last)
     }
 
     #[inline]
     fn size_hint(&self) -> (usize, Option<usize>) {
-        match self.state {
-            ChainState::Both => {
-                let (a_lower, a_upper) = self.a.size_hint();
-                let (b_lower, b_upper) = self.b.size_hint();
+        match self {
+            Chain { a: Some(a), b: Some(b) } => {
+                let (a_lower, a_upper) = a.size_hint();
+                let (b_lower, b_upper) = b.size_hint();
 
                 let lower = a_lower.saturating_add(b_lower);
 
@@ -189,8 +158,9 @@ fn size_hint(&self) -> (usize, Option<usize>) {
 
                 (lower, upper)
             }
-            ChainState::Front => self.a.size_hint(),
-            ChainState::Back => self.b.size_hint(),
+            Chain { a: Some(a), b: None } => a.size_hint(),
+            Chain { a: None, b: Some(b) } => b.size_hint(),
+            Chain { a: None, b: None } => (0, Some(0)),
         }
     }
 }
@@ -203,82 +173,71 @@ impl<A, B> DoubleEndedIterator for Chain<A, B>
 {
     #[inline]
     fn next_back(&mut self) -> Option<A::Item> {
-        match self.state {
-            ChainState::Both => match self.b.next_back() {
-                elt @ Some(..) => elt,
-                None => {
-                    self.state = ChainState::Front;
-                    self.a.next_back()
-                }
-            },
-            ChainState::Front => self.a.next_back(),
-            ChainState::Back => self.b.next_back(),
+        match fuse!(self.b.next_back()) {
+            None => fuse!(self.a.next_back()),
+            item => item,
         }
     }
 
     #[inline]
     fn nth_back(&mut self, mut n: usize) -> Option<A::Item> {
-        match self.state {
-            ChainState::Both | ChainState::Back => {
-                for x in self.b.by_ref().rev() {
-                    if n == 0 {
-                        return Some(x);
-                    }
-                    n -= 1;
-                }
-                if let ChainState::Both = self.state {
-                    self.state = ChainState::Front;
+        if let Some(ref mut b) = self.b {
+            while let Some(x) = b.next_back() {
+                if n == 0 {
+                    return Some(x);
                 }
+                n -= 1;
             }
-            ChainState::Front => {}
+            self.b = None;
         }
-        if let ChainState::Front = self.state { self.a.nth_back(n) } else { None }
+        fuse!(self.a.nth_back(n))
     }
 
-    fn try_rfold<Acc, F, R>(&mut self, init: Acc, mut f: F) -> R
+    #[inline]
+    fn rfind<P>(&mut self, mut predicate: P) -> Option<Self::Item>
+    where
+        P: FnMut(&Self::Item) -> bool,
+    {
+        match fuse!(self.b.rfind(&mut predicate)) {
+            None => fuse!(self.a.rfind(predicate)),
+            item => item,
+        }
+    }
+
+    fn try_rfold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R
     where
         Self: Sized,
         F: FnMut(Acc, Self::Item) -> R,
         R: Try<Ok = Acc>,
     {
-        let mut accum = init;
-        match self.state {
-            ChainState::Both | ChainState::Back => {
-                accum = self.b.try_rfold(accum, &mut f)?;
-                if let ChainState::Both = self.state {
-                    self.state = ChainState::Front;
-                }
-            }
-            _ => {}
+        if let Some(ref mut b) = self.b {
+            acc = b.try_rfold(acc, &mut f)?;
+            self.b = None;
         }
-        if let ChainState::Front = self.state {
-            accum = self.a.try_rfold(accum, &mut f)?;
+        if let Some(ref mut a) = self.a {
+            acc = a.try_rfold(acc, f)?;
+            self.a = None;
         }
-        Try::from_ok(accum)
+        Try::from_ok(acc)
     }
 
-    fn rfold<Acc, F>(self, init: Acc, mut f: F) -> Acc
+    fn rfold<Acc, F>(self, mut acc: Acc, mut f: F) -> Acc
     where
         F: FnMut(Acc, Self::Item) -> Acc,
     {
-        let mut accum = init;
-        match self.state {
-            ChainState::Both | ChainState::Back => {
-                accum = self.b.rfold(accum, &mut f);
-            }
-            _ => {}
+        if let Some(b) = self.b {
+            acc = b.rfold(acc, &mut f);
         }
-        match self.state {
-            ChainState::Both | ChainState::Front => {
-                accum = self.a.rfold(accum, &mut f);
-            }
-            _ => {}
+        if let Some(a) = self.a {
+            acc = a.rfold(acc, f);
         }
-        accum
+        acc
     }
 }
 
 // Note: *both* must be fused to handle double-ended iterators.
+// Now that we "fuse" both sides, we *could* implement this unconditionally,
+// but we should be cautious about committing to that in the public API.
 #[stable(feature = "fused", since = "1.26.0")]
 impl<A, B> FusedIterator for Chain<A, B>
 where
index 5fe007d6de298d3a1ff3bb0a6910a856c85d2e88..9779954d75944a9ecfb2fd2c53ea90bfb50f38d0 100644 (file)
@@ -259,7 +259,7 @@ fn lower_item_kind(
                 hir::ItemKind::Const(ty, body_id)
             }
             ItemKind::Fn(_, FnSig { ref decl, header }, ref generics, ref body) => {
-                let fn_def_id = self.resolver.definitions().local_def_id(id).expect_local();
+                let fn_def_id = self.resolver.definitions().local_def_id(id);
                 self.with_new_scopes(|this| {
                     this.current_item = Some(ident.span);
 
@@ -346,7 +346,7 @@ fn lower_item_kind(
                 self_ty: ref ty,
                 items: ref impl_items,
             } => {
-                let def_id = self.resolver.definitions().local_def_id(id).expect_local();
+                let def_id = self.resolver.definitions().local_def_id(id);
 
                 // Lower the "impl header" first. This ordering is important
                 // for in-band lifetimes! Consider `'a` here:
@@ -645,7 +645,7 @@ fn rebuild_vis(&mut self, vis: &hir::Visibility<'hir>) -> hir::Visibility<'hir>
     }
 
     fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
-        let def_id = self.resolver.definitions().local_def_id(i.id).expect_local();
+        let def_id = self.resolver.definitions().local_def_id(i.id);
         hir::ForeignItem {
             hir_id: self.lower_node_id(i.id),
             ident: i.ident,
@@ -746,7 +746,7 @@ fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::Stru
     }
 
     fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem<'hir> {
-        let trait_item_def_id = self.resolver.definitions().local_def_id(i.id).expect_local();
+        let trait_item_def_id = self.resolver.definitions().local_def_id(i.id);
 
         let (generics, kind) = match i.kind {
             AssocItemKind::Const(_, ref ty, ref default) => {
@@ -811,7 +811,7 @@ fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
     }
 
     fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem<'hir> {
-        let impl_item_def_id = self.resolver.definitions().local_def_id(i.id).expect_local();
+        let impl_item_def_id = self.resolver.definitions().local_def_id(i.id);
 
         let (generics, kind) = match &i.kind {
             AssocItemKind::Const(_, ty, expr) => {
index 9028edc73a031fc91f079550c9058e5a1983ab6d..9bb1f57a52457b27c9ba403a5c7bd29bf33ddf10 100644 (file)
@@ -464,8 +464,7 @@ fn visit_item(&mut self, item: &'tcx Item) {
                     | ItemKind::Enum(_, ref generics)
                     | ItemKind::TyAlias(_, ref generics, ..)
                     | ItemKind::Trait(_, _, ref generics, ..) => {
-                        let def_id =
-                            self.lctx.resolver.definitions().local_def_id(item.id).expect_local();
+                        let def_id = self.lctx.resolver.definitions().local_def_id(item.id);
                         let count = generics
                             .params
                             .iter()
@@ -600,7 +599,7 @@ fn with_hir_id_owner<T>(&mut self, owner: NodeId, f: impl FnOnce(&mut Self) -> T
             .item_local_id_counters
             .insert(owner, HIR_ID_COUNTER_LOCKED)
             .unwrap_or_else(|| panic!("no `item_local_id_counters` entry for {:?}", owner));
-        let def_id = self.resolver.definitions().local_def_id(owner).expect_local();
+        let def_id = self.resolver.definitions().local_def_id(owner);
         self.current_hir_id_owner.push((def_id, counter));
         let ret = f(self);
         let (new_def_id, new_counter) = self.current_hir_id_owner.pop().unwrap();
@@ -1280,8 +1279,7 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_, 'hir>) ->
                     }
                     ImplTraitContext::Universal(in_band_ty_params) => {
                         // Add a definition for the in-band `Param`.
-                        let def_id =
-                            self.resolver.definitions().local_def_id(def_node_id).expect_local();
+                        let def_id = self.resolver.definitions().local_def_id(def_node_id);
 
                         let hir_bounds = self.lower_param_bounds(
                             bounds,
@@ -1369,8 +1367,7 @@ fn lower_opaque_impl_trait(
         // frequently opened issues show.
         let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);
 
-        let opaque_ty_def_id =
-            self.resolver.definitions().local_def_id(opaque_ty_node_id).expect_local();
+        let opaque_ty_def_id = self.resolver.definitions().local_def_id(opaque_ty_node_id);
 
         self.allocate_hir_id_counter(opaque_ty_node_id);
 
@@ -1799,8 +1796,7 @@ fn lower_async_fn_ret_ty(
 
         let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::Async, span, None);
 
-        let opaque_ty_def_id =
-            self.resolver.definitions().local_def_id(opaque_ty_node_id).expect_local();
+        let opaque_ty_def_id = self.resolver.definitions().local_def_id(opaque_ty_node_id);
 
         self.allocate_hir_id_counter(opaque_ty_node_id);
 
index a36314448b170b82734ee9fb8ad58101598d2d43..9db5c40c8e362df1e74dcd166332b2cae8107ad5 100644 (file)
@@ -29,7 +29,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
 
     assert!(!instance.substs.needs_infer());
     assert!(!instance.substs.has_escaping_bound_vars());
-    assert!(!instance.substs.has_param_types());
+    assert!(!instance.substs.has_param_types_or_consts());
 
     if let Some(&llfn) = cx.instances.borrow().get(&instance) {
         return llfn;
index 29389b44adc27e1d830d82430efc9a55e4ddaf6b..486ea7f22dfffb1c968607e57fc60682ece68f11 100644 (file)
@@ -47,7 +47,7 @@ fn predefine_fn(
         visibility: Visibility,
         symbol_name: &str,
     ) {
-        assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types());
+        assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types_or_consts());
 
         let fn_abi = FnAbi::of_instance(self, instance, &[]);
         let lldecl = self.declare_fn(symbol_name, &fn_abi);
index 49786bc3b068d75e6444f6a8772f027f850cf563..20e64f0c488515c5baec199c38afd8d0e0117a84 100644 (file)
@@ -154,7 +154,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
 // The third parameter is for env vars, used on windows to set up the
 // path for MSVC to find its DLLs, and gcc to find its bundled
 // toolchain
-pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathBuf, Command) {
+fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> Command {
     let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe");
 
     // If our linker looks like a batch script on Windows then to execute this
@@ -193,6 +193,7 @@ pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathB
                     _ => None,
                 };
                 if let Some(ref a) = arch {
+                    // FIXME: Move this to `fn linker_with_args`.
                     let mut arg = OsString::from("/LIBPATH:");
                     arg.push(format!("{}\\lib\\{}\\store", root_lib_path.display(), a.to_string()));
                     cmd.arg(&arg);
@@ -232,7 +233,7 @@ pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathB
     }
     cmd.env("PATH", env::join_paths(new_path).unwrap());
 
-    (linker.to_path_buf(), cmd)
+    cmd
 }
 
 pub fn each_linked_rlib(
@@ -284,11 +285,7 @@ pub fn each_linked_rlib(
 /// building an `.rlib` (stomping over one another), or writing an `.rmeta` into a
 /// directory being searched for `extern crate` (observing an incomplete file).
 /// The returned path is the temporary file containing the complete metadata.
-pub fn emit_metadata<'a>(
-    sess: &'a Session,
-    metadata: &EncodedMetadata,
-    tmpdir: &TempDir,
-) -> PathBuf {
+pub fn emit_metadata(sess: &Session, metadata: &EncodedMetadata, tmpdir: &TempDir) -> PathBuf {
     let out_filename = tmpdir.path().join(METADATA_FILENAME);
     let result = fs::write(&out_filename, &metadata.raw_data);
 
@@ -487,95 +484,18 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
     target_cpu: &str,
 ) {
     info!("preparing {:?} to {:?}", crate_type, out_filename);
-    let (linker, flavor) = linker_and_flavor(sess);
-
-    let any_dynamic_crate = crate_type == config::CrateType::Dylib
-        || codegen_results.crate_info.dependency_formats.iter().any(|(ty, list)| {
-            *ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic)
-        });
-
-    // The invocations of cc share some flags across platforms
-    let (pname, mut cmd) = get_linker(sess, &linker, flavor);
-
-    if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) {
-        cmd.args(args);
-    }
-    if let Some(args) = sess.target.target.options.pre_link_args_crt.get(&flavor) {
-        if sess.crt_static(Some(crate_type)) {
-            cmd.args(args);
-        }
-    }
-    cmd.args(&sess.opts.debugging_opts.pre_link_args);
-
-    if sess.target.target.options.is_like_fuchsia {
-        let prefix = match sess.opts.debugging_opts.sanitizer {
-            Some(Sanitizer::Address) => "asan/",
-            _ => "",
-        };
-        cmd.arg(format!("--dynamic-linker={}ld.so.1", prefix));
-    }
-
-    let pre_link_objects = if crate_type == config::CrateType::Executable {
-        &sess.target.target.options.pre_link_objects_exe
-    } else {
-        &sess.target.target.options.pre_link_objects_dll
-    };
-    for obj in pre_link_objects {
-        cmd.arg(get_file_path(sess, obj));
-    }
-
-    if crate_type == config::CrateType::Executable && sess.crt_static(Some(crate_type)) {
-        for obj in &sess.target.target.options.pre_link_objects_exe_crt {
-            cmd.arg(get_file_path(sess, obj));
-        }
-    }
-
-    if sess.target.target.options.is_like_emscripten {
-        cmd.arg("-s");
-        cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
-            "DISABLE_EXCEPTION_CATCHING=1"
-        } else {
-            "DISABLE_EXCEPTION_CATCHING=0"
-        });
-    }
+    let (linker_path, flavor) = linker_and_flavor(sess);
+    let mut cmd = linker_with_args::<B>(
+        &linker_path,
+        flavor,
+        sess,
+        crate_type,
+        tmpdir,
+        out_filename,
+        codegen_results,
+        target_cpu,
+    );
 
-    {
-        let mut linker = codegen_results.linker_info.to_linker(cmd, &sess, flavor, target_cpu);
-        link_sanitizer_runtime(sess, crate_type, &mut *linker);
-        link_args::<B>(
-            &mut *linker,
-            flavor,
-            sess,
-            crate_type,
-            tmpdir,
-            out_filename,
-            codegen_results,
-        );
-        cmd = linker.finalize();
-    }
-    if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
-        cmd.args(args);
-    }
-    if any_dynamic_crate {
-        if let Some(args) = sess.target.target.options.late_link_args_dynamic.get(&flavor) {
-            cmd.args(args);
-        }
-    } else {
-        if let Some(args) = sess.target.target.options.late_link_args_static.get(&flavor) {
-            cmd.args(args);
-        }
-    }
-    for obj in &sess.target.target.options.post_link_objects {
-        cmd.arg(get_file_path(sess, obj));
-    }
-    if sess.crt_static(Some(crate_type)) {
-        for obj in &sess.target.target.options.post_link_objects_crt {
-            cmd.arg(get_file_path(sess, obj));
-        }
-    }
-    if let Some(args) = sess.target.target.options.post_link_args.get(&flavor) {
-        cmd.args(args);
-    }
     for &(ref k, ref v) in &sess.target.target.options.link_env {
         cmd.env(k, v);
     }
@@ -597,7 +517,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
     let mut i = 0;
     loop {
         i += 1;
-        prog = sess.time("run_linker", || exec_linker(sess, &mut cmd, out_filename, tmpdir));
+        prog = sess.time("run_linker", || exec_linker(sess, &cmd, out_filename, tmpdir));
         let output = match prog {
             Ok(ref output) => output,
             Err(_) => break,
@@ -698,7 +618,7 @@ fn escape_string(s: &[u8]) -> String {
                 output.extend_from_slice(&prog.stdout);
                 sess.struct_err(&format!(
                     "linking with `{}` failed: {}",
-                    pname.display(),
+                    linker_path.display(),
                     prog.status
                 ))
                 .note(&format!("{:?}", &cmd))
@@ -714,9 +634,12 @@ fn escape_string(s: &[u8]) -> String {
 
             let mut linker_error = {
                 if linker_not_found {
-                    sess.struct_err(&format!("linker `{}` not found", pname.display()))
+                    sess.struct_err(&format!("linker `{}` not found", linker_path.display()))
                 } else {
-                    sess.struct_err(&format!("could not exec the linker `{}`", pname.display()))
+                    sess.struct_err(&format!(
+                        "could not exec the linker `{}`",
+                        linker_path.display()
+                    ))
                 }
             };
 
@@ -787,7 +710,7 @@ fn link_sanitizer_runtime(sess: &Session, crate_type: config::CrateType, linker:
             // PR #41352 for details).
             let libname = format!("rustc{}_rt.{}", channel, name);
             let rpath = default_tlib.to_str().expect("non-utf8 component in path");
-            linker.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]);
+            linker.args(&["-Wl,-rpath", "-Xlinker", rpath]);
             linker.link_dylib(Symbol::intern(&libname));
         }
         "x86_64-unknown-linux-gnu" | "x86_64-fuchsia" | "aarch64-fuchsia" => {
@@ -817,7 +740,7 @@ pub fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool
         && (info.compiler_builtins == Some(cnum) || info.is_no_builtins.contains(&cnum))
 }
 
-pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
+fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
     fn infer_from(
         sess: &Session,
         linker: Option<PathBuf>,
@@ -905,7 +828,7 @@ fn infer_from(
 /// Returns a boolean indicating whether we should preserve the object files on
 /// the filesystem for their debug information. This is often useful with
 /// split-dwarf like schemes.
-pub fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
+fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
     // If the objects don't have debuginfo there's nothing to preserve.
     if sess.opts.debuginfo == config::DebugInfo::None {
         return false;
@@ -959,7 +882,7 @@ enum RlibFlavor {
     StaticlibBase,
 }
 
-pub fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLibrary]) {
+fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLibrary]) {
     let lib_args: Vec<_> = all_native_libs
         .iter()
         .filter(|l| relevant_lib(sess, l))
@@ -1061,7 +984,7 @@ fn probe(sess: &Session) -> Option<PathBuf> {
     }
 }
 
-pub fn get_file_path(sess: &Session, name: &str) -> PathBuf {
+fn get_object_file_path(sess: &Session, name: &str) -> PathBuf {
     // prefer system {,dll}crt2.o libs, see get_crt_libs_path comment for more details
     if sess.target.target.llvm_target.contains("windows-gnu") {
         if let Some(compiler_libs_path) = get_crt_libs_path(sess) {
@@ -1085,9 +1008,9 @@ pub fn get_file_path(sess: &Session, name: &str) -> PathBuf {
     PathBuf::from(name)
 }
 
-pub fn exec_linker(
+fn exec_linker(
     sess: &Session,
-    cmd: &mut Command,
+    cmd: &Command,
     out_filename: &Path,
     tmpdir: &Path,
 ) -> io::Result<Output> {
@@ -1233,134 +1156,142 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     }
 }
 
-fn link_args<'a, B: ArchiveBuilder<'a>>(
+/// Add begin object files defined by the target spec.
+fn add_pre_link_objects(cmd: &mut dyn Linker, sess: &Session, crate_type: config::CrateType) {
+    let pre_link_objects = if crate_type == config::CrateType::Executable {
+        &sess.target.target.options.pre_link_objects_exe
+    } else {
+        &sess.target.target.options.pre_link_objects_dll
+    };
+    for obj in pre_link_objects {
+        cmd.add_object(&get_object_file_path(sess, obj));
+    }
+
+    if crate_type == config::CrateType::Executable && sess.crt_static(Some(crate_type)) {
+        for obj in &sess.target.target.options.pre_link_objects_exe_crt {
+            cmd.add_object(&get_object_file_path(sess, obj));
+        }
+    }
+}
+
+/// Add end object files defined by the target spec.
+fn add_post_link_objects(cmd: &mut dyn Linker, sess: &Session, crate_type: config::CrateType) {
+    for obj in &sess.target.target.options.post_link_objects {
+        cmd.add_object(&get_object_file_path(sess, obj));
+    }
+    if sess.crt_static(Some(crate_type)) {
+        for obj in &sess.target.target.options.post_link_objects_crt {
+            cmd.add_object(&get_object_file_path(sess, obj));
+        }
+    }
+}
+
+/// Add arbitrary "pre-link" args defined by the target spec or from command line.
+/// FIXME: Determine where exactly these args need to be inserted.
+fn add_pre_link_args(
     cmd: &mut dyn Linker,
+    sess: &Session,
     flavor: LinkerFlavor,
-    sess: &'a Session,
     crate_type: config::CrateType,
-    tmpdir: &Path,
-    out_filename: &Path,
-    codegen_results: &CodegenResults,
 ) {
-    // Linker plugins should be specified early in the list of arguments
-    cmd.linker_plugin_lto();
-
-    // The default library location, we need this to find the runtime.
-    // The location of crates will be determined as needed.
-    let lib_path = sess.target_filesearch(PathKind::All).get_lib_path();
+    if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) {
+        cmd.args(args);
+    }
+    if let Some(args) = sess.target.target.options.pre_link_args_crt.get(&flavor) {
+        if sess.crt_static(Some(crate_type)) {
+            cmd.args(args);
+        }
+    }
+    cmd.args(&sess.opts.debugging_opts.pre_link_args);
+}
 
-    // target descriptor
-    let t = &sess.target.target;
+/// Add arbitrary "user defined" args defined from command line and by `#[link_args]` attributes.
+/// FIXME: Determine where exactly these args need to be inserted.
+fn add_user_defined_link_args(
+    cmd: &mut dyn Linker,
+    sess: &Session,
+    codegen_results: &CodegenResults,
+) {
+    cmd.args(&sess.opts.cg.link_args);
+    cmd.args(&*codegen_results.crate_info.link_args);
+}
 
-    // prefer system mingw-w64 libs, see get_crt_libs_path comment for more details
-    if cfg!(windows) && sess.target.target.llvm_target.contains("windows-gnu") {
-        if let Some(compiler_libs_path) = get_crt_libs_path(sess) {
-            cmd.include_path(&compiler_libs_path);
+/// Add arbitrary "late link" args defined by the target spec.
+/// FIXME: Determine where exactly these args need to be inserted.
+fn add_late_link_args(
+    cmd: &mut dyn Linker,
+    sess: &Session,
+    flavor: LinkerFlavor,
+    crate_type: config::CrateType,
+    codegen_results: &CodegenResults,
+) {
+    if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
+        cmd.args(args);
+    }
+    let any_dynamic_crate = crate_type == config::CrateType::Dylib
+        || codegen_results.crate_info.dependency_formats.iter().any(|(ty, list)| {
+            *ty == crate_type && list.iter().any(|&linkage| linkage == Linkage::Dynamic)
+        });
+    if any_dynamic_crate {
+        if let Some(args) = sess.target.target.options.late_link_args_dynamic.get(&flavor) {
+            cmd.args(args);
+        }
+    } else {
+        if let Some(args) = sess.target.target.options.late_link_args_static.get(&flavor) {
+            cmd.args(args);
         }
     }
+}
 
-    cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
+/// Add arbitrary "post-link" args defined by the target spec.
+/// FIXME: Determine where exactly these args need to be inserted.
+fn add_post_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
+    if let Some(args) = sess.target.target.options.post_link_args.get(&flavor) {
+        cmd.args(args);
+    }
+}
 
+/// Add object files containing code from the current crate.
+fn add_local_crate_regular_objects(cmd: &mut dyn Linker, codegen_results: &CodegenResults) {
     for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) {
         cmd.add_object(obj);
     }
-    cmd.output_filename(out_filename);
+}
 
-    if crate_type == config::CrateType::Executable && sess.target.target.options.is_like_windows {
-        if let Some(ref s) = codegen_results.windows_subsystem {
-            cmd.subsystem(s);
-        }
+/// Add object files for allocator code linked once for the whole crate tree.
+fn add_local_crate_allocator_objects(cmd: &mut dyn Linker, codegen_results: &CodegenResults) {
+    if let Some(obj) = codegen_results.allocator_module.as_ref().and_then(|m| m.object.as_ref()) {
+        cmd.add_object(obj);
     }
+}
 
-    // If we're building something like a dynamic library then some platforms
-    // need to make sure that all symbols are exported correctly from the
-    // dynamic library.
-    cmd.export_symbols(tmpdir, crate_type);
-
+/// Add object files containing metadata for the current crate.
+fn add_local_crate_metadata_objects(
+    cmd: &mut dyn Linker,
+    crate_type: config::CrateType,
+    codegen_results: &CodegenResults,
+) {
     // When linking a dynamic library, we put the metadata into a section of the
     // executable. This metadata is in a separate object file from the main
     // object file, so we link that in here.
     if crate_type == config::CrateType::Dylib || crate_type == config::CrateType::ProcMacro {
-        let obj = codegen_results.metadata_module.as_ref().and_then(|m| m.object.as_ref());
-        if let Some(obj) = obj {
+        if let Some(obj) = codegen_results.metadata_module.as_ref().and_then(|m| m.object.as_ref())
+        {
             cmd.add_object(obj);
         }
     }
+}
 
-    let obj = codegen_results.allocator_module.as_ref().and_then(|m| m.object.as_ref());
-    if let Some(obj) = obj {
-        cmd.add_object(obj);
-    }
-
-    // Try to strip as much out of the generated object by removing unused
-    // sections if possible. See more comments in linker.rs
-    if !sess.opts.cg.link_dead_code {
-        let keep_metadata = crate_type == config::CrateType::Dylib;
-        cmd.gc_sections(keep_metadata);
-    }
-
-    let attr_link_args = codegen_results.crate_info.link_args.iter();
-    let user_link_args: Vec<_> =
-        sess.opts.cg.link_args.iter().chain(attr_link_args).cloned().collect();
-
-    if crate_type == config::CrateType::Executable {
-        let mut position_independent_executable = false;
-
-        if t.options.position_independent_executables {
-            if is_pic(sess)
-                && !sess.crt_static(Some(crate_type))
-                && !user_link_args.iter().any(|x| x == "-static")
-            {
-                position_independent_executable = true;
-            }
-        }
-
-        if position_independent_executable {
-            cmd.position_independent_executable();
-        } else {
-            // recent versions of gcc can be configured to generate position
-            // independent executables by default. We have to pass -no-pie to
-            // explicitly turn that off. Not applicable to ld.
-            if sess.target.target.options.linker_is_gnu && flavor != LinkerFlavor::Ld {
-                cmd.no_position_independent_executable();
-            }
-        }
-    }
-
-    let relro_level = match sess.opts.debugging_opts.relro_level {
-        Some(level) => level,
-        None => t.options.relro_level,
-    };
-    match relro_level {
-        RelroLevel::Full => {
-            cmd.full_relro();
-        }
-        RelroLevel::Partial => {
-            cmd.partial_relro();
-        }
-        RelroLevel::Off => {
-            cmd.no_relro();
-        }
-        RelroLevel::None => {}
-    }
-
-    // Pass optimization flags down to the linker.
-    cmd.optimize();
-
-    // Pass debuginfo flags down to the linker.
-    cmd.debuginfo();
-
-    // We want to, by default, prevent the compiler from accidentally leaking in
-    // any system libraries, so we may explicitly ask linkers to not link to any
-    // libraries by default. Note that this does not happen for windows because
-    // windows pulls in some large number of libraries and I couldn't quite
-    // figure out which subset we wanted.
-    //
-    // This is all naturally configurable via the standard methods as well.
-    if !sess.opts.cg.default_linker_libraries.unwrap_or(false) && t.options.no_default_libraries {
-        cmd.no_default_libraries();
-    }
-
+/// Link native libraries corresponding to the current crate and all libraries corresponding to
+/// all its dependency crates.
+/// FIXME: Consider combining this with the functions above adding object files for the local crate.
+fn link_local_crate_native_libs_and_dependent_crate_libs<'a, B: ArchiveBuilder<'a>>(
+    cmd: &mut dyn Linker,
+    sess: &'a Session,
+    crate_type: config::CrateType,
+    codegen_results: &CodegenResults,
+    tmpdir: &Path,
+) {
     // Take careful note of the ordering of the arguments we pass to the linker
     // here. Linkers will assume that things on the left depend on things to the
     // right. Things on the right cannot depend on things on the left. This is
@@ -1398,22 +1329,73 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
     if sess.opts.debugging_opts.link_native_libraries.unwrap_or(true) {
         add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
     }
-    // Tell the linker what we're doing.
+}
+
+/// Add sysroot and other globally set directories to the directory search list.
+fn add_library_search_dirs(cmd: &mut dyn Linker, sess: &Session) {
+    // Prefer system mingw-w64 libs, see get_crt_libs_path comment for more details.
+    if cfg!(windows) && sess.target.target.llvm_target.contains("windows-gnu") {
+        if let Some(compiler_libs_path) = get_crt_libs_path(sess) {
+            cmd.include_path(&compiler_libs_path);
+        }
+    }
+
+    // The default library location, we need this to find the runtime.
+    // The location of crates will be determined as needed.
+    let lib_path = sess.target_filesearch(PathKind::All).get_lib_path();
+    cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
+}
+
+/// Add options requesting executables to be position-independent or not position-independent.
+fn add_position_independent_executable_args(
+    cmd: &mut dyn Linker,
+    sess: &Session,
+    flavor: LinkerFlavor,
+    crate_type: config::CrateType,
+    codegen_results: &CodegenResults,
+) {
     if crate_type != config::CrateType::Executable {
-        cmd.build_dylib(out_filename);
+        return;
     }
-    if crate_type == config::CrateType::Executable && sess.crt_static(Some(crate_type)) {
-        cmd.build_static_executable();
+
+    if sess.target.target.options.position_independent_executables {
+        let attr_link_args = &*codegen_results.crate_info.link_args;
+        let mut user_defined_link_args = sess.opts.cg.link_args.iter().chain(attr_link_args);
+        if is_pic(sess)
+            && !sess.crt_static(Some(crate_type))
+            && !user_defined_link_args.any(|x| x == "-static")
+        {
+            cmd.position_independent_executable();
+            return;
+        }
     }
 
-    if sess.opts.cg.profile_generate.enabled() {
-        cmd.pgo_gen();
+    // Recent versions of gcc can be configured to generate position
+    // independent executables by default. We have to pass -no-pie to
+    // explicitly turn that off. Not applicable to ld.
+    if sess.target.target.options.linker_is_gnu && flavor != LinkerFlavor::Ld {
+        cmd.no_position_independent_executable();
     }
+}
 
-    if sess.opts.debugging_opts.control_flow_guard != CFGuard::Disabled {
-        cmd.control_flow_guard();
+/// Add options making relocation sections in the produced ELF files read-only
+/// and suppressing lazy binding.
+fn add_relro_args(cmd: &mut dyn Linker, sess: &Session) {
+    match sess.opts.debugging_opts.relro_level.unwrap_or(sess.target.target.options.relro_level) {
+        RelroLevel::Full => cmd.full_relro(),
+        RelroLevel::Partial => cmd.partial_relro(),
+        RelroLevel::Off => cmd.no_relro(),
+        RelroLevel::None => {}
     }
+}
 
+/// Add library search paths used at runtime by dynamic linkers.
+fn add_rpath_args(
+    cmd: &mut dyn Linker,
+    sess: &Session,
+    codegen_results: &CodegenResults,
+    out_filename: &Path,
+) {
     // FIXME (#2397): At some point we want to rpath our guesses as to
     // where extern libraries might live, based on the
     // addl_lib_search_paths
@@ -1437,10 +1419,177 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
         };
         cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
     }
+}
+
+/// Produce the linker command line containing linker path and arguments.
+/// `NO-OPT-OUT` marks the arguments that cannot be removed from the command line
+/// by the user without creating a custom target specification.
+/// `OBJECT-FILES` specify whether the arguments can add object files.
+/// `CUSTOMIZATION-POINT` means that arbitrary arguments defined by the user
+/// or by the target spec can be inserted here.
+/// `AUDIT-ORDER` - need to figure out whether the option is order-dependent or not.
+fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
+    path: &Path,
+    flavor: LinkerFlavor,
+    sess: &'a Session,
+    crate_type: config::CrateType,
+    tmpdir: &Path,
+    out_filename: &Path,
+    codegen_results: &CodegenResults,
+    target_cpu: &str,
+) -> Command {
+    let base_cmd = get_linker(sess, path, flavor);
+    // FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
+    // to the linker args construction.
+    assert!(base_cmd.get_args().is_empty() || sess.target.target.target_vendor == "uwp");
+    let cmd = &mut *codegen_results.linker_info.to_linker(base_cmd, &sess, flavor, target_cpu);
+
+    // NO-OPT-OUT, OBJECT-FILES-MAYBE, CUSTOMIZATION-POINT
+    add_pre_link_args(cmd, sess, flavor, crate_type);
+
+    // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+    if sess.target.target.options.is_like_fuchsia {
+        let prefix = match sess.opts.debugging_opts.sanitizer {
+            Some(Sanitizer::Address) => "asan/",
+            _ => "",
+        };
+        cmd.arg(format!("--dynamic-linker={}ld.so.1", prefix));
+    }
+
+    // NO-OPT-OUT, OBJECT-FILES-YES
+    add_pre_link_objects(cmd, sess, crate_type);
+
+    // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+    if sess.target.target.options.is_like_emscripten {
+        cmd.arg("-s");
+        cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
+            "DISABLE_EXCEPTION_CATCHING=1"
+        } else {
+            "DISABLE_EXCEPTION_CATCHING=0"
+        });
+    }
+
+    // OBJECT-FILES-YES, AUDIT-ORDER
+    link_sanitizer_runtime(sess, crate_type, cmd);
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    // Linker plugins should be specified early in the list of arguments
+    // FIXME: How "early" exactly?
+    cmd.linker_plugin_lto();
+
+    // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+    // FIXME: Order-dependent, at least relatively to other args adding searh directories.
+    add_library_search_dirs(cmd, sess);
+
+    // OBJECT-FILES-YES
+    add_local_crate_regular_objects(cmd, codegen_results);
+
+    // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+    cmd.output_filename(out_filename);
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    if crate_type == config::CrateType::Executable && sess.target.target.options.is_like_windows {
+        if let Some(ref s) = codegen_results.windows_subsystem {
+            cmd.subsystem(s);
+        }
+    }
+
+    // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+    // If we're building something like a dynamic library then some platforms
+    // need to make sure that all symbols are exported correctly from the
+    // dynamic library.
+    cmd.export_symbols(tmpdir, crate_type);
+
+    // OBJECT-FILES-YES
+    add_local_crate_metadata_objects(cmd, crate_type, codegen_results);
+
+    // OBJECT-FILES-YES
+    add_local_crate_allocator_objects(cmd, codegen_results);
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    // FIXME: Order dependent, applies to the following objects. Where should it be placed?
+    // Try to strip as much out of the generated object by removing unused
+    // sections if possible. See more comments in linker.rs
+    if !sess.opts.cg.link_dead_code {
+        let keep_metadata = crate_type == config::CrateType::Dylib;
+        cmd.gc_sections(keep_metadata);
+    }
+
+    // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+    add_position_independent_executable_args(cmd, sess, flavor, crate_type, codegen_results);
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    add_relro_args(cmd, sess);
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    // Pass optimization flags down to the linker.
+    cmd.optimize();
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    // Pass debuginfo flags down to the linker.
+    cmd.debuginfo();
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    // We want to, by default, prevent the compiler from accidentally leaking in
+    // any system libraries, so we may explicitly ask linkers to not link to any
+    // libraries by default. Note that this does not happen for windows because
+    // windows pulls in some large number of libraries and I couldn't quite
+    // figure out which subset we wanted.
+    //
+    // This is all naturally configurable via the standard methods as well.
+    if !sess.opts.cg.default_linker_libraries.unwrap_or(false)
+        && sess.target.target.options.no_default_libraries
+    {
+        cmd.no_default_libraries();
+    }
+
+    // OBJECT-FILES-YES
+    link_local_crate_native_libs_and_dependent_crate_libs::<B>(
+        cmd,
+        sess,
+        crate_type,
+        codegen_results,
+        tmpdir,
+    );
+
+    // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+    // Tell the linker what we're doing.
+    if crate_type != config::CrateType::Executable {
+        cmd.build_dylib(out_filename);
+    }
+    if crate_type == config::CrateType::Executable && sess.crt_static(Some(crate_type)) {
+        cmd.build_static_executable();
+    }
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    if sess.opts.cg.profile_generate.enabled() {
+        cmd.pgo_gen();
+    }
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    if sess.opts.debugging_opts.control_flow_guard != CFGuard::Disabled {
+        cmd.control_flow_guard();
+    }
+
+    // OBJECT-FILES-NO, AUDIT-ORDER
+    add_rpath_args(cmd, sess, codegen_results, out_filename);
+
+    // OBJECT-FILES-MAYBE, CUSTOMIZATION-POINT
+    add_user_defined_link_args(cmd, sess, codegen_results);
+
+    // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+    cmd.finalize();
+
+    // NO-OPT-OUT, OBJECT-FILES-MAYBE, CUSTOMIZATION-POINT
+    add_late_link_args(cmd, sess, flavor, crate_type, codegen_results);
+
+    // NO-OPT-OUT, OBJECT-FILES-YES
+    add_post_link_objects(cmd, sess, crate_type);
+
+    // NO-OPT-OUT, OBJECT-FILES-MAYBE, CUSTOMIZATION-POINT
+    add_post_link_args(cmd, sess, flavor);
 
-    // Finally add all the linker arguments provided on the command line along
-    // with any #[link_args] attributes found inside the crate
-    cmd.args(&user_link_args);
+    cmd.take_cmd()
 }
 
 // # Native library linking
@@ -1454,7 +1603,7 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
 // Also note that the native libraries linked here are only the ones located
 // in the current crate. Upstream crates with native library dependencies
 // may have their native library pulled in above.
-pub fn add_local_native_libraries(
+fn add_local_native_libraries(
     cmd: &mut dyn Linker,
     sess: &Session,
     codegen_results: &CodegenResults,
@@ -1784,7 +1933,7 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
 // generic function calls a native function, then the generic function must
 // be instantiated in the target crate, meaning that the native symbol must
 // also be resolved in the target crate.
-pub fn add_upstream_native_libraries(
+fn add_upstream_native_libraries(
     cmd: &mut dyn Linker,
     sess: &Session,
     codegen_results: &CodegenResults,
@@ -1841,14 +1990,14 @@ pub fn add_upstream_native_libraries(
     }
 }
 
-pub fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
+fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
     match lib.cfg {
         Some(ref cfg) => rustc_attr::cfg_matches(cfg, &sess.parse_sess, None),
         None => true,
     }
 }
 
-pub fn are_upstream_rust_objects_already_included(sess: &Session) -> bool {
+fn are_upstream_rust_objects_already_included(sess: &Session) -> bool {
     match sess.lto() {
         config::Lto::Fat => true,
         config::Lto::Thin => {
index c0c533524b09861eaf79cbe4fbe9aef1c40b5fa0..0baa37ae9f1ab76eafb6e8fa1fdb185b8bf75c28 100644 (file)
@@ -6,6 +6,7 @@
 use std::fs::{self, File};
 use std::io::prelude::*;
 use std::io::{self, BufWriter};
+use std::mem;
 use std::path::{Path, PathBuf};
 
 use rustc_data_structures::fx::FxHashMap;
@@ -87,6 +88,7 @@ pub fn to_linker<'a>(
 /// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
 /// MSVC linker (e.g., `link.exe`) is being used.
 pub trait Linker {
+    fn cmd(&mut self) -> &mut Command;
     fn link_dylib(&mut self, lib: Symbol);
     fn link_rust_dylib(&mut self, lib: Symbol, path: &Path);
     fn link_framework(&mut self, framework: Symbol);
@@ -111,14 +113,26 @@ pub trait Linker {
     fn no_default_libraries(&mut self);
     fn build_dylib(&mut self, out_filename: &Path);
     fn build_static_executable(&mut self);
-    fn args(&mut self, args: &[String]);
     fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType);
     fn subsystem(&mut self, subsystem: &str);
     fn group_start(&mut self);
     fn group_end(&mut self);
     fn linker_plugin_lto(&mut self);
-    // Should have been finalize(self), but we don't support self-by-value on trait objects (yet?).
-    fn finalize(&mut self) -> Command;
+    fn finalize(&mut self);
+}
+
+impl dyn Linker + '_ {
+    pub fn arg(&mut self, arg: impl AsRef<OsStr>) {
+        self.cmd().arg(arg);
+    }
+
+    pub fn args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) {
+        self.cmd().args(args);
+    }
+
+    pub fn take_cmd(&mut self) -> Command {
+        mem::replace(self.cmd(), Command::new(""))
+    }
 }
 
 pub struct GccLinker<'a> {
@@ -208,6 +222,9 @@ fn push_linker_plugin_lto_args(&mut self, plugin_path: Option<&OsStr>) {
 }
 
 impl<'a> Linker for GccLinker<'a> {
+    fn cmd(&mut self) -> &mut Command {
+        &mut self.cmd
+    }
     fn link_dylib(&mut self, lib: Symbol) {
         self.hint_dynamic();
         self.cmd.arg(format!("-l{}", lib));
@@ -251,9 +268,6 @@ fn no_relro(&mut self) {
     fn build_static_executable(&mut self) {
         self.cmd.arg("-static");
     }
-    fn args(&mut self, args: &[String]) {
-        self.cmd.args(args);
-    }
 
     fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
         self.hint_dynamic();
@@ -505,10 +519,8 @@ fn subsystem(&mut self, subsystem: &str) {
         self.linker_arg(&subsystem);
     }
 
-    fn finalize(&mut self) -> Command {
+    fn finalize(&mut self) {
         self.hint_dynamic(); // Reset to default before returning the composed command line.
-
-        ::std::mem::replace(&mut self.cmd, Command::new(""))
     }
 
     fn group_start(&mut self) {
@@ -545,15 +557,15 @@ pub struct MsvcLinker<'a> {
 }
 
 impl<'a> Linker for MsvcLinker<'a> {
+    fn cmd(&mut self) -> &mut Command {
+        &mut self.cmd
+    }
     fn link_rlib(&mut self, lib: &Path) {
         self.cmd.arg(lib);
     }
     fn add_object(&mut self, path: &Path) {
         self.cmd.arg(path);
     }
-    fn args(&mut self, args: &[String]) {
-        self.cmd.args(args);
-    }
 
     fn build_dylib(&mut self, out_filename: &Path) {
         self.cmd.arg("/DLL");
@@ -758,9 +770,7 @@ fn subsystem(&mut self, subsystem: &str) {
         }
     }
 
-    fn finalize(&mut self) -> Command {
-        ::std::mem::replace(&mut self.cmd, Command::new(""))
-    }
+    fn finalize(&mut self) {}
 
     // MSVC doesn't need group indicators
     fn group_start(&mut self) {}
@@ -778,6 +788,9 @@ pub struct EmLinker<'a> {
 }
 
 impl<'a> Linker for EmLinker<'a> {
+    fn cmd(&mut self) -> &mut Command {
+        &mut self.cmd
+    }
     fn include_path(&mut self, path: &Path) {
         self.cmd.arg("-L").arg(path);
     }
@@ -837,10 +850,6 @@ fn no_relro(&mut self) {
         // noop
     }
 
-    fn args(&mut self, args: &[String]) {
-        self.cmd.args(args);
-    }
-
     fn framework_path(&mut self, _path: &Path) {
         bug!("frameworks are not supported on Emscripten")
     }
@@ -928,9 +937,7 @@ fn subsystem(&mut self, _subsystem: &str) {
         // noop
     }
 
-    fn finalize(&mut self) -> Command {
-        ::std::mem::replace(&mut self.cmd, Command::new(""))
-    }
+    fn finalize(&mut self) {}
 
     // Appears not necessary on Emscripten
     fn group_start(&mut self) {}
@@ -992,6 +999,10 @@ fn new(mut cmd: Command, sess: &'a Session, info: &'a LinkerInfo) -> WasmLd<'a>
 }
 
 impl<'a> Linker for WasmLd<'a> {
+    fn cmd(&mut self) -> &mut Command {
+        &mut self.cmd
+    }
+
     fn link_dylib(&mut self, lib: Symbol) {
         self.cmd.arg("-l").sym_arg(lib);
     }
@@ -1030,10 +1041,6 @@ fn no_relro(&mut self) {}
 
     fn build_static_executable(&mut self) {}
 
-    fn args(&mut self, args: &[String]) {
-        self.cmd.args(args);
-    }
-
     fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
         self.cmd.arg("-l").sym_arg(lib);
     }
@@ -1098,9 +1105,7 @@ fn subsystem(&mut self, _subsystem: &str) {}
 
     fn no_position_independent_executable(&mut self) {}
 
-    fn finalize(&mut self) -> Command {
-        ::std::mem::replace(&mut self.cmd, Command::new(""))
-    }
+    fn finalize(&mut self) {}
 
     // Not needed for now with LLD
     fn group_start(&mut self) {}
@@ -1162,6 +1167,10 @@ pub struct PtxLinker<'a> {
 }
 
 impl<'a> Linker for PtxLinker<'a> {
+    fn cmd(&mut self) -> &mut Command {
+        &mut self.cmd
+    }
+
     fn link_rlib(&mut self, path: &Path) {
         self.cmd.arg("--rlib").arg(path);
     }
@@ -1182,10 +1191,6 @@ fn add_object(&mut self, path: &Path) {
         self.cmd.arg("--bitcode").arg(path);
     }
 
-    fn args(&mut self, args: &[String]) {
-        self.cmd.args(args);
-    }
-
     fn optimize(&mut self) {
         match self.sess.lto() {
             Lto::Thin | Lto::Fat | Lto::ThinLocal => {
@@ -1200,14 +1205,12 @@ fn output_filename(&mut self, path: &Path) {
         self.cmd.arg("-o").arg(path);
     }
 
-    fn finalize(&mut self) -> Command {
+    fn finalize(&mut self) {
         // Provide the linker with fallback to internal `target-cpu`.
         self.cmd.arg("--fallback-arch").arg(match self.sess.opts.cg.target_cpu {
             Some(ref s) => s,
             None => &self.sess.target.target.options.cpu,
         });
-
-        ::std::mem::replace(&mut self.cmd, Command::new(""))
     }
 
     fn link_dylib(&mut self, _lib: Symbol) {
index 6e690655f60c57409196d623a9df612a6c511dbf..8d9982131c33e0ec5ade815553c0289b1e686dcb 100644 (file)
 E0735: include_str!("./error_codes/E0735.md"),
 E0736: include_str!("./error_codes/E0736.md"),
 E0737: include_str!("./error_codes/E0737.md"),
-E0738: include_str!("./error_codes/E0738.md"),
 E0739: include_str!("./error_codes/E0739.md"),
 E0740: include_str!("./error_codes/E0740.md"),
 E0741: include_str!("./error_codes/E0741.md"),
     E0722, // Malformed `#[optimize]` attribute
     E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
     E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
+//  E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
 }
index 1e3457e96c5f87954db3af7b3f543a04d657cd0a..254751fc45e305686c311c6f397229659cc7b573 100644 (file)
@@ -1,9 +1,4 @@
-You tried to move out of a value which was borrowed.
-
-This can also happen when using a type implementing `Fn` or `FnMut`, as neither
-allows moving out of them (they usually represent closures which can be called
-more than once). Much of the text following applies equally well to non-`FnOnce`
-closure bodies.
+A borrowed value was moved out.
 
 Erroneous code example:
 
@@ -32,6 +27,11 @@ you have three choices:
 * Somehow reclaim the ownership.
 * Implement the `Copy` trait on the type.
 
+This can also happen when using a type implementing `Fn` or `FnMut`, as neither
+allows moving out of them (they usually represent closures which can be called
+more than once). Much of the text following applies equally well to non-`FnOnce`
+closure bodies.
+
 Examples:
 
 ```
index d5be417888b547ea63e236ddb209546dc1fc3aef..e045e04bdbe11ac23b981af155fbfa163c581269 100644 (file)
@@ -1,16 +1,29 @@
-Cannot mutate place in this match guard.
+The matched value was assigned in a match guard.
 
-When matching on a variable it cannot be mutated in the match guards, as this
-could cause the match to be non-exhaustive:
+Erroneous code example:
 
 ```compile_fail,E0510
 let mut x = Some(0);
 match x {
-    None => (),
-    Some(_) if { x = None; false } => (),
-    Some(v) => (), // No longer matches
+    None => {}
+    Some(_) if { x = None; false } => {} // error!
+    Some(_) => {}
 }
 ```
 
+When matching on a variable it cannot be mutated in the match guards, as this
+could cause the match to be non-exhaustive.
+
 Here executing `x = None` would modify the value being matched and require us
-to go "back in time" to the `None` arm.
+to go "back in time" to the `None` arm. To fix it, change the value in the match
+arm:
+
+```
+let mut x = Some(0);
+match x {
+    None => {}
+    Some(_) => {
+        x = None; // ok!
+    }
+}
+```
diff --git a/src/librustc_error_codes/error_codes/E0738.md b/src/librustc_error_codes/error_codes/E0738.md
deleted file mode 100644 (file)
index 8f31b70..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-`#[track_caller]` cannot be used to annotate foreign functions.
-
-Erroneous example:
-
-```compile_fail,E0738
-#![feature(track_caller)]
-extern "Rust" {
-    #[track_caller]
-    fn bar();
-}
-```
index 314af77f2ca1681779b3426dd43ba95404337622..58f34787613be41f1186180ac2dabb86502ae55b 100644 (file)
@@ -326,10 +326,9 @@ pub fn opt_local_def_id(&self, node: ast::NodeId) -> Option<LocalDefId> {
         self.node_id_to_def_id.get(&node).copied()
     }
 
-    // FIXME(eddyb) this function can and should return `LocalDefId`.
     #[inline]
-    pub fn local_def_id(&self, node: ast::NodeId) -> DefId {
-        self.opt_local_def_id(node).unwrap().to_def_id()
+    pub fn local_def_id(&self, node: ast::NodeId) -> LocalDefId {
+        self.opt_local_def_id(node).unwrap()
     }
 
     #[inline]
index 347a5ff6d56a41736a1bcd3d697bf785fa57e28a..c3df5bd3d61abf33564621c5d8947b97dbeec4c6 100644 (file)
@@ -488,12 +488,12 @@ fn canonicalize<V>(
         V: TypeFoldable<'tcx>,
     {
         let needs_canonical_flags = if canonicalize_region_mode.any() {
-            TypeFlags::KEEP_IN_LOCAL_TCX |
+            TypeFlags::NEEDS_INFER |
             TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
             TypeFlags::HAS_TY_PLACEHOLDER |
             TypeFlags::HAS_CT_PLACEHOLDER
         } else {
-            TypeFlags::KEEP_IN_LOCAL_TCX
+            TypeFlags::NEEDS_INFER
                 | TypeFlags::HAS_RE_PLACEHOLDER
                 | TypeFlags::HAS_TY_PLACEHOLDER
                 | TypeFlags::HAS_CT_PLACEHOLDER
@@ -524,7 +524,7 @@ fn canonicalize<V>(
         // Once we have canonicalized `out_value`, it should not
         // contain anything that ties it to this inference context
         // anymore, so it should live in the global arena.
-        debug_assert!(!out_value.has_type_flags(TypeFlags::KEEP_IN_LOCAL_TCX));
+        debug_assert!(!out_value.needs_infer());
 
         let canonical_variables = tcx.intern_canonical_var_infos(&canonicalizer.variables);
 
index 22b90f2415540c5aa6442dd3a394813a0b589b41..b908b75a257e3a619485585b31849157b8989d92 100644 (file)
@@ -181,10 +181,8 @@ fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
     }
 
     fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
-        if !t.needs_infer() && !ty::keep_local(&t) {
+        if !t.needs_infer() {
             t // micro-optimize -- if there is nothing in this type that this fold affects...
-        // ^ we need to have the `keep_local` check to un-default
-        // defaulted tuples.
         } else {
             let t = self.infcx.shallow_resolve(t);
             match t.kind {
@@ -222,10 +220,8 @@ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
     }
 
     fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
-        if !c.needs_infer() && !ty::keep_local(&c) {
+        if !c.needs_infer() {
             c // micro-optimize -- if there is nothing in this const that this fold affects...
-        // ^ we need to have the `keep_local` check to un-default
-        // defaulted tuples.
         } else {
             let c = self.infcx.shallow_resolve(c);
             match c.val {
index c74b399555a8a874ff96bd74e75af1aeb1515019..aa7c87e9f7bd2a12c49fe59cbc158e32c6fc128f 100644 (file)
@@ -355,6 +355,19 @@ fn from(ctx: UnusedDelimsCtx) -> &'static str {
 trait UnusedDelimLint {
     const DELIM_STR: &'static str;
 
+    /// Due to `ref` pattern, there can be a difference between using
+    /// `{ expr }` and `expr` in pattern-matching contexts. This means
+    /// that we should only lint `unused_parens` and not `unused_braces`
+    /// in this case.
+    ///
+    /// ```rust
+    /// let mut a = 7;
+    /// let ref b = { a }; // We actually borrow a copy of `a` here.
+    /// a += 1; // By mutating `a` we invalidate any borrows of `a`.
+    /// assert_eq!(b + 1, a); // `b` does not borrow `a`, so we can still use it here.
+    /// ```
+    const LINT_EXPR_IN_PATTERN_MATCHING_CTX: bool;
+
     // this cannot be a constant is it refers to a static.
     fn lint(&self) -> &'static Lint;
 
@@ -454,7 +467,10 @@ fn emit_unused_delims(
     fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
         use rustc_ast::ast::ExprKind::*;
         let (value, ctx, followed_by_block, left_pos, right_pos) = match e.kind {
-            If(ref cond, ref block, ..) => {
+            // Do not lint `unused_braces` in `if let` expressions.
+            If(ref cond, ref block, ..)
+                if !matches!(cond.kind, Let(_, _)) || Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX =>
+            {
                 let left = e.span.lo() + rustc_span::BytePos(2);
                 let right = block.span.lo();
                 (cond, UnusedDelimsCtx::IfCond, true, Some(left), Some(right))
@@ -470,7 +486,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
                 (cond, UnusedDelimsCtx::ForIterExpr, true, None, Some(block.span.lo()))
             }
 
-            Match(ref head, _) => {
+            Match(ref head, _) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
                 let left = e.span.lo() + rustc_span::BytePos(5);
                 (head, UnusedDelimsCtx::MatchScrutineeExpr, true, Some(left), None)
             }
@@ -512,7 +528,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
 
     fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
         match s.kind {
-            StmtKind::Local(ref local) => {
+            StmtKind::Local(ref local) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
                 if let Some(ref value) = local.init {
                     self.check_unused_delims_expr(
                         cx,
@@ -565,6 +581,8 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
 impl UnusedDelimLint for UnusedParens {
     const DELIM_STR: &'static str = "parentheses";
 
+    const LINT_EXPR_IN_PATTERN_MATCHING_CTX: bool = true;
+
     fn lint(&self) -> &'static Lint {
         UNUSED_PARENS
     }
@@ -736,6 +754,8 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
 impl UnusedDelimLint for UnusedBraces {
     const DELIM_STR: &'static str = "braces";
 
+    const LINT_EXPR_IN_PATTERN_MATCHING_CTX: bool = false;
+
     fn lint(&self) -> &'static Lint {
         UNUSED_BRACES
     }
index 00ecc7a7a0aa1b7c3da43ec8c135a310eaa2f431..af0f7efc3e3548ad9781708d3c391c79377f6126 100644 (file)
@@ -5,13 +5,15 @@
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_index::vec::IndexVec;
 use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
+use smallvec::SmallVec;
 use std::iter;
 use std::ops::{Deref, DerefMut, Index, IndexMut};
 use std::vec::IntoIter;
 
 #[derive(Clone, Debug)]
 pub struct Cache {
-    predecessors: Option<IndexVec<BasicBlock, Vec<BasicBlock>>>,
+    // Typically 95%+ of the inner vectors have 4 or fewer elements.
+    predecessors: Option<IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>>,
 }
 
 impl rustc_serialize::Encodable for Cache {
@@ -44,7 +46,7 @@ pub fn invalidate_predecessors(&mut self) {
 
     pub fn ensure_predecessors(&mut self, body: &Body<'_>) {
         if self.predecessors.is_none() {
-            let mut result = IndexVec::from_elem(vec![], body.basic_blocks());
+            let mut result = IndexVec::from_elem(smallvec![], body.basic_blocks());
             for (bb, data) in body.basic_blocks().iter_enumerated() {
                 if let Some(ref term) = data.terminator {
                     for &tgt in term.successors() {
@@ -58,7 +60,11 @@ pub fn ensure_predecessors(&mut self, body: &Body<'_>) {
     }
 
     /// This will recompute the predecessors cache if it is not available
-    fn predecessors(&mut self, body: &Body<'_>) -> &IndexVec<BasicBlock, Vec<BasicBlock>> {
+    // njn: typedef?
+    fn predecessors(
+        &mut self,
+        body: &Body<'_>,
+    ) -> &IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>> {
         self.ensure_predecessors(body);
         self.predecessors.as_ref().unwrap()
     }
@@ -137,7 +143,7 @@ pub fn ensure_predecessors(&mut self) {
         self.cache.ensure_predecessors(&self.body);
     }
 
-    pub fn predecessors(&mut self) -> &IndexVec<BasicBlock, Vec<BasicBlock>> {
+    pub fn predecessors(&mut self) -> &IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>> {
         self.cache.predecessors(&self.body)
     }
 
@@ -199,7 +205,7 @@ fn new(body: &'a Body<'tcx>, cache: &'a Cache) -> Self {
         Self { body, cache }
     }
 
-    pub fn predecessors(&self) -> &IndexVec<BasicBlock, Vec<BasicBlock>> {
+    pub fn predecessors(&self) -> &IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>> {
         self.cache.predecessors.as_ref().unwrap()
     }
 
index 076134b8e9462c630cb61459331d40d084ff277a..b336a30e3d338fa2f7f9ff9872682ca203fc7ac0 100644 (file)
@@ -1162,17 +1162,17 @@ pub fn create_global_ctxt(
             maybe_unused_trait_imports: resolutions
                 .maybe_unused_trait_imports
                 .into_iter()
-                .map(|id| definitions.local_def_id(id))
+                .map(|id| definitions.local_def_id(id).to_def_id())
                 .collect(),
             maybe_unused_extern_crates: resolutions
                 .maybe_unused_extern_crates
                 .into_iter()
-                .map(|(id, sp)| (definitions.local_def_id(id), sp))
+                .map(|(id, sp)| (definitions.local_def_id(id).to_def_id(), sp))
                 .collect(),
             glob_map: resolutions
                 .glob_map
                 .into_iter()
-                .map(|(id, names)| (definitions.local_def_id(id), names))
+                .map(|(id, names)| (definitions.local_def_id(id).to_def_id(), names))
                 .collect(),
             extern_prelude: resolutions.extern_prelude,
             untracked_crate: krate,
@@ -2065,10 +2065,6 @@ pub fn $method(self, v: $ty) -> &'tcx $ty {
     }
 }
 
-pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
-    x.has_type_flags(ty::TypeFlags::KEEP_IN_LOCAL_TCX)
-}
-
 direct_interners!(
     region: mk_region(RegionKind),
     goal: mk_goal(GoalKind<'tcx>),
index 4bf08096edeb8e589f25ee24760bbf721ffd9bbf..ba165925b64747b2b3e15a027e8902199b149c3c 100644 (file)
@@ -40,7 +40,7 @@ fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
     }
 
     fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
-        if ty.has_local_value() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
+        if ty.needs_infer() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
     }
 
     fn fold_binder<T>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T>
index 99a6511b297acff58ac56216f88666edf735de9c..172f6d4608b1f428b632d30d174aab85cb8418e2 100644 (file)
@@ -28,7 +28,7 @@ pub fn for_const(c: &ty::Const<'_>) -> TypeFlags {
     }
 
     fn add_flags(&mut self, flags: TypeFlags) {
-        self.flags = self.flags | (flags & TypeFlags::NOMINAL_FLAGS);
+        self.flags = self.flags | flags;
     }
 
     /// indicates that `self` refers to something at binding level `binder`
@@ -109,13 +109,12 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
             }
 
             &ty::Infer(infer) => {
-                self.add_flags(TypeFlags::HAS_TY_INFER);
                 self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
                 match infer {
                     ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {}
 
                     ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => {
-                        self.add_flags(TypeFlags::KEEP_IN_LOCAL_TCX)
+                        self.add_flags(TypeFlags::HAS_TY_INFER)
                     }
                 }
             }
@@ -221,11 +220,10 @@ fn add_const(&mut self, c: &ty::Const<'_>) {
                 self.add_flags(TypeFlags::HAS_CT_PROJECTION);
             }
             ty::ConstKind::Infer(infer) => {
-                self.add_flags(TypeFlags::HAS_CT_INFER);
                 self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
                 match infer {
                     InferConst::Fresh(_) => {}
-                    InferConst::Var(_) => self.add_flags(TypeFlags::KEEP_IN_LOCAL_TCX),
+                    InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER),
                 }
             }
             ty::ConstKind::Bound(debruijn, _) => {
index 7b23460eb6e4c06e8797b817f26bce7d3b017b46..d144e507691ce1695c87f7366fa58eb5cee0c7ce 100644 (file)
@@ -84,7 +84,7 @@ fn has_opaque_types(&self) -> bool {
     fn references_error(&self) -> bool {
         self.has_type_flags(TypeFlags::HAS_TY_ERR)
     }
-    fn has_param_types(&self) -> bool {
+    fn has_param_types_or_consts(&self) -> bool {
         self.has_type_flags(TypeFlags::HAS_TY_PARAM | TypeFlags::HAS_CT_PARAM)
     }
     fn has_infer_types(&self) -> bool {
@@ -96,9 +96,6 @@ fn has_infer_types_or_consts(&self) -> bool {
     fn has_infer_consts(&self) -> bool {
         self.has_type_flags(TypeFlags::HAS_CT_INFER)
     }
-    fn has_local_value(&self) -> bool {
-        self.has_type_flags(TypeFlags::KEEP_IN_LOCAL_TCX)
-    }
     fn needs_infer(&self) -> bool {
         self.has_type_flags(TypeFlags::NEEDS_INFER)
     }
index cf0222370f288f2871cb713732a9f8709fec5567..894f9070ce1549ec4bd2f8bf9017b5b59799a96d 100644 (file)
@@ -91,7 +91,7 @@ pub fn monomorphic_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
         // There shouldn't be any params - if there are, then
         // Instance.ty_env should have been used to provide the proper
         // ParamEnv
-        if self.substs.has_param_types() {
+        if self.substs.has_param_types_or_consts() {
             bug!("Instance.ty called for type {:?} with params in substs: {:?}", ty, self.substs);
         }
         tcx.subst_and_normalize_erasing_regions(self.substs, ty::ParamEnv::reveal_all(), &ty)
index 5740f8cc091c42c65568fcb564ce447059267cbd..1bb338d43ad0a4acf076fdbb22783060554443bc 100644 (file)
@@ -1585,7 +1585,7 @@ fn record_layout_for_printing_outlined(&self, layout: TyAndLayout<'tcx>) {
         // Ignore layouts that are done with non-empty environments or
         // non-monomorphic layouts, as the user only wants to see the stuff
         // resulting from the final codegen session.
-        if layout.ty.has_param_types() || !self.param_env.caller_bounds.is_empty() {
+        if layout.ty.has_param_types_or_consts() || !self.param_env.caller_bounds.is_empty() {
             return;
         }
 
@@ -1754,7 +1754,7 @@ pub fn compute(
                 let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
                 match tail.kind {
                     ty::Param(_) | ty::Projection(_) => {
-                        debug_assert!(tail.has_param_types());
+                        debug_assert!(tail.has_param_types_or_consts());
                         Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(&tail) })
                     }
                     _ => bug!(
index 3683ea3288feb10909c1260b72dc12939db67f7d..8dbf27b0ed872c85f0a7a3545f5c75da5d517e4e 100644 (file)
@@ -71,7 +71,7 @@
 pub use self::binding::BindingMode;
 pub use self::binding::BindingMode::*;
 
-pub use self::context::{keep_local, tls, FreeRegionInfo, TyCtxt};
+pub use self::context::{tls, FreeRegionInfo, TyCtxt};
 pub use self::context::{
     CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, ResolvedOpaqueTy,
     UserType, UserTypeAnnotationIndex,
@@ -577,50 +577,23 @@ pub struct TypeFlags: u32 {
                                           | TypeFlags::HAS_TY_OPAQUE.bits
                                           | TypeFlags::HAS_CT_PROJECTION.bits;
 
-        /// Present if the type belongs in a local type context.
-        /// Set for placeholders and inference variables that are not "Fresh".
-        const KEEP_IN_LOCAL_TCX           = 1 << 13;
-
         /// Is an error type reachable?
-        const HAS_TY_ERR                  = 1 << 14;
+        const HAS_TY_ERR                  = 1 << 13;
 
         /// Does this have any region that "appears free" in the type?
         /// Basically anything but [ReLateBound] and [ReErased].
-        const HAS_FREE_REGIONS            = 1 << 15;
+        const HAS_FREE_REGIONS            = 1 << 14;
 
         /// Does this have any [ReLateBound] regions? Used to check
         /// if a global bound is safe to evaluate.
-        const HAS_RE_LATE_BOUND           = 1 << 16;
+        const HAS_RE_LATE_BOUND           = 1 << 15;
 
         /// Does this have any [ReErased] regions?
-        const HAS_RE_ERASED               = 1 << 17;
+        const HAS_RE_ERASED               = 1 << 16;
 
         /// Does this value have parameters/placeholders/inference variables which could be
         /// replaced later, in a way that would change the results of `impl` specialization?
-        const STILL_FURTHER_SPECIALIZABLE = 1 << 18;
-
-        /// Flags representing the nominal content of a type,
-        /// computed by FlagsComputation. If you add a new nominal
-        /// flag, it should be added here too.
-        const NOMINAL_FLAGS               = TypeFlags::HAS_TY_PARAM.bits
-                                          | TypeFlags::HAS_RE_PARAM.bits
-                                          | TypeFlags::HAS_CT_PARAM.bits
-                                          | TypeFlags::HAS_TY_INFER.bits
-                                          | TypeFlags::HAS_RE_INFER.bits
-                                          | TypeFlags::HAS_CT_INFER.bits
-                                          | TypeFlags::HAS_TY_PLACEHOLDER.bits
-                                          | TypeFlags::HAS_RE_PLACEHOLDER.bits
-                                          | TypeFlags::HAS_CT_PLACEHOLDER.bits
-                                          | TypeFlags::HAS_FREE_LOCAL_REGIONS.bits
-                                          | TypeFlags::HAS_TY_PROJECTION.bits
-                                          | TypeFlags::HAS_TY_OPAQUE.bits
-                                          | TypeFlags::HAS_CT_PROJECTION.bits
-                                          | TypeFlags::KEEP_IN_LOCAL_TCX.bits
-                                          | TypeFlags::HAS_TY_ERR.bits
-                                          | TypeFlags::HAS_FREE_REGIONS.bits
-                                          | TypeFlags::HAS_RE_LATE_BOUND.bits
-                                          | TypeFlags::HAS_RE_ERASED.bits
-                                          | TypeFlags::STILL_FURTHER_SPECIALIZABLE.bits;
+        const STILL_FURTHER_SPECIALIZABLE = 1 << 17;
     }
 }
 
index 5ff77d073d388bd7c7c01306d82fd0be6f397502..4d668e6ee59777810c1e1aa7154d595bed6baa4c 100644 (file)
@@ -510,7 +510,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
     let tcx = relation.tcx();
 
     let eagerly_eval = |x: &'tcx ty::Const<'tcx>| {
-        if !x.val.has_local_value() {
+        if !x.val.needs_infer() {
             return x.eval(tcx, relation.param_env()).val;
         }
         x.val
index fbd5049b0fbcb6789abeaa64ae463f736e04fa90..081e6f06b331155b01e8909e20b83dcc1ecaedbb 100644 (file)
@@ -1605,7 +1605,6 @@ pub fn type_flags(&self) -> TypeFlags {
                 flags = flags | TypeFlags::HAS_FREE_REGIONS;
                 flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
                 flags = flags | TypeFlags::HAS_RE_INFER;
-                flags = flags | TypeFlags::KEEP_IN_LOCAL_TCX;
                 flags = flags | TypeFlags::STILL_FURTHER_SPECIALIZABLE;
             }
             ty::RePlaceholder(..) => {
@@ -2343,8 +2342,8 @@ pub fn eval(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> &Const<'tcx>
         let try_const_eval = |did, param_env: ParamEnv<'tcx>, substs, promoted| {
             let param_env_and_substs = param_env.with_reveal_all().and(substs);
 
-            // Avoid querying `tcx.const_eval(...)` with any e.g. inference vars.
-            if param_env_and_substs.has_local_value() {
+            // Avoid querying `tcx.const_eval(...)` with any inference vars.
+            if param_env_and_substs.needs_infer() {
                 return None;
             }
 
@@ -2359,12 +2358,12 @@ pub fn eval(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> &Const<'tcx>
 
         match self.val {
             ConstKind::Unevaluated(did, substs, promoted) => {
-                // HACK(eddyb) when substs contain e.g. inference variables,
+                // HACK(eddyb) when substs contain inference variables,
                 // attempt using identity substs instead, that will succeed
                 // when the expression doesn't depend on any parameters.
                 // FIXME(eddyb, skinny121) pass `InferCtxt` into here when it's available, so that
                 // we can call `infcx.const_eval_resolve` which handles inference variables.
-                if substs.has_local_value() {
+                if substs.needs_infer() {
                     let identity_substs = InternalSubsts::identity_for_item(tcx, did);
                     // The `ParamEnv` needs to match the `identity_substs`.
                     let identity_param_env = tcx.param_env(did);
index 9df5760563129802b790870965b86e89c353529a..65561e224dbfdead3f285f67ff1e21e05e7cbb92 100644 (file)
@@ -760,47 +760,26 @@ pub(in crate::borrow_check) fn report_borrowed_value_does_not_live_long_enough(
             (
                 Some(ref name),
                 BorrowExplanation::MustBeValidFor {
-                    category: category @ ConstraintCategory::Return,
+                    category:
+                        category
+                        @
+                        (ConstraintCategory::Return
+                        | ConstraintCategory::CallArgument
+                        | ConstraintCategory::OpaqueType),
                     from_closure: false,
                     ref region_name,
                     span,
                     ..
                 },
-            )
-            | (
-                Some(ref name),
-                BorrowExplanation::MustBeValidFor {
-                    category: category @ ConstraintCategory::CallArgument,
-                    from_closure: false,
-                    ref region_name,
-                    span,
-                    ..
-                },
-            ) if borrow_spans.for_closure() => self.report_escaping_closure_capture(
-                borrow_spans,
-                borrow_span,
-                region_name,
-                category,
-                span,
-                &format!("`{}`", name),
-            ),
-            (
-                Some(ref name),
-                BorrowExplanation::MustBeValidFor {
-                    category: category @ ConstraintCategory::OpaqueType,
-                    from_closure: false,
-                    ref region_name,
+            ) if borrow_spans.for_generator() | borrow_spans.for_closure() => self
+                .report_escaping_closure_capture(
+                    borrow_spans,
+                    borrow_span,
+                    region_name,
+                    category,
                     span,
-                    ..
-                },
-            ) if borrow_spans.for_generator() => self.report_escaping_closure_capture(
-                borrow_spans,
-                borrow_span,
-                region_name,
-                category,
-                span,
-                &format!("`{}`", name),
-            ),
+                    &format!("`{}`", name),
+                ),
             (
                 ref name,
                 BorrowExplanation::MustBeValidFor {
@@ -1187,7 +1166,6 @@ fn report_escaping_closure_capture(
     ) -> DiagnosticBuilder<'cx> {
         let tcx = self.infcx.tcx;
         let args_span = use_span.args_or_use();
-        let mut err = self.cannot_capture_in_long_lived_closure(args_span, captured_var, var_span);
 
         let suggestion = match tcx.sess.source_map().span_to_snippet(args_span) {
             Ok(mut string) => {
@@ -1213,6 +1191,9 @@ fn report_escaping_closure_capture(
             },
             None => "closure",
         };
+
+        let mut err =
+            self.cannot_capture_in_long_lived_closure(args_span, kind, captured_var, var_span);
         err.span_suggestion(
             args_span,
             &format!(
@@ -1225,8 +1206,9 @@ fn report_escaping_closure_capture(
         );
 
         let msg = match category {
-            ConstraintCategory::Return => "closure is returned here".to_string(),
-            ConstraintCategory::OpaqueType => "generator is returned here".to_string(),
+            ConstraintCategory::Return | ConstraintCategory::OpaqueType => {
+                format!("{} is returned here", kind)
+            }
             ConstraintCategory::CallArgument => {
                 fr_name.highlight_region_name(&mut err);
                 format!("function requires argument type to outlive `{}`", fr_name)
index 303f43b0ee210c558de521fdcb547e210461ad18..400121166335f6f8122b3190e1315d691684fccc 100644 (file)
@@ -995,15 +995,15 @@ fn try_promote_type_test_subject(
                 self.definitions[upper_bound].external_name.unwrap_or(r)
             } else {
                 // In the case of a failure, use a `ReVar` result. This will
-                // cause the `has_local_value` later on to return `None`.
+                // cause the `needs_infer` later on to return `None`.
                 r
             }
         });
 
         debug!("try_promote_type_test_subject: folded ty = {:?}", ty);
 
-        // `has_local_value` will only be true if we failed to promote some region.
-        if ty.has_local_value() {
+        // `needs_infer` will only be true if we failed to promote some region.
+        if ty.needs_infer() {
             return None;
         }
 
index 3dfcfe16fb51493e5f51fd32345c59e0623fd528..cc63f5f39d53cf85b8432dbf60be31ce41a40c29 100644 (file)
@@ -2,12 +2,21 @@
 
 use crate::dataflow::BottomValue;
 use crate::dataflow::{self, GenKill, Results, ResultsRefCursor};
+use crate::util::storage::AlwaysLiveLocals;
 use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
 use rustc_middle::mir::*;
 use std::cell::RefCell;
 
-#[derive(Copy, Clone)]
-pub struct MaybeStorageLive;
+#[derive(Clone)]
+pub struct MaybeStorageLive {
+    always_live_locals: AlwaysLiveLocals,
+}
+
+impl MaybeStorageLive {
+    pub fn new(always_live_locals: AlwaysLiveLocals) -> Self {
+        MaybeStorageLive { always_live_locals }
+    }
+}
 
 impl dataflow::AnalysisDomain<'tcx> for MaybeStorageLive {
     type Idx = Local;
@@ -19,9 +28,12 @@ fn bits_per_block(&self, body: &mir::Body<'tcx>) -> usize {
     }
 
     fn initialize_start_block(&self, body: &mir::Body<'tcx>, on_entry: &mut BitSet<Self::Idx>) {
-        // The resume argument is live on function entry (we don't care about
-        // the `self` argument)
-        for arg in body.args_iter().skip(1) {
+        assert_eq!(body.local_decls.len(), self.always_live_locals.domain_size());
+        for local in self.always_live_locals.iter() {
+            on_entry.insert(local);
+        }
+
+        for arg in body.args_iter() {
             on_entry.insert(arg);
         }
     }
index 72d20644fe8b20303240fa1391431f99e1b0a305..e0b5f634bf3dfb38e4571bb76dbf1b22c0e8654e 100644 (file)
@@ -24,6 +24,7 @@
     Immediate, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, OpTy, Operand, Place, PlaceTy,
     ScalarMaybeUndef, StackPopJump,
 };
+use crate::util::storage::AlwaysLiveLocals;
 
 pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
     /// Stores the `Machine` instance.
@@ -610,17 +611,17 @@ pub fn push_stack_frame(
             // Now mark those locals as dead that we do not want to initialize
             match self.tcx.def_kind(instance.def_id()) {
                 // statics and constants don't have `Storage*` statements, no need to look for them
+                //
+                // FIXME: The above is likely untrue. See
+                // <https://github.com/rust-lang/rust/pull/70004#issuecomment-602022110>. Is it
+                // okay to ignore `StorageDead`/`StorageLive` annotations during CTFE?
                 Some(DefKind::Static) | Some(DefKind::Const) | Some(DefKind::AssocConst) => {}
                 _ => {
-                    for block in body.basic_blocks() {
-                        for stmt in block.statements.iter() {
-                            use rustc_middle::mir::StatementKind::{StorageDead, StorageLive};
-                            match stmt.kind {
-                                StorageLive(local) | StorageDead(local) => {
-                                    locals[local].value = LocalValue::Dead;
-                                }
-                                _ => {}
-                            }
+                    // Mark locals that use `Storage*` annotations as dead on function entry.
+                    let always_live = AlwaysLiveLocals::new(self.body());
+                    for local in locals.indices() {
+                        if !always_live.contains(local) {
+                            locals[local].value = LocalValue::Dead;
                         }
                     }
                 }
index e07b8535b9009e0fd153c1a1334d1c52f5bb3376..07822f865d2bd545370d245ec2dc7e41366571e0 100644 (file)
@@ -25,6 +25,7 @@
 #![feature(stmt_expr_attributes)]
 #![feature(trait_alias)]
 #![feature(option_expect_none)]
+#![feature(or_patterns)]
 #![recursion_limit = "256"]
 
 #[macro_use]
index 53eec1f6dc3dec62af38fe1d2f0cdecb4c3d5882..d25fd8ebb0c2bea75c73acac407a88ff3071539b 100644 (file)
 use crate::transform::{MirPass, MirSource};
 use crate::util::dump_mir;
 use crate::util::liveness;
+use crate::util::storage;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
 use rustc_index::bit_set::{BitMatrix, BitSet};
 use rustc_index::vec::{Idx, IndexVec};
-use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
+use rustc_middle::mir::visit::{MutVisitor, PlaceContext};
 use rustc_middle::mir::*;
 use rustc_middle::ty::subst::SubstsRef;
 use rustc_middle::ty::GeneratorSubsts;
@@ -222,6 +223,9 @@ struct TransformVisitor<'tcx> {
     // A list of suspension points, generated during the transform
     suspension_points: Vec<SuspensionPoint<'tcx>>,
 
+    // The set of locals that have no `StorageLive`/`StorageDead` annotations.
+    always_live_locals: storage::AlwaysLiveLocals,
+
     // The original RETURN_PLACE local
     new_ret_local: Local,
 }
@@ -416,19 +420,6 @@ fn replace_local<'tcx>(
     new_local
 }
 
-struct StorageIgnored(liveness::LiveVarSet);
-
-impl<'tcx> Visitor<'tcx> for StorageIgnored {
-    fn visit_statement(&mut self, statement: &Statement<'tcx>, _location: Location) {
-        match statement.kind {
-            StatementKind::StorageLive(l) | StatementKind::StorageDead(l) => {
-                self.0.remove(l);
-            }
-            _ => (),
-        }
-    }
-}
-
 struct LivenessInfo {
     /// Which locals are live across any suspension point.
     ///
@@ -454,6 +445,7 @@ fn locals_live_across_suspend_points(
     tcx: TyCtxt<'tcx>,
     body: ReadOnlyBodyAndCache<'_, 'tcx>,
     source: MirSource<'tcx>,
+    always_live_locals: &storage::AlwaysLiveLocals,
     movable: bool,
 ) -> LivenessInfo {
     let def_id = source.def_id();
@@ -461,16 +453,11 @@ fn locals_live_across_suspend_points(
 
     // Calculate when MIR locals have live storage. This gives us an upper bound of their
     // lifetimes.
-    let mut storage_live = MaybeStorageLive
+    let mut storage_live = MaybeStorageLive::new(always_live_locals.clone())
         .into_engine(tcx, body_ref, def_id)
         .iterate_to_fixpoint()
         .into_results_cursor(body_ref);
 
-    // Find the MIR locals which do not use StorageLive/StorageDead statements.
-    // The storage of these locals are always live.
-    let mut ignored = StorageIgnored(BitSet::new_filled(body.local_decls.len()));
-    ignored.visit_body(&body);
-
     // Calculate the MIR locals which have been previously
     // borrowed (even if they are still active).
     let borrowed_locals_results =
@@ -515,11 +502,14 @@ fn locals_live_across_suspend_points(
             }
 
             storage_live.seek_before(loc);
-            let storage_liveness = storage_live.get();
+            let mut storage_liveness = storage_live.get().clone();
+
+            // Later passes handle the generator's `self` argument separately.
+            storage_liveness.remove(SELF_ARG);
 
             // Store the storage liveness for later use so we can restore the state
             // after a suspension point
-            storage_liveness_map.insert(block, storage_liveness.clone());
+            storage_liveness_map.insert(block, storage_liveness);
 
             requires_storage_cursor.seek_before(loc);
             let storage_required = requires_storage_cursor.get().clone();
@@ -551,8 +541,12 @@ fn locals_live_across_suspend_points(
         .map(|live_here| renumber_bitset(&live_here, &live_locals))
         .collect();
 
-    let storage_conflicts =
-        compute_storage_conflicts(body_ref, &live_locals, &ignored, requires_storage_results);
+    let storage_conflicts = compute_storage_conflicts(
+        body_ref,
+        &live_locals,
+        always_live_locals.clone(),
+        requires_storage_results,
+    );
 
     LivenessInfo {
         live_locals,
@@ -590,18 +584,18 @@ fn renumber_bitset(
 fn compute_storage_conflicts(
     body: &'mir Body<'tcx>,
     stored_locals: &liveness::LiveVarSet,
-    ignored: &StorageIgnored,
+    always_live_locals: storage::AlwaysLiveLocals,
     requires_storage: dataflow::Results<'tcx, MaybeRequiresStorage<'mir, 'tcx>>,
 ) -> BitMatrix<GeneratorSavedLocal, GeneratorSavedLocal> {
-    assert_eq!(body.local_decls.len(), ignored.0.domain_size());
     assert_eq!(body.local_decls.len(), stored_locals.domain_size());
+
     debug!("compute_storage_conflicts({:?})", body.span);
-    debug!("ignored = {:?}", ignored.0);
+    debug!("always_live = {:?}", always_live_locals);
 
-    // Storage ignored locals are not eligible for overlap, since their storage
-    // is always live.
-    let mut ineligible_locals = ignored.0.clone();
-    ineligible_locals.intersect(&stored_locals);
+    // Locals that are always live or ones that need to be stored across
+    // suspension points are not eligible for overlap.
+    let mut ineligible_locals = always_live_locals.into_inner();
+    ineligible_locals.intersect(stored_locals);
 
     // Compute the storage conflicts for all eligible locals.
     let mut visitor = StorageConflictVisitor {
@@ -697,6 +691,7 @@ fn compute_layout<'tcx>(
     source: MirSource<'tcx>,
     upvars: &Vec<Ty<'tcx>>,
     interior: Ty<'tcx>,
+    always_live_locals: &storage::AlwaysLiveLocals,
     movable: bool,
     body: &mut BodyAndCache<'tcx>,
 ) -> (
@@ -710,7 +705,13 @@ fn compute_layout<'tcx>(
         live_locals_at_suspension_points,
         storage_conflicts,
         storage_liveness,
-    } = locals_live_across_suspend_points(tcx, read_only!(body), source, movable);
+    } = locals_live_across_suspend_points(
+        tcx,
+        read_only!(body),
+        source,
+        always_live_locals,
+        movable,
+    );
 
     // Erase regions from the types passed in from typeck so we can compare them with
     // MIR types
@@ -1180,7 +1181,10 @@ fn create_cases<'tcx>(
                     }
 
                     let l = Local::new(i);
-                    if point.storage_liveness.contains(l) && !transform.remap.contains_key(&l) {
+                    let needs_storage_live = point.storage_liveness.contains(l)
+                        && !transform.remap.contains_key(&l)
+                        && !transform.always_live_locals.contains(l);
+                    if needs_storage_live {
                         statements
                             .push(Statement { source_info, kind: StatementKind::StorageLive(l) });
                     }
@@ -1276,11 +1280,13 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut BodyAn
             },
         );
 
+        let always_live_locals = storage::AlwaysLiveLocals::new(&body);
+
         // Extract locals which are live across suspension point into `layout`
         // `remap` gives a mapping from local indices onto generator struct indices
         // `storage_liveness` tells us which locals have live storage at suspension points
         let (remap, layout, storage_liveness) =
-            compute_layout(tcx, source, &upvars, interior, movable, body);
+            compute_layout(tcx, source, &upvars, interior, &always_live_locals, movable, body);
 
         let can_return = can_return(tcx, body);
 
@@ -1294,6 +1300,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut BodyAn
             state_substs,
             remap,
             storage_liveness,
+            always_live_locals,
             suspension_points: Vec::new(),
             new_ret_local,
             discr_ty,
index 808dd833774e42567fd0b7cf078ac96c0221f612..f8bb7e7a85d1117356715ccd170ea256609c6cc0 100644 (file)
@@ -431,6 +431,7 @@ impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> {
     crate fn cannot_capture_in_long_lived_closure(
         &self,
         closure_span: Span,
+        closure_kind: &str,
         borrowed_path: &str,
         capture_span: Span,
     ) -> DiagnosticBuilder<'cx> {
@@ -438,9 +439,10 @@ impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> {
             self,
             closure_span,
             E0373,
-            "closure may outlive the current function, \
+            "{} may outlive the current function, \
              but it borrows {}, \
              which is owned by the current function",
+            closure_kind,
             borrowed_path,
         );
         err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))
index bb9d168d9193a689d7de30fb9cb5853c45dab911..3e501193e8dc4b97d8c80279d3059c27eab7eec1 100644 (file)
@@ -3,6 +3,7 @@
 pub mod def_use;
 pub mod elaborate_drops;
 pub mod patch;
+pub mod storage;
 
 mod alignment;
 pub mod collect_writes;
diff --git a/src/librustc_mir/util/storage.rs b/src/librustc_mir/util/storage.rs
new file mode 100644 (file)
index 0000000..0b7b1c2
--- /dev/null
@@ -0,0 +1,47 @@
+use rustc_index::bit_set::BitSet;
+use rustc_middle::mir::visit::Visitor;
+use rustc_middle::mir::{self, Local, Location};
+
+/// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
+///
+/// These locals have fixed storage for the duration of the body.
+//
+// FIXME: Currently, we need to traverse the entire MIR to compute this. We should instead store it
+// as a field in the `LocalDecl` for each `Local`.
+#[derive(Debug, Clone)]
+pub struct AlwaysLiveLocals(BitSet<Local>);
+
+impl AlwaysLiveLocals {
+    pub fn new(body: &mir::Body<'tcx>) -> Self {
+        let mut ret = AlwaysLiveLocals(BitSet::new_filled(body.local_decls.len()));
+
+        let mut vis = StorageAnnotationVisitor(&mut ret);
+        vis.visit_body(body);
+
+        ret
+    }
+
+    pub fn into_inner(self) -> BitSet<Local> {
+        self.0
+    }
+}
+
+impl std::ops::Deref for AlwaysLiveLocals {
+    type Target = BitSet<Local>;
+
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+
+/// Removes locals that have `Storage*` annotations from `AlwaysLiveLocals`.
+struct StorageAnnotationVisitor<'a>(&'a mut AlwaysLiveLocals);
+
+impl Visitor<'tcx> for StorageAnnotationVisitor<'_> {
+    fn visit_statement(&mut self, statement: &mir::Statement<'tcx>, _location: Location) {
+        use mir::StatementKind::{StorageDead, StorageLive};
+        if let StorageLive(l) | StorageDead(l) = statement.kind {
+            (self.0).0.remove(l);
+        }
+    }
+}
index 04cb509d44e4b32b337a53640d969b04fd5f07f4..6e1a4ecf47a44e98ebb7f5cfb643aa041cf68653 100644 (file)
@@ -178,11 +178,11 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
             build::construct_const(cx, body_id, return_ty, return_ty_span)
         };
 
-        lints::check(tcx, &body, def_id);
-
         let mut body = BodyAndCache::new(body);
         body.ensure_predecessors();
 
+        lints::check(tcx, &body.unwrap_read_only(), def_id);
+
         // The borrow checker will replace all the regions here with its own
         // inference variables. There's no point having non-erased regions here.
         // The exception is `body.user_type_annotations`, which is used unmodified
index b1628ec58c3c65620beec2f568022608d51464f5..a7370c36f0b9f85b1b0efc039016b60ab68f1c36 100644 (file)
 use rustc_hir::def_id::DefId;
 use rustc_hir::intravisit::FnKind;
 use rustc_index::bit_set::BitSet;
+use rustc_index::vec::IndexVec;
 use rustc_middle::hir::map::blocks::FnLikeNode;
-use rustc_middle::mir::{self, Body, TerminatorKind};
+use rustc_middle::mir::{BasicBlock, Body, ReadOnlyBodyAndCache, TerminatorKind, START_BLOCK};
 use rustc_middle::ty::subst::InternalSubsts;
 use rustc_middle::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt};
 use rustc_session::lint::builtin::UNCONDITIONAL_RECURSION;
+use std::collections::VecDeque;
 
-crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId) {
+crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &ReadOnlyBodyAndCache<'_, 'tcx>, def_id: DefId) {
     let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
 
     if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir().get(hir_id)) {
-        check_fn_for_unconditional_recursion(tcx, fn_like_node.kind(), body, def_id);
+        if let FnKind::Closure(_) = fn_like_node.kind() {
+            // closures can't recur, so they don't matter.
+            return;
+        }
+
+        check_fn_for_unconditional_recursion(tcx, body, def_id);
     }
 }
 
 fn check_fn_for_unconditional_recursion<'tcx>(
     tcx: TyCtxt<'tcx>,
-    fn_kind: FnKind<'_>,
-    body: &Body<'tcx>,
+    body: &ReadOnlyBodyAndCache<'_, 'tcx>,
     def_id: DefId,
 ) {
-    if let FnKind::Closure(_) = fn_kind {
-        // closures can't recur, so they don't matter.
-        return;
-    }
+    let self_calls = find_blocks_calling_self(tcx, &body, def_id);
 
-    //FIXME(#54444) rewrite this lint to use the dataflow framework
-
-    // Walk through this function (say `f`) looking to see if
-    // every possible path references itself, i.e., the function is
-    // called recursively unconditionally. This is done by trying
-    // to find a path from the entry node to the exit node that
-    // *doesn't* call `f` by traversing from the entry while
-    // pretending that calls of `f` are sinks (i.e., ignoring any
-    // exit edges from them).
-    //
-    // NB. this has an edge case with non-returning statements,
-    // like `loop {}` or `panic!()`: control flow never reaches
-    // the exit node through these, so one can have a function
-    // that never actually calls itself but is still picked up by
-    // this lint:
-    //
-    //     fn f(cond: bool) {
-    //         if !cond { panic!() } // could come from `assert!(cond)`
-    //         f(false)
-    //     }
-    //
-    // In general, functions of that form may be able to call
-    // itself a finite number of times and then diverge. The lint
-    // considers this to be an error for two reasons, (a) it is
-    // easier to implement, and (b) it seems rare to actually want
-    // to have behaviour like the above, rather than
-    // e.g., accidentally recursing after an assert.
-
-    let basic_blocks = body.basic_blocks();
-    let mut reachable_without_self_call_queue = vec![mir::START_BLOCK];
-    let mut reached_exit_without_self_call = false;
-    let mut self_call_locations = vec![];
-    let mut visited = BitSet::new_empty(basic_blocks.len());
+    // Stores a list of `Span`s for every basic block. Those are the spans of self-calls where we
+    // know that one of them will definitely be reached. If the list is empty, the block either
+    // wasn't processed yet or will not always go to a self-call.
+    let mut results = IndexVec::from_elem_n(vec![], body.basic_blocks().len());
 
-    let param_env = tcx.param_env(def_id);
-    let trait_substs_count = match tcx.opt_associated_item(def_id) {
-        Some(AssocItem { container: AssocItemContainer::TraitContainer(trait_def_id), .. }) => {
-            tcx.generics_of(trait_def_id).count()
-        }
-        _ => 0,
-    };
-    let caller_substs = &InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count];
+    // We start the analysis at the self calls and work backwards.
+    let mut queue: VecDeque<_> = self_calls.iter().collect();
 
-    while let Some(bb) = reachable_without_self_call_queue.pop() {
-        if !visited.insert(bb) {
-            //already done
+    while let Some(bb) = queue.pop_front() {
+        if !results[bb].is_empty() {
+            // Already propagated.
             continue;
         }
 
-        let block = &basic_blocks[bb];
-
-        if let Some(ref terminator) = block.terminator {
-            match terminator.kind {
-                TerminatorKind::Call { ref func, .. } => {
-                    let func_ty = func.ty(body, tcx);
-
-                    if let ty::FnDef(fn_def_id, substs) = func_ty.kind {
-                        let (call_fn_id, call_substs) = if let Some(instance) =
-                            Instance::resolve(tcx, param_env, fn_def_id, substs)
-                        {
-                            (instance.def_id(), instance.substs)
-                        } else {
-                            (fn_def_id, substs)
-                        };
-
-                        let is_self_call = call_fn_id == def_id
-                            && &call_substs[..caller_substs.len()] == caller_substs;
-
-                        if is_self_call {
-                            self_call_locations.push(terminator.source_info);
-
-                            //this is a self call so we shouldn't explore
-                            //further down this path
-                            continue;
-                        }
-                    }
+        let locations = if self_calls.contains(bb) {
+            // `bb` *is* a self-call.
+            // We don't look at successors here because they are irrelevant here and we don't want
+            // to lint them (eg. `f(); f()` should only lint the first call).
+            vec![bb]
+        } else {
+            // If *all* successors of `bb` lead to a self-call, emit notes at all of their
+            // locations.
+
+            // Determine all "relevant" successors. We ignore successors only reached via unwinding.
+            let terminator = body[bb].terminator();
+            let relevant_successors = match &terminator.kind {
+                TerminatorKind::Call { destination: None, .. }
+                | TerminatorKind::Yield { .. }
+                | TerminatorKind::GeneratorDrop => None.into_iter().chain(&[]),
+                TerminatorKind::SwitchInt { targets, .. } => None.into_iter().chain(targets),
+                TerminatorKind::Goto { target }
+                | TerminatorKind::Drop { target, .. }
+                | TerminatorKind::DropAndReplace { target, .. }
+                | TerminatorKind::Assert { target, .. }
+                | TerminatorKind::FalseEdges { real_target: target, .. }
+                | TerminatorKind::FalseUnwind { real_target: target, .. }
+                | TerminatorKind::Call { destination: Some((_, target)), .. } => {
+                    Some(target).into_iter().chain(&[])
                 }
-                TerminatorKind::Abort | TerminatorKind::Return => {
-                    //found a path!
-                    reached_exit_without_self_call = true;
-                    break;
+                TerminatorKind::Resume
+                | TerminatorKind::Abort
+                | TerminatorKind::Return
+                | TerminatorKind::Unreachable => {
+                    // We propagate backwards, so these should never be encountered here.
+                    unreachable!("unexpected terminator {:?}", terminator.kind)
                 }
-                _ => {}
+            };
+
+            // If all our successors are known to lead to self-calls, then we do too.
+            let all_are_self_calls =
+                relevant_successors.clone().all(|&succ| !results[succ].is_empty());
+
+            if all_are_self_calls {
+                // We'll definitely lead to a self-call. Merge all call locations of the successors
+                // for linting them later.
+                relevant_successors.flat_map(|&succ| results[succ].iter().copied()).collect()
+            } else {
+                // At least 1 successor does not always lead to a self-call, so we also don't.
+                vec![]
             }
+        };
 
-            for successor in terminator.successors() {
-                reachable_without_self_call_queue.push(*successor);
-            }
+        if !locations.is_empty() {
+            // This is a newly confirmed-to-always-reach-self-call block.
+            results[bb] = locations;
+
+            // Propagate backwards through the CFG.
+            debug!("propagate loc={:?} in {:?} -> {:?}", results[bb], bb, body.predecessors()[bb]);
+            queue.extend(body.predecessors()[bb].iter().copied());
         }
     }
 
-    // Check the number of self calls because a function that
-    // doesn't return (e.g., calls a `-> !` function or `loop { /*
-    // no break */ }`) shouldn't be linted unless it actually
-    // recurs.
-    if !reached_exit_without_self_call && !self_call_locations.is_empty() {
+    debug!("unconditional recursion results: {:?}", results);
+
+    let self_call_locations = &mut results[START_BLOCK];
+    self_call_locations.sort();
+    self_call_locations.dedup();
+
+    if !self_call_locations.is_empty() {
         let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
         let sp = tcx.sess.source_map().guess_head_span(tcx.hir().span(hir_id));
         tcx.struct_span_lint_hir(UNCONDITIONAL_RECURSION, hir_id, sp, |lint| {
             let mut db = lint.build("function cannot return without recursing");
             db.span_label(sp, "cannot return without recursing");
             // offer some help to the programmer.
-            for location in &self_call_locations {
-                db.span_label(location.span, "recursive call site");
+            for bb in self_call_locations {
+                let span = body.basic_blocks()[*bb].terminator().source_info.span;
+                db.span_label(span, "recursive call site");
             }
             db.help("a `loop` may express intention better if this is on purpose");
             db.emit();
         });
     }
 }
+
+/// Finds blocks with `Call` terminators that would end up calling back into the same method.
+fn find_blocks_calling_self<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    body: &Body<'tcx>,
+    def_id: DefId,
+) -> BitSet<BasicBlock> {
+    let param_env = tcx.param_env(def_id);
+
+    // If this is trait/impl method, extract the trait's substs.
+    let trait_substs_count = match tcx.opt_associated_item(def_id) {
+        Some(AssocItem { container: AssocItemContainer::TraitContainer(trait_def_id), .. }) => {
+            tcx.generics_of(trait_def_id).count()
+        }
+        _ => 0,
+    };
+    let trait_substs = &InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count];
+
+    let mut self_calls = BitSet::new_empty(body.basic_blocks().len());
+
+    for (bb, data) in body.basic_blocks().iter_enumerated() {
+        if let TerminatorKind::Call { func, .. } = &data.terminator().kind {
+            let func_ty = func.ty(body, tcx);
+
+            if let ty::FnDef(fn_def_id, substs) = func_ty.kind {
+                let (call_fn_id, call_substs) =
+                    if let Some(instance) = Instance::resolve(tcx, param_env, fn_def_id, substs) {
+                        (instance.def_id(), instance.substs)
+                    } else {
+                        (fn_def_id, substs)
+                    };
+
+                // FIXME(#57965): Make this work across function boundaries
+
+                // If this is a trait fn, the substs on the trait have to match, or we might be
+                // calling into an entirely different method (for example, a call from the default
+                // method in the trait to `<A as Trait<B>>::method`, where `A` and/or `B` are
+                // specific types).
+                let is_self_call =
+                    call_fn_id == def_id && &call_substs[..trait_substs.len()] == trait_substs;
+
+                if is_self_call {
+                    self_calls.insert(bb);
+                }
+            }
+        }
+    }
+
+    self_calls
+}
index 619a8c6f229b3b7f1202ea346b22584a30eb0607..3f2c02f6c461bb96887a08af0097d4501c90a4d0 100644 (file)
@@ -141,7 +141,7 @@ fn check_track_caller(
         target: Target,
     ) -> bool {
         match target {
-            Target::Fn if attr::contains_name(attrs, sym::naked) => {
+            _ if attr::contains_name(attrs, sym::naked) => {
                 struct_span_err!(
                     self.tcx.sess,
                     *attr_span,
@@ -151,17 +151,7 @@ fn check_track_caller(
                 .emit();
                 false
             }
-            Target::ForeignFn => {
-                struct_span_err!(
-                    self.tcx.sess,
-                    *attr_span,
-                    E0738,
-                    "`#[track_caller]` is not supported on foreign functions",
-                )
-                .emit();
-                false
-            }
-            Target::Fn | Target::Method(..) => true,
+            Target::Fn | Target::Method(..) | Target::ForeignFn => true,
             _ => {
                 struct_span_err!(
                     self.tcx.sess,
index 485480d020f5b9f6d3083684143ae25a47caec1c..4c02127c1066990ac3ef9867f495d94df5aba865 100644 (file)
@@ -717,9 +717,17 @@ fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
             self.cx.parent
         );
 
+        // Save all state that is specific to the outer function
+        // body. These will be restored once down below, once we've
+        // visited the body.
         let outer_ec = mem::replace(&mut self.expr_and_pat_count, 0);
         let outer_cx = self.cx;
         let outer_ts = mem::take(&mut self.terminating_scopes);
+        // The 'pessimistic yield' flag is set to true when we are
+        // processing a `+=` statement and have to make pessimistic
+        // control flow assumptions. This doesn't apply to nested
+        // bodies within the `+=` statements. See #69307.
+        let outer_pessimistic_yield = mem::replace(&mut self.pessimistic_yield, false);
         self.terminating_scopes.insert(body.value.hir_id.local_id);
 
         if let Some(root_id) = self.cx.root_id {
@@ -771,6 +779,7 @@ fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
         self.expr_and_pat_count = outer_ec;
         self.cx = outer_cx;
         self.terminating_scopes = outer_ts;
+        self.pessimistic_yield = outer_pessimistic_yield;
     }
 
     fn visit_arm(&mut self, a: &'tcx Arm<'tcx>) {
index 567022fe4052f453e24130a3be974147d75a5736..34470c2ded5f9440c92e822836a6f270748d771f 100644 (file)
@@ -1238,7 +1238,13 @@ fn visit_trait_ref(&mut self, trait_ref: &'tcx hir::TraitRef<'tcx>) {
         if !self.in_body {
             // Avoid calling `hir_trait_to_predicates` in bodies, it will ICE.
             // The traits' privacy in bodies is already checked as a part of trait object types.
-            let bounds = rustc_typeck::hir_trait_to_predicates(self.tcx, trait_ref);
+            let bounds = rustc_typeck::hir_trait_to_predicates(
+                self.tcx,
+                trait_ref,
+                // NOTE: This isn't really right, but the actual type doesn't matter here. It's
+                // just required by `ty::TraitRef`.
+                self.tcx.types.never,
+            );
 
             for (trait_predicate, _, _) in bounds.trait_bounds {
                 if self.visit_trait(*trait_predicate.skip_binder()) {
index 73983e1644cb01bb30e03898e3e36a98dd1da9cb..fa2b51058a3781380241e79f59e07b0d524e387f 100644 (file)
@@ -1112,6 +1112,7 @@ fn new(size: usize) -> DepNodeColorMap {
         DepNodeColorMap { values: (0..size).map(|_| AtomicU32::new(COMPRESSED_NONE)).collect() }
     }
 
+    #[inline]
     fn get(&self, index: SerializedDepNodeIndex) -> Option<DepNodeColor> {
         match self.values[index].load(Ordering::Acquire) {
             COMPRESSED_NONE => None,
index b371a914c6fce02304d26bd16c237862b4a91e7c..9da13f236643b72f13281a3e2461aa989f150c32 100644 (file)
@@ -51,6 +51,7 @@ pub struct QueryState<CTX: QueryContext, C: QueryCache> {
 }
 
 impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
+    #[inline]
     pub(super) fn get_lookup<'tcx>(
         &'tcx self,
         key: &C::Key,
index 51089f73c28144ed6fa5e270c7307079191fdfb3..0ad33f1a120c7a378fcf3d712466f861b2f1fb78 100644 (file)
@@ -26,7 +26,7 @@
 use rustc_expand::base::SyntaxExtension;
 use rustc_expand::expand::AstFragment;
 use rustc_hir::def::{self, *};
-use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
+use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
 use rustc_metadata::creader::LoadedMacro;
 use rustc_middle::bug;
 use rustc_middle::hir::exports::Export;
@@ -96,7 +96,7 @@ impl<'a> Resolver<'a> {
     }
 
     crate fn get_module(&mut self, def_id: DefId) -> Module<'a> {
-        if def_id.krate == LOCAL_CRATE {
+        if let Some(def_id) = def_id.as_local() {
             return self.module_map[&def_id];
         }
 
@@ -675,12 +675,18 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
 
             ItemKind::Mod(..) => {
                 let def_id = self.r.definitions.local_def_id(item.id);
-                let module_kind = ModuleKind::Def(DefKind::Mod, def_id, ident.name);
+                let module_kind = ModuleKind::Def(DefKind::Mod, def_id.to_def_id(), ident.name);
                 let module = self.r.arenas.alloc_module(ModuleData {
                     no_implicit_prelude: parent.no_implicit_prelude || {
                         attr::contains_name(&item.attrs, sym::no_implicit_prelude)
                     },
-                    ..ModuleData::new(Some(parent), module_kind, def_id, expansion, item.span)
+                    ..ModuleData::new(
+                        Some(parent),
+                        module_kind,
+                        def_id.to_def_id(),
+                        expansion,
+                        item.span,
+                    )
                 });
                 self.r.define(parent, ident, TypeNS, (module, vis, sp, expansion));
                 self.r.module_map.insert(def_id, module);
@@ -691,15 +697,18 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
 
             // These items live in the value namespace.
             ItemKind::Static(..) => {
-                let res = Res::Def(DefKind::Static, self.r.definitions.local_def_id(item.id));
+                let res =
+                    Res::Def(DefKind::Static, self.r.definitions.local_def_id(item.id).to_def_id());
                 self.r.define(parent, ident, ValueNS, (res, vis, sp, expansion));
             }
             ItemKind::Const(..) => {
-                let res = Res::Def(DefKind::Const, self.r.definitions.local_def_id(item.id));
+                let res =
+                    Res::Def(DefKind::Const, self.r.definitions.local_def_id(item.id).to_def_id());
                 self.r.define(parent, ident, ValueNS, (res, vis, sp, expansion));
             }
             ItemKind::Fn(..) => {
-                let res = Res::Def(DefKind::Fn, self.r.definitions.local_def_id(item.id));
+                let res =
+                    Res::Def(DefKind::Fn, self.r.definitions.local_def_id(item.id).to_def_id());
                 self.r.define(parent, ident, ValueNS, (res, vis, sp, expansion));
 
                 // Functions introducing procedural macros reserve a slot
@@ -713,12 +722,12 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
                     None => DefKind::TyAlias,
                     Some(_) => DefKind::OpaqueTy,
                 };
-                let res = Res::Def(def_kind, self.r.definitions.local_def_id(item.id));
+                let res = Res::Def(def_kind, self.r.definitions.local_def_id(item.id).to_def_id());
                 self.r.define(parent, ident, TypeNS, (res, vis, sp, expansion));
             }
 
             ItemKind::Enum(_, _) => {
-                let def_id = self.r.definitions.local_def_id(item.id);
+                let def_id = self.r.definitions.local_def_id(item.id).to_def_id();
                 self.r.variant_vis.insert(def_id, vis);
                 let module_kind = ModuleKind::Def(DefKind::Enum, def_id, ident.name);
                 let module = self.r.new_module(
@@ -733,14 +742,17 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
             }
 
             ItemKind::TraitAlias(..) => {
-                let res = Res::Def(DefKind::TraitAlias, self.r.definitions.local_def_id(item.id));
+                let res = Res::Def(
+                    DefKind::TraitAlias,
+                    self.r.definitions.local_def_id(item.id).to_def_id(),
+                );
                 self.r.define(parent, ident, TypeNS, (res, vis, sp, expansion));
             }
 
             // These items live in both the type and value namespaces.
             ItemKind::Struct(ref vdata, _) => {
                 // Define a name in the type namespace.
-                let def_id = self.r.definitions.local_def_id(item.id);
+                let def_id = self.r.definitions.local_def_id(item.id).to_def_id();
                 let res = Res::Def(DefKind::Struct, def_id);
                 self.r.define(parent, ident, TypeNS, (res, vis, sp, expansion));
 
@@ -773,7 +785,7 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
                     }
                     let ctor_res = Res::Def(
                         DefKind::Ctor(CtorOf::Struct, CtorKind::from_ast(vdata)),
-                        self.r.definitions.local_def_id(ctor_node_id),
+                        self.r.definitions.local_def_id(ctor_node_id).to_def_id(),
                     );
                     self.r.define(parent, ident, ValueNS, (ctor_res, ctor_vis, sp, expansion));
                     self.r.struct_constructors.insert(def_id, (ctor_res, ctor_vis));
@@ -781,7 +793,7 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
             }
 
             ItemKind::Union(ref vdata, _) => {
-                let def_id = self.r.definitions.local_def_id(item.id);
+                let def_id = self.r.definitions.local_def_id(item.id).to_def_id();
                 let res = Res::Def(DefKind::Union, def_id);
                 self.r.define(parent, ident, TypeNS, (res, vis, sp, expansion));
 
@@ -790,7 +802,7 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
             }
 
             ItemKind::Trait(..) => {
-                let def_id = self.r.definitions.local_def_id(item.id);
+                let def_id = self.r.definitions.local_def_id(item.id).to_def_id();
 
                 // Add all the items within to a new module.
                 let module_kind = ModuleKind::Def(DefKind::Trait, def_id, ident.name);
@@ -815,15 +827,18 @@ fn build_reduced_graph_for_item(&mut self, item: &'b Item) {
     /// Constructs the reduced graph for one foreign item.
     fn build_reduced_graph_for_foreign_item(&mut self, item: &ForeignItem) {
         let (res, ns) = match item.kind {
-            ForeignItemKind::Fn(..) => {
-                (Res::Def(DefKind::Fn, self.r.definitions.local_def_id(item.id)), ValueNS)
-            }
-            ForeignItemKind::Static(..) => {
-                (Res::Def(DefKind::Static, self.r.definitions.local_def_id(item.id)), ValueNS)
-            }
-            ForeignItemKind::TyAlias(..) => {
-                (Res::Def(DefKind::ForeignTy, self.r.definitions.local_def_id(item.id)), TypeNS)
-            }
+            ForeignItemKind::Fn(..) => (
+                Res::Def(DefKind::Fn, self.r.definitions.local_def_id(item.id).to_def_id()),
+                ValueNS,
+            ),
+            ForeignItemKind::Static(..) => (
+                Res::Def(DefKind::Static, self.r.definitions.local_def_id(item.id).to_def_id()),
+                ValueNS,
+            ),
+            ForeignItemKind::TyAlias(..) => (
+                Res::Def(DefKind::ForeignTy, self.r.definitions.local_def_id(item.id).to_def_id()),
+                TypeNS,
+            ),
             ForeignItemKind::MacCall(_) => unreachable!(),
         };
         let parent = self.parent_scope.module;
@@ -1121,7 +1136,7 @@ fn define_macro(&mut self, item: &ast::Item) -> MacroRulesScope<'a> {
             _ => unreachable!(),
         };
 
-        let def_id = self.r.definitions.local_def_id(item.id);
+        let def_id = self.r.definitions.local_def_id(item.id).to_def_id();
         let res = Res::Def(DefKind::Macro(ext.macro_kind()), def_id);
         self.r.macro_map.insert(def_id, ext);
         self.r.local_macro_def_scopes.insert(item.id, parent_scope.module);
@@ -1251,7 +1266,7 @@ fn visit_assoc_item(&mut self, item: &'b AssocItem, ctxt: AssocCtxt) {
         }
 
         // Add the item to the trait info.
-        let item_def_id = self.r.definitions.local_def_id(item.id);
+        let item_def_id = self.r.definitions.local_def_id(item.id).to_def_id();
         let (res, ns) = match item.kind {
             AssocItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
             AssocItemKind::Fn(_, ref sig, _, _) => {
@@ -1353,7 +1368,7 @@ fn visit_variant(&mut self, variant: &'b ast::Variant) {
         let ident = variant.ident;
 
         // Define a name in the type namespace.
-        let def_id = self.r.definitions.local_def_id(variant.id);
+        let def_id = self.r.definitions.local_def_id(variant.id).to_def_id();
         let res = Res::Def(DefKind::Variant, def_id);
         self.r.define(parent, ident, TypeNS, (res, vis, variant.span, expn_id));
 
@@ -1371,7 +1386,7 @@ fn visit_variant(&mut self, variant: &'b ast::Variant) {
         // It's ok to use the variant's id as a ctor id since an
         // error will be reported on any use of such resolution anyway.
         let ctor_node_id = variant.data.ctor_id().unwrap_or(variant.id);
-        let ctor_def_id = self.r.definitions.local_def_id(ctor_node_id);
+        let ctor_def_id = self.r.definitions.local_def_id(ctor_node_id).to_def_id();
         let ctor_kind = CtorKind::from_ast(&variant.data);
         let ctor_res = Res::Def(DefKind::Ctor(CtorOf::Variant, ctor_kind), ctor_def_id);
         self.r.define(parent, ident, ValueNS, (ctor_res, ctor_vis, variant.span, expn_id));
index 2b90527a825377bada77264b3f5e918aaa83aca0..c5f4cc3d39b74b2b96b6ef334ea772681f7095f9 100644 (file)
@@ -745,7 +745,7 @@ fn resolve_adt(&mut self, item: &'ast Item, generics: &'ast Generics) {
         debug!("resolve_adt");
         self.with_current_self_item(item, |this| {
             this.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
-                let item_def_id = this.r.definitions.local_def_id(item.id);
+                let item_def_id = this.r.definitions.local_def_id(item.id).to_def_id();
                 this.with_self_rib(Res::SelfTy(None, Some(item_def_id)), |this| {
                     visit::walk_item(this, item);
                 });
@@ -825,7 +825,7 @@ fn resolve_item(&mut self, item: &'ast Item) {
             ItemKind::Trait(.., ref generics, ref bounds, ref trait_items) => {
                 // Create a new rib for the trait-wide type parameters.
                 self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
-                    let local_def_id = this.r.definitions.local_def_id(item.id);
+                    let local_def_id = this.r.definitions.local_def_id(item.id).to_def_id();
                     this.with_self_rib(Res::SelfTy(Some(local_def_id), None), |this| {
                         this.visit_generics(generics);
                         walk_list!(this, visit_param_bound, bounds);
@@ -866,7 +866,7 @@ fn resolve_item(&mut self, item: &'ast Item) {
             ItemKind::TraitAlias(ref generics, ref bounds) => {
                 // Create a new rib for the trait-wide type parameters.
                 self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
-                    let local_def_id = this.r.definitions.local_def_id(item.id);
+                    let local_def_id = this.r.definitions.local_def_id(item.id).to_def_id();
                     this.with_self_rib(Res::SelfTy(Some(local_def_id), None), |this| {
                         this.visit_generics(generics);
                         walk_list!(this, visit_param_bound, bounds);
@@ -947,7 +947,7 @@ fn with_generic_param_rib<'c, F>(&'c mut self, generics: &'c Generics, kind: Rib
             seen_bindings.entry(ident).or_insert(param.ident.span);
 
             // Plain insert (no renaming).
-            let res = Res::Def(def_kind, self.r.definitions.local_def_id(param.id));
+            let res = Res::Def(def_kind, self.r.definitions.local_def_id(param.id).to_def_id());
 
             match param.kind {
                 GenericParamKind::Type { .. } => {
@@ -1097,7 +1097,7 @@ fn resolve_implementation(
             this.with_self_rib(Res::SelfTy(None, None), |this| {
                 // Resolve the trait reference, if necessary.
                 this.with_optional_trait_ref(opt_trait_reference.as_ref(), |this, trait_id| {
-                    let item_def_id = this.r.definitions.local_def_id(item_id);
+                    let item_def_id = this.r.definitions.local_def_id(item_id).to_def_id();
                     this.with_self_rib(Res::SelfTy(trait_id, Some(item_def_id)), |this| {
                         if let Some(trait_ref) = opt_trait_reference.as_ref() {
                             // Resolve type arguments in the trait path.
@@ -1906,7 +1906,7 @@ fn resolve_block(&mut self, block: &'ast Block) {
             if let StmtKind::Item(ref item) = stmt.kind {
                 if let ItemKind::MacroDef(..) = item.kind {
                     num_macro_definition_ribs += 1;
-                    let res = self.r.definitions.local_def_id(item.id);
+                    let res = self.r.definitions.local_def_id(item.id).to_def_id();
                     self.ribs[ValueNS].push(Rib::new(MacroDefinition(res)));
                     self.label_ribs.push(Rib::new(MacroDefinition(res)));
                 }
index 21f43b6fd4f6473b20e6bb735c681141171280b1..45521b1415b3806f3f43edd6f9cf4eb5ee74d719 100644 (file)
@@ -32,7 +32,7 @@
 use rustc_expand::base::SyntaxExtension;
 use rustc_hir::def::Namespace::*;
 use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
-use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX};
+use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
 use rustc_hir::definitions::{DefKey, Definitions};
 use rustc_hir::PrimTy::{self, Bool, Char, Float, Int, Str, Uint};
 use rustc_hir::{GlobMap, TraitMap};
@@ -885,7 +885,7 @@ pub struct Resolver<'a> {
     /// some AST passes can generate identifiers that only resolve to local or
     /// language items.
     empty_module: Module<'a>,
-    module_map: FxHashMap<DefId, Module<'a>>,
+    module_map: FxHashMap<LocalDefId, Module<'a>>,
     extern_module_map: FxHashMap<DefId, Module<'a>>,
     binding_parent_modules: FxHashMap<PtrKey<'a, NameBinding<'a>>, Module<'a>>,
     underscore_disambiguator: u32,
@@ -1121,7 +1121,7 @@ pub fn new(
             )
         });
         let mut module_map = FxHashMap::default();
-        module_map.insert(DefId::local(CRATE_DEF_INDEX), graph_root);
+        module_map.insert(LocalDefId { local_def_index: CRATE_DEF_INDEX }, graph_root);
 
         let mut definitions = Definitions::default();
         definitions.create_root_def(crate_name, session.local_crate_disambiguator());
@@ -2480,8 +2480,7 @@ fn report_with_use_injections(&mut self, krate: &Crate) {
             let (span, found_use) = UsePlacementFinder::check(krate, node_id);
             if !candidates.is_empty() {
                 diagnostics::show_candidates(&mut err, span, &candidates, better, found_use);
-            }
-            if let Some((span, msg, sugg, appl)) = suggestion {
+            } else if let Some((span, msg, sugg, appl)) = suggestion {
                 err.span_suggestion(span, msg, sugg, appl);
             }
             err.emit();
index 5efd3daebb9e2d0aeb60ccf8829e9826fad5b70d..aa78ac609457f5aee144781beec0a725e7a4fe74 100644 (file)
@@ -190,7 +190,7 @@ fn expansion_for_ast_pass(
 
         let parent_scope = if let Some(module_id) = parent_module_id {
             let parent_def_id = self.definitions.local_def_id(module_id);
-            self.definitions.add_parent_module_of_macro_def(expn_id, parent_def_id);
+            self.definitions.add_parent_module_of_macro_def(expn_id, parent_def_id.to_def_id());
             self.module_map[&parent_def_id]
         } else {
             self.definitions.add_parent_module_of_macro_def(
index 58a03dbe388e65aeafd2af3f5e32171d3ed9f1f5..4e2423bc3b11452ac5be6eaa0abf44db2724fd3b 100644 (file)
@@ -1017,7 +1017,13 @@ pub fn get_cmd_lint_options(
     let mut describe_lints = false;
 
     for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
-        for (arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
+        for (passed_arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
+            let arg_pos = if let lint::Forbid = level {
+                // forbid is always specified last, so it can't be overridden
+                usize::max_value()
+            } else {
+                passed_arg_pos
+            };
             if lint_name == "help" {
                 describe_lints = true;
             } else {
index 24eb22fbd00b1b57a735d9a211ecb63535f9cd0c..66df4fe9511622f57787fa5f71a21ea1fc3f8e8b 100644 (file)
@@ -43,7 +43,7 @@ fn type_is_copy_modulo_regions(
     ) -> bool {
         let ty = self.resolve_vars_if_possible(&ty);
 
-        if !(param_env, ty).has_local_value() {
+        if !(param_env, ty).needs_infer() {
             return ty.is_copy_modulo_regions(self.tcx, param_env, span);
         }
 
index 9a853c32eaa26aa528b065e4030544399d6e4166..193ca36e0fd0e53c60531b057a02647ea4a84864 100644 (file)
@@ -259,8 +259,8 @@ fn do_normalize_predicates<'tcx>(
                 return Err(ErrorReported);
             }
         };
-        if predicates.has_local_value() {
-            // FIXME: shouldn't we, you know, actually report an error here? or an ICE?
+        if predicates.needs_infer() {
+            tcx.sess.delay_span_bug(span, "encountered inference variables after `fully_resolve`");
             Err(ErrorReported)
         } else {
             Ok(predicates)
index 56e4ac5c72a49df2f5f554c502f5aa6629a852cf..0a85999c60da75fd77c27ff0900bd38fb7626078 100644 (file)
@@ -820,7 +820,7 @@ fn insert_evaluation_cache(
         }
 
         if self.can_use_global_caches(param_env) {
-            if !trait_ref.has_local_value() {
+            if !trait_ref.needs_infer() {
                 debug!(
                     "insert_evaluation_cache(trait_ref={:?}, candidate={:?}) global",
                     trait_ref, result,
@@ -1178,10 +1178,10 @@ fn is_knowable<'o>(&mut self, stack: &TraitObligationStack<'o, 'tcx>) -> Option<
     /// Do note that if the type itself is not in the
     /// global tcx, the local caches will be used.
     fn can_use_global_caches(&self, param_env: ty::ParamEnv<'tcx>) -> bool {
-        // If there are any e.g. inference variables in the `ParamEnv`, then we
+        // If there are any inference variables in the `ParamEnv`, then we
         // always use a cache local to this particular scope. Otherwise, we
         // switch to a global cache.
-        if param_env.has_local_value() {
+        if param_env.needs_infer() {
             return false;
         }
 
@@ -1242,7 +1242,7 @@ fn can_cache_candidate(
         result: &SelectionResult<'tcx, SelectionCandidate<'tcx>>,
     ) -> bool {
         match result {
-            Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.has_local_value(),
+            Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.needs_infer(),
             _ => true,
         }
     }
@@ -1269,8 +1269,8 @@ fn insert_candidate_cache(
         if self.can_use_global_caches(param_env) {
             if let Err(Overflow) = candidate {
                 // Don't cache overflow globally; we only produce this in certain modes.
-            } else if !trait_ref.has_local_value() {
-                if !candidate.has_local_value() {
+            } else if !trait_ref.needs_infer() {
+                if !candidate.needs_infer() {
                     debug!(
                         "insert_candidate_cache(trait_ref={:?}, candidate={:?}) global",
                         trait_ref, candidate,
index 6b38749e1e70ab4afb7d5a3f344401849a5d7240..d506ddab909e752b5aa2d2a7ee71ac2be2ae5e7e 100644 (file)
@@ -134,6 +134,152 @@ enum Elaborate {
     None,
 }
 
+fn extend_cause_with_original_assoc_item_obligation<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    trait_ref: &ty::TraitRef<'tcx>,
+    item: Option<&hir::Item<'tcx>>,
+    cause: &mut traits::ObligationCause<'tcx>,
+    pred: &ty::Predicate<'_>,
+    mut trait_assoc_items: impl Iterator<Item = ty::AssocItem>,
+) {
+    let trait_item =
+        tcx.hir().as_local_hir_id(trait_ref.def_id).and_then(|trait_id| tcx.hir().find(trait_id));
+    let (trait_name, trait_generics) = match trait_item {
+        Some(hir::Node::Item(hir::Item {
+            ident,
+            kind: hir::ItemKind::Trait(.., generics, _, _),
+            ..
+        }))
+        | Some(hir::Node::Item(hir::Item {
+            ident,
+            kind: hir::ItemKind::TraitAlias(generics, _),
+            ..
+        })) => (Some(ident), Some(generics)),
+        _ => (None, None),
+    };
+
+    let item_span = item.map(|i| tcx.sess.source_map().guess_head_span(i.span));
+    match pred {
+        ty::Predicate::Projection(proj) => {
+            // The obligation comes not from the current `impl` nor the `trait` being
+            // implemented, but rather from a "second order" obligation, like in
+            // `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs`:
+            //
+            //   error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
+            //     --> $DIR/point-at-type-on-obligation-failure.rs:13:5
+            //      |
+            //   LL |     type Ok;
+            //      |          -- associated type defined here
+            //   ...
+            //   LL | impl Bar for Foo {
+            //      | ---------------- in this `impl` item
+            //   LL |     type Ok = ();
+            //      |     ^^^^^^^^^^^^^ expected `u32`, found `()`
+            //      |
+            //      = note: expected type `u32`
+            //                 found type `()`
+            //
+            // FIXME: we would want to point a span to all places that contributed to this
+            // obligation. In the case above, it should be closer to:
+            //
+            //   error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
+            //     --> $DIR/point-at-type-on-obligation-failure.rs:13:5
+            //      |
+            //   LL |     type Ok;
+            //      |          -- associated type defined here
+            //   LL |     type Sibling: Bar2<Ok=Self::Ok>;
+            //      |     -------------------------------- obligation set here
+            //   ...
+            //   LL | impl Bar for Foo {
+            //      | ---------------- in this `impl` item
+            //   LL |     type Ok = ();
+            //      |     ^^^^^^^^^^^^^ expected `u32`, found `()`
+            //   ...
+            //   LL | impl Bar2 for Foo2 {
+            //      | ---------------- in this `impl` item
+            //   LL |     type Ok = u32;
+            //      |     -------------- obligation set here
+            //      |
+            //      = note: expected type `u32`
+            //                 found type `()`
+            if let Some(hir::ItemKind::Impl { items, .. }) = item.map(|i| &i.kind) {
+                let trait_assoc_item = tcx.associated_item(proj.projection_def_id());
+                if let Some(impl_item) =
+                    items.iter().find(|item| item.ident == trait_assoc_item.ident)
+                {
+                    cause.span = impl_item.span;
+                    cause.code = traits::AssocTypeBound(Box::new(AssocTypeBoundData {
+                        impl_span: item_span,
+                        original: trait_assoc_item.ident.span,
+                        bounds: vec![],
+                    }));
+                }
+            }
+        }
+        ty::Predicate::Trait(proj, _) => {
+            // An associated item obligation born out of the `trait` failed to be met.
+            // Point at the `impl` that failed the obligation, the associated item that
+            // needed to meet the obligation, and the definition of that associated item,
+            // which should hold the obligation in most cases. An example can be seen in
+            // `src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs`:
+            //
+            //   error[E0277]: the trait bound `bool: Bar` is not satisfied
+            //     --> $DIR/point-at-type-on-obligation-failure-2.rs:8:5
+            //      |
+            //   LL |     type Assoc: Bar;
+            //      |          ----- associated type defined here
+            //   ...
+            //   LL | impl Foo for () {
+            //      | --------------- in this `impl` item
+            //   LL |     type Assoc = bool;
+            //      |     ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool`
+            //
+            // If the obligation comes from the where clause in the `trait`, we point at it:
+            //
+            //   error[E0277]: the trait bound `bool: Bar` is not satisfied
+            //     --> $DIR/point-at-type-on-obligation-failure-2.rs:8:5
+            //      |
+            //      | trait Foo where <Self as Foo>>::Assoc: Bar {
+            //      |                 -------------------------- restricted in this bound
+            //   LL |     type Assoc;
+            //      |          ----- associated type defined here
+            //   ...
+            //   LL | impl Foo for () {
+            //      | --------------- in this `impl` item
+            //   LL |     type Assoc = bool;
+            //      |     ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool`
+            if let (
+                ty::Projection(ty::ProjectionTy { item_def_id, .. }),
+                Some(hir::ItemKind::Impl { items, .. }),
+            ) = (&proj.skip_binder().self_ty().kind, item.map(|i| &i.kind))
+            {
+                if let Some((impl_item, trait_assoc_item)) = trait_assoc_items
+                    .find(|i| i.def_id == *item_def_id)
+                    .and_then(|trait_assoc_item| {
+                        items
+                            .iter()
+                            .find(|i| i.ident == trait_assoc_item.ident)
+                            .map(|impl_item| (impl_item, trait_assoc_item))
+                    })
+                {
+                    let bounds = trait_generics
+                        .map(|generics| {
+                            get_generic_bound_spans(&generics, trait_name, trait_assoc_item.ident)
+                        })
+                        .unwrap_or_else(Vec::new);
+                    cause.span = impl_item.span;
+                    cause.code = traits::AssocTypeBound(Box::new(AssocTypeBoundData {
+                        impl_span: item_span,
+                        original: trait_assoc_item.ident.span,
+                        bounds,
+                    }));
+                }
+            }
+        }
+        _ => {}
+    }
+}
+
 impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
     fn cause(&mut self, code: traits::ObligationCauseCode<'tcx>) -> traits::ObligationCause<'tcx> {
         traits::ObligationCause::new(self.span, self.body_id, code)
@@ -163,170 +309,20 @@ fn compute_trait_ref(&mut self, trait_ref: &ty::TraitRef<'tcx>, elaborate: Elabo
         let cause = self.cause(traits::MiscObligation);
         let param_env = self.param_env;
 
-        let item = &self.item;
-        let extend_cause_with_original_assoc_item_obligation =
-            |cause: &mut traits::ObligationCause<'_>,
-             pred: &ty::Predicate<'_>,
-             trait_assoc_items: &[ty::AssocItem]| {
-                let trait_item = tcx
-                    .hir()
-                    .as_local_hir_id(trait_ref.def_id)
-                    .and_then(|trait_id| tcx.hir().find(trait_id));
-                let (trait_name, trait_generics) = match trait_item {
-                    Some(hir::Node::Item(hir::Item {
-                        ident,
-                        kind: hir::ItemKind::Trait(.., generics, _, _),
-                        ..
-                    }))
-                    | Some(hir::Node::Item(hir::Item {
-                        ident,
-                        kind: hir::ItemKind::TraitAlias(generics, _),
-                        ..
-                    })) => (Some(ident), Some(generics)),
-                    _ => (None, None),
-                };
-
-                let item_span = item.map(|i| tcx.sess.source_map().guess_head_span(i.span));
-                match pred {
-                    ty::Predicate::Projection(proj) => {
-                        // The obligation comes not from the current `impl` nor the `trait` being
-                        // implemented, but rather from a "second order" obligation, like in
-                        // `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs`:
-                        //
-                        //   error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
-                        //     --> $DIR/point-at-type-on-obligation-failure.rs:13:5
-                        //      |
-                        //   LL |     type Ok;
-                        //      |          -- associated type defined here
-                        //   ...
-                        //   LL | impl Bar for Foo {
-                        //      | ---------------- in this `impl` item
-                        //   LL |     type Ok = ();
-                        //      |     ^^^^^^^^^^^^^ expected `u32`, found `()`
-                        //      |
-                        //      = note: expected type `u32`
-                        //                 found type `()`
-                        //
-                        // FIXME: we would want to point a span to all places that contributed to this
-                        // obligation. In the case above, it should be closer to:
-                        //
-                        //   error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
-                        //     --> $DIR/point-at-type-on-obligation-failure.rs:13:5
-                        //      |
-                        //   LL |     type Ok;
-                        //      |          -- associated type defined here
-                        //   LL |     type Sibling: Bar2<Ok=Self::Ok>;
-                        //      |     -------------------------------- obligation set here
-                        //   ...
-                        //   LL | impl Bar for Foo {
-                        //      | ---------------- in this `impl` item
-                        //   LL |     type Ok = ();
-                        //      |     ^^^^^^^^^^^^^ expected `u32`, found `()`
-                        //   ...
-                        //   LL | impl Bar2 for Foo2 {
-                        //      | ---------------- in this `impl` item
-                        //   LL |     type Ok = u32;
-                        //      |     -------------- obligation set here
-                        //      |
-                        //      = note: expected type `u32`
-                        //                 found type `()`
-                        if let Some(hir::ItemKind::Impl { items, .. }) = item.map(|i| &i.kind) {
-                            let trait_assoc_item = tcx.associated_item(proj.projection_def_id());
-                            if let Some(impl_item) =
-                                items.iter().find(|item| item.ident == trait_assoc_item.ident)
-                            {
-                                cause.span = impl_item.span;
-                                cause.code = traits::AssocTypeBound(Box::new(AssocTypeBoundData {
-                                    impl_span: item_span,
-                                    original: trait_assoc_item.ident.span,
-                                    bounds: vec![],
-                                }));
-                            }
-                        }
-                    }
-                    ty::Predicate::Trait(proj, _) => {
-                        // An associated item obligation born out of the `trait` failed to be met.
-                        // Point at the `impl` that failed the obligation, the associated item that
-                        // needed to meet the obligation, and the definition of that associated item,
-                        // which should hold the obligation in most cases. An example can be seen in
-                        // `src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs`:
-                        //
-                        //   error[E0277]: the trait bound `bool: Bar` is not satisfied
-                        //     --> $DIR/point-at-type-on-obligation-failure-2.rs:8:5
-                        //      |
-                        //   LL |     type Assoc: Bar;
-                        //      |          ----- associated type defined here
-                        //   ...
-                        //   LL | impl Foo for () {
-                        //      | --------------- in this `impl` item
-                        //   LL |     type Assoc = bool;
-                        //      |     ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool`
-                        //
-                        // If the obligation comes from the where clause in the `trait`, we point at it:
-                        //
-                        //   error[E0277]: the trait bound `bool: Bar` is not satisfied
-                        //     --> $DIR/point-at-type-on-obligation-failure-2.rs:8:5
-                        //      |
-                        //      | trait Foo where <Self as Foo>>::Assoc: Bar {
-                        //      |                 -------------------------- restricted in this bound
-                        //   LL |     type Assoc;
-                        //      |          ----- associated type defined here
-                        //   ...
-                        //   LL | impl Foo for () {
-                        //      | --------------- in this `impl` item
-                        //   LL |     type Assoc = bool;
-                        //      |     ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool`
-                        if let (
-                            ty::Projection(ty::ProjectionTy { item_def_id, .. }),
-                            Some(hir::ItemKind::Impl { items, .. }),
-                        ) = (&proj.skip_binder().self_ty().kind, item.map(|i| &i.kind))
-                        {
-                            if let Some((impl_item, trait_assoc_item)) = trait_assoc_items
-                                .iter()
-                                .find(|i| i.def_id == *item_def_id)
-                                .and_then(|trait_assoc_item| {
-                                    items
-                                        .iter()
-                                        .find(|i| i.ident == trait_assoc_item.ident)
-                                        .map(|impl_item| (impl_item, trait_assoc_item))
-                                })
-                            {
-                                let bounds = trait_generics
-                                    .map(|generics| {
-                                        get_generic_bound_spans(
-                                            &generics,
-                                            trait_name,
-                                            trait_assoc_item.ident,
-                                        )
-                                    })
-                                    .unwrap_or_else(Vec::new);
-                                cause.span = impl_item.span;
-                                cause.code = traits::AssocTypeBound(Box::new(AssocTypeBoundData {
-                                    impl_span: item_span,
-                                    original: trait_assoc_item.ident.span,
-                                    bounds,
-                                }));
-                            }
-                        }
-                    }
-                    _ => {}
-                }
-            };
+        let item = self.item;
 
         if let Elaborate::All = elaborate {
-            // FIXME: Make `extend_cause_with_original_assoc_item_obligation` take an iterator
-            // instead of a slice.
-            let trait_assoc_items: Vec<_> =
-                tcx.associated_items(trait_ref.def_id).in_definition_order().copied().collect();
-
             let predicates = obligations.iter().map(|obligation| obligation.predicate).collect();
             let implied_obligations = traits::elaborate_predicates(tcx, predicates);
             let implied_obligations = implied_obligations.map(|pred| {
                 let mut cause = cause.clone();
                 extend_cause_with_original_assoc_item_obligation(
+                    tcx,
+                    trait_ref,
+                    item,
                     &mut cause,
                     &pred,
-                    &*trait_assoc_items,
+                    tcx.associated_items(trait_ref.def_id).in_definition_order().copied(),
                 );
                 traits::Obligation::new(cause, param_env, pred)
             });
index add706b5fcc9a7fa335c73df71e11d4addc7b359..f075d1e74d455df26ab62f9eb7fd81e379a0eef3 100644 (file)
@@ -271,11 +271,35 @@ pub fn report_method_error<'b>(
                     let mut candidates = all_traits(self.tcx).into_iter().filter_map(|info| {
                         self.associated_item(info.def_id, item_name, Namespace::ValueNS)
                     });
-                    if let (true, false, SelfSource::MethodCall(expr), Some(_)) = (
+                    // There are methods that are defined on the primitive types and won't be
+                    // found when exploring `all_traits`, but we also need them to be acurate on
+                    // our suggestions (#47759).
+                    let fund_assoc = |opt_def_id: Option<DefId>| {
+                        opt_def_id
+                            .and_then(|id| self.associated_item(id, item_name, Namespace::ValueNS))
+                            .is_some()
+                    };
+                    let lang_items = tcx.lang_items();
+                    let found_candidate = candidates.next().is_some()
+                        || fund_assoc(lang_items.i8_impl())
+                        || fund_assoc(lang_items.i16_impl())
+                        || fund_assoc(lang_items.i32_impl())
+                        || fund_assoc(lang_items.i64_impl())
+                        || fund_assoc(lang_items.i128_impl())
+                        || fund_assoc(lang_items.u8_impl())
+                        || fund_assoc(lang_items.u16_impl())
+                        || fund_assoc(lang_items.u32_impl())
+                        || fund_assoc(lang_items.u64_impl())
+                        || fund_assoc(lang_items.u128_impl())
+                        || fund_assoc(lang_items.f32_impl())
+                        || fund_assoc(lang_items.f32_runtime_impl())
+                        || fund_assoc(lang_items.f64_impl())
+                        || fund_assoc(lang_items.f64_runtime_impl());
+                    if let (true, false, SelfSource::MethodCall(expr), true) = (
                         actual.is_numeric(),
                         actual.has_concrete_skeleton(),
                         source,
-                        candidates.next(),
+                        found_candidate,
                     ) {
                         let mut err = struct_span_err!(
                             tcx.sess,
index b0ff17ad56d7c5dd13cd46500cfffa50cb205e53..cb794bfd7e1e93fa1f5d7f9723913a846b91b8ca 100644 (file)
@@ -369,7 +369,7 @@ fn check_type_defn<'tcx, F>(
                 packed && {
                     let ty = variant.fields.last().unwrap().ty;
                     let ty = fcx.tcx.erase_regions(&ty);
-                    if ty.has_local_value() {
+                    if ty.needs_infer() {
                         fcx_tcx
                             .sess
                             .delay_span_bug(item.span, &format!("inference variables in {:?}", ty));
@@ -706,13 +706,13 @@ fn check_where_clauses<'tcx, 'fcx>(
                         return default_ty.into();
                     }
                 }
-                // Mark unwanted params as error.
-                fcx.tcx.types.err.into()
+
+                fcx.tcx.mk_param_from_def(param)
             }
 
             GenericParamDefKind::Const => {
                 // FIXME(const_generics:defaults)
-                fcx.tcx.consts.err.into()
+                fcx.tcx.mk_param_from_def(param)
             }
         }
     });
@@ -750,7 +750,10 @@ fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
             let substituted_pred = pred.subst(fcx.tcx, substs);
             // Don't check non-defaulted params, dependent defaults (including lifetimes)
             // or preds with multiple params.
-            if substituted_pred.references_error() || param_count.params.len() > 1 || has_region {
+            if substituted_pred.has_param_types_or_consts()
+                || param_count.params.len() > 1
+                || has_region
+            {
                 None
             } else if predicates.predicates.iter().any(|&(p, _)| p == substituted_pred) {
                 // Avoid duplication of predicates that contain no parameters, for example.
index 2b2ebb3135fd183a32a4b106eb5bd011ba6a8f8b..28574c68e941a9eaf4c93fc256ea1fea2a288d71 100644 (file)
@@ -365,8 +365,12 @@ fn visit_user_provided_tys(&mut self) {
         for (&local_id, c_ty) in fcx_tables.user_provided_types().iter() {
             let hir_id = hir::HirId { owner: common_hir_owner, local_id };
 
-            if cfg!(debug_assertions) && c_ty.has_local_value() {
-                span_bug!(hir_id.to_span(self.fcx.tcx), "writeback: `{:?}` is a local value", c_ty);
+            if cfg!(debug_assertions) && c_ty.needs_infer() {
+                span_bug!(
+                    hir_id.to_span(self.fcx.tcx),
+                    "writeback: `{:?}` has inference variables",
+                    c_ty
+                );
             };
 
             self.tables.user_provided_types_mut().insert(hir_id, c_ty.clone());
@@ -399,10 +403,10 @@ fn visit_user_provided_sigs(&mut self) {
         assert_eq!(fcx_tables.hir_owner, self.tables.hir_owner);
 
         for (&def_id, c_sig) in fcx_tables.user_provided_sigs.iter() {
-            if cfg!(debug_assertions) && c_sig.has_local_value() {
+            if cfg!(debug_assertions) && c_sig.needs_infer() {
                 span_bug!(
                     self.fcx.tcx.hir().span_if_local(def_id).unwrap(),
-                    "writeback: `{:?}` is a local value",
+                    "writeback: `{:?}` has inference variables",
                     c_sig
                 );
             };
@@ -457,7 +461,7 @@ fn visit_opaque_types(&mut self, span: Span) {
                 }
             }
 
-            if !opaque_defn.substs.has_local_value() {
+            if !opaque_defn.substs.needs_infer() {
                 // We only want to add an entry into `concrete_opaque_types`
                 // if we actually found a defining usage of this opaque type.
                 // Otherwise, we do nothing - we'll either find a defining usage
@@ -485,7 +489,7 @@ fn visit_opaque_types(&mut self, span: Span) {
                     }
                 }
             } else {
-                self.tcx().sess.delay_span_bug(span, "`opaque_defn` is a local value");
+                self.tcx().sess.delay_span_bug(span, "`opaque_defn` has inference variables");
             }
         }
     }
@@ -579,8 +583,8 @@ fn resolve<T>(&self, x: &T, span: &dyn Locatable) -> T
         T: TypeFoldable<'tcx>,
     {
         let x = x.fold_with(&mut Resolver::new(self.fcx, span, self.body));
-        if cfg!(debug_assertions) && x.has_local_value() {
-            span_bug!(span.to_span(self.fcx.tcx), "writeback: `{:?}` is a local value", x);
+        if cfg!(debug_assertions) && x.needs_infer() {
+            span_bug!(span.to_span(self.fcx.tcx), "writeback: `{:?}` has inference variables", x);
         }
         x
     }
index 7ea6c1c17869a2ad6c7dcbb870b69f3c601da34b..69d0b3723b0ad8d251a8bf800b03105c8215a60b 100644 (file)
@@ -367,6 +367,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
 pub fn hir_trait_to_predicates<'tcx>(
     tcx: TyCtxt<'tcx>,
     hir_trait: &hir::TraitRef<'_>,
+    self_ty: Ty<'tcx>,
 ) -> Bounds<'tcx> {
     // In case there are any projections, etc., find the "environment"
     // def-ID that will be used to determine the traits/predicates in
@@ -380,7 +381,7 @@ pub fn hir_trait_to_predicates<'tcx>(
         hir_trait,
         DUMMY_SP,
         hir::Constness::NotConst,
-        tcx.types.err,
+        self_ty,
         &mut bounds,
         true,
     );
index 2871fa606b57042ed7347f433dd5a37e19a5bf58..afa6e49a05cf1abecd304609fc6ffab0cb372aa4 100644 (file)
@@ -315,11 +315,9 @@ fn add_constraints_from_ty(
                 self.add_constraints_from_region(current, r, contra);
 
                 if let Some(poly_trait_ref) = data.principal() {
-                    let poly_trait_ref =
-                        poly_trait_ref.with_self_ty(self.tcx(), self.tcx().types.err);
-                    self.add_constraints_from_trait_ref(
+                    self.add_constraints_from_invariant_substs(
                         current,
-                        *poly_trait_ref.skip_binder(),
+                        poly_trait_ref.skip_binder().substs,
                         variance,
                     );
                 }
index 5c35dc5513266482dd4e63878e23ed637c601b3c..03413f67f88fb2f685f697b47394d44f19888f21 100644 (file)
@@ -1936,6 +1936,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Span {
         let hi = sm.lookup_char_pos(self.hi());
         Span {
             filename,
+            cnum: lo.file.cnum,
             loline: lo.line,
             locol: lo.col.to_usize(),
             hiline: hi.line,
index 2e5ecacee12dfa5fce9d5a39bf67fdab701fec43..0a682857b18259fee5ff7398681b35c1c4100fff 100644 (file)
@@ -14,7 +14,7 @@
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 use rustc_hir as hir;
 use rustc_hir::def::Res;
-use rustc_hir::def_id::{CrateNum, DefId};
+use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
 use rustc_hir::lang_items;
 use rustc_hir::Mutability;
 use rustc_index::vec::IndexVec;
@@ -1357,6 +1357,7 @@ pub enum VariantKind {
 #[derive(Clone, Debug)]
 pub struct Span {
     pub filename: FileName,
+    pub cnum: CrateNum,
     pub loline: usize,
     pub locol: usize,
     pub hiline: usize,
@@ -1368,6 +1369,7 @@ impl Span {
     pub fn empty() -> Span {
         Span {
             filename: FileName::Anon(0),
+            cnum: LOCAL_CRATE,
             loline: 0,
             locol: 0,
             hiline: 0,
index f51f47a8d3387702a9b1292edab2a687663e027e..da020b85ed499cc1be7c48dad8a82968c6b15b77 100644 (file)
@@ -47,7 +47,7 @@
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 use rustc_feature::UnstableFeatures;
 use rustc_hir as hir;
-use rustc_hir::def_id::DefId;
+use rustc_hir::def_id::{DefId, LOCAL_CRATE};
 use rustc_hir::Mutability;
 use rustc_middle::middle::privacy::AccessLevels;
 use rustc_middle::middle::stability;
@@ -1623,14 +1623,14 @@ fn src_href(&self, item: &clean::Item) -> Option<String> {
             _ => return None,
         };
 
-        let (krate, path) = if item.def_id.is_local() {
+        let (krate, path) = if item.source.cnum == LOCAL_CRATE {
             if let Some(path) = self.shared.local_sources.get(file) {
                 (&self.shared.layout.krate, path)
             } else {
                 return None;
             }
         } else {
-            let (krate, src_root) = match *self.cache.extern_locations.get(&item.def_id.krate)? {
+            let (krate, src_root) = match *self.cache.extern_locations.get(&item.source.cnum)? {
                 (ref name, ref src, Local) => (name, src),
                 (ref name, ref src, Remote(ref s)) => {
                     root = s.to_string();
index 86f46b2d7e15422214dfc8ca029583447eec6ecd..c5f44baced2e47c3e8f6f9e7f1fc6d98d6a3be05 100644 (file)
@@ -5,6 +5,7 @@
 use crate::html::highlight;
 use crate::html::layout;
 use crate::html::render::{Error, SharedContext, BASIC_KEYWORDS};
+use rustc_hir::def_id::LOCAL_CRATE;
 use rustc_span::source_map::FileName;
 use std::ffi::OsStr;
 use std::fs;
@@ -37,8 +38,8 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
         if self.scx.include_sources
             // skip all synthetic "files"
             && item.source.filename.is_real()
-            // skip non-local items
-            && item.def_id.is_local()
+            // skip non-local files
+            && item.source.cnum == LOCAL_CRATE
         {
             // If it turns out that we couldn't read this file, then we probably
             // can't read any of the files (generating html output from json or
index 91e37ed833a4faddaa4eb06c399245bb71ee4a29..0fa4a1d2353cac33ca1265144ba8e4a76b72bdd5 100644 (file)
@@ -24,7 +24,7 @@
         // If we're not documenting libstd then we just expose the main modules
         // as we otherwise would.
 
-        #[cfg(any(target_os = "redox", unix, target_os = "vxworks"))]
+        #[cfg(any(target_os = "redox", unix, target_os = "vxworks", target_os = "hermit"))]
         #[stable(feature = "rust1", since = "1.0.0")]
         pub use crate::sys::ext as unix;
 
diff --git a/src/libstd/sys/hermit/ext/ffi.rs b/src/libstd/sys/hermit/ext/ffi.rs
new file mode 100644 (file)
index 0000000..07b59a0
--- /dev/null
@@ -0,0 +1,38 @@
+//! HermitCore-specific extension to the primitives in the `std::ffi` module
+//!
+//! # Examples
+//!
+//! ```
+//! use std::ffi::OsString;
+//! use std::os::hermit::ffi::OsStringExt;
+//!
+//! let bytes = b"foo".to_vec();
+//!
+//! // OsStringExt::from_vec
+//! let os_string = OsString::from_vec(bytes);
+//! assert_eq!(os_string.to_str(), Some("foo"));
+//!
+//! // OsStringExt::into_vec
+//! let bytes = os_string.into_vec();
+//! assert_eq!(bytes, b"foo");
+//! ```
+//!
+//! ```
+//! use std::ffi::OsStr;
+//! use std::os::hermit::ffi::OsStrExt;
+//!
+//! let bytes = b"foo";
+//!
+//! // OsStrExt::from_bytes
+//! let os_str = OsStr::from_bytes(bytes);
+//! assert_eq!(os_str.to_str(), Some("foo"));
+//!
+//! // OsStrExt::as_bytes
+//! let bytes = os_str.as_bytes();
+//! assert_eq!(bytes, b"foo");
+//! ```
+
+#![stable(feature = "rust1", since = "1.0.0")]
+
+#[stable(feature = "rust1", since = "1.0.0")]
+pub use crate::sys_common::os_str_bytes::*;
diff --git a/src/libstd/sys/hermit/ext/mod.rs b/src/libstd/sys/hermit/ext/mod.rs
new file mode 100644 (file)
index 0000000..ea87d0a
--- /dev/null
@@ -0,0 +1,14 @@
+#![stable(feature = "rust1", since = "1.0.0")]
+#![allow(missing_docs)]
+
+pub mod ffi;
+
+/// A prelude for conveniently writing platform-specific code.
+///
+/// Includes all extension traits, and some important type definitions.
+#[stable(feature = "rust1", since = "1.0.0")]
+pub mod prelude {
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub use super::ffi::{OsStrExt, OsStringExt};
+}
index 6736d964e521b9850db1190a8d90e9eeddf6b05d..f739df88ea6aa66ab3488aa46757edcf44cf4bb6 100644 (file)
@@ -21,6 +21,7 @@
 pub mod cmath;
 pub mod condvar;
 pub mod env;
+pub mod ext;
 pub mod fast_thread_local;
 pub mod fd;
 pub mod fs;
index 74dd41fd50147c941c936faf86b94314a36a17e8..d745e87a07258258ebe442c6f1171733e7c0506c 100644 (file)
@@ -81,10 +81,54 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
     }
 }
 
+pub fn unrolled_find_u16s(needle: u16, haystack: &[u16]) -> Option<usize> {
+    let ptr = haystack.as_ptr();
+    let mut len = haystack.len();
+    let mut start = &haystack[..];
+
+    // For performance reasons unfold the loop eight times.
+    while len >= 8 {
+        if start[0] == needle {
+            return Some((start.as_ptr() as usize - ptr as usize) / 2);
+        }
+        if start[1] == needle {
+            return Some((start[1..].as_ptr() as usize - ptr as usize) / 2);
+        }
+        if start[2] == needle {
+            return Some((start[2..].as_ptr() as usize - ptr as usize) / 2);
+        }
+        if start[3] == needle {
+            return Some((start[3..].as_ptr() as usize - ptr as usize) / 2);
+        }
+        if start[4] == needle {
+            return Some((start[4..].as_ptr() as usize - ptr as usize) / 2);
+        }
+        if start[5] == needle {
+            return Some((start[5..].as_ptr() as usize - ptr as usize) / 2);
+        }
+        if start[6] == needle {
+            return Some((start[6..].as_ptr() as usize - ptr as usize) / 2);
+        }
+        if start[7] == needle {
+            return Some((start[7..].as_ptr() as usize - ptr as usize) / 2);
+        }
+
+        start = &start[8..];
+        len -= 8;
+    }
+
+    for (i, c) in start.iter().enumerate() {
+        if *c == needle {
+            return Some((start.as_ptr() as usize - ptr as usize) / 2 + i);
+        }
+    }
+    None
+}
+
 pub fn to_u16s<S: AsRef<OsStr>>(s: S) -> crate::io::Result<Vec<u16>> {
     fn inner(s: &OsStr) -> crate::io::Result<Vec<u16>> {
         let mut maybe_result: Vec<u16> = s.encode_wide().collect();
-        if maybe_result.iter().any(|&u| u == 0) {
+        if unrolled_find_u16s(0, &maybe_result).is_some() {
             return Err(crate::io::Error::new(
                 ErrorKind::InvalidInput,
                 "strings passed to WinAPI cannot contain NULs",
@@ -214,7 +258,7 @@ fn wide_char_to_multi_byte(
 }
 
 pub fn truncate_utf16_at_nul(v: &[u16]) -> &[u16] {
-    match v.iter().position(|c| *c == 0) {
+    match unrolled_find_u16s(0, v) {
         // don't include the 0
         Some(i) => &v[..i],
         None => v,
index 1dd942e252f6bbc9a607fff04d57eaefdca843d0..29e99c0afd27f0a3b6daa0ed049769aac322271e 100644 (file)
@@ -253,6 +253,7 @@ pub fn with<F, R>(&'static self, f: F) -> R
     /// This function will still `panic!()` if the key is uninitialized and the
     /// key's initializer panics.
     #[stable(feature = "thread_local_try_with", since = "1.26.0")]
+    #[inline]
     pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError>
     where
         F: FnOnce(&T) -> R,
index a6f86d4e384ae91d3ab95d8f75c5d29dbbb4e78d..a0550466cf07b4c8b805d1fff53c9f3576ca52f0 100644 (file)
@@ -1,9 +1,7 @@
 This folder contains tests for MIR optimizations.
 
-There are two test formats. One allows specifying a pattern to look for in the MIR, which also
-permits leaving placeholders, but requires you to manually change the pattern if anything changes.
-The other emits MIR to extra files that you can automatically update by specifying `--bless` on
-the command line (just like `ui` tests updating `.stderr` files).
+The `mir-opt` test format emits MIR to extra files that you can automatically update by specifying
+`--bless` on the command line (just like `ui` tests updating `.stderr` files).
 
 # `--bless`able test format
 
@@ -39,79 +37,3 @@ This exists mainly for completeness and is rarely useful.
 ```
 // EMIT_MIR $file_name_of_some_mir_dump.before.mir
 ```
-
-# Inline test format
-
-```
-(arbitrary rust code)
-// END RUST SOURCE
-// START $file_name_of_some_mir_dump_0
-//  $expected_line_0
-// (lines or elision)
-// $expected_line_N
-// END $file_name_of_some_mir_dump_0
-// (lines or elision)
-// START $file_name_of_some_mir_dump_N
-//  $expected_line_0
-// (lines or elision)
-// $expected_line_N
-// END $file_name_of_some_mir_dump_N
-```
-
-All the test information is in comments so the test is runnable.
-
-For each $file_name, compiletest expects [$expected_line_0, ...,
-$expected_line_N] to appear in the dumped MIR in order.  Currently it allows
-other non-matched lines before and after, but not between $expected_lines,
-should you want to skip lines, you must include an elision comment, of the form
-(as a regex) `//\s*...\s*`. The lines will be skipped lazily, that is, if there
-are two identical lines in the output that match the line after the elision
-comment, the first one will be matched.
-
-Examples:
-
-The following blocks will not match the one after it.
-
-```
-bb0: {
-    StorageLive(_1);
-    _1 = const true;
-    StorageDead(_1);
-}
-```
-
-```
-bb0: {
-    StorageLive(_1);
-    _1 = const true;
-    goto -> bb1
-}
-bb1: {
-    StorageDead(_1);
-    return;
-}
-```
-
-But this will match the one above,
-
-```
-bb0: {
-    StorageLive(_1);
-    _1 = const true;
-    ...
-    StorageDead(_1);
-    ...
-}
-```
-
-Lines match ignoring whitespace, and the prefix "//" is removed.
-
-It also currently strips trailing comments -- partly because the full file path
-in "scope comments" is unpredictable and partly because tidy complains about
-the lines being too long.
-
-compiletest handles dumping the MIR before and after every pass for you.  The
-test writer only has to specify the file names of the dumped files (not the
-full path to the file) and what lines to expect.  There is an option to rustc
-that tells it to dump the mir into some directly (rather then always dumping to
-the current directory).
index bbd1ca68a8672d3747838f66fdd65c5568ccb312..6cd14ccf434f2ee8bdb6f260638b2b4899b004f0 100644 (file)
@@ -1,3 +1,5 @@
+// EMIT_MIR rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
+
 fn address_of_reborrow() {
     let y = &[0; 10];
     let mut z = &mut [0; 10];
@@ -35,6 +37,7 @@ fn address_of_reborrow() {
 }
 
 // The normal borrows here should be preserved
+// EMIT_MIR rustc.borrow_and_cast.SimplifyCfg-initial.after.mir
 fn borrow_and_cast(mut x: i32) {
     let p = &x as *const i32;
     let q = &mut x as *const i32;
@@ -42,71 +45,3 @@ fn borrow_and_cast(mut x: i32) {
 }
 
 fn main() {}
-
-// START rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
-// bb0: {
-//  ...
-//  _5 = &raw const (*_1); // & to *const casts
-//  ...
-//  _7 = &raw const (*_1);
-//  ...
-//  _11 = &raw const (*_1);
-//  ...
-//  _14 = &raw const (*_1);
-//  ...
-//  _16 = &raw const (*_1);
-//  ...
-//  _17 = &raw const (*_1); // & to *const coercions
-//  ...
-//  _18 = &raw const (*_1);
-//  ...
-//  _20 = &raw const (*_1);
-//  ...
-//  _22 = &raw const (*_1);
-// ...
-//  _24 = &raw const (*_2); // &mut to *const casts
-// ...
-//  _26 = &raw const (*_2);
-// ...
-//  _30 = &raw const (*_2);
-// ...
-//  _33 = &raw const (*_2);
-// ...
-//  _34 = &raw const (*_2); // &mut to *const coercions
-// ...
-//  _35 = &raw const (*_2);
-// ...
-//  _37 = &raw const (*_2);
-// ...
-//  _39 = &raw const (*_2);
-// ...
-//  _41 = &raw mut (*_2); // &mut to *mut casts
-// ...
-//  _43 = &raw mut (*_2);
-// ...
-//  _47 = &raw mut (*_2);
-// ...
-//  _50 = &raw mut (*_2);
-// ...
-//  _51 = &raw mut (*_2); // &mut to *mut coercions
-// ...
-//  _52 = &raw mut (*_2);
-// ...
-//  _54 = &raw mut (*_2);
-// ...
-//  _56 = &raw mut (*_2);
-// ...
-// }
-// END rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
-
-// START rustc.borrow_and_cast.EraseRegions.after.mir
-// bb0: {
-//  ...
-//  _4 = &_1;
-//  ...
-//  _7 = &mut _1;
-//  ...
-//  _10 = &mut _1;
-//  ...
-// }
-// END rustc.borrow_and_cast.EraseRegions.after.mir
diff --git a/src/test/mir-opt/address-of/rustc.address_of_reborrow.SimplifyCfg-initial.after.mir b/src/test/mir-opt/address-of/rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
new file mode 100644 (file)
index 0000000..af07da4
--- /dev/null
@@ -0,0 +1,320 @@
+// MIR for `address_of_reborrow` after SimplifyCfg-initial
+
+| User Type Annotations
+| 0: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:7:5: 7:18
+| 1: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:9:5: 9:25
+| 2: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:13:12: 13:20
+| 3: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:13:12: 13:20
+| 4: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) } at $DIR/address-of.rs:14:12: 14:28
+| 5: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) } at $DIR/address-of.rs:14:12: 14:28
+| 6: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:15:12: 15:27
+| 7: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:15:12: 15:27
+| 8: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) } at $DIR/address-of.rs:16:12: 16:24
+| 9: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) } at $DIR/address-of.rs:16:12: 16:24
+| 10: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:18:5: 18:18
+| 11: Canonical { max_universe: U3, variables: [CanonicalVarInfo { kind: Region(U3) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:20:5: 20:25
+| 12: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:23:12: 23:20
+| 13: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:23:12: 23:20
+| 14: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) } at $DIR/address-of.rs:24:12: 24:28
+| 15: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) } at $DIR/address-of.rs:24:12: 24:28
+| 16: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:25:12: 25:27
+| 17: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:25:12: 25:27
+| 18: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) } at $DIR/address-of.rs:26:12: 26:24
+| 19: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) } at $DIR/address-of.rs:26:12: 26:24
+| 20: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) } at $DIR/address-of.rs:28:5: 28:16
+| 21: Canonical { max_universe: U6, variables: [CanonicalVarInfo { kind: Region(U6) }], value: Ty(*mut dyn std::marker::Send) } at $DIR/address-of.rs:30:5: 30:23
+| 22: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) } at $DIR/address-of.rs:33:12: 33:18
+| 23: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) } at $DIR/address-of.rs:33:12: 33:18
+| 24: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) } at $DIR/address-of.rs:34:12: 34:26
+| 25: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) } at $DIR/address-of.rs:34:12: 34:26
+| 26: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) } at $DIR/address-of.rs:35:12: 35:25
+| 27: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) } at $DIR/address-of.rs:35:12: 35:25
+| 28: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) } at $DIR/address-of.rs:36:12: 36:22
+| 29: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) } at $DIR/address-of.rs:36:12: 36:22
+|
+fn address_of_reborrow() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/address-of.rs:3:26: 3:26
+    let _1: &[i32; 10];                  // in scope 0 at $DIR/address-of.rs:4:9: 4:10
+    let _2: [i32; 10];                   // in scope 0 at $DIR/address-of.rs:4:14: 4:21
+    let mut _4: [i32; 10];               // in scope 0 at $DIR/address-of.rs:5:22: 5:29
+    let _5: *const [i32; 10];            // in scope 0 at $DIR/address-of.rs:7:5: 7:18
+    let mut _6: *const [i32; 10];        // in scope 0 at $DIR/address-of.rs:7:5: 7:18
+    let _7: *const [i32; 10];            // in scope 0 at $DIR/address-of.rs:8:5: 8:26
+    let _8: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:9:5: 9:25
+    let mut _9: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:9:5: 9:25
+    let mut _10: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:9:5: 9:6
+    let _11: *const [i32];               // in scope 0 at $DIR/address-of.rs:10:5: 10:22
+    let mut _12: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:10:5: 10:6
+    let _13: *const i32;                 // in scope 0 at $DIR/address-of.rs:11:5: 11:20
+    let mut _14: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:11:5: 11:6
+    let mut _18: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:15:30: 15:31
+    let mut _20: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:16:27: 16:28
+    let _21: *const [i32; 10];           // in scope 0 at $DIR/address-of.rs:18:5: 18:18
+    let mut _22: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:18:5: 18:18
+    let _23: *const [i32; 10];           // in scope 0 at $DIR/address-of.rs:19:5: 19:26
+    let _24: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:20:5: 20:25
+    let mut _25: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:20:5: 20:25
+    let mut _26: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:20:5: 20:6
+    let _27: *const [i32];               // in scope 0 at $DIR/address-of.rs:21:5: 21:22
+    let mut _28: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:21:5: 21:6
+    let mut _32: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:25:30: 25:31
+    let mut _34: *const [i32; 10];       // in scope 0 at $DIR/address-of.rs:26:27: 26:28
+    let _35: *mut [i32; 10];             // in scope 0 at $DIR/address-of.rs:28:5: 28:16
+    let mut _36: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:28:5: 28:16
+    let _37: *mut [i32; 10];             // in scope 0 at $DIR/address-of.rs:29:5: 29:24
+    let _38: *mut dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:30:5: 30:23
+    let mut _39: *mut dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:30:5: 30:23
+    let mut _40: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:30:5: 30:6
+    let _41: *mut [i32];                 // in scope 0 at $DIR/address-of.rs:31:5: 31:20
+    let mut _42: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:31:5: 31:6
+    let mut _46: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:35:28: 35:29
+    let mut _48: *mut [i32; 10];         // in scope 0 at $DIR/address-of.rs:36:25: 36:26
+    scope 1 {
+        debug y => _1;                   // in scope 1 at $DIR/address-of.rs:4:9: 4:10
+        let mut _3: &mut [i32; 10];      // in scope 1 at $DIR/address-of.rs:5:9: 5:14
+        scope 2 {
+            debug z => _3;               // in scope 2 at $DIR/address-of.rs:5:9: 5:14
+            let _15: *const [i32; 10] as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 2 at $DIR/address-of.rs:13:9: 13:10
+            scope 3 {
+                debug p => _15;          // in scope 3 at $DIR/address-of.rs:13:9: 13:10
+                let _16: *const [i32; 10] as UserTypeProjection { base: UserType(4), projs: [] }; // in scope 3 at $DIR/address-of.rs:14:9: 14:10
+                scope 4 {
+                    debug p => _16;      // in scope 4 at $DIR/address-of.rs:14:9: 14:10
+                    let _17: *const dyn std::marker::Send as UserTypeProjection { base: UserType(6), projs: [] }; // in scope 4 at $DIR/address-of.rs:15:9: 15:10
+                    scope 5 {
+                        debug p => _17;  // in scope 5 at $DIR/address-of.rs:15:9: 15:10
+                        let _19: *const [i32] as UserTypeProjection { base: UserType(8), projs: [] }; // in scope 5 at $DIR/address-of.rs:16:9: 16:10
+                        scope 6 {
+                            debug p => _19; // in scope 6 at $DIR/address-of.rs:16:9: 16:10
+                            let _29: *const [i32; 10] as UserTypeProjection { base: UserType(12), projs: [] }; // in scope 6 at $DIR/address-of.rs:23:9: 23:10
+                            scope 7 {
+                                debug p => _29; // in scope 7 at $DIR/address-of.rs:23:9: 23:10
+                                let _30: *const [i32; 10] as UserTypeProjection { base: UserType(14), projs: [] }; // in scope 7 at $DIR/address-of.rs:24:9: 24:10
+                                scope 8 {
+                                    debug p => _30; // in scope 8 at $DIR/address-of.rs:24:9: 24:10
+                                    let _31: *const dyn std::marker::Send as UserTypeProjection { base: UserType(16), projs: [] }; // in scope 8 at $DIR/address-of.rs:25:9: 25:10
+                                    scope 9 {
+                                        debug p => _31; // in scope 9 at $DIR/address-of.rs:25:9: 25:10
+                                        let _33: *const [i32] as UserTypeProjection { base: UserType(18), projs: [] }; // in scope 9 at $DIR/address-of.rs:26:9: 26:10
+                                        scope 10 {
+                                            debug p => _33; // in scope 10 at $DIR/address-of.rs:26:9: 26:10
+                                            let _43: *mut [i32; 10] as UserTypeProjection { base: UserType(22), projs: [] }; // in scope 10 at $DIR/address-of.rs:33:9: 33:10
+                                            scope 11 {
+                                                debug p => _43; // in scope 11 at $DIR/address-of.rs:33:9: 33:10
+                                                let _44: *mut [i32; 10] as UserTypeProjection { base: UserType(24), projs: [] }; // in scope 11 at $DIR/address-of.rs:34:9: 34:10
+                                                scope 12 {
+                                                    debug p => _44; // in scope 12 at $DIR/address-of.rs:34:9: 34:10
+                                                    let _45: *mut dyn std::marker::Send as UserTypeProjection { base: UserType(26), projs: [] }; // in scope 12 at $DIR/address-of.rs:35:9: 35:10
+                                                    scope 13 {
+                                                        debug p => _45; // in scope 13 at $DIR/address-of.rs:35:9: 35:10
+                                                        let _47: *mut [i32] as UserTypeProjection { base: UserType(28), projs: [] }; // in scope 13 at $DIR/address-of.rs:36:9: 36:10
+                                                        scope 14 {
+                                                            debug p => _47; // in scope 14 at $DIR/address-of.rs:36:9: 36:10
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/address-of.rs:4:9: 4:10
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/address-of.rs:4:14: 4:21
+        _2 = [const 0i32; 10];           // bb0[2]: scope 0 at $DIR/address-of.rs:4:14: 4:21
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/address-of.rs:4:15: 4:16
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+        _1 = &_2;                        // bb0[3]: scope 0 at $DIR/address-of.rs:4:13: 4:21
+        FakeRead(ForLet, _1);            // bb0[4]: scope 0 at $DIR/address-of.rs:4:9: 4:10
+        StorageLive(_3);                 // bb0[5]: scope 1 at $DIR/address-of.rs:5:9: 5:14
+        StorageLive(_4);                 // bb0[6]: scope 1 at $DIR/address-of.rs:5:22: 5:29
+        _4 = [const 0i32; 10];           // bb0[7]: scope 1 at $DIR/address-of.rs:5:22: 5:29
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/address-of.rs:5:23: 5:24
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+        _3 = &mut _4;                    // bb0[8]: scope 1 at $DIR/address-of.rs:5:17: 5:29
+        FakeRead(ForLet, _3);            // bb0[9]: scope 1 at $DIR/address-of.rs:5:9: 5:14
+        StorageLive(_5);                 // bb0[10]: scope 2 at $DIR/address-of.rs:7:5: 7:18
+        StorageLive(_6);                 // bb0[11]: scope 2 at $DIR/address-of.rs:7:5: 7:18
+        _6 = &raw const (*_1);           // bb0[12]: scope 2 at $DIR/address-of.rs:7:5: 7:6
+        AscribeUserType(_6, o, UserTypeProjection { base: UserType(0), projs: [] }); // bb0[13]: scope 2 at $DIR/address-of.rs:7:5: 7:18
+        _5 = _6;                         // bb0[14]: scope 2 at $DIR/address-of.rs:7:5: 7:18
+        StorageDead(_6);                 // bb0[15]: scope 2 at $DIR/address-of.rs:7:18: 7:19
+        StorageDead(_5);                 // bb0[16]: scope 2 at $DIR/address-of.rs:7:18: 7:19
+        StorageLive(_7);                 // bb0[17]: scope 2 at $DIR/address-of.rs:8:5: 8:26
+        _7 = &raw const (*_1);           // bb0[18]: scope 2 at $DIR/address-of.rs:8:5: 8:6
+        StorageDead(_7);                 // bb0[19]: scope 2 at $DIR/address-of.rs:8:26: 8:27
+        StorageLive(_8);                 // bb0[20]: scope 2 at $DIR/address-of.rs:9:5: 9:25
+        StorageLive(_9);                 // bb0[21]: scope 2 at $DIR/address-of.rs:9:5: 9:25
+        StorageLive(_10);                // bb0[22]: scope 2 at $DIR/address-of.rs:9:5: 9:6
+        _10 = &raw const (*_1);          // bb0[23]: scope 2 at $DIR/address-of.rs:9:5: 9:6
+        _9 = move _10 as *const dyn std::marker::Send (Pointer(Unsize)); // bb0[24]: scope 2 at $DIR/address-of.rs:9:5: 9:6
+        StorageDead(_10);                // bb0[25]: scope 2 at $DIR/address-of.rs:9:5: 9:6
+        AscribeUserType(_9, o, UserTypeProjection { base: UserType(1), projs: [] }); // bb0[26]: scope 2 at $DIR/address-of.rs:9:5: 9:25
+        _8 = _9;                         // bb0[27]: scope 2 at $DIR/address-of.rs:9:5: 9:25
+        StorageDead(_9);                 // bb0[28]: scope 2 at $DIR/address-of.rs:9:25: 9:26
+        StorageDead(_8);                 // bb0[29]: scope 2 at $DIR/address-of.rs:9:25: 9:26
+        StorageLive(_11);                // bb0[30]: scope 2 at $DIR/address-of.rs:10:5: 10:22
+        StorageLive(_12);                // bb0[31]: scope 2 at $DIR/address-of.rs:10:5: 10:6
+        _12 = &raw const (*_1);          // bb0[32]: scope 2 at $DIR/address-of.rs:10:5: 10:6
+        _11 = move _12 as *const [i32] (Pointer(Unsize)); // bb0[33]: scope 2 at $DIR/address-of.rs:10:5: 10:6
+        StorageDead(_12);                // bb0[34]: scope 2 at $DIR/address-of.rs:10:5: 10:6
+        StorageDead(_11);                // bb0[35]: scope 2 at $DIR/address-of.rs:10:22: 10:23
+        StorageLive(_13);                // bb0[36]: scope 2 at $DIR/address-of.rs:11:5: 11:20
+        StorageLive(_14);                // bb0[37]: scope 2 at $DIR/address-of.rs:11:5: 11:6
+        _14 = &raw const (*_1);          // bb0[38]: scope 2 at $DIR/address-of.rs:11:5: 11:6
+        _13 = move _14 as *const i32 (Pointer(ArrayToPointer)); // bb0[39]: scope 2 at $DIR/address-of.rs:11:5: 11:20
+        StorageDead(_14);                // bb0[40]: scope 2 at $DIR/address-of.rs:11:19: 11:20
+        StorageDead(_13);                // bb0[41]: scope 2 at $DIR/address-of.rs:11:20: 11:21
+        StorageLive(_15);                // bb0[42]: scope 2 at $DIR/address-of.rs:13:9: 13:10
+        _15 = &raw const (*_1);          // bb0[43]: scope 2 at $DIR/address-of.rs:13:23: 13:24
+        FakeRead(ForLet, _15);           // bb0[44]: scope 2 at $DIR/address-of.rs:13:9: 13:10
+        AscribeUserType(_15, o, UserTypeProjection { base: UserType(3), projs: [] }); // bb0[45]: scope 2 at $DIR/address-of.rs:13:12: 13:20
+        StorageLive(_16);                // bb0[46]: scope 3 at $DIR/address-of.rs:14:9: 14:10
+        _16 = &raw const (*_1);          // bb0[47]: scope 3 at $DIR/address-of.rs:14:31: 14:32
+        FakeRead(ForLet, _16);           // bb0[48]: scope 3 at $DIR/address-of.rs:14:9: 14:10
+        AscribeUserType(_16, o, UserTypeProjection { base: UserType(5), projs: [] }); // bb0[49]: scope 3 at $DIR/address-of.rs:14:12: 14:28
+        StorageLive(_17);                // bb0[50]: scope 4 at $DIR/address-of.rs:15:9: 15:10
+        StorageLive(_18);                // bb0[51]: scope 4 at $DIR/address-of.rs:15:30: 15:31
+        _18 = &raw const (*_1);          // bb0[52]: scope 4 at $DIR/address-of.rs:15:30: 15:31
+        _17 = move _18 as *const dyn std::marker::Send (Pointer(Unsize)); // bb0[53]: scope 4 at $DIR/address-of.rs:15:30: 15:31
+        StorageDead(_18);                // bb0[54]: scope 4 at $DIR/address-of.rs:15:30: 15:31
+        FakeRead(ForLet, _17);           // bb0[55]: scope 4 at $DIR/address-of.rs:15:9: 15:10
+        AscribeUserType(_17, o, UserTypeProjection { base: UserType(7), projs: [] }); // bb0[56]: scope 4 at $DIR/address-of.rs:15:12: 15:27
+        StorageLive(_19);                // bb0[57]: scope 5 at $DIR/address-of.rs:16:9: 16:10
+        StorageLive(_20);                // bb0[58]: scope 5 at $DIR/address-of.rs:16:27: 16:28
+        _20 = &raw const (*_1);          // bb0[59]: scope 5 at $DIR/address-of.rs:16:27: 16:28
+        _19 = move _20 as *const [i32] (Pointer(Unsize)); // bb0[60]: scope 5 at $DIR/address-of.rs:16:27: 16:28
+        StorageDead(_20);                // bb0[61]: scope 5 at $DIR/address-of.rs:16:27: 16:28
+        FakeRead(ForLet, _19);           // bb0[62]: scope 5 at $DIR/address-of.rs:16:9: 16:10
+        AscribeUserType(_19, o, UserTypeProjection { base: UserType(9), projs: [] }); // bb0[63]: scope 5 at $DIR/address-of.rs:16:12: 16:24
+        StorageLive(_21);                // bb0[64]: scope 6 at $DIR/address-of.rs:18:5: 18:18
+        StorageLive(_22);                // bb0[65]: scope 6 at $DIR/address-of.rs:18:5: 18:18
+        _22 = &raw const (*_3);          // bb0[66]: scope 6 at $DIR/address-of.rs:18:5: 18:6
+        AscribeUserType(_22, o, UserTypeProjection { base: UserType(10), projs: [] }); // bb0[67]: scope 6 at $DIR/address-of.rs:18:5: 18:18
+        _21 = _22;                       // bb0[68]: scope 6 at $DIR/address-of.rs:18:5: 18:18
+        StorageDead(_22);                // bb0[69]: scope 6 at $DIR/address-of.rs:18:18: 18:19
+        StorageDead(_21);                // bb0[70]: scope 6 at $DIR/address-of.rs:18:18: 18:19
+        StorageLive(_23);                // bb0[71]: scope 6 at $DIR/address-of.rs:19:5: 19:26
+        _23 = &raw const (*_3);          // bb0[72]: scope 6 at $DIR/address-of.rs:19:5: 19:6
+        StorageDead(_23);                // bb0[73]: scope 6 at $DIR/address-of.rs:19:26: 19:27
+        StorageLive(_24);                // bb0[74]: scope 6 at $DIR/address-of.rs:20:5: 20:25
+        StorageLive(_25);                // bb0[75]: scope 6 at $DIR/address-of.rs:20:5: 20:25
+        StorageLive(_26);                // bb0[76]: scope 6 at $DIR/address-of.rs:20:5: 20:6
+        _26 = &raw const (*_3);          // bb0[77]: scope 6 at $DIR/address-of.rs:20:5: 20:6
+        _25 = move _26 as *const dyn std::marker::Send (Pointer(Unsize)); // bb0[78]: scope 6 at $DIR/address-of.rs:20:5: 20:6
+        StorageDead(_26);                // bb0[79]: scope 6 at $DIR/address-of.rs:20:5: 20:6
+        AscribeUserType(_25, o, UserTypeProjection { base: UserType(11), projs: [] }); // bb0[80]: scope 6 at $DIR/address-of.rs:20:5: 20:25
+        _24 = _25;                       // bb0[81]: scope 6 at $DIR/address-of.rs:20:5: 20:25
+        StorageDead(_25);                // bb0[82]: scope 6 at $DIR/address-of.rs:20:25: 20:26
+        StorageDead(_24);                // bb0[83]: scope 6 at $DIR/address-of.rs:20:25: 20:26
+        StorageLive(_27);                // bb0[84]: scope 6 at $DIR/address-of.rs:21:5: 21:22
+        StorageLive(_28);                // bb0[85]: scope 6 at $DIR/address-of.rs:21:5: 21:6
+        _28 = &raw const (*_3);          // bb0[86]: scope 6 at $DIR/address-of.rs:21:5: 21:6
+        _27 = move _28 as *const [i32] (Pointer(Unsize)); // bb0[87]: scope 6 at $DIR/address-of.rs:21:5: 21:6
+        StorageDead(_28);                // bb0[88]: scope 6 at $DIR/address-of.rs:21:5: 21:6
+        StorageDead(_27);                // bb0[89]: scope 6 at $DIR/address-of.rs:21:22: 21:23
+        StorageLive(_29);                // bb0[90]: scope 6 at $DIR/address-of.rs:23:9: 23:10
+        _29 = &raw const (*_3);          // bb0[91]: scope 6 at $DIR/address-of.rs:23:23: 23:24
+        FakeRead(ForLet, _29);           // bb0[92]: scope 6 at $DIR/address-of.rs:23:9: 23:10
+        AscribeUserType(_29, o, UserTypeProjection { base: UserType(13), projs: [] }); // bb0[93]: scope 6 at $DIR/address-of.rs:23:12: 23:20
+        StorageLive(_30);                // bb0[94]: scope 7 at $DIR/address-of.rs:24:9: 24:10
+        _30 = &raw const (*_3);          // bb0[95]: scope 7 at $DIR/address-of.rs:24:31: 24:32
+        FakeRead(ForLet, _30);           // bb0[96]: scope 7 at $DIR/address-of.rs:24:9: 24:10
+        AscribeUserType(_30, o, UserTypeProjection { base: UserType(15), projs: [] }); // bb0[97]: scope 7 at $DIR/address-of.rs:24:12: 24:28
+        StorageLive(_31);                // bb0[98]: scope 8 at $DIR/address-of.rs:25:9: 25:10
+        StorageLive(_32);                // bb0[99]: scope 8 at $DIR/address-of.rs:25:30: 25:31
+        _32 = &raw const (*_3);          // bb0[100]: scope 8 at $DIR/address-of.rs:25:30: 25:31
+        _31 = move _32 as *const dyn std::marker::Send (Pointer(Unsize)); // bb0[101]: scope 8 at $DIR/address-of.rs:25:30: 25:31
+        StorageDead(_32);                // bb0[102]: scope 8 at $DIR/address-of.rs:25:30: 25:31
+        FakeRead(ForLet, _31);           // bb0[103]: scope 8 at $DIR/address-of.rs:25:9: 25:10
+        AscribeUserType(_31, o, UserTypeProjection { base: UserType(17), projs: [] }); // bb0[104]: scope 8 at $DIR/address-of.rs:25:12: 25:27
+        StorageLive(_33);                // bb0[105]: scope 9 at $DIR/address-of.rs:26:9: 26:10
+        StorageLive(_34);                // bb0[106]: scope 9 at $DIR/address-of.rs:26:27: 26:28
+        _34 = &raw const (*_3);          // bb0[107]: scope 9 at $DIR/address-of.rs:26:27: 26:28
+        _33 = move _34 as *const [i32] (Pointer(Unsize)); // bb0[108]: scope 9 at $DIR/address-of.rs:26:27: 26:28
+        StorageDead(_34);                // bb0[109]: scope 9 at $DIR/address-of.rs:26:27: 26:28
+        FakeRead(ForLet, _33);           // bb0[110]: scope 9 at $DIR/address-of.rs:26:9: 26:10
+        AscribeUserType(_33, o, UserTypeProjection { base: UserType(19), projs: [] }); // bb0[111]: scope 9 at $DIR/address-of.rs:26:12: 26:24
+        StorageLive(_35);                // bb0[112]: scope 10 at $DIR/address-of.rs:28:5: 28:16
+        StorageLive(_36);                // bb0[113]: scope 10 at $DIR/address-of.rs:28:5: 28:16
+        _36 = &raw mut (*_3);            // bb0[114]: scope 10 at $DIR/address-of.rs:28:5: 28:6
+        AscribeUserType(_36, o, UserTypeProjection { base: UserType(20), projs: [] }); // bb0[115]: scope 10 at $DIR/address-of.rs:28:5: 28:16
+        _35 = _36;                       // bb0[116]: scope 10 at $DIR/address-of.rs:28:5: 28:16
+        StorageDead(_36);                // bb0[117]: scope 10 at $DIR/address-of.rs:28:16: 28:17
+        StorageDead(_35);                // bb0[118]: scope 10 at $DIR/address-of.rs:28:16: 28:17
+        StorageLive(_37);                // bb0[119]: scope 10 at $DIR/address-of.rs:29:5: 29:24
+        _37 = &raw mut (*_3);            // bb0[120]: scope 10 at $DIR/address-of.rs:29:5: 29:6
+        StorageDead(_37);                // bb0[121]: scope 10 at $DIR/address-of.rs:29:24: 29:25
+        StorageLive(_38);                // bb0[122]: scope 10 at $DIR/address-of.rs:30:5: 30:23
+        StorageLive(_39);                // bb0[123]: scope 10 at $DIR/address-of.rs:30:5: 30:23
+        StorageLive(_40);                // bb0[124]: scope 10 at $DIR/address-of.rs:30:5: 30:6
+        _40 = &raw mut (*_3);            // bb0[125]: scope 10 at $DIR/address-of.rs:30:5: 30:6
+        _39 = move _40 as *mut dyn std::marker::Send (Pointer(Unsize)); // bb0[126]: scope 10 at $DIR/address-of.rs:30:5: 30:6
+        StorageDead(_40);                // bb0[127]: scope 10 at $DIR/address-of.rs:30:5: 30:6
+        AscribeUserType(_39, o, UserTypeProjection { base: UserType(21), projs: [] }); // bb0[128]: scope 10 at $DIR/address-of.rs:30:5: 30:23
+        _38 = _39;                       // bb0[129]: scope 10 at $DIR/address-of.rs:30:5: 30:23
+        StorageDead(_39);                // bb0[130]: scope 10 at $DIR/address-of.rs:30:23: 30:24
+        StorageDead(_38);                // bb0[131]: scope 10 at $DIR/address-of.rs:30:23: 30:24
+        StorageLive(_41);                // bb0[132]: scope 10 at $DIR/address-of.rs:31:5: 31:20
+        StorageLive(_42);                // bb0[133]: scope 10 at $DIR/address-of.rs:31:5: 31:6
+        _42 = &raw mut (*_3);            // bb0[134]: scope 10 at $DIR/address-of.rs:31:5: 31:6
+        _41 = move _42 as *mut [i32] (Pointer(Unsize)); // bb0[135]: scope 10 at $DIR/address-of.rs:31:5: 31:6
+        StorageDead(_42);                // bb0[136]: scope 10 at $DIR/address-of.rs:31:5: 31:6
+        StorageDead(_41);                // bb0[137]: scope 10 at $DIR/address-of.rs:31:20: 31:21
+        StorageLive(_43);                // bb0[138]: scope 10 at $DIR/address-of.rs:33:9: 33:10
+        _43 = &raw mut (*_3);            // bb0[139]: scope 10 at $DIR/address-of.rs:33:21: 33:22
+        FakeRead(ForLet, _43);           // bb0[140]: scope 10 at $DIR/address-of.rs:33:9: 33:10
+        AscribeUserType(_43, o, UserTypeProjection { base: UserType(23), projs: [] }); // bb0[141]: scope 10 at $DIR/address-of.rs:33:12: 33:18
+        StorageLive(_44);                // bb0[142]: scope 11 at $DIR/address-of.rs:34:9: 34:10
+        _44 = &raw mut (*_3);            // bb0[143]: scope 11 at $DIR/address-of.rs:34:29: 34:30
+        FakeRead(ForLet, _44);           // bb0[144]: scope 11 at $DIR/address-of.rs:34:9: 34:10
+        AscribeUserType(_44, o, UserTypeProjection { base: UserType(25), projs: [] }); // bb0[145]: scope 11 at $DIR/address-of.rs:34:12: 34:26
+        StorageLive(_45);                // bb0[146]: scope 12 at $DIR/address-of.rs:35:9: 35:10
+        StorageLive(_46);                // bb0[147]: scope 12 at $DIR/address-of.rs:35:28: 35:29
+        _46 = &raw mut (*_3);            // bb0[148]: scope 12 at $DIR/address-of.rs:35:28: 35:29
+        _45 = move _46 as *mut dyn std::marker::Send (Pointer(Unsize)); // bb0[149]: scope 12 at $DIR/address-of.rs:35:28: 35:29
+        StorageDead(_46);                // bb0[150]: scope 12 at $DIR/address-of.rs:35:28: 35:29
+        FakeRead(ForLet, _45);           // bb0[151]: scope 12 at $DIR/address-of.rs:35:9: 35:10
+        AscribeUserType(_45, o, UserTypeProjection { base: UserType(27), projs: [] }); // bb0[152]: scope 12 at $DIR/address-of.rs:35:12: 35:25
+        StorageLive(_47);                // bb0[153]: scope 13 at $DIR/address-of.rs:36:9: 36:10
+        StorageLive(_48);                // bb0[154]: scope 13 at $DIR/address-of.rs:36:25: 36:26
+        _48 = &raw mut (*_3);            // bb0[155]: scope 13 at $DIR/address-of.rs:36:25: 36:26
+        _47 = move _48 as *mut [i32] (Pointer(Unsize)); // bb0[156]: scope 13 at $DIR/address-of.rs:36:25: 36:26
+        StorageDead(_48);                // bb0[157]: scope 13 at $DIR/address-of.rs:36:25: 36:26
+        FakeRead(ForLet, _47);           // bb0[158]: scope 13 at $DIR/address-of.rs:36:9: 36:10
+        AscribeUserType(_47, o, UserTypeProjection { base: UserType(29), projs: [] }); // bb0[159]: scope 13 at $DIR/address-of.rs:36:12: 36:22
+        _0 = ();                         // bb0[160]: scope 0 at $DIR/address-of.rs:3:26: 37:2
+        StorageDead(_47);                // bb0[161]: scope 13 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_45);                // bb0[162]: scope 12 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_44);                // bb0[163]: scope 11 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_43);                // bb0[164]: scope 10 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_33);                // bb0[165]: scope 9 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_31);                // bb0[166]: scope 8 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_30);                // bb0[167]: scope 7 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_29);                // bb0[168]: scope 6 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_19);                // bb0[169]: scope 5 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_17);                // bb0[170]: scope 4 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_16);                // bb0[171]: scope 3 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_15);                // bb0[172]: scope 2 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_4);                 // bb0[173]: scope 1 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_3);                 // bb0[174]: scope 1 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_2);                 // bb0[175]: scope 0 at $DIR/address-of.rs:37:1: 37:2
+        StorageDead(_1);                 // bb0[176]: scope 0 at $DIR/address-of.rs:37:1: 37:2
+        return;                          // bb0[177]: scope 0 at $DIR/address-of.rs:37:2: 37:2
+    }
+}
diff --git a/src/test/mir-opt/address-of/rustc.borrow_and_cast.SimplifyCfg-initial.after.mir b/src/test/mir-opt/address-of/rustc.borrow_and_cast.SimplifyCfg-initial.after.mir
new file mode 100644 (file)
index 0000000..29ccff4
--- /dev/null
@@ -0,0 +1,47 @@
+// MIR for `borrow_and_cast` after SimplifyCfg-initial
+
+fn borrow_and_cast(_1: i32) -> () {
+    debug x => _1;                       // in scope 0 at $DIR/address-of.rs:41:20: 41:25
+    let mut _0: ();                      // return place in scope 0 at $DIR/address-of.rs:41:32: 41:32
+    let _2: *const i32;                  // in scope 0 at $DIR/address-of.rs:42:9: 42:10
+    let _3: &i32;                        // in scope 0 at $DIR/address-of.rs:42:13: 42:15
+    let _5: &mut i32;                    // in scope 0 at $DIR/address-of.rs:43:13: 43:19
+    let mut _7: &mut i32;                // in scope 0 at $DIR/address-of.rs:44:13: 44:19
+    scope 1 {
+        debug p => _2;                   // in scope 1 at $DIR/address-of.rs:42:9: 42:10
+        let _4: *const i32;              // in scope 1 at $DIR/address-of.rs:43:9: 43:10
+        scope 2 {
+            debug q => _4;               // in scope 2 at $DIR/address-of.rs:43:9: 43:10
+            let _6: *mut i32;            // in scope 2 at $DIR/address-of.rs:44:9: 44:10
+            scope 3 {
+                debug r => _6;           // in scope 3 at $DIR/address-of.rs:44:9: 44:10
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/address-of.rs:42:9: 42:10
+        StorageLive(_3);                 // bb0[1]: scope 0 at $DIR/address-of.rs:42:13: 42:15
+        _3 = &_1;                        // bb0[2]: scope 0 at $DIR/address-of.rs:42:13: 42:15
+        _2 = &raw const (*_3);           // bb0[3]: scope 0 at $DIR/address-of.rs:42:13: 42:15
+        FakeRead(ForLet, _2);            // bb0[4]: scope 0 at $DIR/address-of.rs:42:9: 42:10
+        StorageDead(_3);                 // bb0[5]: scope 0 at $DIR/address-of.rs:42:29: 42:30
+        StorageLive(_4);                 // bb0[6]: scope 1 at $DIR/address-of.rs:43:9: 43:10
+        StorageLive(_5);                 // bb0[7]: scope 1 at $DIR/address-of.rs:43:13: 43:19
+        _5 = &mut _1;                    // bb0[8]: scope 1 at $DIR/address-of.rs:43:13: 43:19
+        _4 = &raw const (*_5);           // bb0[9]: scope 1 at $DIR/address-of.rs:43:13: 43:19
+        FakeRead(ForLet, _4);            // bb0[10]: scope 1 at $DIR/address-of.rs:43:9: 43:10
+        StorageDead(_5);                 // bb0[11]: scope 1 at $DIR/address-of.rs:43:33: 43:34
+        StorageLive(_6);                 // bb0[12]: scope 2 at $DIR/address-of.rs:44:9: 44:10
+        StorageLive(_7);                 // bb0[13]: scope 2 at $DIR/address-of.rs:44:13: 44:19
+        _7 = &mut _1;                    // bb0[14]: scope 2 at $DIR/address-of.rs:44:13: 44:19
+        _6 = &raw mut (*_7);             // bb0[15]: scope 2 at $DIR/address-of.rs:44:13: 44:19
+        FakeRead(ForLet, _6);            // bb0[16]: scope 2 at $DIR/address-of.rs:44:9: 44:10
+        StorageDead(_7);                 // bb0[17]: scope 2 at $DIR/address-of.rs:44:31: 44:32
+        _0 = ();                         // bb0[18]: scope 0 at $DIR/address-of.rs:41:32: 45:2
+        StorageDead(_6);                 // bb0[19]: scope 2 at $DIR/address-of.rs:45:1: 45:2
+        StorageDead(_4);                 // bb0[20]: scope 1 at $DIR/address-of.rs:45:1: 45:2
+        StorageDead(_2);                 // bb0[21]: scope 0 at $DIR/address-of.rs:45:1: 45:2
+        return;                          // bb0[22]: scope 0 at $DIR/address-of.rs:45:2: 45:2
+    }
+}
index 57f30acb3a643bc35ab4934e638e20e7a35510fa..4667c4f66b296038570dadacb3af15f47c3a452d 100644 (file)
@@ -7,35 +7,11 @@ unsafe fn foo(z: *mut usize) -> u32 {
     99
 }
 
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir
 fn main() {
     let mut x = [42, 43, 44];
     let mut y = 1;
     let z: *mut usize = &mut y;
     x[y] = unsafe { foo(z) };
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyCfg-elaborate-drops.after.mir
-//     bb0: {
-//         ...
-//         _4 = &mut _2;
-//         _3 = &raw mut (*_4);
-//         ...
-//         _6 = _3;
-//         _5 = const foo(move _6) -> bb1;
-//     }
-//
-//     bb1: {
-//         ...
-//         _7 = _2;
-//         _8 = Len(_1);
-//         _9 = Lt(_7, _8);
-//         assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2;
-//     }
-//
-//     bb2: {
-//         _1[_7] = move _5;
-//         ...
-//         return;
-//     }
-// END rustc.main.SimplifyCfg-elaborate-drops.after.mir
diff --git a/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..052a335
--- /dev/null
@@ -0,0 +1,91 @@
+// MIR for `main` after SimplifyCfg-elaborate-drops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/array-index-is-temporary.rs:12:11: 12:11
+    let mut _1: [u32; 3];                // in scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14
+    let mut _4: &mut usize;              // in scope 0 at $DIR/array-index-is-temporary.rs:15:25: 15:31
+    let mut _5: u32;                     // in scope 0 at $DIR/array-index-is-temporary.rs:16:12: 16:29
+    let mut _6: *mut usize;              // in scope 0 at $DIR/array-index-is-temporary.rs:16:25: 16:26
+    let _7: usize;                       // in scope 0 at $DIR/array-index-is-temporary.rs:16:7: 16:8
+    let mut _8: usize;                   // in scope 0 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+    let mut _9: bool;                    // in scope 0 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/array-index-is-temporary.rs:13:9: 13:14
+        let mut _2: usize;               // in scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14
+        scope 2 {
+            debug y => _2;               // in scope 2 at $DIR/array-index-is-temporary.rs:14:9: 14:14
+            let _3: *mut usize as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10
+            scope 3 {
+                debug z => _3;           // in scope 3 at $DIR/array-index-is-temporary.rs:15:9: 15:10
+                scope 4 {
+                }
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14
+        _1 = [const 42u32, const 43u32, const 44u32]; // bb0[1]: scope 0 at $DIR/array-index-is-temporary.rs:13:17: 13:29
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000002a))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:13:18: 13:20
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000002b))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:13:22: 13:24
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000002b)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000002c))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:13:26: 13:28
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000002c)) }
+        StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14
+        _2 = const 1usize;               // bb0[3]: scope 1 at $DIR/array-index-is-temporary.rs:14:17: 14:18
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:14:17: 14:18
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+        StorageLive(_3);                 // bb0[4]: scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10
+        StorageLive(_4);                 // bb0[5]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
+        _4 = &mut _2;                    // bb0[6]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
+        _3 = &raw mut (*_4);             // bb0[7]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
+        StorageDead(_4);                 // bb0[8]: scope 2 at $DIR/array-index-is-temporary.rs:15:31: 15:32
+        StorageLive(_5);                 // bb0[9]: scope 3 at $DIR/array-index-is-temporary.rs:16:12: 16:29
+        StorageLive(_6);                 // bb0[10]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
+        _6 = _3;                         // bb0[11]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
+        _5 = const foo(move _6) -> bb1;  // bb0[12]: scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
+                                         // ty::Const
+                                         // + ty: unsafe fn(*mut usize) -> u32 {foo}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
+                                         // + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1: {
+        StorageDead(_6);                 // bb1[0]: scope 4 at $DIR/array-index-is-temporary.rs:16:26: 16:27
+        StorageLive(_7);                 // bb1[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8
+        _7 = _2;                         // bb1[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8
+        _8 = Len(_1);                    // bb1[3]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+        _9 = Lt(_7, _8);                 // bb1[4]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+        assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; // bb1[5]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+    }
+
+    bb2: {
+        _1[_7] = move _5;                // bb2[0]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:29
+        StorageDead(_5);                 // bb2[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29
+        StorageDead(_7);                 // bb2[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30
+        _0 = ();                         // bb2[3]: scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2
+        StorageDead(_3);                 // bb2[4]: scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2
+        StorageDead(_2);                 // bb2[5]: scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2
+        StorageDead(_1);                 // bb2[6]: scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2
+        return;                          // bb2[7]: scope 0 at $DIR/array-index-is-temporary.rs:17:2: 17:2
+    }
+}
diff --git a/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..e180f44
--- /dev/null
@@ -0,0 +1,91 @@
+// MIR for `main` after SimplifyCfg-elaborate-drops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/array-index-is-temporary.rs:12:11: 12:11
+    let mut _1: [u32; 3];                // in scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14
+    let mut _4: &mut usize;              // in scope 0 at $DIR/array-index-is-temporary.rs:15:25: 15:31
+    let mut _5: u32;                     // in scope 0 at $DIR/array-index-is-temporary.rs:16:12: 16:29
+    let mut _6: *mut usize;              // in scope 0 at $DIR/array-index-is-temporary.rs:16:25: 16:26
+    let _7: usize;                       // in scope 0 at $DIR/array-index-is-temporary.rs:16:7: 16:8
+    let mut _8: usize;                   // in scope 0 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+    let mut _9: bool;                    // in scope 0 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/array-index-is-temporary.rs:13:9: 13:14
+        let mut _2: usize;               // in scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14
+        scope 2 {
+            debug y => _2;               // in scope 2 at $DIR/array-index-is-temporary.rs:14:9: 14:14
+            let _3: *mut usize as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10
+            scope 3 {
+                debug z => _3;           // in scope 3 at $DIR/array-index-is-temporary.rs:15:9: 15:10
+                scope 4 {
+                }
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14
+        _1 = [const 42u32, const 43u32, const 44u32]; // bb0[1]: scope 0 at $DIR/array-index-is-temporary.rs:13:17: 13:29
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000002a))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:13:18: 13:20
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000002b))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:13:22: 13:24
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000002b)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000002c))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:13:26: 13:28
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000002c)) }
+        StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14
+        _2 = const 1usize;               // bb0[3]: scope 1 at $DIR/array-index-is-temporary.rs:14:17: 14:18
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000001))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:14:17: 14:18
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+        StorageLive(_3);                 // bb0[4]: scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10
+        StorageLive(_4);                 // bb0[5]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
+        _4 = &mut _2;                    // bb0[6]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
+        _3 = &raw mut (*_4);             // bb0[7]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
+        StorageDead(_4);                 // bb0[8]: scope 2 at $DIR/array-index-is-temporary.rs:15:31: 15:32
+        StorageLive(_5);                 // bb0[9]: scope 3 at $DIR/array-index-is-temporary.rs:16:12: 16:29
+        StorageLive(_6);                 // bb0[10]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
+        _6 = _3;                         // bb0[11]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
+        _5 = const foo(move _6) -> bb1;  // bb0[12]: scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
+                                         // ty::Const
+                                         // + ty: unsafe fn(*mut usize) -> u32 {foo}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
+                                         // + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1: {
+        StorageDead(_6);                 // bb1[0]: scope 4 at $DIR/array-index-is-temporary.rs:16:26: 16:27
+        StorageLive(_7);                 // bb1[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8
+        _7 = _2;                         // bb1[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8
+        _8 = Len(_1);                    // bb1[3]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+        _9 = Lt(_7, _8);                 // bb1[4]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+        assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; // bb1[5]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
+    }
+
+    bb2: {
+        _1[_7] = move _5;                // bb2[0]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:29
+        StorageDead(_5);                 // bb2[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29
+        StorageDead(_7);                 // bb2[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30
+        _0 = ();                         // bb2[3]: scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2
+        StorageDead(_3);                 // bb2[4]: scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2
+        StorageDead(_2);                 // bb2[5]: scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2
+        StorageDead(_1);                 // bb2[6]: scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2
+        return;                          // bb2[7]: scope 0 at $DIR/array-index-is-temporary.rs:17:2: 17:2
+    }
+}
index fa1a291858becca149f0abe544f4be40434da9e4..beaf0baf12c0ba93ec2cc80fd6bfc566a3d1c66c 100644 (file)
@@ -2,6 +2,7 @@
 
 #![feature(box_syntax)]
 
+// EMIT_MIR rustc.main.ElaborateDrops.before.mir
 fn main() {
     let x = box S::new();
     drop(x);
@@ -18,60 +19,3 @@ fn drop(&mut self) {
         println!("splat!");
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.ElaborateDrops.before.mir
-//     let mut _0: ();
-//     let _1: std::boxed::Box<S>;
-//     let mut _2: std::boxed::Box<S>;
-//     let _3: ();
-//     let mut _4: std::boxed::Box<S>;
-//     scope 1 {
-//         debug x => _1;
-//     }
-//     bb0: {
-//         StorageLive(_1);
-//         StorageLive(_2);
-//         _2 = Box(S);
-//         (*_2) = const S::new() -> [return: bb2, unwind: bb3];
-//     }
-//
-//     bb1 (cleanup): {
-//         resume;
-//     }
-//
-//     bb2: {
-//         _1 = move _2;
-//         drop(_2) -> bb4;
-//     }
-//
-//     bb3 (cleanup): {
-//         drop(_2) -> bb1;
-//     }
-//
-//     bb4: {
-//         StorageDead(_2);
-//         StorageLive(_3);
-//         StorageLive(_4);
-//         _4 = move _1;
-//         _3 = const std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7];
-//     }
-//
-//     bb5: {
-//         StorageDead(_4);
-//         StorageDead(_3);
-//         _0 = ();
-//         drop(_1) -> bb8;
-//     }
-//     bb6 (cleanup): {
-//         drop(_1) -> bb1;
-//     }
-//     bb7 (cleanup): {
-//         drop(_4) -> bb6;
-//     }
-//     bb8: {
-//         StorageDead(_1);
-//         return;
-//     }
-// }
-// END rustc.main.ElaborateDrops.before.mir
diff --git a/src/test/mir-opt/box_expr/rustc.main.ElaborateDrops.before.mir b/src/test/mir-opt/box_expr/rustc.main.ElaborateDrops.before.mir
new file mode 100644 (file)
index 0000000..6198653
--- /dev/null
@@ -0,0 +1,72 @@
+// MIR for `main` before ElaborateDrops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/box_expr.rs:6:11: 6:11
+    let _1: std::boxed::Box<S>;          // in scope 0 at $DIR/box_expr.rs:7:9: 7:10
+    let mut _2: std::boxed::Box<S>;      // in scope 0 at $DIR/box_expr.rs:7:13: 7:25
+    let _3: ();                          // in scope 0 at $DIR/box_expr.rs:8:5: 8:12
+    let mut _4: std::boxed::Box<S>;      // in scope 0 at $DIR/box_expr.rs:8:10: 8:11
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/box_expr.rs:7:9: 7:10
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/box_expr.rs:7:9: 7:10
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/box_expr.rs:7:13: 7:25
+        _2 = Box(S);                     // bb0[2]: scope 0 at $DIR/box_expr.rs:7:13: 7:25
+        (*_2) = const S::new() -> [return: bb2, unwind: bb3]; // bb0[3]: scope 0 at $DIR/box_expr.rs:7:17: 7:25
+                                         // ty::Const
+                                         // + ty: fn() -> S {S::new}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/box_expr.rs:7:17: 7:23
+                                         // + literal: Const { ty: fn() -> S {S::new}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/box_expr.rs:6:1: 9:2
+    }
+
+    bb2: {
+        _1 = move _2;                    // bb2[0]: scope 0 at $DIR/box_expr.rs:7:13: 7:25
+        drop(_2) -> bb4;                 // bb2[1]: scope 0 at $DIR/box_expr.rs:7:24: 7:25
+    }
+
+    bb3 (cleanup): {
+        drop(_2) -> bb1;                 // bb3[0]: scope 0 at $DIR/box_expr.rs:7:24: 7:25
+    }
+
+    bb4: {
+        StorageDead(_2);                 // bb4[0]: scope 0 at $DIR/box_expr.rs:7:24: 7:25
+        StorageLive(_3);                 // bb4[1]: scope 1 at $DIR/box_expr.rs:8:5: 8:12
+        StorageLive(_4);                 // bb4[2]: scope 1 at $DIR/box_expr.rs:8:10: 8:11
+        _4 = move _1;                    // bb4[3]: scope 1 at $DIR/box_expr.rs:8:10: 8:11
+        _3 = const std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7]; // bb4[4]: scope 1 at $DIR/box_expr.rs:8:5: 8:12
+                                         // ty::Const
+                                         // + ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/box_expr.rs:8:5: 8:9
+                                         // + literal: Const { ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb5: {
+        StorageDead(_4);                 // bb5[0]: scope 1 at $DIR/box_expr.rs:8:11: 8:12
+        StorageDead(_3);                 // bb5[1]: scope 1 at $DIR/box_expr.rs:8:12: 8:13
+        _0 = ();                         // bb5[2]: scope 0 at $DIR/box_expr.rs:6:11: 9:2
+        drop(_1) -> bb8;                 // bb5[3]: scope 0 at $DIR/box_expr.rs:9:1: 9:2
+    }
+
+    bb6 (cleanup): {
+        drop(_1) -> bb1;                 // bb6[0]: scope 0 at $DIR/box_expr.rs:9:1: 9:2
+    }
+
+    bb7 (cleanup): {
+        drop(_4) -> bb6;                 // bb7[0]: scope 1 at $DIR/box_expr.rs:8:11: 8:12
+    }
+
+    bb8: {
+        StorageDead(_1);                 // bb8[0]: scope 0 at $DIR/box_expr.rs:9:1: 9:2
+        return;                          // bb8[1]: scope 0 at $DIR/box_expr.rs:9:2: 9:2
+    }
+}
index 0fb685c3c4e6d2bff2b9fa8c02c4903d1999008c..317e96d6f52d6ad77d12276554118d0b4650f81e 100644 (file)
@@ -1,15 +1,7 @@
 // compile-flags: -Z mir-opt-level=0
 
+// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir
 fn main() {
     let x = b"foo";
     let y = [5u8, b'x'];
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyCfg-elaborate-drops.after.mir
-// ...
-// _1 = const b"foo";
-// ...
-// _2 = [const 5u8, const 120u8];
-// ...
-// END rustc.main.SimplifyCfg-elaborate-drops.after.mir
diff --git a/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..14be9c9
--- /dev/null
@@ -0,0 +1,46 @@
+// MIR for `main` after SimplifyCfg-elaborate-drops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/byte_slice.rs:4:11: 4:11
+    let _1: &[u8; 3];                    // in scope 0 at $DIR/byte_slice.rs:5:9: 5:10
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/byte_slice.rs:5:9: 5:10
+        let _2: [u8; 2];                 // in scope 1 at $DIR/byte_slice.rs:6:9: 6:10
+        scope 2 {
+            debug y => _2;               // in scope 2 at $DIR/byte_slice.rs:6:9: 6:10
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/byte_slice.rs:5:9: 5:10
+        _1 = const b"foo";               // bb0[1]: scope 0 at $DIR/byte_slice.rs:5:13: 5:19
+                                         // ty::Const
+                                         // + ty: &[u8; 3]
+                                         // + val: Value(Scalar(alloc0+0))
+                                         // mir::Constant
+                                         // + span: $DIR/byte_slice.rs:5:13: 5:19
+                                         // + literal: Const { ty: &[u8; 3], val: Value(Scalar(alloc0+0)) }
+        StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/byte_slice.rs:6:9: 6:10
+        _2 = [const 5u8, const 120u8];   // bb0[3]: scope 1 at $DIR/byte_slice.rs:6:13: 6:24
+                                         // ty::Const
+                                         // + ty: u8
+                                         // + val: Value(Scalar(0x05))
+                                         // mir::Constant
+                                         // + span: $DIR/byte_slice.rs:6:14: 6:17
+                                         // + literal: Const { ty: u8, val: Value(Scalar(0x05)) }
+                                         // ty::Const
+                                         // + ty: u8
+                                         // + val: Value(Scalar(0x78))
+                                         // mir::Constant
+                                         // + span: $DIR/byte_slice.rs:6:19: 6:23
+                                         // + literal: Const { ty: u8, val: Value(Scalar(0x78)) }
+        _0 = ();                         // bb0[4]: scope 0 at $DIR/byte_slice.rs:4:11: 7:2
+        StorageDead(_2);                 // bb0[5]: scope 1 at $DIR/byte_slice.rs:7:1: 7:2
+        StorageDead(_1);                 // bb0[6]: scope 0 at $DIR/byte_slice.rs:7:1: 7:2
+        return;                          // bb0[7]: scope 0 at $DIR/byte_slice.rs:7:2: 7:2
+    }
+}
+
+alloc0 (size: 3, align: 1) {
+    66 6f 6f                                        â”‚ foo
+}
index 9a046202cd004135fb0cdf5474e3a65e0ae36fad..aa1c7459ea155f542fe8ba4a34dd2989eff762ed 100644 (file)
@@ -1,3 +1,6 @@
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.norm2.InstCombine.diff
+
 fn norm2(x: [f32; 2]) -> f32 {
     let a = x[0];
     let b = x[1];
@@ -7,17 +10,3 @@
 fn main() {
     assert_eq!(norm2([3.0, 4.0]), 5.0*5.0);
 }
-
-// END RUST SOURCE
-
-// START rustc.norm2.InstCombine.before.mir
-//     _4 = Len(_1);
-//     ...
-//     _8 = Len(_1);
-// END rustc.norm2.InstCombine.before.mir
-
-// START rustc.norm2.InstCombine.after.mir
-//     _4 = const 2usize;
-//     ...
-//     _8 = const 2usize;
-// END rustc.norm2.InstCombine.after.mir
diff --git a/src/test/mir-opt/combine_array_len/32bit/rustc.norm2.InstCombine.diff b/src/test/mir-opt/combine_array_len/32bit/rustc.norm2.InstCombine.diff
new file mode 100644 (file)
index 0000000..7ec1c9a
--- /dev/null
@@ -0,0 +1,101 @@
+- // MIR for `norm2` before InstCombine
++ // MIR for `norm2` after InstCombine
+  
+  fn norm2(_1: [f32; 2]) -> f32 {
+      debug x => _1;                       // in scope 0 at $DIR/combine_array_len.rs:4:10: 4:11
+      let mut _0: f32;                     // return place in scope 0 at $DIR/combine_array_len.rs:4:26: 4:29
+      let _2: f32;                         // in scope 0 at $DIR/combine_array_len.rs:5:9: 5:10
+      let _3: usize;                       // in scope 0 at $DIR/combine_array_len.rs:5:15: 5:16
+      let mut _4: usize;                   // in scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+      let mut _5: bool;                    // in scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+      let _7: usize;                       // in scope 0 at $DIR/combine_array_len.rs:6:15: 6:16
+      let mut _8: usize;                   // in scope 0 at $DIR/combine_array_len.rs:6:13: 6:17
+      let mut _9: bool;                    // in scope 0 at $DIR/combine_array_len.rs:6:13: 6:17
+      let mut _10: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:5: 7:8
+      let mut _11: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:5: 7:6
+      let mut _12: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:7: 7:8
+      let mut _13: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:11: 7:14
+      let mut _14: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:11: 7:12
+      let mut _15: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:13: 7:14
+      scope 1 {
+          debug a => _2;                   // in scope 1 at $DIR/combine_array_len.rs:5:9: 5:10
+          let _6: f32;                     // in scope 1 at $DIR/combine_array_len.rs:6:9: 6:10
+          scope 2 {
+              debug b => _6;               // in scope 2 at $DIR/combine_array_len.rs:6:9: 6:10
+          }
+      }
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/combine_array_len.rs:5:9: 5:10
+          StorageLive(_3);                 // bb0[1]: scope 0 at $DIR/combine_array_len.rs:5:15: 5:16
+          _3 = const 0usize;               // bb0[2]: scope 0 at $DIR/combine_array_len.rs:5:15: 5:16
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/combine_array_len.rs:5:15: 5:16
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) }
+-         _4 = Len(_1);                    // bb0[3]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
++         _4 = const 2usize;               // bb0[3]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
++                                          // ty::Const
++                                          // + ty: usize
++                                          // + val: Value(Scalar(0x00000002))
++                                          // mir::Constant
++                                          // + span: $DIR/combine_array_len.rs:5:13: 5:17
++                                          // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) }
+          _5 = Lt(_3, _4);                 // bb0[4]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+          assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[5]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+      }
+  
+      bb1: {
+          _2 = _1[_3];                     // bb1[0]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+          StorageDead(_3);                 // bb1[1]: scope 0 at $DIR/combine_array_len.rs:5:17: 5:18
+          StorageLive(_6);                 // bb1[2]: scope 1 at $DIR/combine_array_len.rs:6:9: 6:10
+          StorageLive(_7);                 // bb1[3]: scope 1 at $DIR/combine_array_len.rs:6:15: 6:16
+          _7 = const 1usize;               // bb1[4]: scope 1 at $DIR/combine_array_len.rs:6:15: 6:16
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/combine_array_len.rs:6:15: 6:16
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+-         _8 = Len(_1);                    // bb1[5]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
++         _8 = const 2usize;               // bb1[5]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
++                                          // ty::Const
++                                          // + ty: usize
++                                          // + val: Value(Scalar(0x00000002))
++                                          // mir::Constant
++                                          // + span: $DIR/combine_array_len.rs:6:13: 6:17
++                                          // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) }
+          _9 = Lt(_7, _8);                 // bb1[6]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
+          assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; // bb1[7]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
+      }
+  
+      bb2: {
+          _6 = _1[_7];                     // bb2[0]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
+          StorageDead(_7);                 // bb2[1]: scope 1 at $DIR/combine_array_len.rs:6:17: 6:18
+          StorageLive(_10);                // bb2[2]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:8
+          StorageLive(_11);                // bb2[3]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:6
+          _11 = _2;                        // bb2[4]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:6
+          StorageLive(_12);                // bb2[5]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8
+          _12 = _2;                        // bb2[6]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8
+          _10 = Mul(move _11, move _12);   // bb2[7]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:8
+          StorageDead(_12);                // bb2[8]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8
+          StorageDead(_11);                // bb2[9]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8
+          StorageLive(_13);                // bb2[10]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:14
+          StorageLive(_14);                // bb2[11]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:12
+          _14 = _6;                        // bb2[12]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:12
+          StorageLive(_15);                // bb2[13]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          _15 = _6;                        // bb2[14]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          _13 = Mul(move _14, move _15);   // bb2[15]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:14
+          StorageDead(_15);                // bb2[16]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          StorageDead(_14);                // bb2[17]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          _0 = Add(move _10, move _13);    // bb2[18]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:14
+          StorageDead(_13);                // bb2[19]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          StorageDead(_10);                // bb2[20]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          StorageDead(_6);                 // bb2[21]: scope 1 at $DIR/combine_array_len.rs:8:1: 8:2
+          StorageDead(_2);                 // bb2[22]: scope 0 at $DIR/combine_array_len.rs:8:1: 8:2
+          return;                          // bb2[23]: scope 0 at $DIR/combine_array_len.rs:8:2: 8:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/combine_array_len/64bit/rustc.norm2.InstCombine.diff b/src/test/mir-opt/combine_array_len/64bit/rustc.norm2.InstCombine.diff
new file mode 100644 (file)
index 0000000..0bab287
--- /dev/null
@@ -0,0 +1,101 @@
+- // MIR for `norm2` before InstCombine
++ // MIR for `norm2` after InstCombine
+  
+  fn norm2(_1: [f32; 2]) -> f32 {
+      debug x => _1;                       // in scope 0 at $DIR/combine_array_len.rs:4:10: 4:11
+      let mut _0: f32;                     // return place in scope 0 at $DIR/combine_array_len.rs:4:26: 4:29
+      let _2: f32;                         // in scope 0 at $DIR/combine_array_len.rs:5:9: 5:10
+      let _3: usize;                       // in scope 0 at $DIR/combine_array_len.rs:5:15: 5:16
+      let mut _4: usize;                   // in scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+      let mut _5: bool;                    // in scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+      let _7: usize;                       // in scope 0 at $DIR/combine_array_len.rs:6:15: 6:16
+      let mut _8: usize;                   // in scope 0 at $DIR/combine_array_len.rs:6:13: 6:17
+      let mut _9: bool;                    // in scope 0 at $DIR/combine_array_len.rs:6:13: 6:17
+      let mut _10: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:5: 7:8
+      let mut _11: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:5: 7:6
+      let mut _12: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:7: 7:8
+      let mut _13: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:11: 7:14
+      let mut _14: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:11: 7:12
+      let mut _15: f32;                    // in scope 0 at $DIR/combine_array_len.rs:7:13: 7:14
+      scope 1 {
+          debug a => _2;                   // in scope 1 at $DIR/combine_array_len.rs:5:9: 5:10
+          let _6: f32;                     // in scope 1 at $DIR/combine_array_len.rs:6:9: 6:10
+          scope 2 {
+              debug b => _6;               // in scope 2 at $DIR/combine_array_len.rs:6:9: 6:10
+          }
+      }
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/combine_array_len.rs:5:9: 5:10
+          StorageLive(_3);                 // bb0[1]: scope 0 at $DIR/combine_array_len.rs:5:15: 5:16
+          _3 = const 0usize;               // bb0[2]: scope 0 at $DIR/combine_array_len.rs:5:15: 5:16
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000000))
+                                           // mir::Constant
+                                           // + span: $DIR/combine_array_len.rs:5:15: 5:16
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
+-         _4 = Len(_1);                    // bb0[3]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
++         _4 = const 2usize;               // bb0[3]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
++                                          // ty::Const
++                                          // + ty: usize
++                                          // + val: Value(Scalar(0x0000000000000002))
++                                          // mir::Constant
++                                          // + span: $DIR/combine_array_len.rs:5:13: 5:17
++                                          // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) }
+          _5 = Lt(_3, _4);                 // bb0[4]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+          assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[5]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+      }
+  
+      bb1: {
+          _2 = _1[_3];                     // bb1[0]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17
+          StorageDead(_3);                 // bb1[1]: scope 0 at $DIR/combine_array_len.rs:5:17: 5:18
+          StorageLive(_6);                 // bb1[2]: scope 1 at $DIR/combine_array_len.rs:6:9: 6:10
+          StorageLive(_7);                 // bb1[3]: scope 1 at $DIR/combine_array_len.rs:6:15: 6:16
+          _7 = const 1usize;               // bb1[4]: scope 1 at $DIR/combine_array_len.rs:6:15: 6:16
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000001))
+                                           // mir::Constant
+                                           // + span: $DIR/combine_array_len.rs:6:15: 6:16
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+-         _8 = Len(_1);                    // bb1[5]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
++         _8 = const 2usize;               // bb1[5]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
++                                          // ty::Const
++                                          // + ty: usize
++                                          // + val: Value(Scalar(0x0000000000000002))
++                                          // mir::Constant
++                                          // + span: $DIR/combine_array_len.rs:6:13: 6:17
++                                          // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) }
+          _9 = Lt(_7, _8);                 // bb1[6]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
+          assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; // bb1[7]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
+      }
+  
+      bb2: {
+          _6 = _1[_7];                     // bb2[0]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17
+          StorageDead(_7);                 // bb2[1]: scope 1 at $DIR/combine_array_len.rs:6:17: 6:18
+          StorageLive(_10);                // bb2[2]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:8
+          StorageLive(_11);                // bb2[3]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:6
+          _11 = _2;                        // bb2[4]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:6
+          StorageLive(_12);                // bb2[5]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8
+          _12 = _2;                        // bb2[6]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8
+          _10 = Mul(move _11, move _12);   // bb2[7]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:8
+          StorageDead(_12);                // bb2[8]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8
+          StorageDead(_11);                // bb2[9]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8
+          StorageLive(_13);                // bb2[10]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:14
+          StorageLive(_14);                // bb2[11]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:12
+          _14 = _6;                        // bb2[12]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:12
+          StorageLive(_15);                // bb2[13]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          _15 = _6;                        // bb2[14]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          _13 = Mul(move _14, move _15);   // bb2[15]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:14
+          StorageDead(_15);                // bb2[16]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          StorageDead(_14);                // bb2[17]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          _0 = Add(move _10, move _13);    // bb2[18]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:14
+          StorageDead(_13);                // bb2[19]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          StorageDead(_10);                // bb2[20]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14
+          StorageDead(_6);                 // bb2[21]: scope 1 at $DIR/combine_array_len.rs:8:1: 8:2
+          StorageDead(_2);                 // bb2[22]: scope 0 at $DIR/combine_array_len.rs:8:1: 8:2
+          return;                          // bb2[23]: scope 0 at $DIR/combine_array_len.rs:8:2: 8:2
+      }
+  }
+  
index d04dcc6a05ce183e870313133141a670c8312261..928ed8265d3fbb3c38e857f1f2def2464a0fe658 100644 (file)
@@ -1,25 +1,6 @@
 // compile-flags: -O
 
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     let x = (0, 1, 2).1 + 0;
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _3 = (const 0i32, const 1i32, const 2i32);
-//      _2 = (_3.1: i32);
-//      _1 = Add(move _2, const 0i32);
-//      ...
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _3 = (const 0i32, const 1i32, const 2i32);
-//      _2 = const 1i32;
-//      _1 = const 1i32;
-//      ...
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..d200192
--- /dev/null
@@ -0,0 +1,62 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/aggregate.rs:4:11: 4:11
+      let _1: i32;                         // in scope 0 at $DIR/aggregate.rs:5:9: 5:10
+      let mut _2: i32;                     // in scope 0 at $DIR/aggregate.rs:5:13: 5:24
+      let mut _3: (i32, i32, i32);         // in scope 0 at $DIR/aggregate.rs:5:13: 5:22
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/aggregate.rs:5:9: 5:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/aggregate.rs:5:9: 5:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/aggregate.rs:5:13: 5:24
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/aggregate.rs:5:13: 5:22
+          _3 = (const 0i32, const 1i32, const 2i32); // bb0[3]: scope 0 at $DIR/aggregate.rs:5:13: 5:22
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/aggregate.rs:5:14: 5:15
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/aggregate.rs:5:17: 5:18
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000002))
+                                           // mir::Constant
+                                           // + span: $DIR/aggregate.rs:5:20: 5:21
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+-         _2 = (_3.1: i32);                // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24
+-         _1 = Add(move _2, const 0i32);   // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28
++         _2 = const 1i32;                 // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24
+                                           // ty::Const
+                                           // + ty: i32
+-                                          // + val: Value(Scalar(0x00000000))
++                                          // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+-                                          // + span: $DIR/aggregate.rs:5:27: 5:28
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
++                                          // + span: $DIR/aggregate.rs:5:13: 5:24
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
++         _1 = const 1i32;                 // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28
++                                          // ty::Const
++                                          // + ty: i32
++                                          // + val: Value(Scalar(0x00000001))
++                                          // mir::Constant
++                                          // + span: $DIR/aggregate.rs:5:13: 5:28
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+          StorageDead(_2);                 // bb0[6]: scope 0 at $DIR/aggregate.rs:5:27: 5:28
+          StorageDead(_3);                 // bb0[7]: scope 0 at $DIR/aggregate.rs:5:28: 5:29
+          _0 = ();                         // bb0[8]: scope 0 at $DIR/aggregate.rs:4:11: 6:2
+          StorageDead(_1);                 // bb0[9]: scope 0 at $DIR/aggregate.rs:6:1: 6:2
+          return;                          // bb0[10]: scope 0 at $DIR/aggregate.rs:6:2: 6:2
+      }
+  }
+  
index 406585b5cab8e1b3299ff94dceeaa990728f2a1a..9301e6f5d0393fad945865a503403a5bfcfe7793 100644 (file)
@@ -1,33 +1,6 @@
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     let x: u32 = [0, 1, 2, 3][2];
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _2 = [const 0u32, const 1u32, const 2u32, const 3u32];
-//      ...
-//      _3 = const 2usize;
-//      _4 = const 4usize;
-//      _5 = Lt(_3, _4);
-//      assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1;
-//  }
-//  bb1: {
-//      _1 = _2[_3];
-//      ...
-//      return;
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _5 = const true;
-//      assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1;
-//  }
-//  bb1: {
-//      _1 = const 2u32;
-//      ...
-//      return;
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..f956ef8
--- /dev/null
@@ -0,0 +1,92 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/array_index.rs:4:11: 4:11
+      let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:5:9: 5:10
+      let mut _2: [u32; 4];                // in scope 0 at $DIR/array_index.rs:5:18: 5:30
+      let _3: usize;                       // in scope 0 at $DIR/array_index.rs:5:31: 5:32
+      let mut _4: usize;                   // in scope 0 at $DIR/array_index.rs:5:18: 5:33
+      let mut _5: bool;                    // in scope 0 at $DIR/array_index.rs:5:18: 5:33
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/array_index.rs:5:9: 5:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/array_index.rs:5:9: 5:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/array_index.rs:5:18: 5:30
+          _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; // bb0[2]: scope 0 at $DIR/array_index.rs:5:18: 5:30
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:19: 5:20
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:22: 5:23
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x00000002))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:25: 5:26
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x00000003))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:28: 5:29
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+          StorageLive(_3);                 // bb0[3]: scope 0 at $DIR/array_index.rs:5:31: 5:32
+          _3 = const 2usize;               // bb0[4]: scope 0 at $DIR/array_index.rs:5:31: 5:32
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000002))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:31: 5:32
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) }
+          _4 = const 4usize;               // bb0[5]: scope 0 at $DIR/array_index.rs:5:18: 5:33
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000004))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:18: 5:33
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000004)) }
+-         _5 = Lt(_3, _4);                 // bb0[6]: scope 0 at $DIR/array_index.rs:5:18: 5:33
+-         assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++         _5 = const true;                 // bb0[6]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/array_index.rs:5:18: 5:33
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
++         assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/array_index.rs:5:18: 5:33
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb1: {
+-         _1 = _2[_3];                     // bb1[0]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++         _1 = const 2u32;                 // bb1[0]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x00000002))
++                                          // mir::Constant
++                                          // + span: $DIR/array_index.rs:5:18: 5:33
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+          StorageDead(_3);                 // bb1[1]: scope 0 at $DIR/array_index.rs:5:33: 5:34
+          StorageDead(_2);                 // bb1[2]: scope 0 at $DIR/array_index.rs:5:33: 5:34
+          _0 = ();                         // bb1[3]: scope 0 at $DIR/array_index.rs:4:11: 6:2
+          StorageDead(_1);                 // bb1[4]: scope 0 at $DIR/array_index.rs:6:1: 6:2
+          return;                          // bb1[5]: scope 0 at $DIR/array_index.rs:6:2: 6:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..c336d6e
--- /dev/null
@@ -0,0 +1,92 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/array_index.rs:4:11: 4:11
+      let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:5:9: 5:10
+      let mut _2: [u32; 4];                // in scope 0 at $DIR/array_index.rs:5:18: 5:30
+      let _3: usize;                       // in scope 0 at $DIR/array_index.rs:5:31: 5:32
+      let mut _4: usize;                   // in scope 0 at $DIR/array_index.rs:5:18: 5:33
+      let mut _5: bool;                    // in scope 0 at $DIR/array_index.rs:5:18: 5:33
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/array_index.rs:5:9: 5:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/array_index.rs:5:9: 5:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/array_index.rs:5:18: 5:30
+          _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; // bb0[2]: scope 0 at $DIR/array_index.rs:5:18: 5:30
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:19: 5:20
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:22: 5:23
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x00000002))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:25: 5:26
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x00000003))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:28: 5:29
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+          StorageLive(_3);                 // bb0[3]: scope 0 at $DIR/array_index.rs:5:31: 5:32
+          _3 = const 2usize;               // bb0[4]: scope 0 at $DIR/array_index.rs:5:31: 5:32
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000002))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:31: 5:32
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) }
+          _4 = const 4usize;               // bb0[5]: scope 0 at $DIR/array_index.rs:5:18: 5:33
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000004))
+                                           // mir::Constant
+                                           // + span: $DIR/array_index.rs:5:18: 5:33
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000004)) }
+-         _5 = Lt(_3, _4);                 // bb0[6]: scope 0 at $DIR/array_index.rs:5:18: 5:33
+-         assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++         _5 = const true;                 // bb0[6]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/array_index.rs:5:18: 5:33
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
++         assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/array_index.rs:5:18: 5:33
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb1: {
+-         _1 = _2[_3];                     // bb1[0]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++         _1 = const 2u32;                 // bb1[0]: scope 0 at $DIR/array_index.rs:5:18: 5:33
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x00000002))
++                                          // mir::Constant
++                                          // + span: $DIR/array_index.rs:5:18: 5:33
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+          StorageDead(_3);                 // bb1[1]: scope 0 at $DIR/array_index.rs:5:33: 5:34
+          StorageDead(_2);                 // bb1[2]: scope 0 at $DIR/array_index.rs:5:33: 5:34
+          _0 = ();                         // bb1[3]: scope 0 at $DIR/array_index.rs:4:11: 6:2
+          StorageDead(_1);                 // bb1[4]: scope 0 at $DIR/array_index.rs:6:1: 6:2
+          return;                          // bb1[5]: scope 0 at $DIR/array_index.rs:6:2: 6:2
+      }
+  }
+  
index cf134dadf27890ea552083929b28b6c00817ef43..d45804ebb6cf29b1a57b878d58195f88a97b271c 100644 (file)
@@ -7,50 +7,7 @@
 
 // Note: this test verifies that we, in fact, do not const prop `box`
 
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     let x = *(box 42) + 0;
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _4 = Box(i32);
-//      (*_4) = const 42i32;
-//      _3 = move _4;
-//      ...
-//      _2 = (*_3);
-//      _1 = Add(move _2, const 0i32);
-//      ...
-//      drop(_3) -> [return: bb2, unwind: bb1];
-//  }
-//  bb1 (cleanup): {
-//      resume;
-//  }
-//  bb2: {
-//      ...
-//      _0 = ();
-//      ...
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _4 = Box(i32);
-//      (*_4) = const 42i32;
-//      _3 = move _4;
-//      ...
-//      _2 = (*_3);
-//      _1 = Add(move _2, const 0i32);
-//      ...
-//      drop(_3) -> [return: bb2, unwind: bb1];
-//  }
-//  bb1 (cleanup): {
-//      resume;
-//  }
-//  bb2: {
-//      ...
-//      _0 = ();
-//      ...
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..50ee2ab
--- /dev/null
@@ -0,0 +1,52 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/boxes.rs:11:11: 11:11
+      let _1: i32;                         // in scope 0 at $DIR/boxes.rs:12:9: 12:10
+      let mut _2: i32;                     // in scope 0 at $DIR/boxes.rs:12:13: 12:22
+      let mut _3: std::boxed::Box<i32>;    // in scope 0 at $DIR/boxes.rs:12:14: 12:22
+      let mut _4: std::boxed::Box<i32>;    // in scope 0 at $DIR/boxes.rs:12:14: 12:22
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/boxes.rs:12:9: 12:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/boxes.rs:12:9: 12:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/boxes.rs:12:13: 12:22
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/boxes.rs:12:14: 12:22
+          StorageLive(_4);                 // bb0[3]: scope 0 at $DIR/boxes.rs:12:14: 12:22
+          _4 = Box(i32);                   // bb0[4]: scope 0 at $DIR/boxes.rs:12:14: 12:22
+          (*_4) = const 42i32;             // bb0[5]: scope 0 at $DIR/boxes.rs:12:19: 12:21
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/boxes.rs:12:19: 12:21
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
+          _3 = move _4;                    // bb0[6]: scope 0 at $DIR/boxes.rs:12:14: 12:22
+          StorageDead(_4);                 // bb0[7]: scope 0 at $DIR/boxes.rs:12:21: 12:22
+          _2 = (*_3);                      // bb0[8]: scope 0 at $DIR/boxes.rs:12:13: 12:22
+          _1 = Add(move _2, const 0i32);   // bb0[9]: scope 0 at $DIR/boxes.rs:12:13: 12:26
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/boxes.rs:12:25: 12:26
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+          StorageDead(_2);                 // bb0[10]: scope 0 at $DIR/boxes.rs:12:25: 12:26
+          drop(_3) -> [return: bb2, unwind: bb1]; // bb0[11]: scope 0 at $DIR/boxes.rs:12:26: 12:27
+      }
+  
+      bb1 (cleanup): {
+          resume;                          // bb1[0]: scope 0 at $DIR/boxes.rs:11:1: 13:2
+      }
+  
+      bb2: {
+          StorageDead(_3);                 // bb2[0]: scope 0 at $DIR/boxes.rs:12:26: 12:27
+          _0 = ();                         // bb2[1]: scope 0 at $DIR/boxes.rs:11:11: 13:2
+          StorageDead(_1);                 // bb2[2]: scope 0 at $DIR/boxes.rs:13:1: 13:2
+          return;                          // bb2[3]: scope 0 at $DIR/boxes.rs:13:2: 13:2
+      }
+  }
+  
index fe98cf24eec009ecc6416033e5b7a38e787a6dae..439bd2df91f574397476eef4bdedb04bffa997cd 100644 (file)
@@ -1,21 +1,6 @@
 // compile-flags: -C overflow-checks=on
 
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     let x: u32 = 1 + 1;
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _2 = CheckedAdd(const 1u32, const 1u32);
-//      assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1;
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _2 = (const 2u32, const false);
-//      assert(!const false, "attempt to add with overflow") -> bb1;
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..0a0a4ff
--- /dev/null
@@ -0,0 +1,59 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/checked_add.rs:4:11: 4:11
+      let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/checked_add.rs:5:9: 5:10
+      let mut _2: (u32, bool);             // in scope 0 at $DIR/checked_add.rs:5:18: 5:23
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/checked_add.rs:5:9: 5:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/checked_add.rs:5:9: 5:10
+-         _2 = CheckedAdd(const 1u32, const 1u32); // bb0[1]: scope 0 at $DIR/checked_add.rs:5:18: 5:23
++         _2 = (const 2u32, const false);  // bb0[1]: scope 0 at $DIR/checked_add.rs:5:18: 5:23
+                                           // ty::Const
+                                           // + ty: u32
+-                                          // + val: Value(Scalar(0x00000001))
++                                          // + val: Value(Scalar(0x00000002))
+                                           // mir::Constant
+-                                          // + span: $DIR/checked_add.rs:5:18: 5:19
+-                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
++                                          // + span: $DIR/checked_add.rs:5:18: 5:23
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+                                           // ty::Const
+-                                          // + ty: u32
+-                                          // + val: Value(Scalar(0x00000001))
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+-                                          // + span: $DIR/checked_add.rs:5:22: 5:23
+-                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+-         assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/checked_add.rs:5:18: 5:23
++                                          // + span: $DIR/checked_add.rs:5:18: 5:23
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
++         assert(!const false, "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/checked_add.rs:5:18: 5:23
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
++                                          // mir::Constant
++                                          // + span: $DIR/checked_add.rs:5:18: 5:23
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+      }
+  
+      bb1: {
+-         _1 = move (_2.0: u32);           // bb1[0]: scope 0 at $DIR/checked_add.rs:5:18: 5:23
++         _1 = const 2u32;                 // bb1[0]: scope 0 at $DIR/checked_add.rs:5:18: 5:23
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x00000002))
++                                          // mir::Constant
++                                          // + span: $DIR/checked_add.rs:5:18: 5:23
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+          _0 = ();                         // bb1[1]: scope 0 at $DIR/checked_add.rs:4:11: 6:2
+          StorageDead(_1);                 // bb1[2]: scope 0 at $DIR/checked_add.rs:6:1: 6:2
+          return;                          // bb1[3]: scope 0 at $DIR/checked_add.rs:6:2: 6:2
+      }
+  }
+  
index 3c8c0ff449345b3ea0440bca6a4d7e36be7a69a8..c6c006c080912bed3c033ab562285e7d0723942f 100644 (file)
@@ -1,31 +1,9 @@
 #[inline(never)]
 fn read(_: usize) { }
 
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     const FOO: &i32 = &1;
     let x = FOO as *const i32 as usize;
     read(x);
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _2 = &raw const (*_3);
-//      _1 = move _2 as usize (Misc);
-//      ...
-//      _5 = _1;
-//      _4 = const read(move _5) -> bb1;
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _3 = const main::FOO;
-//      _2 = &raw const (*_3);
-//      _1 = move _2 as usize (Misc);
-//      ...
-//      _5 = _1;
-//      _4 = const read(move _5) -> bb1;
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..f4a5b64
--- /dev/null
@@ -0,0 +1,50 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/const_prop_fails_gracefully.rs:5:11: 5:11
+      let _1: usize;                       // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10
+      let mut _2: *const i32;              // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:30
+      let _3: &i32;                        // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
+      let _4: ();                          // in scope 0 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12
+      let mut _5: usize;                   // in scope 0 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:30
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
+          _3 = const main::FOO;            // bb0[3]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
+                                           // ty::Const
+                                           // + ty: &i32
+                                           // + val: Unevaluated(DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), [], None)
+                                           // mir::Constant
+                                           // + span: $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
+                                           // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), [], None) }
+          _2 = &raw const (*_3);           // bb0[4]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
+          _1 = move _2 as usize (Misc);    // bb0[5]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39
+          StorageDead(_2);                 // bb0[6]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:38: 7:39
+          StorageDead(_3);                 // bb0[7]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:39: 7:40
+          StorageLive(_4);                 // bb0[8]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12
+          StorageLive(_5);                 // bb0[9]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11
+          _5 = _1;                         // bb0[10]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11
+          _4 = const read(move _5) -> bb1; // bb0[11]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12
+                                           // ty::Const
+                                           // + ty: fn(usize) {read}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/const_prop_fails_gracefully.rs:8:5: 8:9
+                                           // + literal: Const { ty: fn(usize) {read}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          StorageDead(_5);                 // bb1[0]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:11: 8:12
+          StorageDead(_4);                 // bb1[1]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:12: 8:13
+          _0 = ();                         // bb1[2]: scope 0 at $DIR/const_prop_fails_gracefully.rs:5:11: 9:2
+          StorageDead(_1);                 // bb1[3]: scope 0 at $DIR/const_prop_fails_gracefully.rs:9:1: 9:2
+          return;                          // bb1[4]: scope 0 at $DIR/const_prop_fails_gracefully.rs:9:2: 9:2
+      }
+  }
+  
index 0e9f33b15e2cc1d68f09fcc3321f3df190139521..1071590dd9e518c7d8086b1dcf448689914bae75 100644 (file)
@@ -6,6 +6,8 @@ trait NeedsDrop:Sized{
 
 impl<This> NeedsDrop for This{}
 
+// EMIT_MIR rustc.hello.ConstProp.diff
+// EMIT_MIR rustc.hello.PreCodegen.before.mir
 fn hello<T>(){
     if <bool>::NEEDS {
         panic!()
@@ -16,49 +18,3 @@ pub fn main() {
     hello::<()>();
     hello::<Vec<()>>();
 }
-
-// END RUST SOURCE
-// START rustc.hello.ConstProp.before.mir
-// let mut _0: ();
-// let mut _1: bool;
-// let mut _2: !;
-// bb0: {
-//   StorageLive(_1);
-//   _1 = const <bool as NeedsDrop>::NEEDS;
-//   switchInt(_1) -> [false: bb1, otherwise: bb2];
-// }
-// bb1: {
-//   _0 = ();
-//   StorageDead(_1);
-//   return;
-// }
-// bb2: {
-//   StorageLive(_2);
-//   const std::rt::begin_panic::<&str>(const "explicit panic");
-// }
-// END rustc.hello.ConstProp.before.mir
-// START rustc.hello.ConstProp.after.mir
-// let mut _0: ();
-// let mut _1: bool;
-// let mut _2: !;
-// bb0: {
-//   StorageLive(_1);
-//   _1 = const false;
-//   switchInt(const false) -> [false: bb1, otherwise: bb2];
-// }
-// bb1: {
-//   _0 = ();
-//   StorageDead(_1);
-//   return;
-// }
-// bb2: {
-//   StorageLive(_2);
-//   const std::rt::begin_panic::<&str>(const "explicit panic");
-// }
-// END rustc.hello.ConstProp.after.mir
-// START rustc.hello.PreCodegen.before.mir
-// let mut _0: ();
-// bb0: {
-//   return;
-// }
-// END rustc.hello.PreCodegen.before.mir
diff --git a/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff
new file mode 100644 (file)
index 0000000..c551bd7
--- /dev/null
@@ -0,0 +1,54 @@
+- // MIR for `hello` before ConstProp
++ // MIR for `hello` after ConstProp
+  
+  fn hello() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/control-flow-simplification.rs:11:14: 11:14
+      let mut _1: bool;                    // in scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21
+      let mut _2: !;                       // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21
+-         _1 = const <bool as NeedsDrop>::NEEDS; // bb0[1]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21
++         _1 = const false;                // bb0[1]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21
+                                           // ty::Const
+                                           // + ty: bool
+-                                          // + val: Unevaluated(DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), [bool], None)
++                                          // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+                                           // + span: $DIR/control-flow-simplification.rs:12:8: 12:21
+-                                          // + literal: Const { ty: bool, val: Unevaluated(DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), [bool], None) }
+-         switchInt(_1) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
++         switchInt(const false) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
++                                          // mir::Constant
++                                          // + span: $DIR/control-flow-simplification.rs:12:5: 14:6
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+      }
+  
+      bb1: {
+          _0 = ();                         // bb1[0]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6
+          StorageDead(_1);                 // bb1[1]: scope 0 at $DIR/control-flow-simplification.rs:15:1: 15:2
+          return;                          // bb1[2]: scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2
+      }
+  
+      bb2: {
+          StorageLive(_2);                 // bb2[0]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL
+          const std::rt::begin_panic::<&str>(const "explicit panic"); // bb2[1]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL
+                                           // ty::Const
+                                           // + ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $SRC_DIR/libstd/macros.rs:LL:COL
+                                           // + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }
+                                           // ty::Const
+                                           // + ty: &str
+                                           // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 })
+                                           // mir::Constant
+                                           // + span: $SRC_DIR/libstd/macros.rs:LL:COL
+                                           // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir
new file mode 100644 (file)
index 0000000..53296f8
--- /dev/null
@@ -0,0 +1,9 @@
+// MIR for `hello` before PreCodegen
+
+fn hello() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/control-flow-simplification.rs:11:14: 11:14
+
+    bb0: {
+        return;                          // bb0[0]: scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2
+    }
+}
index 636aa1af6533341513200eb57adda716331d6488..04541b94ad7801a0e5d466144da1388a84c0b05e 100644 (file)
@@ -1,53 +1,7 @@
 // compile-flags: -O
 
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0;
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _3 = std::option::Option::<bool>::Some(const true,);
-//      _4 = discriminant(_3);
-//      switchInt(move _4) -> [1isize: bb2, otherwise: bb1];
-//  }
-//  bb1: {
-//      _2 = const 10i32;
-//      goto -> bb4;
-//  }
-//  bb2: {
-//      switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3];
-//  }
-//  bb3: {
-//      _2 = const 42i32;
-//      goto -> bb4;
-//  }
-//  bb4: {
-//      _1 = Add(move _2, const 0i32);
-//      ...
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _3 = const {transmute(0x01): std::option::Option<bool>};
-//      _4 = const 1isize;
-//      switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1];
-//  }
-//  bb1: {
-//      _2 = const 10i32;
-//      goto -> bb4;
-//  }
-//  bb2: {
-//      switchInt(const true) -> [false: bb1, otherwise: bb3];
-//  }
-//  bb3: {
-//      _2 = const 42i32;
-//      goto -> bb4;
-//  }
-//  bb4: {
-//      _1 = Add(move _2, const 0i32);
-//      ...
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..7423a3c
--- /dev/null
@@ -0,0 +1,95 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/discriminant.rs:5:11: 5:11
+      let _1: i32;                         // in scope 0 at $DIR/discriminant.rs:6:9: 6:10
+      let mut _2: i32;                     // in scope 0 at $DIR/discriminant.rs:6:13: 6:64
+      let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:6:34: 6:44
+      let mut _4: isize;                   // in scope 0 at $DIR/discriminant.rs:6:21: 6:31
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/discriminant.rs:6:9: 6:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/discriminant.rs:6:9: 6:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/discriminant.rs:6:34: 6:44
+-         _3 = std::option::Option::<bool>::Some(const true,); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44
++         _3 = const {transmute(0x01): std::option::Option<bool>}; // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44
+                                           // ty::Const
+-                                          // + ty: bool
++                                          // + ty: std::option::Option<bool>
+                                           // + val: Value(Scalar(0x01))
+                                           // mir::Constant
+-                                          // + span: $DIR/discriminant.rs:6:39: 6:43
+-                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+-         _4 = discriminant(_3);           // bb0[4]: scope 0 at $DIR/discriminant.rs:6:21: 6:31
+-         switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:6:21: 6:31
++                                          // + span: $DIR/discriminant.rs:6:34: 6:44
++                                          // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) }
++         _4 = const 1isize;               // bb0[4]: scope 0 at $DIR/discriminant.rs:6:21: 6:31
++                                          // ty::Const
++                                          // + ty: isize
++                                          // + val: Value(Scalar(0x00000001))
++                                          // mir::Constant
++                                          // + span: $DIR/discriminant.rs:6:21: 6:31
++                                          // + literal: Const { ty: isize, val: Value(Scalar(0x00000001)) }
++         switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:6:21: 6:31
++                                          // ty::Const
++                                          // + ty: isize
++                                          // + val: Value(Scalar(0x00000001))
++                                          // mir::Constant
++                                          // + span: $DIR/discriminant.rs:6:21: 6:31
++                                          // + literal: Const { ty: isize, val: Value(Scalar(0x00000001)) }
+      }
+  
+      bb1: {
+          _2 = const 10i32;                // bb1[0]: scope 0 at $DIR/discriminant.rs:6:59: 6:61
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x0000000a))
+                                           // mir::Constant
+                                           // + span: $DIR/discriminant.rs:6:59: 6:61
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) }
+          goto -> bb4;                     // bb1[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64
+      }
+  
+      bb2: {
+-         switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:6:26: 6:30
++         switchInt(const true) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:6:26: 6:30
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/discriminant.rs:6:26: 6:30
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb3: {
+          _2 = const 42i32;                // bb3[0]: scope 0 at $DIR/discriminant.rs:6:47: 6:49
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/discriminant.rs:6:47: 6:49
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
+          goto -> bb4;                     // bb3[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64
+      }
+  
+      bb4: {
+          _1 = Add(move _2, const 0i32);   // bb4[0]: scope 0 at $DIR/discriminant.rs:6:13: 6:68
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/discriminant.rs:6:67: 6:68
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+          StorageDead(_2);                 // bb4[1]: scope 0 at $DIR/discriminant.rs:6:67: 6:68
+          StorageDead(_3);                 // bb4[2]: scope 0 at $DIR/discriminant.rs:6:68: 6:69
+          _0 = ();                         // bb4[3]: scope 0 at $DIR/discriminant.rs:5:11: 7:2
+          StorageDead(_1);                 // bb4[4]: scope 0 at $DIR/discriminant.rs:7:1: 7:2
+          return;                          // bb4[5]: scope 0 at $DIR/discriminant.rs:7:2: 7:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..60d18cd
--- /dev/null
@@ -0,0 +1,95 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/discriminant.rs:5:11: 5:11
+      let _1: i32;                         // in scope 0 at $DIR/discriminant.rs:6:9: 6:10
+      let mut _2: i32;                     // in scope 0 at $DIR/discriminant.rs:6:13: 6:64
+      let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:6:34: 6:44
+      let mut _4: isize;                   // in scope 0 at $DIR/discriminant.rs:6:21: 6:31
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/discriminant.rs:6:9: 6:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/discriminant.rs:6:9: 6:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/discriminant.rs:6:34: 6:44
+-         _3 = std::option::Option::<bool>::Some(const true,); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44
++         _3 = const {transmute(0x01): std::option::Option<bool>}; // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44
+                                           // ty::Const
+-                                          // + ty: bool
++                                          // + ty: std::option::Option<bool>
+                                           // + val: Value(Scalar(0x01))
+                                           // mir::Constant
+-                                          // + span: $DIR/discriminant.rs:6:39: 6:43
+-                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+-         _4 = discriminant(_3);           // bb0[4]: scope 0 at $DIR/discriminant.rs:6:21: 6:31
+-         switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:6:21: 6:31
++                                          // + span: $DIR/discriminant.rs:6:34: 6:44
++                                          // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) }
++         _4 = const 1isize;               // bb0[4]: scope 0 at $DIR/discriminant.rs:6:21: 6:31
++                                          // ty::Const
++                                          // + ty: isize
++                                          // + val: Value(Scalar(0x0000000000000001))
++                                          // mir::Constant
++                                          // + span: $DIR/discriminant.rs:6:21: 6:31
++                                          // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) }
++         switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:6:21: 6:31
++                                          // ty::Const
++                                          // + ty: isize
++                                          // + val: Value(Scalar(0x0000000000000001))
++                                          // mir::Constant
++                                          // + span: $DIR/discriminant.rs:6:21: 6:31
++                                          // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) }
+      }
+  
+      bb1: {
+          _2 = const 10i32;                // bb1[0]: scope 0 at $DIR/discriminant.rs:6:59: 6:61
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x0000000a))
+                                           // mir::Constant
+                                           // + span: $DIR/discriminant.rs:6:59: 6:61
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) }
+          goto -> bb4;                     // bb1[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64
+      }
+  
+      bb2: {
+-         switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:6:26: 6:30
++         switchInt(const true) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:6:26: 6:30
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/discriminant.rs:6:26: 6:30
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb3: {
+          _2 = const 42i32;                // bb3[0]: scope 0 at $DIR/discriminant.rs:6:47: 6:49
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/discriminant.rs:6:47: 6:49
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
+          goto -> bb4;                     // bb3[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64
+      }
+  
+      bb4: {
+          _1 = Add(move _2, const 0i32);   // bb4[0]: scope 0 at $DIR/discriminant.rs:6:13: 6:68
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/discriminant.rs:6:67: 6:68
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+          StorageDead(_2);                 // bb4[1]: scope 0 at $DIR/discriminant.rs:6:67: 6:68
+          StorageDead(_3);                 // bb4[2]: scope 0 at $DIR/discriminant.rs:6:68: 6:69
+          _0 = ();                         // bb4[3]: scope 0 at $DIR/discriminant.rs:5:11: 7:2
+          StorageDead(_1);                 // bb4[4]: scope 0 at $DIR/discriminant.rs:7:1: 7:2
+          return;                          // bb4[5]: scope 0 at $DIR/discriminant.rs:7:2: 7:2
+      }
+  }
+  
index b4ee18ed1b53bfaf4d9bef642ae86ec76719d260..961e4447d8b6b8118f55714137898666619d795f 100644 (file)
@@ -1,23 +1,6 @@
 // compile-flags: -C overflow-checks=on
 
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     let x = (2u32 as u8) + 1;
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-// bb0: {
-//     ...
-//     _2 = const 2u32 as u8 (Misc);
-//     _3 = CheckedAdd(move _2, const 1u8);
-//     assert(!move (_3.1: bool), "attempt to add with overflow") -> bb1;
-//}
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-// bb0: {
-//     ...
-//     _2 = const 2u8;
-//     _3 = (const 3u8, const false);
-//     assert(!const false, "attempt to add with overflow") -> bb1;
-// }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..ca3e3bb
--- /dev/null
@@ -0,0 +1,70 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/indirect.rs:4:11: 4:11
+      let _1: u8;                          // in scope 0 at $DIR/indirect.rs:5:9: 5:10
+      let mut _2: u8;                      // in scope 0 at $DIR/indirect.rs:5:13: 5:25
+      let mut _3: (u8, bool);              // in scope 0 at $DIR/indirect.rs:5:13: 5:29
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/indirect.rs:5:9: 5:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/indirect.rs:5:9: 5:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/indirect.rs:5:13: 5:25
+-         _2 = const 2u32 as u8 (Misc);    // bb0[2]: scope 0 at $DIR/indirect.rs:5:13: 5:25
++         _2 = const 2u8;                  // bb0[2]: scope 0 at $DIR/indirect.rs:5:13: 5:25
+                                           // ty::Const
+-                                          // + ty: u32
+-                                          // + val: Value(Scalar(0x00000002))
++                                          // + ty: u8
++                                          // + val: Value(Scalar(0x02))
+                                           // mir::Constant
+-                                          // + span: $DIR/indirect.rs:5:14: 5:18
+-                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+-         _3 = CheckedAdd(move _2, const 1u8); // bb0[3]: scope 0 at $DIR/indirect.rs:5:13: 5:29
++                                          // + span: $DIR/indirect.rs:5:13: 5:25
++                                          // + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
++         _3 = (const 3u8, const false);   // bb0[3]: scope 0 at $DIR/indirect.rs:5:13: 5:29
+                                           // ty::Const
+                                           // + ty: u8
+-                                          // + val: Value(Scalar(0x01))
++                                          // + val: Value(Scalar(0x03))
+                                           // mir::Constant
+-                                          // + span: $DIR/indirect.rs:5:28: 5:29
+-                                          // + literal: Const { ty: u8, val: Value(Scalar(0x01)) }
+-         assert(!move (_3.1: bool), "attempt to add with overflow") -> bb1; // bb0[4]: scope 0 at $DIR/indirect.rs:5:13: 5:29
++                                          // + span: $DIR/indirect.rs:5:13: 5:29
++                                          // + literal: Const { ty: u8, val: Value(Scalar(0x03)) }
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
++                                          // mir::Constant
++                                          // + span: $DIR/indirect.rs:5:13: 5:29
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
++         assert(!const false, "attempt to add with overflow") -> bb1; // bb0[4]: scope 0 at $DIR/indirect.rs:5:13: 5:29
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
++                                          // mir::Constant
++                                          // + span: $DIR/indirect.rs:5:13: 5:29
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+      }
+  
+      bb1: {
+-         _1 = move (_3.0: u8);            // bb1[0]: scope 0 at $DIR/indirect.rs:5:13: 5:29
++         _1 = const 3u8;                  // bb1[0]: scope 0 at $DIR/indirect.rs:5:13: 5:29
++                                          // ty::Const
++                                          // + ty: u8
++                                          // + val: Value(Scalar(0x03))
++                                          // mir::Constant
++                                          // + span: $DIR/indirect.rs:5:13: 5:29
++                                          // + literal: Const { ty: u8, val: Value(Scalar(0x03)) }
+          StorageDead(_2);                 // bb1[1]: scope 0 at $DIR/indirect.rs:5:28: 5:29
+          _0 = ();                         // bb1[2]: scope 0 at $DIR/indirect.rs:4:11: 6:2
+          StorageDead(_1);                 // bb1[3]: scope 0 at $DIR/indirect.rs:6:1: 6:2
+          return;                          // bb1[4]: scope 0 at $DIR/indirect.rs:6:2: 6:2
+      }
+  }
+  
index f332bb895095bf276e861b72f1c229454306a7a3..50a1405b77b4c7db4162eebeb0406fb7f3040686 100644 (file)
@@ -11,28 +11,7 @@ fn encode(this: ((), u8, u8)) {
     assert!(this.2 == 0);
 }
 
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     encode(((), 0, 0));
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _3 = ();
-//      _2 = (move _3, const 0u8, const 0u8);
-//      ...
-//      _1 = const encode(move _2) -> bb1;
-//      ...
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _3 = const ();
-//      _2 = (move _3, const 0u8, const 0u8);
-//      ...
-//      _1 = const encode(move _2) -> bb1;
-//      ...
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..d3ebaa0
--- /dev/null
@@ -0,0 +1,52 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue-66971.rs:15:11: 15:11
+      let _1: ();                          // in scope 0 at $DIR/issue-66971.rs:16:5: 16:23
+      let mut _2: ((), u8, u8);            // in scope 0 at $DIR/issue-66971.rs:16:12: 16:22
+      let mut _3: ();                      // in scope 0 at $DIR/issue-66971.rs:16:13: 16:15
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/issue-66971.rs:16:5: 16:23
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/issue-66971.rs:16:12: 16:22
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15
+-         _3 = ();                         // bb0[3]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15
++         _3 = const ();                   // bb0[3]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15
++                                          // ty::Const
++                                          // + ty: ()
++                                          // + val: Value(Scalar(<ZST>))
++                                          // mir::Constant
++                                          // + span: $DIR/issue-66971.rs:16:13: 16:15
++                                          // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
+          _2 = (move _3, const 0u8, const 0u8); // bb0[4]: scope 0 at $DIR/issue-66971.rs:16:12: 16:22
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+                                           // + span: $DIR/issue-66971.rs:16:17: 16:18
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+                                           // + span: $DIR/issue-66971.rs:16:20: 16:21
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
+          StorageDead(_3);                 // bb0[5]: scope 0 at $DIR/issue-66971.rs:16:21: 16:22
+          _1 = const encode(move _2) -> bb1; // bb0[6]: scope 0 at $DIR/issue-66971.rs:16:5: 16:23
+                                           // ty::Const
+                                           // + ty: fn(((), u8, u8)) {encode}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/issue-66971.rs:16:5: 16:11
+                                           // + literal: Const { ty: fn(((), u8, u8)) {encode}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          StorageDead(_2);                 // bb1[0]: scope 0 at $DIR/issue-66971.rs:16:22: 16:23
+          StorageDead(_1);                 // bb1[1]: scope 0 at $DIR/issue-66971.rs:16:23: 16:24
+          _0 = ();                         // bb1[2]: scope 0 at $DIR/issue-66971.rs:15:11: 17:2
+          return;                          // bb1[3]: scope 0 at $DIR/issue-66971.rs:17:2: 17:2
+      }
+  }
+  
index c6d753a1209cd5b03b6a543a0c10aa784bb06b3e..3c832eb1344022ae373408a9a7a32a5f5008cc44 100644 (file)
@@ -6,29 +6,7 @@ fn test(this: ((u8, u8),)) {
     assert!((this.0).0 == 1);
 }
 
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     test(((1, 2),));
 }
-
-// Important bit is parameter passing so we only check that below
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _3 = (const 1u8, const 2u8);
-//      _2 = (move _3,);
-//      ...
-//      _1 = const test(move _2) -> bb1;
-//      ...
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _3 = (const 1u8, const 2u8);
-//      _2 = (move _3,);
-//      ...
-//      _1 = const test(move _2) -> bb1;
-//      ...
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..96a20ed
--- /dev/null
@@ -0,0 +1,47 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue-67019.rs:10:11: 10:11
+      let _1: ();                          // in scope 0 at $DIR/issue-67019.rs:11:5: 11:20
+      let mut _2: ((u8, u8),);             // in scope 0 at $DIR/issue-67019.rs:11:10: 11:19
+      let mut _3: (u8, u8);                // in scope 0 at $DIR/issue-67019.rs:11:11: 11:17
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/issue-67019.rs:11:5: 11:20
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/issue-67019.rs:11:10: 11:19
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/issue-67019.rs:11:11: 11:17
+          _3 = (const 1u8, const 2u8);     // bb0[3]: scope 0 at $DIR/issue-67019.rs:11:11: 11:17
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x01))
+                                           // mir::Constant
+-                                          // + span: $DIR/issue-67019.rs:11:12: 11:13
++                                          // + span: $DIR/issue-67019.rs:11:11: 11:17
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x01)) }
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x02))
+                                           // mir::Constant
+-                                          // + span: $DIR/issue-67019.rs:11:15: 11:16
++                                          // + span: $DIR/issue-67019.rs:11:11: 11:17
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
+          _2 = (move _3,);                 // bb0[4]: scope 0 at $DIR/issue-67019.rs:11:10: 11:19
+          StorageDead(_3);                 // bb0[5]: scope 0 at $DIR/issue-67019.rs:11:18: 11:19
+          _1 = const test(move _2) -> bb1; // bb0[6]: scope 0 at $DIR/issue-67019.rs:11:5: 11:20
+                                           // ty::Const
+                                           // + ty: fn(((u8, u8),)) {test}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/issue-67019.rs:11:5: 11:9
+                                           // + literal: Const { ty: fn(((u8, u8),)) {test}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          StorageDead(_2);                 // bb1[0]: scope 0 at $DIR/issue-67019.rs:11:19: 11:20
+          StorageDead(_1);                 // bb1[1]: scope 0 at $DIR/issue-67019.rs:11:20: 11:21
+          _0 = ();                         // bb1[2]: scope 0 at $DIR/issue-67019.rs:10:11: 12:2
+          return;                          // bb1[3]: scope 0 at $DIR/issue-67019.rs:12:2: 12:2
+      }
+  }
+  
index 93a53db9093608cf472185be56f729ff5b895002..0ae172e777b9b28129a8cc118c944c4283cef1a2 100644 (file)
@@ -5,145 +5,11 @@ struct Point {
     y: u32,
 }
 
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.main.ConstProp.diff
+// EMIT_MIR rustc.main.SimplifyLocals.after.mir
 fn main() {
     let x = 2 + 2;
     let y = [0, 1, 2, 3, 4, 5][3];
     let z = (Point { x: 12, y: 42}).y;
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-// let mut _0: ();
-// let _1: i32;
-// let mut _2: (i32, bool);
-// let mut _4: [i32; 6];
-// let _5: usize;
-// let mut _6: usize;
-// let mut _7: bool;
-// let mut _9: Point;
-// scope 1 {
-//   debug x => _1;
-//   let _3: i32;
-//   scope 2 {
-//     debug y => _3;
-//     let _8: u32;
-//     scope 3 {
-//       debug z => _8;
-//     }
-//   }
-// }
-// bb0: {
-//   StorageLive(_1);
-//   _2 = CheckedAdd(const 2i32, const 2i32);
-//   assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1;
-// }
-// bb1: {
-//   _1 = move (_2.0: i32);
-//   StorageLive(_3);
-//   StorageLive(_4);
-//   _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32];
-//   StorageLive(_5);
-//   _5 = const 3usize;
-//   _6 = const 6usize;
-//   _7 = Lt(_5, _6);
-//   assert(move _7, "index out of bounds: the len is move _6 but the index is _5") -> bb2;
-// }
-// bb2: {
-//   _3 = _4[_5];
-//   StorageDead(_5);
-//   StorageDead(_4);
-//   StorageLive(_8);
-//   StorageLive(_9);
-//   _9 = Point { x: const 12u32, y: const 42u32 };
-//   _8 = (_9.1: u32);
-//   StorageDead(_9);
-//   _0 = ();
-//   StorageDead(_8);
-//   StorageDead(_3);
-//   StorageDead(_1);
-//   return;
-// }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-// let mut _0: ();
-// let _1: i32;
-// let mut _2: (i32, bool);
-// let mut _4: [i32; 6];
-// let _5: usize;
-// let mut _6: usize;
-// let mut _7: bool;
-// let mut _9: Point;
-// scope 1 {
-//   debug x => _1;
-//   let _3: i32;
-//   scope 2 {
-//     debug y => _3;
-//     let _8: u32;
-//     scope 3 {
-//       debug z => _8;
-//     }
-//   }
-// }
-// bb0: {
-//   StorageLive(_1);
-//   _2 = (const 4i32, const false);
-//   assert(!const false, "attempt to add with overflow") -> bb1;
-// }
-// bb1: {
-//   _1 = const 4i32;
-//   StorageLive(_3);
-//   StorageLive(_4);
-//   _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32];
-//   StorageLive(_5);
-//   _5 = const 3usize;
-//   _6 = const 6usize;
-//   _7 = const true;
-//   assert(const true, "index out of bounds: the len is move _6 but the index is _5") -> bb2;
-// }
-// bb2: {
-//   _3 = const 3i32;
-//   StorageDead(_5);
-//   StorageDead(_4);
-//   StorageLive(_8);
-//   StorageLive(_9);
-//   _9 = Point { x: const 12u32, y: const 42u32 };
-//   _8 = const 42u32;
-//   StorageDead(_9);
-//   _0 = ();
-//   StorageDead(_8);
-//   StorageDead(_3);
-//   StorageDead(_1);
-//   return;
-// }
-// END rustc.main.ConstProp.after.mir
-// START rustc.main.SimplifyLocals.after.mir
-// let mut _0: ();
-// let _1: i32;
-// let mut _3: [i32; 6];
-// scope 1 {
-//   debug x => _1;
-//   let _2: i32;
-//   scope 2 {
-//     debug y => _2;
-//     let _4: u32;
-//     scope 3 {
-//       debug z => _4;
-//     }
-//   }
-// }
-// bb0: {
-//   StorageLive(_1);
-//   _1 = const 4i32;
-//   StorageLive(_2);
-//   StorageLive(_3);
-//   _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32];
-//   _2 = const 3i32;
-//   StorageDead(_3);
-//   StorageLive(_4);
-//   _4 = const 42u32;
-//   StorageDead(_4);
-//   StorageDead(_2);
-//   StorageDead(_1);
-//   return;
-// }
-// END rustc.main.SimplifyLocals.after.mir
diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..d8bd397
--- /dev/null
@@ -0,0 +1,181 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11
+      let _1: i32;                         // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+      let mut _2: (i32, bool);             // in scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
+      let mut _4: [i32; 6];                // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+      let _5: usize;                       // in scope 0 at $DIR/optimizes_into_variable.rs:13:32: 13:33
+      let mut _6: usize;                   // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+      let mut _7: bool;                    // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+      let mut _9: Point;                   // in scope 0 at $DIR/optimizes_into_variable.rs:14:13: 14:36
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+          let _3: i32;                     // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+          scope 2 {
+              debug y => _3;               // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+              let _8: u32;                 // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+              scope 3 {
+                  debug z => _8;           // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+              }
+          }
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+-         _2 = CheckedAdd(const 2i32, const 2i32); // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++         _2 = (const 4i32, const false);  // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
+                                           // ty::Const
+                                           // + ty: i32
+-                                          // + val: Value(Scalar(0x00000002))
++                                          // + val: Value(Scalar(0x00000004))
+                                           // mir::Constant
+-                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:14
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
++                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+                                           // ty::Const
+-                                          // + ty: i32
+-                                          // + val: Value(Scalar(0x00000002))
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+-                                          // + span: $DIR/optimizes_into_variable.rs:12:17: 12:18
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+-         assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
++         assert(!const false, "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+      }
+  
+      bb1: {
+-         _1 = move (_2.0: i32);           // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++         _1 = const 4i32;                 // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // ty::Const
++                                          // + ty: i32
++                                          // + val: Value(Scalar(0x00000004))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+          StorageLive(_3);                 // bb1[1]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+          StorageLive(_4);                 // bb1[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+          _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb1[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000002))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000003))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000004))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000005))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
+          StorageLive(_5);                 // bb1[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:32: 13:33
+          _5 = const 3usize;               // bb1[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:32: 13:33
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000003))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:32: 13:33
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000003)) }
+          _6 = const 6usize;               // bb1[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000006))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000006)) }
+-         _7 = Lt(_5, _6);                 // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+-         assert(move _7, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++         _7 = const true;                 // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
++         assert(const true, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb2: {
+-         _3 = _4[_5];                     // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++         _3 = const 3i32;                 // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // ty::Const
++                                          // + ty: i32
++                                          // + val: Value(Scalar(0x00000003))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+          StorageDead(_5);                 // bb2[1]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
+          StorageDead(_4);                 // bb2[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
+          StorageLive(_8);                 // bb2[3]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+          StorageLive(_9);                 // bb2[4]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
+          _9 = Point { x: const 12u32, y: const 42u32 }; // bb2[5]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x0000000c))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:14:25: 14:27
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) }
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:14:32: 14:34
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+-         _8 = (_9.1: u32);                // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
++         _8 = const 42u32;                // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x0000002a))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+          StorageDead(_9);                 // bb2[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:38: 14:39
+          _0 = ();                         // bb2[8]: scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2
+          StorageDead(_8);                 // bb2[9]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+          StorageDead(_3);                 // bb2[10]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+          StorageDead(_1);                 // bb2[11]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+          return;                          // bb2[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir
new file mode 100644 (file)
index 0000000..db4d2d1
--- /dev/null
@@ -0,0 +1,88 @@
+// MIR for `main` after SimplifyLocals
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11
+    let _1: i32;                         // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+    let mut _3: [i32; 6];                // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+        let _2: i32;                     // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+        scope 2 {
+            debug y => _2;               // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+            let _4: u32;                 // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+            scope 3 {
+                debug z => _4;           // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+        _1 = const 4i32;                 // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000004))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+        StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+        StorageLive(_3);                 // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+        _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb0[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000004))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000005))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
+        _2 = const 3i32;                 // bb0[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        StorageDead(_3);                 // bb0[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
+        StorageLive(_4);                 // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+        _4 = const 42u32;                // bb0[8]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000002a))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+        StorageDead(_4);                 // bb0[9]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+        StorageDead(_2);                 // bb0[10]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+        StorageDead(_1);                 // bb0[11]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+        return;                          // bb0[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2
+    }
+}
diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..9e646e7
--- /dev/null
@@ -0,0 +1,181 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11
+      let _1: i32;                         // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+      let mut _2: (i32, bool);             // in scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
+      let mut _4: [i32; 6];                // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+      let _5: usize;                       // in scope 0 at $DIR/optimizes_into_variable.rs:13:32: 13:33
+      let mut _6: usize;                   // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+      let mut _7: bool;                    // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+      let mut _9: Point;                   // in scope 0 at $DIR/optimizes_into_variable.rs:14:13: 14:36
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+          let _3: i32;                     // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+          scope 2 {
+              debug y => _3;               // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+              let _8: u32;                 // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+              scope 3 {
+                  debug z => _8;           // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+              }
+          }
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+-         _2 = CheckedAdd(const 2i32, const 2i32); // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++         _2 = (const 4i32, const false);  // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
+                                           // ty::Const
+                                           // + ty: i32
+-                                          // + val: Value(Scalar(0x00000002))
++                                          // + val: Value(Scalar(0x00000004))
+                                           // mir::Constant
+-                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:14
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
++                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+                                           // ty::Const
+-                                          // + ty: i32
+-                                          // + val: Value(Scalar(0x00000002))
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+-                                          // + span: $DIR/optimizes_into_variable.rs:12:17: 12:18
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+-         assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
++         assert(!const false, "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+      }
+  
+      bb1: {
+-         _1 = move (_2.0: i32);           // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++         _1 = const 4i32;                 // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // ty::Const
++                                          // + ty: i32
++                                          // + val: Value(Scalar(0x00000004))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+          StorageLive(_3);                 // bb1[1]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+          StorageLive(_4);                 // bb1[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+          _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb1[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000002))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000003))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000004))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000005))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
+          StorageLive(_5);                 // bb1[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:32: 13:33
+          _5 = const 3usize;               // bb1[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:32: 13:33
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000003))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:32: 13:33
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) }
+          _6 = const 6usize;               // bb1[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000006))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000006)) }
+-         _7 = Lt(_5, _6);                 // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+-         assert(move _7, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++         _7 = const true;                 // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
++         assert(const true, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb2: {
+-         _3 = _4[_5];                     // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++         _3 = const 3i32;                 // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // ty::Const
++                                          // + ty: i32
++                                          // + val: Value(Scalar(0x00000003))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+          StorageDead(_5);                 // bb2[1]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
+          StorageDead(_4);                 // bb2[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
+          StorageLive(_8);                 // bb2[3]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+          StorageLive(_9);                 // bb2[4]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
+          _9 = Point { x: const 12u32, y: const 42u32 }; // bb2[5]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x0000000c))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:14:25: 14:27
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) }
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/optimizes_into_variable.rs:14:32: 14:34
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+-         _8 = (_9.1: u32);                // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
++         _8 = const 42u32;                // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x0000002a))
++                                          // mir::Constant
++                                          // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+          StorageDead(_9);                 // bb2[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:38: 14:39
+          _0 = ();                         // bb2[8]: scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2
+          StorageDead(_8);                 // bb2[9]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+          StorageDead(_3);                 // bb2[10]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+          StorageDead(_1);                 // bb2[11]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+          return;                          // bb2[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir
new file mode 100644 (file)
index 0000000..db4d2d1
--- /dev/null
@@ -0,0 +1,88 @@
+// MIR for `main` after SimplifyLocals
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11
+    let _1: i32;                         // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+    let mut _3: [i32; 6];                // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+        let _2: i32;                     // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+        scope 2 {
+            debug y => _2;               // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+            let _4: u32;                 // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+            scope 3 {
+                debug z => _4;           // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
+        _1 = const 4i32;                 // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000004))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+        StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
+        StorageLive(_3);                 // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+        _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb0[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000004))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000005))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
+        _2 = const 3i32;                 // bb0[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        StorageDead(_3);                 // bb0[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
+        StorageLive(_4);                 // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
+        _4 = const 42u32;                // bb0[8]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000002a))
+                                         // mir::Constant
+                                         // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+        StorageDead(_4);                 // bb0[9]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+        StorageDead(_2);                 // bb0[10]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+        StorageDead(_1);                 // bb0[11]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2
+        return;                          // bb0[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2
+    }
+}
index d307cebd71539fb3fa37307f6cf27dfcfe59ac8b..9635f7050a687b89543bf4616d429d8a9521dc4f 100644 (file)
@@ -2,30 +2,7 @@
 
 static FOO: u8 = 2;
 
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     let x = FOO + FOO;
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _3 = const {alloc0+0: &u8};
-//      _2 = (*_3);
-//      ...
-//      _5 = const {alloc0+0: &u8};
-//      _4 = (*_5);
-//      _1 = Add(move _2, move _4);
-//      ...
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _2 = const 2u8;
-//      ...
-//      _4 = const 2u8;
-//      _1 = const 4u8;
-//      ...
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..6183b22
--- /dev/null
@@ -0,0 +1,72 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/read_immutable_static.rs:6:11: 6:11
+      let _1: u8;                          // in scope 0 at $DIR/read_immutable_static.rs:7:9: 7:10
+      let mut _2: u8;                      // in scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16
+      let mut _3: &u8;                     // in scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16
+      let mut _4: u8;                      // in scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22
+      let mut _5: &u8;                     // in scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/read_immutable_static.rs:7:9: 7:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/read_immutable_static.rs:7:9: 7:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16
+          _3 = const {alloc0+0: &u8};      // bb0[3]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16
+                                           // ty::Const
+                                           // + ty: &u8
+                                           // + val: Value(Scalar(alloc0+0))
+                                           // mir::Constant
+                                           // + span: $DIR/read_immutable_static.rs:7:13: 7:16
+                                           // + literal: Const { ty: &u8, val: Value(Scalar(alloc0+0)) }
+-         _2 = (*_3);                      // bb0[4]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16
++         _2 = const 2u8;                  // bb0[4]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16
++                                          // ty::Const
++                                          // + ty: u8
++                                          // + val: Value(Scalar(0x02))
++                                          // mir::Constant
++                                          // + span: $DIR/read_immutable_static.rs:7:13: 7:16
++                                          // + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
+          StorageLive(_4);                 // bb0[5]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22
+          StorageLive(_5);                 // bb0[6]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22
+          _5 = const {alloc0+0: &u8};      // bb0[7]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22
+                                           // ty::Const
+                                           // + ty: &u8
+                                           // + val: Value(Scalar(alloc0+0))
+                                           // mir::Constant
+                                           // + span: $DIR/read_immutable_static.rs:7:19: 7:22
+                                           // + literal: Const { ty: &u8, val: Value(Scalar(alloc0+0)) }
+-         _4 = (*_5);                      // bb0[8]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22
+-         _1 = Add(move _2, move _4);      // bb0[9]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:22
++         _4 = const 2u8;                  // bb0[8]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22
++                                          // ty::Const
++                                          // + ty: u8
++                                          // + val: Value(Scalar(0x02))
++                                          // mir::Constant
++                                          // + span: $DIR/read_immutable_static.rs:7:19: 7:22
++                                          // + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
++         _1 = const 4u8;                  // bb0[9]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:22
++                                          // ty::Const
++                                          // + ty: u8
++                                          // + val: Value(Scalar(0x04))
++                                          // mir::Constant
++                                          // + span: $DIR/read_immutable_static.rs:7:13: 7:22
++                                          // + literal: Const { ty: u8, val: Value(Scalar(0x04)) }
+          StorageDead(_4);                 // bb0[10]: scope 0 at $DIR/read_immutable_static.rs:7:21: 7:22
+          StorageDead(_2);                 // bb0[11]: scope 0 at $DIR/read_immutable_static.rs:7:21: 7:22
+          StorageDead(_5);                 // bb0[12]: scope 0 at $DIR/read_immutable_static.rs:7:22: 7:23
+          StorageDead(_3);                 // bb0[13]: scope 0 at $DIR/read_immutable_static.rs:7:22: 7:23
+          _0 = ();                         // bb0[14]: scope 0 at $DIR/read_immutable_static.rs:6:11: 8:2
+          StorageDead(_1);                 // bb0[15]: scope 0 at $DIR/read_immutable_static.rs:8:1: 8:2
+          return;                          // bb0[16]: scope 0 at $DIR/read_immutable_static.rs:8:2: 8:2
+      }
+  }
+  
+  alloc0 (static: FOO, size: 1, align: 1) {
+      02                                              â”‚ .
+  }
+  
index 8b48296a5d9111f9a2dd7ff9e4b6300899aed84a..fc33e0e1f3b1879c9382501047f45465c36554d0 100644 (file)
@@ -1,41 +1,6 @@
+// EMIT_MIR rustc.main.PromoteTemps.diff
+// EMIT_MIR rustc.main.ConstProp.diff
+
 fn main() {
     *(&4);
 }
-
-// END RUST SOURCE
-// START rustc.main.PromoteTemps.before.mir
-// bb0: {
-//     ...
-//     _3 = const 4i32;
-//     _2 = &_3;
-//     _1 = (*_2);
-//     ...
-//}
-// END rustc.main.PromoteTemps.before.mir
-// START rustc.main.PromoteTemps.after.mir
-// bb0: {
-//     ...
-//     _4 = const main::promoted[0];
-//     _2 = &(*_4);
-//     _1 = (*_2);
-//     ...
-//}
-// END rustc.main.PromoteTemps.after.mir
-// START rustc.main.ConstProp.before.mir
-// bb0: {
-//     ...
-//     _4 = const main::promoted[0];
-//     _2 = _4;
-//     _1 = (*_2);
-//     ...
-//}
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-// bb0: {
-//     ...
-//     _4 = const main::promoted[0];
-//     _2 = _4;
-//     _1 = const 4i32;
-//     ...
-// }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..0f8563d
--- /dev/null
@@ -0,0 +1,36 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/ref_deref.rs:4:11: 4:11
+      let _1: i32;                         // in scope 0 at $DIR/ref_deref.rs:5:5: 5:10
+      let mut _2: &i32;                    // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+      let _3: i32;                         // in scope 0 at $DIR/ref_deref.rs:5:8: 5:9
+      let mut _4: &i32;                    // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+          _4 = const main::promoted[0];    // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+                                           // ty::Const
+                                           // + ty: &i32
+                                           // + val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0]))
+                                           // mir::Constant
+                                           // + span: $DIR/ref_deref.rs:5:6: 5:10
+                                           // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) }
+          _2 = _4;                         // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+-         _1 = (*_2);                      // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10
++         _1 = const 4i32;                 // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10
++                                          // ty::Const
++                                          // + ty: i32
++                                          // + val: Value(Scalar(0x00000004))
++                                          // mir::Constant
++                                          // + span: $DIR/ref_deref.rs:5:5: 5:10
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+          StorageDead(_2);                 // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11
+          StorageDead(_1);                 // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11
+          _0 = ();                         // bb0[7]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2
+          return;                          // bb0[8]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff b/src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff
new file mode 100644 (file)
index 0000000..ea1baa4
--- /dev/null
@@ -0,0 +1,42 @@
+- // MIR for `main` before PromoteTemps
++ // MIR for `main` after PromoteTemps
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/ref_deref.rs:4:11: 4:11
+      let _1: i32;                         // in scope 0 at $DIR/ref_deref.rs:5:5: 5:10
+      let mut _2: &i32;                    // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+      let _3: i32;                         // in scope 0 at $DIR/ref_deref.rs:5:8: 5:9
++     let mut _4: &i32;                    // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+-         StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:8: 5:9
+-         _3 = const 4i32;                 // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:8: 5:9
++         _4 = const main::promoted[0];    // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+                                           // ty::Const
+-                                          // + ty: i32
+-                                          // + val: Value(Scalar(0x00000004))
++                                          // + ty: &i32
++                                          // + val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0]))
+                                           // mir::Constant
+-                                          // + span: $DIR/ref_deref.rs:5:8: 5:9
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+-         _2 = &_3;                        // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+-         _1 = (*_2);                      // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10
+-         StorageDead(_3);                 // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11
+-         StorageDead(_2);                 // bb0[7]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11
+-         StorageDead(_1);                 // bb0[8]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11
+-         _0 = ();                         // bb0[9]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2
+-         return;                          // bb0[10]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2
++                                          // + span: $DIR/ref_deref.rs:5:6: 5:10
++                                          // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) }
++         _2 = &(*_4);                     // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10
++         _1 = (*_2);                      // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10
++         StorageDead(_2);                 // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11
++         StorageDead(_1);                 // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11
++         _0 = ();                         // bb0[7]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2
++         return;                          // bb0[8]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2
+      }
+  }
+  
index ca539fb7462a5eb176eabc7eef5686632748c428..0322e3006431713d1c5145d98fdded2d1c62878e 100644 (file)
@@ -1,41 +1,6 @@
+// EMIT_MIR rustc.main.PromoteTemps.diff
+// EMIT_MIR rustc.main.ConstProp.diff
+
 fn main() {
     *(&(4, 5).1); // This does not currently propagate (#67862)
 }
-
-// END RUST SOURCE
-// START rustc.main.PromoteTemps.before.mir
-// bb0: {
-//     ...
-//     _3 = (const 4i32, const 5i32);
-//     _2 = &(_3.1: i32);
-//     _1 = (*_2);
-//     ...
-//}
-// END rustc.main.PromoteTemps.before.mir
-// START rustc.main.PromoteTemps.after.mir
-// bb0: {
-//     ...
-//     _4 = const main::promoted[0];
-//     _2 = &((*_4).1: i32);
-//     _1 = (*_2);
-//     ...
-//}
-// END rustc.main.PromoteTemps.after.mir
-// START rustc.main.ConstProp.before.mir
-// bb0: {
-//     ...
-//     _4 = const main::promoted[0];
-//     _2 = &((*_4).1: i32);
-//     _1 = (*_2);
-//     ...
-//}
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-// bb0: {
-//     ...
-//     _4 = const main::promoted[0];
-//     _2 = &((*_4).1: i32);
-//     _1 = (*_2);
-//     ...
-// }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..c4b3d6b
--- /dev/null
@@ -0,0 +1,29 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/ref_deref_project.rs:4:11: 4:11
+      let _1: i32;                         // in scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
+      let mut _2: &i32;                    // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+      let _3: (i32, i32);                  // in scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14
+      let mut _4: &(i32, i32);             // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+          _4 = const main::promoted[0];    // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+                                           // ty::Const
+                                           // + ty: &(i32, i32)
+                                           // + val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0]))
+                                           // mir::Constant
+                                           // + span: $DIR/ref_deref_project.rs:5:6: 5:17
+                                           // + literal: Const { ty: &(i32, i32), val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) }
+          _2 = &((*_4).1: i32);            // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+          _1 = (*_2);                      // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
+          StorageDead(_2);                 // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
+          StorageDead(_1);                 // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
+          _0 = ();                         // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2
+          return;                          // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff
new file mode 100644 (file)
index 0000000..852436e
--- /dev/null
@@ -0,0 +1,48 @@
+- // MIR for `main` before PromoteTemps
++ // MIR for `main` after PromoteTemps
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/ref_deref_project.rs:4:11: 4:11
+      let _1: i32;                         // in scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
+      let mut _2: &i32;                    // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+      let _3: (i32, i32);                  // in scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14
++     let mut _4: &(i32, i32);             // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+-         StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14
+-         _3 = (const 4i32, const 5i32);   // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14
++         _4 = const main::promoted[0];    // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+                                           // ty::Const
+-                                          // + ty: i32
+-                                          // + val: Value(Scalar(0x00000004))
++                                          // + ty: &(i32, i32)
++                                          // + val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0]))
+                                           // mir::Constant
+-                                          // + span: $DIR/ref_deref_project.rs:5:9: 5:10
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+-                                          // ty::Const
+-                                          // + ty: i32
+-                                          // + val: Value(Scalar(0x00000005))
+-                                          // mir::Constant
+-                                          // + span: $DIR/ref_deref_project.rs:5:12: 5:13
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
+-         _2 = &(_3.1: i32);               // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+-         _1 = (*_2);                      // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
+-         StorageDead(_3);                 // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
+-         StorageDead(_2);                 // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
+-         StorageDead(_1);                 // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
+-         _0 = ();                         // bb0[9]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2
+-         return;                          // bb0[10]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2
++                                          // + span: $DIR/ref_deref_project.rs:5:6: 5:17
++                                          // + literal: Const { ty: &(i32, i32), val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) }
++         _2 = &((*_4).1: i32);            // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
++         _1 = (*_2);                      // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
++         StorageDead(_2);                 // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
++         StorageDead(_1);                 // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
++         _0 = ();                         // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2
++         return;                          // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2
+      }
+  }
+  
index 4d6fe905b0c3546e01bce91235e731a592281d22..834eb0cb1e943f713e1ef3b4191b69fc00ac23cd 100644 (file)
@@ -1,25 +1,5 @@
+// EMIT_MIR rustc.main.ConstProp.diff
+
 fn main() {
     let _ = main as usize as *const fn();
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _3 = const main as fn() (Pointer(ReifyFnPointer));
-//      _2 = move _3 as usize (Misc);
-//      ...
-//      _1 = move _2 as *const fn() (Misc);
-//      ...
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _3 = const main as fn() (Pointer(ReifyFnPointer));
-//      _2 = move _3 as usize (Misc);
-//      ...
-//      _1 = move _2 as *const fn() (Misc);
-//      ...
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..7a41a8a
--- /dev/null
@@ -0,0 +1,32 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/reify_fn_ptr.rs:3:11: 3:11
+      let mut _1: *const fn();             // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41
+      let mut _2: usize;                   // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26
+      let mut _3: fn();                    // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17
+      scope 1 {
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17
+          _3 = const main as fn() (Pointer(ReifyFnPointer)); // bb0[3]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17
+                                           // ty::Const
+                                           // + ty: fn() {main}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/reify_fn_ptr.rs:4:13: 4:17
+                                           // + literal: Const { ty: fn() {main}, val: Value(Scalar(<ZST>)) }
+          _2 = move _3 as usize (Misc);    // bb0[4]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26
+          StorageDead(_3);                 // bb0[5]: scope 0 at $DIR/reify_fn_ptr.rs:4:25: 4:26
+          _1 = move _2 as *const fn() (Misc); // bb0[6]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41
+          StorageDead(_2);                 // bb0[7]: scope 0 at $DIR/reify_fn_ptr.rs:4:40: 4:41
+          StorageDead(_1);                 // bb0[8]: scope 0 at $DIR/reify_fn_ptr.rs:4:41: 4:42
+          _0 = ();                         // bb0[9]: scope 0 at $DIR/reify_fn_ptr.rs:3:11: 5:2
+          return;                          // bb0[10]: scope 0 at $DIR/reify_fn_ptr.rs:5:2: 5:2
+      }
+  }
+  
index 48c06290cec00f387b7212395c39c368d5a1c63e..cdbfc46d6ca0e35214a65af4868c4532ac17807d 100644 (file)
@@ -1,37 +1,7 @@
 // compile-flags: -O
 
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     let x: u32 = [42; 8][2] + 0;
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _3 = [const 42u32; 8];
-//      ...
-//      _4 = const 2usize;
-//      _5 = const 8usize;
-//      _6 = Lt(_4, _5);
-//      assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1;
-//  }
-//  bb1: {
-//      _2 = _3[_4];
-//      _1 = Add(move _2, const 0u32);
-//      ...
-//      return;
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _6 = const true;
-//      assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1;
-//  }
-//  bb1: {
-//      _2 = const 42u32;
-//      _1 = const 42u32;
-//      ...
-//      return;
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..dce98d8
--- /dev/null
@@ -0,0 +1,88 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/repeat.rs:5:11: 5:11
+      let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/repeat.rs:6:9: 6:10
+      let mut _2: u32;                     // in scope 0 at $DIR/repeat.rs:6:18: 6:28
+      let mut _3: [u32; 8];                // in scope 0 at $DIR/repeat.rs:6:18: 6:25
+      let _4: usize;                       // in scope 0 at $DIR/repeat.rs:6:26: 6:27
+      let mut _5: usize;                   // in scope 0 at $DIR/repeat.rs:6:18: 6:28
+      let mut _6: bool;                    // in scope 0 at $DIR/repeat.rs:6:18: 6:28
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/repeat.rs:6:9: 6:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/repeat.rs:6:9: 6:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/repeat.rs:6:18: 6:25
+          _3 = [const 42u32; 8];           // bb0[3]: scope 0 at $DIR/repeat.rs:6:18: 6:25
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/repeat.rs:6:19: 6:21
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+          StorageLive(_4);                 // bb0[4]: scope 0 at $DIR/repeat.rs:6:26: 6:27
+          _4 = const 2usize;               // bb0[5]: scope 0 at $DIR/repeat.rs:6:26: 6:27
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000002))
+                                           // mir::Constant
+                                           // + span: $DIR/repeat.rs:6:26: 6:27
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) }
+          _5 = const 8usize;               // bb0[6]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000008))
+                                           // mir::Constant
+                                           // + span: $DIR/repeat.rs:6:18: 6:28
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000008)) }
+-         _6 = Lt(_4, _5);                 // bb0[7]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+-         assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:6:18: 6:28
++         _6 = const true;                 // bb0[7]: scope 0 at $DIR/repeat.rs:6:18: 6:28
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/repeat.rs:6:18: 6:28
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
++         assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:6:18: 6:28
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/repeat.rs:6:18: 6:28
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb1: {
+-         _2 = _3[_4];                     // bb1[0]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+-         _1 = Add(move _2, const 0u32);   // bb1[1]: scope 0 at $DIR/repeat.rs:6:18: 6:32
++         _2 = const 42u32;                // bb1[0]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+                                           // ty::Const
+                                           // + ty: u32
+-                                          // + val: Value(Scalar(0x00000000))
++                                          // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+-                                          // + span: $DIR/repeat.rs:6:31: 6:32
+-                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
++                                          // + span: $DIR/repeat.rs:6:18: 6:28
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
++         _1 = const 42u32;                // bb1[1]: scope 0 at $DIR/repeat.rs:6:18: 6:32
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x0000002a))
++                                          // mir::Constant
++                                          // + span: $DIR/repeat.rs:6:18: 6:32
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+          StorageDead(_2);                 // bb1[2]: scope 0 at $DIR/repeat.rs:6:31: 6:32
+          StorageDead(_4);                 // bb1[3]: scope 0 at $DIR/repeat.rs:6:32: 6:33
+          StorageDead(_3);                 // bb1[4]: scope 0 at $DIR/repeat.rs:6:32: 6:33
+          _0 = ();                         // bb1[5]: scope 0 at $DIR/repeat.rs:5:11: 7:2
+          StorageDead(_1);                 // bb1[6]: scope 0 at $DIR/repeat.rs:7:1: 7:2
+          return;                          // bb1[7]: scope 0 at $DIR/repeat.rs:7:2: 7:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..c9e6402
--- /dev/null
@@ -0,0 +1,88 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/repeat.rs:5:11: 5:11
+      let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/repeat.rs:6:9: 6:10
+      let mut _2: u32;                     // in scope 0 at $DIR/repeat.rs:6:18: 6:28
+      let mut _3: [u32; 8];                // in scope 0 at $DIR/repeat.rs:6:18: 6:25
+      let _4: usize;                       // in scope 0 at $DIR/repeat.rs:6:26: 6:27
+      let mut _5: usize;                   // in scope 0 at $DIR/repeat.rs:6:18: 6:28
+      let mut _6: bool;                    // in scope 0 at $DIR/repeat.rs:6:18: 6:28
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/repeat.rs:6:9: 6:10
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/repeat.rs:6:9: 6:10
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/repeat.rs:6:18: 6:25
+          _3 = [const 42u32; 8];           // bb0[3]: scope 0 at $DIR/repeat.rs:6:18: 6:25
+                                           // ty::Const
+                                           // + ty: u32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/repeat.rs:6:19: 6:21
+                                           // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+          StorageLive(_4);                 // bb0[4]: scope 0 at $DIR/repeat.rs:6:26: 6:27
+          _4 = const 2usize;               // bb0[5]: scope 0 at $DIR/repeat.rs:6:26: 6:27
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000002))
+                                           // mir::Constant
+                                           // + span: $DIR/repeat.rs:6:26: 6:27
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) }
+          _5 = const 8usize;               // bb0[6]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000008))
+                                           // mir::Constant
+                                           // + span: $DIR/repeat.rs:6:18: 6:28
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000008)) }
+-         _6 = Lt(_4, _5);                 // bb0[7]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+-         assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:6:18: 6:28
++         _6 = const true;                 // bb0[7]: scope 0 at $DIR/repeat.rs:6:18: 6:28
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/repeat.rs:6:18: 6:28
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
++         assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:6:18: 6:28
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/repeat.rs:6:18: 6:28
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb1: {
+-         _2 = _3[_4];                     // bb1[0]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+-         _1 = Add(move _2, const 0u32);   // bb1[1]: scope 0 at $DIR/repeat.rs:6:18: 6:32
++         _2 = const 42u32;                // bb1[0]: scope 0 at $DIR/repeat.rs:6:18: 6:28
+                                           // ty::Const
+                                           // + ty: u32
+-                                          // + val: Value(Scalar(0x00000000))
++                                          // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+-                                          // + span: $DIR/repeat.rs:6:31: 6:32
+-                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
++                                          // + span: $DIR/repeat.rs:6:18: 6:28
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
++         _1 = const 42u32;                // bb1[1]: scope 0 at $DIR/repeat.rs:6:18: 6:32
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x0000002a))
++                                          // mir::Constant
++                                          // + span: $DIR/repeat.rs:6:18: 6:32
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) }
+          StorageDead(_2);                 // bb1[2]: scope 0 at $DIR/repeat.rs:6:31: 6:32
+          StorageDead(_4);                 // bb1[3]: scope 0 at $DIR/repeat.rs:6:32: 6:33
+          StorageDead(_3);                 // bb1[4]: scope 0 at $DIR/repeat.rs:6:32: 6:33
+          _0 = ();                         // bb1[5]: scope 0 at $DIR/repeat.rs:5:11: 7:2
+          StorageDead(_1);                 // bb1[6]: scope 0 at $DIR/repeat.rs:7:1: 7:2
+          return;                          // bb1[7]: scope 0 at $DIR/repeat.rs:7:2: 7:2
+      }
+  }
+  
index ea7c1e7ccd0cb24e3ee95ce553394ac1ec789a6a..8d5b63b9afd88beab61b1a334eec643b9d28b442 100644 (file)
@@ -1,5 +1,7 @@
 // compile-flags: -C overflow-checks=on
 
+// EMIT_MIR rustc.add.ConstProp.diff
+// EMIT_MIR rustc.add.PreCodegen.before.mir
 fn add() -> u32 {
     2 + 2
 }
@@ -7,42 +9,3 @@ fn add() -> u32 {
 fn main() {
     add();
 }
-
-// END RUST SOURCE
-// START rustc.add.ConstProp.before.mir
-// fn add() -> u32 {
-//     let mut _0: u32;
-//     let mut _1: (u32, bool);
-//     bb0: {
-//         _1 = CheckedAdd(const 2u32, const 2u32);
-//         assert(!move (_1.1: bool), "attempt to add with overflow") -> bb1;
-//     }
-//     bb1: {
-//         _0 = move (_1.0: u32);
-//         return;
-//     }
-// }
-// END rustc.add.ConstProp.before.mir
-// START rustc.add.ConstProp.after.mir
-// fn add() -> u32 {
-//     let mut _0: u32;
-//     let mut _1: (u32, bool);
-//     bb0: {
-//         _1 = (const 4u32, const false);
-//         assert(!const false, "attempt to add with overflow") -> bb1;
-//     }
-//     bb1: {
-//         _0 = const 4u32;
-//         return;
-//     }
-// }
-// END rustc.add.ConstProp.after.mir
-// START rustc.add.PreCodegen.before.mir
-// fn add() -> u32 {
-//     let mut _0: u32;
-//     bb0: {
-//         _0 = const 4u32;
-//         return;
-//     }
-// }
-// END rustc.add.PreCodegen.before.mir
diff --git a/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff b/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff
new file mode 100644 (file)
index 0000000..3453c42
--- /dev/null
@@ -0,0 +1,52 @@
+- // MIR for `add` before ConstProp
++ // MIR for `add` after ConstProp
+  
+  fn add() -> u32 {
+      let mut _0: u32;                     // return place in scope 0 at $DIR/return_place.rs:5:13: 5:16
+      let mut _1: (u32, bool);             // in scope 0 at $DIR/return_place.rs:6:5: 6:10
+  
+      bb0: {
+-         _1 = CheckedAdd(const 2u32, const 2u32); // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10
++         _1 = (const 4u32, const false);  // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10
+                                           // ty::Const
+                                           // + ty: u32
+-                                          // + val: Value(Scalar(0x00000002))
++                                          // + val: Value(Scalar(0x00000004))
+                                           // mir::Constant
+-                                          // + span: $DIR/return_place.rs:6:5: 6:6
+-                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
++                                          // + span: $DIR/return_place.rs:6:5: 6:10
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) }
+                                           // ty::Const
+-                                          // + ty: u32
+-                                          // + val: Value(Scalar(0x00000002))
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+-                                          // + span: $DIR/return_place.rs:6:9: 6:10
+-                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+-         assert(!move (_1.1: bool), "attempt to add with overflow") -> bb1; // bb0[1]: scope 0 at $DIR/return_place.rs:6:5: 6:10
++                                          // + span: $DIR/return_place.rs:6:5: 6:10
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
++         assert(!const false, "attempt to add with overflow") -> bb1; // bb0[1]: scope 0 at $DIR/return_place.rs:6:5: 6:10
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x00))
++                                          // mir::Constant
++                                          // + span: $DIR/return_place.rs:6:5: 6:10
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+      }
+  
+      bb1: {
+-         _0 = move (_1.0: u32);           // bb1[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10
++         _0 = const 4u32;                 // bb1[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x00000004))
++                                          // mir::Constant
++                                          // + span: $DIR/return_place.rs:6:5: 6:10
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) }
+          return;                          // bb1[1]: scope 0 at $DIR/return_place.rs:7:2: 7:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir b/src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir
new file mode 100644 (file)
index 0000000..9af6be7
--- /dev/null
@@ -0,0 +1,16 @@
+// MIR for `add` before PreCodegen
+
+fn add() -> u32 {
+    let mut _0: u32;                     // return place in scope 0 at $DIR/return_place.rs:5:13: 5:16
+
+    bb0: {
+        _0 = const 4u32;                 // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000004))
+                                         // mir::Constant
+                                         // + span: $DIR/return_place.rs:6:5: 6:10
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) }
+        return;                          // bb0[1]: scope 0 at $DIR/return_place.rs:7:2: 7:2
+    }
+}
index 43813e43d3681f9f46fb86c328606fcee2680137..0312f5e8e3a3ab2b06925135689081f5b3fe3fa0 100644 (file)
@@ -1,43 +1,6 @@
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+
+// EMIT_MIR rustc.main.ConstProp.diff
 fn main() {
     (&[1u32, 2, 3] as &[u32])[1];
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _9 = const main::promoted[0];
-//      _4 = _9;
-//      _3 = _4;
-//      _2 = move _3 as &[u32] (Pointer(Unsize));
-//      ...
-//      _6 = const 1usize;
-//      _7 = Len((*_2));
-//      _8 = Lt(_6, _7);
-//      assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1;
-//  }
-//  bb1: {
-//      _1 = (*_2)[_6];
-//      ...
-//      return;
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      _9 = const main::promoted[0];
-//      _4 = _9;
-//      _3 = _4;
-//      _2 = move _3 as &[u32] (Pointer(Unsize));
-//      ...
-//      _6 = const 1usize;
-//      _7 = const 3usize;
-//      _8 = const true;
-//      assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1;
-//  }
-//  bb1: {
-//      _1 = const 2u32;
-//      ...
-//      return;
-//  }
-// END rustc.main.ConstProp.after.mir
diff --git a/src/test/mir-opt/const_prop/slice_len/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/slice_len/32bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..5f82107
--- /dev/null
@@ -0,0 +1,83 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/slice_len.rs:4:11: 4:11
+      let _1: u32;                         // in scope 0 at $DIR/slice_len.rs:5:5: 5:33
+      let mut _2: &[u32];                  // in scope 0 at $DIR/slice_len.rs:5:5: 5:30
+      let mut _3: &[u32; 3];               // in scope 0 at $DIR/slice_len.rs:5:6: 5:19
+      let _4: &[u32; 3];                   // in scope 0 at $DIR/slice_len.rs:5:6: 5:19
+      let _5: [u32; 3];                    // in scope 0 at $DIR/slice_len.rs:5:7: 5:19
+      let _6: usize;                       // in scope 0 at $DIR/slice_len.rs:5:31: 5:32
+      let mut _7: usize;                   // in scope 0 at $DIR/slice_len.rs:5:5: 5:33
+      let mut _8: bool;                    // in scope 0 at $DIR/slice_len.rs:5:5: 5:33
+      let mut _9: &[u32; 3];               // in scope 0 at $DIR/slice_len.rs:5:6: 5:19
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/slice_len.rs:5:5: 5:30
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          StorageLive(_4);                 // bb0[3]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          _9 = const main::promoted[0];    // bb0[4]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+                                           // ty::Const
+                                           // + ty: &[u32; 3]
+                                           // + val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0]))
+                                           // mir::Constant
+                                           // + span: $DIR/slice_len.rs:5:6: 5:19
+                                           // + literal: Const { ty: &[u32; 3], val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0])) }
+          _4 = _9;                         // bb0[5]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          _3 = _4;                         // bb0[6]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          _2 = move _3 as &[u32] (Pointer(Unsize)); // bb0[7]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          StorageDead(_3);                 // bb0[8]: scope 0 at $DIR/slice_len.rs:5:18: 5:19
+          StorageLive(_6);                 // bb0[9]: scope 0 at $DIR/slice_len.rs:5:31: 5:32
+          _6 = const 1usize;               // bb0[10]: scope 0 at $DIR/slice_len.rs:5:31: 5:32
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/slice_len.rs:5:31: 5:32
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+-         _7 = Len((*_2));                 // bb0[11]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
+-         _8 = Lt(_6, _7);                 // bb0[12]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
+-         assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++         _7 = const 3usize;               // bb0[11]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++                                          // ty::Const
++                                          // + ty: usize
++                                          // + val: Value(Scalar(0x00000003))
++                                          // mir::Constant
++                                          // + span: $DIR/slice_len.rs:5:5: 5:33
++                                          // + literal: Const { ty: usize, val: Value(Scalar(0x00000003)) }
++         _8 = const true;                 // bb0[12]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/slice_len.rs:5:5: 5:33
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
++         assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/slice_len.rs:5:5: 5:33
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb1: {
+-         _1 = (*_2)[_6];                  // bb1[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++         _1 = const 2u32;                 // bb1[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x00000002))
++                                          // mir::Constant
++                                          // + span: $DIR/slice_len.rs:5:5: 5:33
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+          StorageDead(_6);                 // bb1[1]: scope 0 at $DIR/slice_len.rs:5:33: 5:34
+          StorageDead(_4);                 // bb1[2]: scope 0 at $DIR/slice_len.rs:5:33: 5:34
+          StorageDead(_2);                 // bb1[3]: scope 0 at $DIR/slice_len.rs:5:33: 5:34
+          StorageDead(_1);                 // bb1[4]: scope 0 at $DIR/slice_len.rs:5:33: 5:34
+          _0 = ();                         // bb1[5]: scope 0 at $DIR/slice_len.rs:4:11: 6:2
+          return;                          // bb1[6]: scope 0 at $DIR/slice_len.rs:6:2: 6:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/slice_len/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/slice_len/64bit/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..46f98b7
--- /dev/null
@@ -0,0 +1,83 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/slice_len.rs:4:11: 4:11
+      let _1: u32;                         // in scope 0 at $DIR/slice_len.rs:5:5: 5:33
+      let mut _2: &[u32];                  // in scope 0 at $DIR/slice_len.rs:5:5: 5:30
+      let mut _3: &[u32; 3];               // in scope 0 at $DIR/slice_len.rs:5:6: 5:19
+      let _4: &[u32; 3];                   // in scope 0 at $DIR/slice_len.rs:5:6: 5:19
+      let _5: [u32; 3];                    // in scope 0 at $DIR/slice_len.rs:5:7: 5:19
+      let _6: usize;                       // in scope 0 at $DIR/slice_len.rs:5:31: 5:32
+      let mut _7: usize;                   // in scope 0 at $DIR/slice_len.rs:5:5: 5:33
+      let mut _8: bool;                    // in scope 0 at $DIR/slice_len.rs:5:5: 5:33
+      let mut _9: &[u32; 3];               // in scope 0 at $DIR/slice_len.rs:5:6: 5:19
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/slice_len.rs:5:5: 5:30
+          StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          StorageLive(_4);                 // bb0[3]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          _9 = const main::promoted[0];    // bb0[4]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+                                           // ty::Const
+                                           // + ty: &[u32; 3]
+                                           // + val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0]))
+                                           // mir::Constant
+                                           // + span: $DIR/slice_len.rs:5:6: 5:19
+                                           // + literal: Const { ty: &[u32; 3], val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0])) }
+          _4 = _9;                         // bb0[5]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          _3 = _4;                         // bb0[6]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          _2 = move _3 as &[u32] (Pointer(Unsize)); // bb0[7]: scope 0 at $DIR/slice_len.rs:5:6: 5:19
+          StorageDead(_3);                 // bb0[8]: scope 0 at $DIR/slice_len.rs:5:18: 5:19
+          StorageLive(_6);                 // bb0[9]: scope 0 at $DIR/slice_len.rs:5:31: 5:32
+          _6 = const 1usize;               // bb0[10]: scope 0 at $DIR/slice_len.rs:5:31: 5:32
+                                           // ty::Const
+                                           // + ty: usize
+                                           // + val: Value(Scalar(0x0000000000000001))
+                                           // mir::Constant
+                                           // + span: $DIR/slice_len.rs:5:31: 5:32
+                                           // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+-         _7 = Len((*_2));                 // bb0[11]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
+-         _8 = Lt(_6, _7);                 // bb0[12]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
+-         assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++         _7 = const 3usize;               // bb0[11]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++                                          // ty::Const
++                                          // + ty: usize
++                                          // + val: Value(Scalar(0x0000000000000003))
++                                          // mir::Constant
++                                          // + span: $DIR/slice_len.rs:5:5: 5:33
++                                          // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) }
++         _8 = const true;                 // bb0[12]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/slice_len.rs:5:5: 5:33
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
++         assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++                                          // ty::Const
++                                          // + ty: bool
++                                          // + val: Value(Scalar(0x01))
++                                          // mir::Constant
++                                          // + span: $DIR/slice_len.rs:5:5: 5:33
++                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+      }
+  
+      bb1: {
+-         _1 = (*_2)[_6];                  // bb1[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++         _1 = const 2u32;                 // bb1[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33
++                                          // ty::Const
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x00000002))
++                                          // mir::Constant
++                                          // + span: $DIR/slice_len.rs:5:5: 5:33
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+          StorageDead(_6);                 // bb1[1]: scope 0 at $DIR/slice_len.rs:5:33: 5:34
+          StorageDead(_4);                 // bb1[2]: scope 0 at $DIR/slice_len.rs:5:33: 5:34
+          StorageDead(_2);                 // bb1[3]: scope 0 at $DIR/slice_len.rs:5:33: 5:34
+          StorageDead(_1);                 // bb1[4]: scope 0 at $DIR/slice_len.rs:5:33: 5:34
+          _0 = ();                         // bb1[5]: scope 0 at $DIR/slice_len.rs:4:11: 6:2
+          return;                          // bb1[6]: scope 0 at $DIR/slice_len.rs:6:2: 6:2
+      }
+  }
+  
index 904d303d87e313527e26e777b9c1cda4e541e700..46e6efb8180ebd16342875a37a96758cad31f3d3 100644 (file)
@@ -1,38 +1,11 @@
 #[inline(never)]
 fn foo(_: i32) { }
 
+// EMIT_MIR rustc.main.ConstProp.diff
+// EMIT_MIR rustc.main.SimplifyBranches-after-const-prop.diff
 fn main() {
     match 1 {
         1 => foo(0),
         _ => foo(-1),
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.ConstProp.before.mir
-//  bb0: {
-//      ...
-//      _1 = const 1i32;
-//      switchInt(_1) -> [1i32: bb2, otherwise: bb1];
-//  }
-// END rustc.main.ConstProp.before.mir
-// START rustc.main.ConstProp.after.mir
-//  bb0: {
-//      ...
-//      switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1];
-//  }
-// END rustc.main.ConstProp.after.mir
-// START rustc.main.SimplifyBranches-after-const-prop.before.mir
-//  bb0: {
-//      ...
-//      _1 = const 1i32;
-//      switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1];
-//  }
-// END rustc.main.SimplifyBranches-after-const-prop.before.mir
-// START rustc.main.SimplifyBranches-after-const-prop.after.mir
-//  bb0: {
-//      ...
-//      _1 = const 1i32;
-//      goto -> bb2;
-//  }
-// END rustc.main.SimplifyBranches-after-const-prop.after.mir
diff --git a/src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff
new file mode 100644 (file)
index 0000000..92b1430
--- /dev/null
@@ -0,0 +1,64 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/switch_int.rs:6:11: 6:11
+      let mut _1: i32;                     // in scope 0 at $DIR/switch_int.rs:7:11: 7:12
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/switch_int.rs:7:11: 7:12
+          _1 = const 1i32;                 // bb0[1]: scope 0 at $DIR/switch_int.rs:7:11: 7:12
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:7:11: 7:12
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+-         switchInt(_1) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10
++         switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10
++                                          // ty::Const
++                                          // + ty: i32
++                                          // + val: Value(Scalar(0x00000001))
++                                          // mir::Constant
++                                          // + span: $DIR/switch_int.rs:8:9: 8:10
++                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+      }
+  
+      bb1: {
+          _0 = const foo(const -1i32) -> bb3; // bb1[0]: scope 0 at $DIR/switch_int.rs:9:14: 9:21
+                                           // ty::Const
+                                           // + ty: fn(i32) {foo}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:9:14: 9:17
+                                           // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0xffffffff))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:9:18: 9:20
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) }
+      }
+  
+      bb2: {
+          _0 = const foo(const 0i32) -> bb3; // bb2[0]: scope 0 at $DIR/switch_int.rs:8:14: 8:20
+                                           // ty::Const
+                                           // + ty: fn(i32) {foo}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:8:14: 8:17
+                                           // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:8:18: 8:19
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+      }
+  
+      bb3: {
+          StorageDead(_1);                 // bb3[0]: scope 0 at $DIR/switch_int.rs:11:1: 11:2
+          return;                          // bb3[1]: scope 0 at $DIR/switch_int.rs:11:2: 11:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff b/src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff
new file mode 100644 (file)
index 0000000..e1805cc
--- /dev/null
@@ -0,0 +1,64 @@
+- // MIR for `main` before SimplifyBranches-after-const-prop
++ // MIR for `main` after SimplifyBranches-after-const-prop
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/switch_int.rs:6:11: 6:11
+      let mut _1: i32;                     // in scope 0 at $DIR/switch_int.rs:7:11: 7:12
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/switch_int.rs:7:11: 7:12
+          _1 = const 1i32;                 // bb0[1]: scope 0 at $DIR/switch_int.rs:7:11: 7:12
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:7:11: 7:12
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+-         switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10
+-                                          // ty::Const
+-                                          // + ty: i32
+-                                          // + val: Value(Scalar(0x00000001))
+-                                          // mir::Constant
+-                                          // + span: $DIR/switch_int.rs:8:9: 8:10
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
++         goto -> bb2;                     // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10
+      }
+  
+      bb1: {
+          _0 = const foo(const -1i32) -> bb3; // bb1[0]: scope 0 at $DIR/switch_int.rs:9:14: 9:21
+                                           // ty::Const
+                                           // + ty: fn(i32) {foo}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:9:14: 9:17
+                                           // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0xffffffff))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:9:18: 9:20
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) }
+      }
+  
+      bb2: {
+          _0 = const foo(const 0i32) -> bb3; // bb2[0]: scope 0 at $DIR/switch_int.rs:8:14: 8:20
+                                           // ty::Const
+                                           // + ty: fn(i32) {foo}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:8:14: 8:17
+                                           // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) }
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/switch_int.rs:8:18: 8:19
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+      }
+  
+      bb3: {
+          StorageDead(_1);                 // bb3[0]: scope 0 at $DIR/switch_int.rs:11:1: 11:2
+          return;                          // bb3[1]: scope 0 at $DIR/switch_int.rs:11:2: 11:2
+      }
+  }
+  
index a86caf04b043b2431f96fb3b192eee4da2714a9a..b5db5497d4823828678a1f7d29457abf23805887 100644 (file)
@@ -1,3 +1,5 @@
+// EMIT_MIR rustc.test.CopyPropagation.diff
+
 fn test(x: u32) -> u32 {
     let y = x;
     y
@@ -7,23 +9,3 @@ fn main() {
     // Make sure the function actually gets instantiated.
     test(0);
 }
-
-// END RUST SOURCE
-// START rustc.test.CopyPropagation.before.mir
-//  bb0: {
-//      ...
-//      _2 = _1;
-//      ...
-//      _0 = _2;
-//      ...
-//      return;
-//  }
-// END rustc.test.CopyPropagation.before.mir
-// START rustc.test.CopyPropagation.after.mir
-//  bb0: {
-//      ...
-//      _0 = _1;
-//      ...
-//      return;
-//  }
-// END rustc.test.CopyPropagation.after.mir
diff --git a/src/test/mir-opt/copy_propagation/rustc.test.CopyPropagation.diff b/src/test/mir-opt/copy_propagation/rustc.test.CopyPropagation.diff
new file mode 100644 (file)
index 0000000..4e9d4c5
--- /dev/null
@@ -0,0 +1,25 @@
+- // MIR for `test` before CopyPropagation
++ // MIR for `test` after CopyPropagation
+  
+  fn test(_1: u32) -> u32 {
+      debug x => _1;                       // in scope 0 at $DIR/copy_propagation.rs:3:9: 3:10
+      let mut _0: u32;                     // return place in scope 0 at $DIR/copy_propagation.rs:3:20: 3:23
+      let _2: u32;                         // in scope 0 at $DIR/copy_propagation.rs:4:9: 4:10
+      scope 1 {
+-         debug y => _2;                   // in scope 1 at $DIR/copy_propagation.rs:4:9: 4:10
++         debug y => _1;                   // in scope 1 at $DIR/copy_propagation.rs:4:9: 4:10
+      }
+  
+      bb0: {
+-         StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/copy_propagation.rs:4:9: 4:10
+-         _2 = _1;                         // bb0[1]: scope 0 at $DIR/copy_propagation.rs:4:13: 4:14
+-         _0 = _2;                         // bb0[2]: scope 1 at $DIR/copy_propagation.rs:5:5: 5:6
+-         StorageDead(_2);                 // bb0[3]: scope 0 at $DIR/copy_propagation.rs:6:1: 6:2
++         nop;                             // bb0[0]: scope 0 at $DIR/copy_propagation.rs:4:9: 4:10
++         nop;                             // bb0[1]: scope 0 at $DIR/copy_propagation.rs:4:13: 4:14
++         _0 = _1;                         // bb0[2]: scope 1 at $DIR/copy_propagation.rs:5:5: 5:6
++         nop;                             // bb0[3]: scope 0 at $DIR/copy_propagation.rs:6:1: 6:2
+          return;                          // bb0[4]: scope 0 at $DIR/copy_propagation.rs:6:2: 6:2
+      }
+  }
+  
index 5e5fed12fb5f3d67e8b778378f64b81b133e3ad7..c4858be7f2b8cecb43e30e2ec069543aa1b01d1b 100644 (file)
@@ -5,21 +5,25 @@ fn dummy(x: u8) -> u8 {
     x
 }
 
+// EMIT_MIR rustc.foo.CopyPropagation.diff
 fn foo(mut x: u8) {
     // calling `dummy` to make an use of `x` that copyprop cannot eliminate
     x = dummy(x); // this will assign a local to `x`
 }
 
+// EMIT_MIR rustc.bar.CopyPropagation.diff
 fn bar(mut x: u8) {
     dummy(x);
     x = 5;
 }
 
+// EMIT_MIR rustc.baz.CopyPropagation.diff
 fn baz(mut x: i32) {
     // self-assignment to a function argument should be eliminated
     x = x;
 }
 
+// EMIT_MIR rustc.arg_src.CopyPropagation.diff
 fn arg_src(mut x: i32) -> i32 {
     let y = x;
     x = 123; // Don't propagate this assignment to `y`
@@ -33,100 +37,3 @@ fn main() {
     baz(0);
     arg_src(0);
 }
-
-// END RUST SOURCE
-// START rustc.foo.CopyPropagation.before.mir
-// bb0: {
-//     ...
-//     _3 = _1;
-//     _2 = const dummy(move _3) -> bb1;
-// }
-// bb1: {
-//     ...
-//     _1 = move _2;
-//     ...
-// }
-// END rustc.foo.CopyPropagation.before.mir
-// START rustc.foo.CopyPropagation.after.mir
-// bb0: {
-//     ...
-//     _3 = _1;
-//     _2 = const dummy(move _3) -> bb1;
-// }
-// bb1: {
-//     ...
-//     _1 = move _2;
-//     ...
-// }
-// END rustc.foo.CopyPropagation.after.mir
-// START rustc.bar.CopyPropagation.before.mir
-// bb0: {
-//     StorageLive(_2);
-//     StorageLive(_3);
-//     _3 = _1;
-//     _2 = const dummy(move _3) -> bb1;
-// }
-// bb1: {
-//     StorageDead(_3);
-//     StorageDead(_2);
-//     _1 = const 5u8;
-//     ...
-//     return;
-// }
-// END rustc.bar.CopyPropagation.before.mir
-// START rustc.bar.CopyPropagation.after.mir
-// bb0: {
-//     ...
-//     _3 = _1;
-//     _2 = const dummy(move _3) -> bb1;
-// }
-// bb1: {
-//     ...
-//     _1 = const 5u8;
-//     ...
-//     return;
-// }
-// END rustc.bar.CopyPropagation.after.mir
-// START rustc.baz.CopyPropagation.before.mir
-// bb0: {
-//     StorageLive(_2);
-//     _2 = _1;
-//     _1 = move _2;
-//     StorageDead(_2);
-//     ...
-//     return;
-// }
-// END rustc.baz.CopyPropagation.before.mir
-// START rustc.baz.CopyPropagation.after.mir
-// bb0: {
-//     ...
-//     _2 = _1;
-//     _1 = move _2;
-//     ...
-//     return;
-// }
-// END rustc.baz.CopyPropagation.after.mir
-// START rustc.arg_src.CopyPropagation.before.mir
-// bb0: {
-//      ...
-//      _2 = _1;
-//      ...
-//      _1 = const 123i32;
-//      ...
-//      _0 = _2;
-//      ...
-//      return;
-//  }
-// END rustc.arg_src.CopyPropagation.before.mir
-// START rustc.arg_src.CopyPropagation.after.mir
-// bb0: {
-//     ...
-//     _2 = _1;
-//     ...
-//     _1 = const 123i32;
-//     ...
-//     _0 = _2;
-//     ...
-//     return;
-// }
-// END rustc.arg_src.CopyPropagation.after.mir
diff --git a/src/test/mir-opt/copy_propagation_arg/rustc.arg_src.CopyPropagation.diff b/src/test/mir-opt/copy_propagation_arg/rustc.arg_src.CopyPropagation.diff
new file mode 100644 (file)
index 0000000..db3f588
--- /dev/null
@@ -0,0 +1,27 @@
+- // MIR for `arg_src` before CopyPropagation
++ // MIR for `arg_src` after CopyPropagation
+  
+  fn arg_src(_1: i32) -> i32 {
+      debug x => _1;                       // in scope 0 at $DIR/copy_propagation_arg.rs:27:12: 27:17
+      let mut _0: i32;                     // return place in scope 0 at $DIR/copy_propagation_arg.rs:27:27: 27:30
+      let _2: i32;                         // in scope 0 at $DIR/copy_propagation_arg.rs:28:9: 28:10
+      scope 1 {
+          debug y => _2;                   // in scope 1 at $DIR/copy_propagation_arg.rs:28:9: 28:10
+      }
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/copy_propagation_arg.rs:28:9: 28:10
+          _2 = _1;                         // bb0[1]: scope 0 at $DIR/copy_propagation_arg.rs:28:13: 28:14
+          _1 = const 123i32;               // bb0[2]: scope 1 at $DIR/copy_propagation_arg.rs:29:5: 29:12
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x0000007b))
+                                           // mir::Constant
+                                           // + span: $DIR/copy_propagation_arg.rs:29:5: 29:12
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x0000007b)) }
+          _0 = _2;                         // bb0[3]: scope 1 at $DIR/copy_propagation_arg.rs:30:5: 30:6
+          StorageDead(_2);                 // bb0[4]: scope 0 at $DIR/copy_propagation_arg.rs:31:1: 31:2
+          return;                          // bb0[5]: scope 0 at $DIR/copy_propagation_arg.rs:31:2: 31:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/copy_propagation_arg/rustc.bar.CopyPropagation.diff b/src/test/mir-opt/copy_propagation_arg/rustc.bar.CopyPropagation.diff
new file mode 100644 (file)
index 0000000..8bdc911
--- /dev/null
@@ -0,0 +1,37 @@
+- // MIR for `bar` before CopyPropagation
++ // MIR for `bar` after CopyPropagation
+  
+  fn bar(_1: u8) -> () {
+      debug x => _1;                       // in scope 0 at $DIR/copy_propagation_arg.rs:15:8: 15:13
+      let mut _0: ();                      // return place in scope 0 at $DIR/copy_propagation_arg.rs:15:19: 15:19
+      let _2: u8;                          // in scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13
+      let mut _3: u8;                      // in scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13
+          StorageLive(_3);                 // bb0[1]: scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12
+          _3 = _1;                         // bb0[2]: scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12
+          _2 = const dummy(move _3) -> bb1; // bb0[3]: scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13
+                                           // ty::Const
+                                           // + ty: fn(u8) -> u8 {dummy}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/copy_propagation_arg.rs:16:5: 16:10
+                                           // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          StorageDead(_3);                 // bb1[0]: scope 0 at $DIR/copy_propagation_arg.rs:16:12: 16:13
+          StorageDead(_2);                 // bb1[1]: scope 0 at $DIR/copy_propagation_arg.rs:16:13: 16:14
+          _1 = const 5u8;                  // bb1[2]: scope 0 at $DIR/copy_propagation_arg.rs:17:5: 17:10
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x05))
+                                           // mir::Constant
+                                           // + span: $DIR/copy_propagation_arg.rs:17:5: 17:10
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x05)) }
+          nop;                             // bb1[3]: scope 0 at $DIR/copy_propagation_arg.rs:15:19: 18:2
+          return;                          // bb1[4]: scope 0 at $DIR/copy_propagation_arg.rs:18:2: 18:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/copy_propagation_arg/rustc.baz.CopyPropagation.diff b/src/test/mir-opt/copy_propagation_arg/rustc.baz.CopyPropagation.diff
new file mode 100644 (file)
index 0000000..10f2a98
--- /dev/null
@@ -0,0 +1,18 @@
+- // MIR for `baz` before CopyPropagation
++ // MIR for `baz` after CopyPropagation
+  
+  fn baz(_1: i32) -> () {
+      debug x => _1;                       // in scope 0 at $DIR/copy_propagation_arg.rs:21:8: 21:13
+      let mut _0: ();                      // return place in scope 0 at $DIR/copy_propagation_arg.rs:21:20: 21:20
+      let mut _2: i32;                     // in scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10
+          _2 = _1;                         // bb0[1]: scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10
+          _1 = move _2;                    // bb0[2]: scope 0 at $DIR/copy_propagation_arg.rs:23:5: 23:10
+          StorageDead(_2);                 // bb0[3]: scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10
+          nop;                             // bb0[4]: scope 0 at $DIR/copy_propagation_arg.rs:21:20: 24:2
+          return;                          // bb0[5]: scope 0 at $DIR/copy_propagation_arg.rs:24:2: 24:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/copy_propagation_arg/rustc.foo.CopyPropagation.diff b/src/test/mir-opt/copy_propagation_arg/rustc.foo.CopyPropagation.diff
new file mode 100644 (file)
index 0000000..a47880c
--- /dev/null
@@ -0,0 +1,31 @@
+- // MIR for `foo` before CopyPropagation
++ // MIR for `foo` after CopyPropagation
+  
+  fn foo(_1: u8) -> () {
+      debug x => _1;                       // in scope 0 at $DIR/copy_propagation_arg.rs:9:8: 9:13
+      let mut _0: ();                      // return place in scope 0 at $DIR/copy_propagation_arg.rs:9:19: 9:19
+      let mut _2: u8;                      // in scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17
+      let mut _3: u8;                      // in scope 0 at $DIR/copy_propagation_arg.rs:11:15: 11:16
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17
+          StorageLive(_3);                 // bb0[1]: scope 0 at $DIR/copy_propagation_arg.rs:11:15: 11:16
+          _3 = _1;                         // bb0[2]: scope 0 at $DIR/copy_propagation_arg.rs:11:15: 11:16
+          _2 = const dummy(move _3) -> bb1; // bb0[3]: scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17
+                                           // ty::Const
+                                           // + ty: fn(u8) -> u8 {dummy}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/copy_propagation_arg.rs:11:9: 11:14
+                                           // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          StorageDead(_3);                 // bb1[0]: scope 0 at $DIR/copy_propagation_arg.rs:11:16: 11:17
+          _1 = move _2;                    // bb1[1]: scope 0 at $DIR/copy_propagation_arg.rs:11:5: 11:17
+          StorageDead(_2);                 // bb1[2]: scope 0 at $DIR/copy_propagation_arg.rs:11:16: 11:17
+          nop;                             // bb1[3]: scope 0 at $DIR/copy_propagation_arg.rs:9:19: 12:2
+          return;                          // bb1[4]: scope 0 at $DIR/copy_propagation_arg.rs:12:2: 12:2
+      }
+  }
+  
index 44c2319bc7eb1c5b0a0b7b15a145fe339b3436f8..9004a6312910070b6c3cd939319c315f74dfcdac 100644 (file)
@@ -4,6 +4,7 @@ struct Baz {
     z: bool,
 }
 
+// EMIT_MIR rustc.bar.Deaggregator.diff
 fn bar(a: usize) -> Baz {
     Baz { x: a, y: 0.0, z: false }
 }
@@ -12,27 +13,3 @@ fn main() {
     // Make sure the function actually gets instantiated.
     bar(0);
 }
-
-// END RUST SOURCE
-// START rustc.bar.Deaggregator.before.mir
-// bb0: {
-//     ...
-//     _2 = _1;
-//     ...
-//     _0 = Baz { x: move _2, y: const 0f32, z: const false };
-//     ...
-//     return;
-// }
-// END rustc.bar.Deaggregator.before.mir
-// START rustc.bar.Deaggregator.after.mir
-// bb0: {
-//     ...
-//     _2 = _1;
-//     ...
-//     (_0.0: usize) = move _2;
-//     (_0.1: f32) = const 0f32;
-//     (_0.2: bool) = const false;
-//     ...
-//     return;
-// }
-// END rustc.bar.Deaggregator.after.mir
diff --git a/src/test/mir-opt/deaggregator_test/rustc.bar.Deaggregator.diff b/src/test/mir-opt/deaggregator_test/rustc.bar.Deaggregator.diff
new file mode 100644 (file)
index 0000000..082f05a
--- /dev/null
@@ -0,0 +1,34 @@
+- // MIR for `bar` before Deaggregator
++ // MIR for `bar` after Deaggregator
+  
+  fn bar(_1: usize) -> Baz {
+      debug a => _1;                       // in scope 0 at $DIR/deaggregator_test.rs:8:8: 8:9
+      let mut _0: Baz;                     // return place in scope 0 at $DIR/deaggregator_test.rs:8:21: 8:24
+      let mut _2: usize;                   // in scope 0 at $DIR/deaggregator_test.rs:9:14: 9:15
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/deaggregator_test.rs:9:14: 9:15
+          _2 = _1;                         // bb0[1]: scope 0 at $DIR/deaggregator_test.rs:9:14: 9:15
+-         _0 = Baz { x: move _2, y: const 0f32, z: const false }; // bb0[2]: scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35
++         (_0.0: usize) = move _2;         // bb0[2]: scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35
++         (_0.1: f32) = const 0f32;        // bb0[3]: scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35
+                                           // ty::Const
+                                           // + ty: f32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/deaggregator_test.rs:9:20: 9:23
+                                           // + literal: Const { ty: f32, val: Value(Scalar(0x00000000)) }
++         (_0.2: bool) = const false;      // bb0[4]: scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35
+                                           // ty::Const
+                                           // + ty: bool
+                                           // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+                                           // + span: $DIR/deaggregator_test.rs:9:28: 9:33
+                                           // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+-         StorageDead(_2);                 // bb0[3]: scope 0 at $DIR/deaggregator_test.rs:9:34: 9:35
+-         return;                          // bb0[4]: scope 0 at $DIR/deaggregator_test.rs:10:2: 10:2
++         StorageDead(_2);                 // bb0[5]: scope 0 at $DIR/deaggregator_test.rs:9:34: 9:35
++         return;                          // bb0[6]: scope 0 at $DIR/deaggregator_test.rs:10:2: 10:2
+      }
+  }
+  
index fed162715906705e9dfd313458deee5071178377..e74eafd011fe398e0c6fe6fa509307477424fc02 100644 (file)
@@ -3,6 +3,7 @@ enum Baz {
     Foo { x: usize },
 }
 
+// EMIT_MIR rustc.bar.Deaggregator.diff
 fn bar(a: usize) -> Baz {
     Baz::Foo { x: a }
 }
@@ -14,24 +15,3 @@ fn main() {
         Baz::Foo { x } => println!("{}", x),
     };
 }
-
-// END RUST SOURCE
-// START rustc.bar.Deaggregator.before.mir
-// bb0: {
-//     StorageLive(_2);
-//     _2 = _1;
-//     _0 = Baz::Foo { x: move _2 };
-//     StorageDead(_2);
-//     return;
-// }
-// END rustc.bar.Deaggregator.before.mir
-// START rustc.bar.Deaggregator.after.mir
-// bb0: {
-//     StorageLive(_2);
-//     _2 = _1;
-//     ((_0 as Foo).0: usize) = move _2;
-//     discriminant(_0) = 1;
-//     StorageDead(_2);
-//     return;
-// }
-// END rustc.bar.Deaggregator.after.mir
diff --git a/src/test/mir-opt/deaggregator_test_enum/rustc.bar.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_enum/rustc.bar.Deaggregator.diff
new file mode 100644 (file)
index 0000000..b1839ef
--- /dev/null
@@ -0,0 +1,21 @@
+- // MIR for `bar` before Deaggregator
++ // MIR for `bar` after Deaggregator
+  
+  fn bar(_1: usize) -> Baz {
+      debug a => _1;                       // in scope 0 at $DIR/deaggregator_test_enum.rs:7:8: 7:9
+      let mut _0: Baz;                     // return place in scope 0 at $DIR/deaggregator_test_enum.rs:7:21: 7:24
+      let mut _2: usize;                   // in scope 0 at $DIR/deaggregator_test_enum.rs:8:19: 8:20
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/deaggregator_test_enum.rs:8:19: 8:20
+          _2 = _1;                         // bb0[1]: scope 0 at $DIR/deaggregator_test_enum.rs:8:19: 8:20
+-         _0 = Baz::Foo { x: move _2 };    // bb0[2]: scope 0 at $DIR/deaggregator_test_enum.rs:8:5: 8:22
+-         StorageDead(_2);                 // bb0[3]: scope 0 at $DIR/deaggregator_test_enum.rs:8:21: 8:22
+-         return;                          // bb0[4]: scope 0 at $DIR/deaggregator_test_enum.rs:9:2: 9:2
++         ((_0 as Foo).0: usize) = move _2; // bb0[2]: scope 0 at $DIR/deaggregator_test_enum.rs:8:5: 8:22
++         discriminant(_0) = 1;            // bb0[3]: scope 0 at $DIR/deaggregator_test_enum.rs:8:5: 8:22
++         StorageDead(_2);                 // bb0[4]: scope 0 at $DIR/deaggregator_test_enum.rs:8:21: 8:22
++         return;                          // bb0[5]: scope 0 at $DIR/deaggregator_test_enum.rs:9:2: 9:2
+      }
+  }
+  
index b39ad1bef8e348aa1ad1da61c7ca15c7c9d7bd55..d5201ed72a8d957a25ace7453e151994d855e859 100644 (file)
@@ -5,6 +5,7 @@ enum Foo {
     B(i32),
 }
 
+// EMIT_MIR rustc.test1.Deaggregator.diff
 fn test1(x: bool, y: i32) -> Foo {
     if x {
         Foo::A(y)
@@ -17,40 +18,3 @@ fn main() {
     // Make sure the function actually gets instantiated.
     test1(false, 0);
 }
-
-// END RUST SOURCE
-// START rustc.test1.Deaggregator.before.mir
-//  bb1: {
-//      StorageLive(_5);
-//      _5 = _2;
-//      _0 = Foo::B(move _5,);
-//      StorageDead(_5);
-//      goto -> bb3;
-//  }
-//  bb2: {
-//      StorageLive(_4);
-//      _4 = _2;
-//      _0 = Foo::A(move _4,);
-//      StorageDead(_4);
-//      goto -> bb3;
-//  }
-// END rustc.test1.Deaggregator.before.mir
-// START rustc.test1.Deaggregator.after.mir
-//  bb1: {
-//      StorageLive(_5);
-//      _5 = _2;
-//      ((_0 as B).0: i32) = move _5;
-//      discriminant(_0) = 1;
-//      StorageDead(_5);
-//      goto -> bb3;
-//  }
-//  bb2: {
-//      StorageLive(_4);
-//      _4 = _2;
-//      ((_0 as A).0: i32) = move _4;
-//      discriminant(_0) = 0;
-//      StorageDead(_4);
-//      goto -> bb3;
-//  }
-// END rustc.test1.Deaggregator.after.mir
-//
diff --git a/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff
new file mode 100644 (file)
index 0000000..a72a679
--- /dev/null
@@ -0,0 +1,47 @@
+- // MIR for `test1` before Deaggregator
++ // MIR for `test1` after Deaggregator
+  
+  fn test1(_1: bool, _2: i32) -> Foo {
+      debug x => _1;                       // in scope 0 at $DIR/deaggregator_test_enum_2.rs:9:10: 9:11
+      debug y => _2;                       // in scope 0 at $DIR/deaggregator_test_enum_2.rs:9:19: 9:20
+      let mut _0: Foo;                     // return place in scope 0 at $DIR/deaggregator_test_enum_2.rs:9:30: 9:33
+      let mut _3: bool;                    // in scope 0 at $DIR/deaggregator_test_enum_2.rs:10:8: 10:9
+      let mut _4: i32;                     // in scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17
+      let mut _5: i32;                     // in scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17
+  
+      bb0: {
+          StorageLive(_3);                 // bb0[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:8: 10:9
+          _3 = _1;                         // bb0[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:8: 10:9
+          switchInt(_3) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6
+      }
+  
+      bb1: {
+          StorageLive(_5);                 // bb1[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17
+          _5 = _2;                         // bb1[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17
+-         _0 = Foo::B(move _5,);           // bb1[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18
+-         StorageDead(_5);                 // bb1[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:17: 13:18
+-         goto -> bb3;                     // bb1[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6
++         ((_0 as B).0: i32) = move _5;    // bb1[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18
++         discriminant(_0) = 1;            // bb1[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18
++         StorageDead(_5);                 // bb1[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:17: 13:18
++         goto -> bb3;                     // bb1[5]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6
+      }
+  
+      bb2: {
+          StorageLive(_4);                 // bb2[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17
+          _4 = _2;                         // bb2[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17
+-         _0 = Foo::A(move _4,);           // bb2[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18
+-         StorageDead(_4);                 // bb2[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:17: 11:18
+-         goto -> bb3;                     // bb2[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6
++         ((_0 as A).0: i32) = move _4;    // bb2[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18
++         discriminant(_0) = 0;            // bb2[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18
++         StorageDead(_4);                 // bb2[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:17: 11:18
++         goto -> bb3;                     // bb2[5]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6
+      }
+  
+      bb3: {
+          StorageDead(_3);                 // bb3[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:15:1: 15:2
+          return;                          // bb3[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:15:2: 15:2
+      }
+  }
+  
index 34c41af273fea08b013cac696f68d048cb9b1b1a..824a970ce2fd3ffe57e259f43606cb15aa7f2a17 100644 (file)
@@ -5,6 +5,7 @@ enum Foo {
     B,
 }
 
+// EMIT_MIR rustc.test.Deaggregator.diff
 fn test(x: i32) -> [Foo; 2] {
     [Foo::A(x), Foo::A(x)]
 }
@@ -13,37 +14,3 @@ fn main() {
     // Make sure the function actually gets instantiated.
     test(0);
 }
-
-// END RUST SOURCE
-// START rustc.test.Deaggregator.before.mir
-// bb0: {
-//     ...
-//     _3 = _1;
-//     ...
-//     _2 = Foo::A(move _3,);
-//     ...
-//     _5 = _1;
-//     _4 = Foo::A(move _5,);
-//     ...
-//     _0 = [move _2, move _4];
-//     ...
-//     return;
-// }
-// END rustc.test.Deaggregator.before.mir
-// START rustc.test.Deaggregator.after.mir
-// bb0: {
-//     ...
-//     _3 = _1;
-//     ...
-//     ((_2 as A).0: i32) = move _3;
-//     discriminant(_2) = 0;
-//     ...
-//     _5 = _1;
-//     ((_4 as A).0: i32) = move _5;
-//     discriminant(_4) = 0;
-//     ...
-//     _0 = [move _2, move _4];
-//     ...
-//     return;
-// }
-// END rustc.test.Deaggregator.after.mir
diff --git a/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff
new file mode 100644 (file)
index 0000000..126dfc1
--- /dev/null
@@ -0,0 +1,42 @@
+- // MIR for `test` before Deaggregator
++ // MIR for `test` after Deaggregator
+  
+  fn test(_1: i32) -> [Foo; 2] {
+      debug x => _1;                       // in scope 0 at $DIR/deaggregator_test_multiple.rs:9:9: 9:10
+      let mut _0: [Foo; 2];                // return place in scope 0 at $DIR/deaggregator_test_multiple.rs:9:20: 9:28
+      let mut _2: Foo;                     // in scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15
+      let mut _3: i32;                     // in scope 0 at $DIR/deaggregator_test_multiple.rs:10:13: 10:14
+      let mut _4: Foo;                     // in scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26
+      let mut _5: i32;                     // in scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25
+  
+      bb0: {
+          StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15
+          StorageLive(_3);                 // bb0[1]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:13: 10:14
+          _3 = _1;                         // bb0[2]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:13: 10:14
+-         _2 = Foo::A(move _3,);           // bb0[3]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15
+-         StorageDead(_3);                 // bb0[4]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:14: 10:15
+-         StorageLive(_4);                 // bb0[5]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26
+-         StorageLive(_5);                 // bb0[6]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25
+-         _5 = _1;                         // bb0[7]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25
+-         _4 = Foo::A(move _5,);           // bb0[8]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26
+-         StorageDead(_5);                 // bb0[9]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:25: 10:26
+-         _0 = [move _2, move _4];         // bb0[10]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:5: 10:27
+-         StorageDead(_4);                 // bb0[11]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27
+-         StorageDead(_2);                 // bb0[12]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27
+-         return;                          // bb0[13]: scope 0 at $DIR/deaggregator_test_multiple.rs:11:2: 11:2
++         ((_2 as A).0: i32) = move _3;    // bb0[3]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15
++         discriminant(_2) = 0;            // bb0[4]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15
++         StorageDead(_3);                 // bb0[5]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:14: 10:15
++         StorageLive(_4);                 // bb0[6]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26
++         StorageLive(_5);                 // bb0[7]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25
++         _5 = _1;                         // bb0[8]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25
++         ((_4 as A).0: i32) = move _5;    // bb0[9]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26
++         discriminant(_4) = 0;            // bb0[10]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26
++         StorageDead(_5);                 // bb0[11]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:25: 10:26
++         _0 = [move _2, move _4];         // bb0[12]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:5: 10:27
++         StorageDead(_4);                 // bb0[13]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27
++         StorageDead(_2);                 // bb0[14]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27
++         return;                          // bb0[15]: scope 0 at $DIR/deaggregator_test_multiple.rs:11:2: 11:2
+      }
+  }
+  
index 4c23582e1f8949498a5943a2fb68541b33a868a9..9fce7928f6a97a04d89eb7a4f781be2c258449d3 100644 (file)
@@ -1,9 +1,8 @@
 // Test that simple or-patterns don't get expanded to exponentially large CFGs
 
-// ignore-tidy-linelength
-
 #![feature(or_patterns)]
 
+// EMIT_MIR rustc.match_tuple.SimplifyCfg-initial.after.mir
 fn match_tuple(x: (u32, bool, Option<i32>, u32)) -> u32 {
     match x {
         (y @ (1 | 4), true | false, Some(1 | 8) | None, z @ (6..=9 | 13..=16)) => y ^ z,
@@ -12,65 +11,3 @@ fn match_tuple(x: (u32, bool, Option<i32>, u32)) -> u32 {
 }
 
 fn main() {}
-
-// END RUST SOURCE
-
-// START rustc.match_tuple.SimplifyCfg-initial.after.mir
-// scope 1 {
-//     debug y => _7;
-//     debug z => _8;
-// }
-// bb0: {
-//     FakeRead(ForMatchedPlace, _1);
-//     switchInt((_1.0: u32)) -> [1u32: bb2, 4u32: bb2, otherwise: bb1];
-// }
-// bb1: {
-//     _0 = const 0u32;
-//     goto -> bb10;
-// }
-// bb2: {
-//     _2 = discriminant((_1.2: std::option::Option<i32>));
-//     switchInt(move _2) -> [0isize: bb4, 1isize: bb3, otherwise: bb1];
-// }
-// bb3: {
-//     switchInt((((_1.2: std::option::Option<i32>) as Some).0: i32)) -> [1i32: bb4, 8i32: bb4, otherwise: bb1];
-// }
-// bb4: {
-//     _5 = Le(const 6u32, (_1.3: u32));
-//     switchInt(move _5) -> [false: bb6, otherwise: bb5];
-// }
-// bb5: {
-//     _6 = Le((_1.3: u32), const 9u32);
-//     switchInt(move _6) -> [false: bb6, otherwise: bb8];
-// }
-// bb6: {
-//     _3 = Le(const 13u32, (_1.3: u32));
-//     switchInt(move _3) -> [false: bb1, otherwise: bb7];
-// }
-// bb7: {
-//     _4 = Le((_1.3: u32), const 16u32);
-//     switchInt(move _4) -> [false: bb1, otherwise: bb8];
-// }
-// bb8: {
-//     falseEdges -> [real: bb9, imaginary: bb1];
-// }
-// bb9: {
-//     StorageLive(_7);
-//     _7 = (_1.0: u32);
-//     StorageLive(_8);
-//     _8 = (_1.3: u32);
-//     StorageLive(_9);
-//     _9 = _7;
-//     StorageLive(_10);
-//     _10 = _8;
-//     _0 = BitXor(move _9, move _10);
-//     StorageDead(_10);
-//     StorageDead(_9);
-//     StorageDead(_8);
-//     StorageDead(_7);
-//     goto -> bb10;
-// }
-// bb10: {
-//     return;
-// }
-// END rustc.match_tuple.SimplifyCfg-initial.after.mir
diff --git a/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir b/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir
new file mode 100644 (file)
index 0000000..192ec1b
--- /dev/null
@@ -0,0 +1,113 @@
+// MIR for `match_tuple` after SimplifyCfg-initial
+
+fn match_tuple(_1: (u32, bool, std::option::Option<i32>, u32)) -> u32 {
+    debug x => _1;                       // in scope 0 at $DIR/exponential-or.rs:6:16: 6:17
+    let mut _0: u32;                     // return place in scope 0 at $DIR/exponential-or.rs:6:53: 6:56
+    let mut _2: isize;                   // in scope 0 at $DIR/exponential-or.rs:8:37: 8:48
+    let mut _3: bool;                    // in scope 0 at $DIR/exponential-or.rs:8:70: 8:77
+    let mut _4: bool;                    // in scope 0 at $DIR/exponential-or.rs:8:70: 8:77
+    let mut _5: bool;                    // in scope 0 at $DIR/exponential-or.rs:8:62: 8:67
+    let mut _6: bool;                    // in scope 0 at $DIR/exponential-or.rs:8:62: 8:67
+    let _7: u32;                         // in scope 0 at $DIR/exponential-or.rs:8:10: 8:21
+    let _8: u32;                         // in scope 0 at $DIR/exponential-or.rs:8:57: 8:78
+    let mut _9: u32;                     // in scope 0 at $DIR/exponential-or.rs:8:83: 8:84
+    let mut _10: u32;                    // in scope 0 at $DIR/exponential-or.rs:8:87: 8:88
+    scope 1 {
+        debug y => _7;                   // in scope 1 at $DIR/exponential-or.rs:8:10: 8:21
+        debug z => _8;                   // in scope 1 at $DIR/exponential-or.rs:8:57: 8:78
+    }
+
+    bb0: {
+        FakeRead(ForMatchedPlace, _1);   // bb0[0]: scope 0 at $DIR/exponential-or.rs:7:11: 7:12
+        switchInt((_1.0: u32)) -> [1u32: bb2, 4u32: bb2, otherwise: bb1]; // bb0[1]: scope 0 at $DIR/exponential-or.rs:8:15: 8:16
+    }
+
+    bb1: {
+        _0 = const 0u32;                 // bb1[0]: scope 0 at $DIR/exponential-or.rs:9:14: 9:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/exponential-or.rs:9:14: 9:15
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+        goto -> bb10;                    // bb1[1]: scope 0 at $DIR/exponential-or.rs:7:5: 10:6
+    }
+
+    bb2: {
+        _2 = discriminant((_1.2: std::option::Option<i32>)); // bb2[0]: scope 0 at $DIR/exponential-or.rs:8:37: 8:48
+        switchInt(move _2) -> [0isize: bb4, 1isize: bb3, otherwise: bb1]; // bb2[1]: scope 0 at $DIR/exponential-or.rs:8:37: 8:48
+    }
+
+    bb3: {
+        switchInt((((_1.2: std::option::Option<i32>) as Some).0: i32)) -> [1i32: bb4, 8i32: bb4, otherwise: bb1]; // bb3[0]: scope 0 at $DIR/exponential-or.rs:8:42: 8:43
+    }
+
+    bb4: {
+        _5 = Le(const 6u32, (_1.3: u32)); // bb4[0]: scope 0 at $DIR/exponential-or.rs:8:62: 8:67
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000006))
+                                         // mir::Constant
+                                         // + span: $DIR/exponential-or.rs:8:62: 8:67
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000006)) }
+        switchInt(move _5) -> [false: bb6, otherwise: bb5]; // bb4[1]: scope 0 at $DIR/exponential-or.rs:8:62: 8:67
+    }
+
+    bb5: {
+        _6 = Le((_1.3: u32), const 9u32); // bb5[0]: scope 0 at $DIR/exponential-or.rs:8:62: 8:67
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000009))
+                                         // mir::Constant
+                                         // + span: $DIR/exponential-or.rs:8:62: 8:67
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000009)) }
+        switchInt(move _6) -> [false: bb6, otherwise: bb8]; // bb5[1]: scope 0 at $DIR/exponential-or.rs:8:62: 8:67
+    }
+
+    bb6: {
+        _3 = Le(const 13u32, (_1.3: u32)); // bb6[0]: scope 0 at $DIR/exponential-or.rs:8:70: 8:77
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x0000000d))
+                                         // mir::Constant
+                                         // + span: $DIR/exponential-or.rs:8:70: 8:77
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x0000000d)) }
+        switchInt(move _3) -> [false: bb1, otherwise: bb7]; // bb6[1]: scope 0 at $DIR/exponential-or.rs:8:70: 8:77
+    }
+
+    bb7: {
+        _4 = Le((_1.3: u32), const 16u32); // bb7[0]: scope 0 at $DIR/exponential-or.rs:8:70: 8:77
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000010))
+                                         // mir::Constant
+                                         // + span: $DIR/exponential-or.rs:8:70: 8:77
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000010)) }
+        switchInt(move _4) -> [false: bb1, otherwise: bb8]; // bb7[1]: scope 0 at $DIR/exponential-or.rs:8:70: 8:77
+    }
+
+    bb8: {
+        falseEdges -> [real: bb9, imaginary: bb1]; // bb8[0]: scope 0 at $DIR/exponential-or.rs:8:9: 8:79
+    }
+
+    bb9: {
+        StorageLive(_7);                 // bb9[0]: scope 0 at $DIR/exponential-or.rs:8:10: 8:21
+        _7 = (_1.0: u32);                // bb9[1]: scope 0 at $DIR/exponential-or.rs:8:10: 8:21
+        StorageLive(_8);                 // bb9[2]: scope 0 at $DIR/exponential-or.rs:8:57: 8:78
+        _8 = (_1.3: u32);                // bb9[3]: scope 0 at $DIR/exponential-or.rs:8:57: 8:78
+        StorageLive(_9);                 // bb9[4]: scope 1 at $DIR/exponential-or.rs:8:83: 8:84
+        _9 = _7;                         // bb9[5]: scope 1 at $DIR/exponential-or.rs:8:83: 8:84
+        StorageLive(_10);                // bb9[6]: scope 1 at $DIR/exponential-or.rs:8:87: 8:88
+        _10 = _8;                        // bb9[7]: scope 1 at $DIR/exponential-or.rs:8:87: 8:88
+        _0 = BitXor(move _9, move _10);  // bb9[8]: scope 1 at $DIR/exponential-or.rs:8:83: 8:88
+        StorageDead(_10);                // bb9[9]: scope 1 at $DIR/exponential-or.rs:8:87: 8:88
+        StorageDead(_9);                 // bb9[10]: scope 1 at $DIR/exponential-or.rs:8:87: 8:88
+        StorageDead(_8);                 // bb9[11]: scope 0 at $DIR/exponential-or.rs:8:88: 8:89
+        StorageDead(_7);                 // bb9[12]: scope 0 at $DIR/exponential-or.rs:8:88: 8:89
+        goto -> bb10;                    // bb9[13]: scope 0 at $DIR/exponential-or.rs:7:5: 10:6
+    }
+
+    bb10: {
+        return;                          // bb10[0]: scope 0 at $DIR/exponential-or.rs:11:2: 11:2
+    }
+}
index 278dc49c9260526b19b8ffd26398d8217e7e93d1..1c3025d5e3faf4fb0bdbc84084b48018e1f39ebe 100644 (file)
@@ -3,45 +3,9 @@
 // Regression test for #58892, generator drop shims should not have blocks
 // spuriously marked as cleanup
 
+// EMIT_MIR rustc.main-{{closure}}.generator_drop.0.mir
 fn main() {
     let gen = || {
         yield;
     };
 }
-
-// END RUST SOURCE
-
-// START rustc.main-{{closure}}.generator_drop.0.mir
-// bb0: {
-//     _7 = discriminant((*_1));
-//     switchInt(move _7) -> [0u32: bb4, 3u32: bb7, otherwise: bb8];
-// }
-// bb1: {
-//     StorageDead(_4);
-//     StorageDead(_3);
-//     goto -> bb5;
-// }
-// bb2: {
-//     return;
-// }
-// bb3: {
-//     return;
-// }
-// bb4: {
-//     goto -> bb6;
-// }
-// bb5: {
-//     goto -> bb2;
-// }
-// bb6: {
-//     goto -> bb3;
-// }
-// bb7: {
-//     StorageLive(_3);
-//     StorageLive(_4);
-//     goto -> bb1;
-// }
-// bb8: {
-//     return;
-// }
-// END rustc.main-{{closure}}.generator_drop.0.mir
diff --git a/src/test/mir-opt/generator-drop-cleanup/rustc.main-{{closure}}.generator_drop.0.mir b/src/test/mir-opt/generator-drop-cleanup/rustc.main-{{closure}}.generator_drop.0.mir
new file mode 100644 (file)
index 0000000..05ed0a6
--- /dev/null
@@ -0,0 +1,53 @@
+// MIR for `main::{{closure}}#0` 0 generator_drop
+// generator_layout = GeneratorLayout { field_tys: [], variant_fields: [[], [], [], []], storage_conflicts: BitMatrix { num_rows: 0, num_columns: 0, words: [], marker: PhantomData } }
+
+fn main::{{closure}}#0(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:8:15: 10:6 {()}]) -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    let mut _2: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    let _3: ();                          // in scope 0 at $DIR/generator-drop-cleanup.rs:9:9: 9:14
+    let mut _4: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:9:9: 9:14
+    let mut _5: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:8:18: 8:18
+    let mut _6: ();                      // in scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    let mut _7: isize;                   // in scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+
+    bb0: {
+        _7 = discriminant((*_1));        // bb0[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+        switchInt(move _7) -> [0u32: bb4, 3u32: bb7, otherwise: bb8]; // bb0[1]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    }
+
+    bb1: {
+        StorageDead(_4);                 // bb1[0]: scope 0 at $DIR/generator-drop-cleanup.rs:9:13: 9:14
+        StorageDead(_3);                 // bb1[1]: scope 0 at $DIR/generator-drop-cleanup.rs:9:14: 9:15
+        goto -> bb5;                     // bb1[2]: scope 0 at $DIR/generator-drop-cleanup.rs:10:5: 10:6
+    }
+
+    bb2: {
+        return;                          // bb2[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    }
+
+    bb3: {
+        return;                          // bb3[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    }
+
+    bb4: {
+        goto -> bb6;                     // bb4[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    }
+
+    bb5: {
+        goto -> bb2;                     // bb5[0]: scope 0 at $DIR/generator-drop-cleanup.rs:10:5: 10:6
+    }
+
+    bb6: {
+        goto -> bb3;                     // bb6[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    }
+
+    bb7: {
+        StorageLive(_3);                 // bb7[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+        StorageLive(_4);                 // bb7[1]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+        goto -> bb1;                     // bb7[2]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    }
+
+    bb8: {
+        return;                          // bb8[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6
+    }
+}
index 82b216a99cf555ad9439ae1ec62a11c8676dd8ac..abfb39c77d6e97fffa4d40a61b937fb2cbeedb1f 100644 (file)
@@ -17,6 +17,7 @@ fn drop(&mut self) {}
 
 fn take<T>(_x: T) {}
 
+// EMIT_MIR rustc.main-{{closure}}.StateTransform.before.mir
 fn main() {
     let _gen = || {
         let a = Foo(5);
@@ -26,89 +27,3 @@ fn main() {
         take(b);
     };
 }
-
-// END RUST SOURCE
-
-// START rustc.main-{{closure}}.StateTransform.before.mir
-// ...
-// let _3: Foo;
-// ...
-// let mut _8: Foo;
-// ...
-// let mut _10: Bar;
-// scope 1 {
-//     debug a => _3;
-//     let _4: Bar;
-//     scope 2 {
-//         debug b => _4;
-//     }
-// }
-// bb0: {
-//     StorageLive(_3);
-//     _3 = Foo(const 5i32,);
-//     StorageLive(_4);
-//     _4 = Bar(const 6i32,);
-//     ...
-//     _5 = yield(move _6) -> [resume: bb2, drop: bb4];
-// }
-// bb1 (cleanup): {
-//     resume;
-// }
-// bb2: {
-//     ...
-//     StorageLive(_7);
-//     StorageLive(_8);
-//     _8 = move _3;
-//     _7 = const take::<Foo>(move _8) -> [return: bb7, unwind: bb9];
-// }
-// bb3 (cleanup): {
-//     StorageDead(_3);
-//     drop(_1) -> bb1;
-// }
-// bb4: {
-//     ...
-//     StorageDead(_4);
-//     drop(_3) -> [return: bb5, unwind: bb3];
-// }
-// bb5: {
-//     StorageDead(_3);
-//     drop(_1) -> [return: bb6, unwind: bb1];
-// }
-// bb6: {
-//     generator_drop;
-// }
-// bb7: {
-//     StorageDead(_8);
-//     StorageDead(_7);
-//     StorageLive(_9);
-//     StorageLive(_10);
-//     _10 = move _4;
-//     _9 = const take::<Bar>(move _10) -> [return: bb10, unwind: bb11];
-// }
-// bb8 (cleanup): {
-//     StorageDead(_4);
-//     StorageDead(_3);
-//     drop(_1) -> bb1;
-// }
-// bb9 (cleanup): {
-//     StorageDead(_8);
-//     StorageDead(_7);
-//     goto -> bb8;
-// }
-// bb10: {
-//     StorageDead(_10);
-//     StorageDead(_9);
-//     ...
-//     StorageDead(_4);
-//     StorageDead(_3);
-//     drop(_1) -> [return: bb12, unwind: bb1];
-// }
-// bb11 (cleanup): {
-//     StorageDead(_10);
-//     StorageDead(_9);
-//     goto -> bb8;
-// }
-// bb12: {
-//     return;
-// }
-// END rustc.main-{{closure}}.StateTransform.before.mir
diff --git a/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir b/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir
new file mode 100644 (file)
index 0000000..cc22982
--- /dev/null
@@ -0,0 +1,130 @@
+// MIR for `main::{{closure}}#0` before StateTransform
+
+fn main::{{closure}}#0(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 28:6 {Foo, Bar, ()}], _2: ()) -> ()
+yields ()
+ {
+    let mut _0: ();                      // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 22:19
+    let _3: Foo;                         // in scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14
+    let _5: ();                          // in scope 0 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
+    let mut _6: ();                      // in scope 0 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
+    let _7: ();                          // in scope 0 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16
+    let mut _8: Foo;                     // in scope 0 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15
+    let _9: ();                          // in scope 0 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16
+    let mut _10: Bar;                    // in scope 0 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15
+    scope 1 {
+        debug a => _3;                   // in scope 1 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14
+        let _4: Bar;                     // in scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14
+        scope 2 {
+            debug b => _4;               // in scope 2 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14
+        }
+    }
+
+    bb0: {
+        StorageLive(_3);                 // bb0[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14
+        _3 = Foo(const 5i32,);           // bb0[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000005))
+                                         // mir::Constant
+                                         // + span: $DIR/generator-storage-dead-unwind.rs:23:21: 23:22
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
+        StorageLive(_4);                 // bb0[2]: scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14
+        _4 = Bar(const 6i32,);           // bb0[3]: scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000006))
+                                         // mir::Constant
+                                         // + span: $DIR/generator-storage-dead-unwind.rs:24:21: 24:22
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000006)) }
+        StorageLive(_5);                 // bb0[4]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
+        StorageLive(_6);                 // bb0[5]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
+        _6 = ();                         // bb0[6]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
+        _5 = yield(move _6) -> [resume: bb2, drop: bb4]; // bb0[7]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 28:6
+    }
+
+    bb2: {
+        StorageDead(_6);                 // bb2[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:13: 25:14
+        StorageDead(_5);                 // bb2[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:14: 25:15
+        StorageLive(_7);                 // bb2[2]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16
+        StorageLive(_8);                 // bb2[3]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15
+        _8 = move _3;                    // bb2[4]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15
+        _7 = const take::<Foo>(move _8) -> [return: bb7, unwind: bb9]; // bb2[5]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16
+                                         // ty::Const
+                                         // + ty: fn(Foo) {take::<Foo>}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/generator-storage-dead-unwind.rs:26:9: 26:13
+                                         // + literal: Const { ty: fn(Foo) {take::<Foo>}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb3 (cleanup): {
+        StorageDead(_3);                 // bb3[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+        drop(_1) -> bb1;                 // bb3[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+    }
+
+    bb4: {
+        StorageDead(_6);                 // bb4[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:13: 25:14
+        StorageDead(_5);                 // bb4[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:14: 25:15
+        StorageDead(_4);                 // bb4[2]: scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+        drop(_3) -> [return: bb5, unwind: bb3]; // bb4[3]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+    }
+
+    bb5: {
+        StorageDead(_3);                 // bb5[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+        drop(_1) -> [return: bb6, unwind: bb1]; // bb5[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+    }
+
+    bb6: {
+        generator_drop;                  // bb6[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 28:6
+    }
+
+    bb7: {
+        StorageDead(_8);                 // bb7[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:15: 26:16
+        StorageDead(_7);                 // bb7[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:16: 26:17
+        StorageLive(_9);                 // bb7[2]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16
+        StorageLive(_10);                // bb7[3]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15
+        _10 = move _4;                   // bb7[4]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15
+        _9 = const take::<Bar>(move _10) -> [return: bb10, unwind: bb11]; // bb7[5]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16
+                                         // ty::Const
+                                         // + ty: fn(Bar) {take::<Bar>}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/generator-storage-dead-unwind.rs:27:9: 27:13
+                                         // + literal: Const { ty: fn(Bar) {take::<Bar>}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb8 (cleanup): {
+        StorageDead(_4);                 // bb8[0]: scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+        StorageDead(_3);                 // bb8[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+        drop(_1) -> bb1;                 // bb8[2]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+    }
+
+    bb9 (cleanup): {
+        StorageDead(_8);                 // bb9[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:15: 26:16
+        StorageDead(_7);                 // bb9[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:16: 26:17
+        goto -> bb8;                     // bb9[2]: scope 2 at $DIR/generator-storage-dead-unwind.rs:1:1: 1:1
+    }
+
+    bb10: {
+        StorageDead(_10);                // bb10[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:15: 27:16
+        StorageDead(_9);                 // bb10[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:16: 27:17
+        _0 = ();                         // bb10[2]: scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 28:6
+        StorageDead(_4);                 // bb10[3]: scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+        StorageDead(_3);                 // bb10[4]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+        drop(_1) -> [return: bb12, unwind: bb1]; // bb10[5]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6
+    }
+
+    bb11 (cleanup): {
+        StorageDead(_10);                // bb11[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:15: 27:16
+        StorageDead(_9);                 // bb11[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:16: 27:17
+        goto -> bb8;                     // bb11[2]: scope 2 at $DIR/generator-storage-dead-unwind.rs:1:1: 1:1
+    }
+
+    bb12: {
+        return;                          // bb12[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:6: 28:6
+    }
+}
index 09e943bd962e64489ff25db8b0283dc08c559357..b537263dd1b72586455bddf0b6b8c91b3dc61ebb 100644 (file)
@@ -13,6 +13,7 @@ fn drop(&mut self) {}
 
 fn callee() {}
 
+// EMIT_MIR rustc.main-{{closure}}.generator_resume.0.mir
 fn main() {
     let _gen = |_x: u8| {
         let _d = HasDrop;
@@ -22,13 +23,3 @@ fn main() {
         }
     };
 }
-
-// END RUST SOURCE
-
-// START rustc.main-{{closure}}.generator_resume.0.mir
-// bb0: {
-//     ...
-//     switchInt(move _11) -> [0u32: bb1, 3u32: bb5, otherwise: bb6];
-// }
-// ...
-// END rustc.main-{{closure}}.generator_resume.0.mir
diff --git a/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir b/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir
new file mode 100644 (file)
index 0000000..a79f0d5
--- /dev/null
@@ -0,0 +1,72 @@
+// MIR for `main::{{closure}}#0` 0 generator_resume
+// generator_layout = GeneratorLayout { field_tys: [HasDrop], variant_fields: [[], [], [], [_0]], storage_conflicts: BitMatrix { num_rows: 1, num_columns: 1, words: [1], marker: PhantomData } }
+
+fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}]>, _2: u8) -> std::ops::GeneratorState<(), ()> {
+    debug _x => _10;                     // in scope 0 at $DIR/generator-tiny.rs:18:17: 18:19
+    let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+    let _3: HasDrop;                     // in scope 0 at $DIR/generator-tiny.rs:19:13: 19:15
+    let mut _4: !;                       // in scope 0 at $DIR/generator-tiny.rs:20:9: 23:10
+    let mut _5: ();                      // in scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+    let _6: u8;                          // in scope 0 at $DIR/generator-tiny.rs:21:13: 21:18
+    let mut _7: ();                      // in scope 0 at $DIR/generator-tiny.rs:21:13: 21:18
+    let _8: ();                          // in scope 0 at $DIR/generator-tiny.rs:22:13: 22:21
+    let mut _9: ();                      // in scope 0 at $DIR/generator-tiny.rs:18:25: 18:25
+    let _10: u8;                         // in scope 0 at $DIR/generator-tiny.rs:18:17: 18:19
+    let mut _11: isize;                  // in scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+    scope 1 {
+        debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:19:13: 19:15
+    }
+
+    bb0: {
+        _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}]))); // bb0[0]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+        switchInt(move _11) -> [0u32: bb1, 3u32: bb5, otherwise: bb6]; // bb0[1]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+    }
+
+    bb1: {
+        _10 = move _2;                   // bb1[0]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+        nop;                             // bb1[1]: scope 0 at $DIR/generator-tiny.rs:19:13: 19:15
+        (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop) = HasDrop; // bb1[2]: scope 0 at $DIR/generator-tiny.rs:19:18: 19:25
+        StorageLive(_4);                 // bb1[3]: scope 1 at $DIR/generator-tiny.rs:20:9: 23:10
+        goto -> bb2;                     // bb1[4]: scope 1 at $DIR/generator-tiny.rs:20:9: 23:10
+    }
+
+    bb2: {
+        StorageLive(_6);                 // bb2[0]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18
+        StorageLive(_7);                 // bb2[1]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18
+        _7 = ();                         // bb2[2]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18
+        _0 = std::ops::GeneratorState::<(), ()>::Yielded(move _7,); // bb2[3]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18
+        discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}]))) = 3; // bb2[4]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18
+        return;                          // bb2[5]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18
+    }
+
+    bb3: {
+        StorageDead(_7);                 // bb3[0]: scope 1 at $DIR/generator-tiny.rs:21:17: 21:18
+        StorageDead(_6);                 // bb3[1]: scope 1 at $DIR/generator-tiny.rs:21:18: 21:19
+        StorageLive(_8);                 // bb3[2]: scope 1 at $DIR/generator-tiny.rs:22:13: 22:21
+        _8 = const callee() -> bb4;      // bb3[3]: scope 1 at $DIR/generator-tiny.rs:22:13: 22:21
+                                         // ty::Const
+                                         // + ty: fn() {callee}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/generator-tiny.rs:22:13: 22:19
+                                         // + literal: Const { ty: fn() {callee}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb4: {
+        StorageDead(_8);                 // bb4[0]: scope 1 at $DIR/generator-tiny.rs:22:21: 22:22
+        _5 = ();                         // bb4[1]: scope 1 at $DIR/generator-tiny.rs:20:14: 23:10
+        goto -> bb2;                     // bb4[2]: scope 1 at $DIR/generator-tiny.rs:20:9: 23:10
+    }
+
+    bb5: {
+        StorageLive(_4);                 // bb5[0]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+        StorageLive(_6);                 // bb5[1]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+        StorageLive(_7);                 // bb5[2]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+        _6 = move _2;                    // bb5[3]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+        goto -> bb3;                     // bb5[4]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+    }
+
+    bb6: {
+        unreachable;                     // bb6[0]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6
+    }
+}
index fcbb189c1117bb3a3e64a6a382e41cb4dfea225f..b1c0f0dd3c8303c201c70c3e182759fafdad482e 100644 (file)
@@ -1,20 +1,5 @@
 // Test graphviz output
 // compile-flags: -Z dump-mir-graphviz
 
-// ignore-tidy-linelength
-
+// EMIT_MIR rustc.main.mir_map.0.dot
 fn main() {}
-
-// END RUST SOURCE
-// START rustc.main.mir_map.0.dot
-// digraph Mir_0_3 { // The name here MUST be an ASCII identifier.
-//     graph [fontname="monospace"];
-//     node [fontname="monospace"];
-//     edge [fontname="monospace"];
-//     label=<fn main() -&gt; ()<br align="left"/>>;
-//     bb0__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">0</td></tr><tr><td align="left" balign="left">_0 = ()<br/></td></tr><tr><td align="left">goto</td></tr></table>>];
-//     bb1__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">1</td></tr><tr><td align="left">resume</td></tr></table>>];
-//     bb2__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">2</td></tr><tr><td align="left">return</td></tr></table>>];
-//     bb0__0_3 -> bb2__0_3 [label=""];
-// }
-// END rustc.main.mir_map.0.dot
diff --git a/src/test/mir-opt/graphviz/rustc.main.mir_map.0.dot b/src/test/mir-opt/graphviz/rustc.main.mir_map.0.dot
new file mode 100644 (file)
index 0000000..2caef34
--- /dev/null
@@ -0,0 +1,10 @@
+digraph Mir_0_3 {
+    graph [fontname="monospace"];
+    node [fontname="monospace"];
+    edge [fontname="monospace"];
+    label=<fn main() -&gt; ()<br align="left"/>>;
+    bb0__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">0</td></tr><tr><td align="left" balign="left">_0 = ()<br/></td></tr><tr><td align="left">goto</td></tr></table>>];
+    bb1__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">1</td></tr><tr><td align="left">resume</td></tr></table>>];
+    bb2__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">2</td></tr><tr><td align="left">return</td></tr></table>>];
+    bb0__0_3 -> bb2__0_3 [label=""];
+}
index b545500371936cf152af686da5433f791548d608..2edde12d72e0bfdc8d68fb1d17fbda3b3303731f 100644 (file)
@@ -6,6 +6,7 @@ fn main() {
     println!("{}", bar());
 }
 
+// EMIT_MIR rustc.bar.Inline.after.mir
 fn bar() -> bool {
     let f = foo;
     f(1, -1)
@@ -15,15 +16,3 @@ fn bar() -> bool {
 fn foo(x: i32, y: i32) -> bool {
     x == y
 }
-
-// END RUST SOURCE
-// START rustc.bar.Inline.after.mir
-// ...
-// bb0: {
-//     ...
-//     _0 = Eq(move _3, move _4);
-//     ...
-//     return;
-// }
-// ...
-// END rustc.bar.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir b/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir
new file mode 100644 (file)
index 0000000..058d9e7
--- /dev/null
@@ -0,0 +1,47 @@
+// MIR for `bar` after Inline
+
+fn bar() -> bool {
+    let mut _0: bool;                    // return place in scope 0 at $DIR/inline-any-operand.rs:10:13: 10:17
+    let _1: fn(i32, i32) -> bool {foo};  // in scope 0 at $DIR/inline-any-operand.rs:11:9: 11:10
+    let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:6
+    let mut _3: i32;                     // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:13
+    let mut _4: i32;                     // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:13
+    scope 1 {
+        debug f => _1;                   // in scope 1 at $DIR/inline-any-operand.rs:11:9: 11:10
+        scope 2 {
+            debug x => _3;               // in scope 2 at $DIR/inline-any-operand.rs:16:8: 16:9
+            debug y => _4;               // in scope 2 at $DIR/inline-any-operand.rs:16:16: 16:17
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/inline-any-operand.rs:11:9: 11:10
+        _1 = const foo;                  // bb0[1]: scope 0 at $DIR/inline-any-operand.rs:11:13: 11:16
+                                         // ty::Const
+                                         // + ty: fn(i32, i32) -> bool {foo}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/inline-any-operand.rs:11:13: 11:16
+                                         // + literal: Const { ty: fn(i32, i32) -> bool {foo}, val: Value(Scalar(<ZST>)) }
+        StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:6
+        _2 = _1;                         // bb0[3]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:6
+        _3 = const 1i32;                 // bb0[4]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/inline-any-operand.rs:12:7: 12:8
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        _4 = const -1i32;                // bb0[5]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0xffffffff))
+                                         // mir::Constant
+                                         // + span: $DIR/inline-any-operand.rs:12:10: 12:12
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) }
+        _0 = Eq(move _3, move _4);       // bb0[6]: scope 2 at $DIR/inline-any-operand.rs:17:5: 17:11
+        StorageDead(_2);                 // bb0[7]: scope 1 at $DIR/inline-any-operand.rs:12:12: 12:13
+        StorageDead(_1);                 // bb0[8]: scope 0 at $DIR/inline-any-operand.rs:13:1: 13:2
+        return;                          // bb0[9]: scope 0 at $DIR/inline-any-operand.rs:13:2: 13:2
+    }
+}
index 768f4953228095acd9a5c786afb44c0dda82e079..a82a91945d862cd8da135b339691a55c2724be00 100644 (file)
@@ -7,6 +7,7 @@ fn main() {
     println!("{}", foo(0, &14));
 }
 
+// EMIT_MIR rustc.foo.Inline.after.mir
 fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
     let x = |r: &i32, _s: &i32| {
         let variable = &*r;
@@ -14,46 +15,3 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
     };
     x(q, q)
 }
-
-// END RUST SOURCE
-// START rustc.foo.Inline.after.mir
-// fn foo(_1: T, _2: &i32) -> i32{
-//     debug _t => _1;
-//     debug q => _2;
-//     let mut _0: i32;
-//     let _3: [closure@foo<T>::{{closure}}#0];
-//     let mut _4: &[closure@foo<T>::{{closure}}#0];
-//     let mut _5: (&i32, &i32);
-//     let mut _6: &i32;
-//     let mut _7: &i32;
-//     let mut _8: &i32;
-//     let mut _9: &i32;
-//     scope 1 {
-//         debug x => _3;
-//         scope 2 {
-//             debug r => _8;
-//             debug _s => _9;
-//         }
-//     }
-//     scope 3 {
-//         debug variable => _8;
-//     }
-//     bb0: {
-//         ...
-//         _3 = [closure@foo::<T>::{{closure}}#0];
-//         ...
-//         _4 = &_3;
-//         ...
-//         _6 = &(*_2);
-//         ...
-//         _7 = &(*_2);
-//         _5 = (move _6, move _7);
-//         _8 = move (_5.0: &i32);
-//         _9 = move (_5.1: &i32);
-//         ...
-//         _0 = (*_8);
-//         ...
-//         return;
-//     }
-// }
-// END rustc.foo.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir
new file mode 100644 (file)
index 0000000..a8e846d
--- /dev/null
@@ -0,0 +1,54 @@
+// MIR for `foo` after Inline
+
+fn foo(_1: T, _2: &i32) -> i32 {
+    debug _t => _1;                      // in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:17: 11:19
+    debug q => _2;                       // in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:24: 11:25
+    let mut _0: i32;                     // return place in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:36: 11:39
+    let _3: [closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10
+    let mut _4: &[closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6
+    let mut _5: (&i32, &i32);            // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
+    let mut _6: &i32;                    // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8
+    let mut _7: &i32;                    // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11
+    let mut _8: &i32;                    // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
+    let mut _9: &i32;                    // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
+    scope 1 {
+        debug x => _3;                   // in scope 1 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10
+        scope 2 {
+            debug r => _8;               // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:14: 12:15
+            debug _s => _9;              // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:23: 12:25
+        }
+    }
+    scope 3 {
+        debug variable => _8;            // in scope 3 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21
+    }
+
+    bb0: {
+        StorageLive(_3);                 // bb0[0]: scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10
+        _3 = [closure@foo::<T>::{{closure}}#0]; // bb0[1]: scope 0 at $DIR/inline-closure-borrows-arg.rs:12:13: 15:6
+                                         // closure
+                                         // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[317d]::foo[0]::{{closure}}[0])
+                                         // + substs: [
+                                         //     T,
+                                         //     i8,
+                                         //     for<'r, 's> extern "rust-call" fn((&'r i32, &'s i32)) -> i32,
+                                         //     (),
+                                         // ]
+        StorageLive(_4);                 // bb0[2]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6
+        _4 = &_3;                        // bb0[3]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6
+        StorageLive(_5);                 // bb0[4]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
+        StorageLive(_6);                 // bb0[5]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8
+        _6 = &(*_2);                     // bb0[6]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8
+        StorageLive(_7);                 // bb0[7]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11
+        _7 = &(*_2);                     // bb0[8]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11
+        _5 = (move _6, move _7);         // bb0[9]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
+        _8 = move (_5.0: &i32);          // bb0[10]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
+        _9 = move (_5.1: &i32);          // bb0[11]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
+        _0 = (*_8);                      // bb0[12]: scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18
+        StorageDead(_7);                 // bb0[13]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12
+        StorageDead(_6);                 // bb0[14]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12
+        StorageDead(_5);                 // bb0[15]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12
+        StorageDead(_4);                 // bb0[16]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12
+        StorageDead(_3);                 // bb0[17]: scope 0 at $DIR/inline-closure-borrows-arg.rs:17:1: 17:2
+        return;                          // bb0[18]: scope 0 at $DIR/inline-closure-borrows-arg.rs:17:2: 17:2
+    }
+}
index e000a418d90c79ae05e2d392169fb15c5f340884..4a0aad9b0e699c937394fea0fc38c4f1ff08135c 100644 (file)
@@ -6,55 +6,8 @@ fn main() {
     println!("{:?}", foo(0, 14));
 }
 
+// EMIT_MIR rustc.foo.Inline.after.mir
 fn foo<T: Copy>(t: T, q: i32) -> (i32, T) {
     let x = |_q| (q, t);
     x(q)
 }
-
-// END RUST SOURCE
-// START rustc.foo.Inline.after.mir
-// fn foo(_1: T, _2: i32) -> (i32, T){
-//     debug t => _1;
-//     debug q => _2;
-//     let mut _0: (i32, T);
-//     let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T];
-//     let mut _4: &i32;
-//     let mut _5: &T;
-//     let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T];
-//     let mut _7: (i32,);
-//     let mut _8: i32;
-//     let mut _11: i32;
-//     scope 1 {
-//         debug x => _3;
-//         scope 2 {
-//             debug _q => _11;
-//             debug q => (*((*_6).0: &i32));
-//             debug t => (*((*_6).1: &T));
-//             let mut _9: i32;
-//             let mut _10: T;
-//         }
-//     }
-//     bb0: {
-//         ...
-//         _4 = &_2;
-//         ...
-//         _5 = &_1;
-//         _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 };
-//         ...
-//         _6 = &_3;
-//         ...
-//         ...
-//         _8 = _2;
-//         _7 = (move _8,);
-//         _11 = move (_7.0: i32);
-//         ...
-//         _9 = (*((*_6).0: &i32));
-//         ...
-//         _10 = (*((*_6).1: &T));
-//         (_0.0: i32) = move _9;
-//         (_0.1: T) = move _10;
-//         ...
-//         return;
-//     }
-// }
-// END rustc.foo.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir
new file mode 100644 (file)
index 0000000..8f7c561
--- /dev/null
@@ -0,0 +1,63 @@
+// MIR for `foo` after Inline
+
+fn foo(_1: T, _2: i32) -> (i32, T) {
+    debug t => _1;                       // in scope 0 at $DIR/inline-closure-captures.rs:10:17: 10:18
+    debug q => _2;                       // in scope 0 at $DIR/inline-closure-captures.rs:10:23: 10:24
+    let mut _0: (i32, T);                // return place in scope 0 at $DIR/inline-closure-captures.rs:10:34: 10:42
+    let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; // in scope 0 at $DIR/inline-closure-captures.rs:11:9: 11:10
+    let mut _4: &i32;                    // in scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
+    let mut _5: &T;                      // in scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
+    let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:6
+    let mut _7: (i32,);                  // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:9
+    let mut _8: i32;                     // in scope 0 at $DIR/inline-closure-captures.rs:12:7: 12:8
+    let mut _11: i32;                    // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:9
+    scope 1 {
+        debug x => _3;                   // in scope 1 at $DIR/inline-closure-captures.rs:11:9: 11:10
+        scope 2 {
+            debug _q => _11;             // in scope 2 at $DIR/inline-closure-captures.rs:11:14: 11:16
+            debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:10:23: 10:24
+            debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18
+            let mut _9: i32;             // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
+            let mut _10: T;              // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
+        }
+    }
+
+    bb0: {
+        StorageLive(_3);                 // bb0[0]: scope 0 at $DIR/inline-closure-captures.rs:11:9: 11:10
+        StorageLive(_4);                 // bb0[1]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
+        _4 = &_2;                        // bb0[2]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
+        StorageLive(_5);                 // bb0[3]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
+        _5 = &_1;                        // bb0[4]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
+        _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; // bb0[5]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
+                                         // closure
+                                         // + def_id: DefId(0:6 ~ inline_closure_captures[317d]::foo[0]::{{closure}}[0])
+                                         // + substs: [
+                                         //     T,
+                                         //     i8,
+                                         //     extern "rust-call" fn((i32,)) -> (i32, T),
+                                         //     (&i32, &T),
+                                         // ]
+        StorageDead(_5);                 // bb0[6]: scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
+        StorageDead(_4);                 // bb0[7]: scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
+        StorageLive(_6);                 // bb0[8]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
+        _6 = &_3;                        // bb0[9]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
+        StorageLive(_7);                 // bb0[10]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
+        StorageLive(_8);                 // bb0[11]: scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8
+        _8 = _2;                         // bb0[12]: scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8
+        _7 = (move _8,);                 // bb0[13]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
+        _11 = move (_7.0: i32);          // bb0[14]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
+        StorageLive(_9);                 // bb0[15]: scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20
+        _9 = (*((*_6).0: &i32));         // bb0[16]: scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20
+        StorageLive(_10);                // bb0[17]: scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23
+        _10 = (*((*_6).1: &T));          // bb0[18]: scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23
+        (_0.0: i32) = move _9;           // bb0[19]: scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24
+        (_0.1: T) = move _10;            // bb0[20]: scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24
+        StorageDead(_10);                // bb0[21]: scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24
+        StorageDead(_9);                 // bb0[22]: scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24
+        StorageDead(_8);                 // bb0[23]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9
+        StorageDead(_7);                 // bb0[24]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9
+        StorageDead(_6);                 // bb0[25]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9
+        StorageDead(_3);                 // bb0[26]: scope 0 at $DIR/inline-closure-captures.rs:13:1: 13:2
+        return;                          // bb0[27]: scope 0 at $DIR/inline-closure-captures.rs:13:2: 13:2
+    }
+}
index bd36e77818edce1d72489068724e1f16f2e3305c..77e424a2bb3f7cfe9a8249e291e5a7a853318783 100644 (file)
@@ -6,45 +6,8 @@ fn main() {
     println!("{}", foo(0, 14));
 }
 
+// EMIT_MIR rustc.foo.Inline.after.mir
 fn foo<T: Copy>(_t: T, q: i32) -> i32 {
     let x = |_t, _q| _t;
     x(q, q)
 }
-
-// END RUST SOURCE
-// START rustc.foo.Inline.after.mir
-// fn foo(_1: T, _2: i32) -> i32{
-//     debug _t => _1;
-//     debug q => _2;
-//     let mut _0: i32;
-//     let _3: [closure@foo<T>::{{closure}}#0];
-//     let mut _4: &[closure@foo<T>::{{closure}}#0];
-//     let mut _5: (i32, i32);
-//     let mut _6: i32;
-//     let mut _7: i32;
-//     let mut _8: i32;
-//     let mut _9: i32;
-//     scope 1 {
-//         debug x => _3;
-//         scope 2 {
-//             debug _t => _8;
-//             debug _q => _9;
-//         }
-//     }
-//     bb0: {
-//         ...
-//         _3 = [closure@foo::<T>::{{closure}}#0];
-//         ...
-//         _4 = &_3;
-//         ...
-//         _6 = _2;
-//         ...
-//         _7 = _2;
-//         _5 = (move _6, move _7);
-//         _8 = move (_5.0: i32);
-//         _9 = move (_5.1: i32);
-//         _0 = _8;
-//         ...
-//         return;
-//     }
-// END rustc.foo.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir
new file mode 100644 (file)
index 0000000..e31032e
--- /dev/null
@@ -0,0 +1,51 @@
+// MIR for `foo` after Inline
+
+fn foo(_1: T, _2: i32) -> i32 {
+    debug _t => _1;                      // in scope 0 at $DIR/inline-closure.rs:10:17: 10:19
+    debug q => _2;                       // in scope 0 at $DIR/inline-closure.rs:10:24: 10:25
+    let mut _0: i32;                     // return place in scope 0 at $DIR/inline-closure.rs:10:35: 10:38
+    let _3: [closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure.rs:11:9: 11:10
+    let mut _4: &[closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:6
+    let mut _5: (i32, i32);              // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12
+    let mut _6: i32;                     // in scope 0 at $DIR/inline-closure.rs:12:7: 12:8
+    let mut _7: i32;                     // in scope 0 at $DIR/inline-closure.rs:12:10: 12:11
+    let mut _8: i32;                     // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12
+    let mut _9: i32;                     // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12
+    scope 1 {
+        debug x => _3;                   // in scope 1 at $DIR/inline-closure.rs:11:9: 11:10
+        scope 2 {
+            debug _t => _8;              // in scope 2 at $DIR/inline-closure.rs:11:14: 11:16
+            debug _q => _9;              // in scope 2 at $DIR/inline-closure.rs:11:18: 11:20
+        }
+    }
+
+    bb0: {
+        StorageLive(_3);                 // bb0[0]: scope 0 at $DIR/inline-closure.rs:11:9: 11:10
+        _3 = [closure@foo::<T>::{{closure}}#0]; // bb0[1]: scope 0 at $DIR/inline-closure.rs:11:13: 11:24
+                                         // closure
+                                         // + def_id: DefId(0:6 ~ inline_closure[317d]::foo[0]::{{closure}}[0])
+                                         // + substs: [
+                                         //     T,
+                                         //     i8,
+                                         //     extern "rust-call" fn((i32, i32)) -> i32,
+                                         //     (),
+                                         // ]
+        StorageLive(_4);                 // bb0[2]: scope 1 at $DIR/inline-closure.rs:12:5: 12:6
+        _4 = &_3;                        // bb0[3]: scope 1 at $DIR/inline-closure.rs:12:5: 12:6
+        StorageLive(_5);                 // bb0[4]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12
+        StorageLive(_6);                 // bb0[5]: scope 1 at $DIR/inline-closure.rs:12:7: 12:8
+        _6 = _2;                         // bb0[6]: scope 1 at $DIR/inline-closure.rs:12:7: 12:8
+        StorageLive(_7);                 // bb0[7]: scope 1 at $DIR/inline-closure.rs:12:10: 12:11
+        _7 = _2;                         // bb0[8]: scope 1 at $DIR/inline-closure.rs:12:10: 12:11
+        _5 = (move _6, move _7);         // bb0[9]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12
+        _8 = move (_5.0: i32);           // bb0[10]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12
+        _9 = move (_5.1: i32);           // bb0[11]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12
+        _0 = _8;                         // bb0[12]: scope 2 at $DIR/inline-closure.rs:11:22: 11:24
+        StorageDead(_7);                 // bb0[13]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12
+        StorageDead(_6);                 // bb0[14]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12
+        StorageDead(_5);                 // bb0[15]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12
+        StorageDead(_4);                 // bb0[16]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12
+        StorageDead(_3);                 // bb0[17]: scope 0 at $DIR/inline-closure.rs:13:1: 13:2
+        return;                          // bb0[18]: scope 0 at $DIR/inline-closure.rs:13:2: 13:2
+    }
+}
index fcb7b4c4fe69d5721f5af5ceb707c43a9ba9ed20..d36d93cd01c126c450c04b1ff6c767ecea30fcc3 100644 (file)
@@ -1,73 +1,9 @@
-// ignore-tidy-linelength
 // ignore-wasm32-bare compiled with panic=abort by default
 // compile-flags: -Z mir-opt-level=3
 // only-64bit FIXME: the mir representation of RawVec depends on ptr size
 #![feature(box_syntax)]
 
+// EMIT_MIR rustc.main.Inline.diff
 fn main() {
     let _x: Box<Vec<u32>> = box Vec::new();
 }
-
-// END RUST SOURCE
-// START rustc.main.Inline.before.mir
-// let mut _0: ();
-// let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] };
-// let mut _2: std::boxed::Box<std::vec::Vec<u32>>;
-// let mut _3: ();
-// scope 1 {
-//   debug _x => _1;
-// }
-// bb0: {
-//   StorageLive(_1);
-//   StorageLive(_2);
-//   _2 = Box(std::vec::Vec<u32>);
-//   (*_2) = const std::vec::Vec::<u32>::new() -> [return: bb2, unwind: bb4];
-// }
-// bb1 (cleanup): {
-//   resume;
-// }
-// bb2: {
-//   _1 = move _2;
-//   StorageDead(_2);
-//   _0 = ();
-//   drop(_1) -> [return: bb3, unwind: bb1];
-// }
-// bb3: {
-//   StorageDead(_1);
-//   return;
-// }
-// bb4 (cleanup): {
-//   _3 = const alloc::alloc::box_free::<std::vec::Vec<u32>>(move (_2.0: std::ptr::Unique<std::vec::Vec<u32>>)) -> bb1;
-// }
-// END rustc.main.Inline.before.mir
-// START rustc.main.Inline.after.mir
-// let mut _0: ();
-// let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] };
-// let mut _2: std::boxed::Box<std::vec::Vec<u32>>;
-// let mut _3: ();
-// let mut _4: &mut std::vec::Vec<u32>;
-// scope 1 {
-//   debug _x => _1;
-// }
-// scope 2 {
-// }
-// bb0: {
-//   StorageLive(_1);
-//   StorageLive(_2);
-//   _2 = Box(std::vec::Vec<u32>);
-//   _4 = &mut (*_2);
-//   ((*_4).0: alloc::raw_vec::RawVec<u32>) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>;
-//   ((*_4).1: usize) = const 0usize;
-//   _1 = move _2;
-//   StorageDead(_2);
-//   _0 = ();
-//   drop(_1) -> [return: bb2, unwind: bb1];
-// }
-// bb1 (cleanup): {
-//   resume;
-// }
-// bb2: {
-//   StorageDead(_1);
-//   return;
-// }
-// END rustc.main.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff
new file mode 100644 (file)
index 0000000..a0db20c
--- /dev/null
@@ -0,0 +1,76 @@
+- // MIR for `main` before Inline
++ // MIR for `main` after Inline
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline-into-box-place.rs:7:11: 7:11
+      let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11
+      let mut _2: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43
+      let mut _3: ();                      // in scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43
++     let mut _4: &mut std::vec::Vec<u32>; // in scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43
+      scope 1 {
+          debug _x => _1;                  // in scope 1 at $DIR/inline-into-box-place.rs:8:9: 8:11
+      }
++     scope 2 {
++     }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43
+          _2 = Box(std::vec::Vec<u32>);    // bb0[2]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43
+-         (*_2) = const std::vec::Vec::<u32>::new() -> [return: bb2, unwind: bb4]; // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43
++         _4 = &mut (*_2);                 // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43
++         ((*_4).0: alloc::raw_vec::RawVec<u32>) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>; // bb0[4]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL
+                                           // ty::Const
+-                                          // + ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new}
+-                                          // + val: Value(Scalar(<ZST>))
++                                          // + ty: alloc::raw_vec::RawVec<u32>
++                                          // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } })
+                                           // mir::Constant
+-                                          // + span: $DIR/inline-into-box-place.rs:8:33: 8:41
+-                                          // + user_ty: UserType(1)
+-                                          // + literal: Const { ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new}, val: Value(Scalar(<ZST>)) }
++                                          // + span: $SRC_DIR/liballoc/vec.rs:LL:COL
++                                          // + user_ty: UserType(0)
++                                          // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
++         ((*_4).1: usize) = const 0usize; // bb0[5]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL
++                                          // ty::Const
++                                          // + ty: usize
++                                          // + val: Value(Scalar(0x0000000000000000))
++                                          // mir::Constant
++                                          // + span: $SRC_DIR/liballoc/vec.rs:LL:COL
++                                          // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
++         _1 = move _2;                    // bb0[6]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43
++         StorageDead(_2);                 // bb0[7]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43
++         _0 = ();                         // bb0[8]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2
++         drop(_1) -> [return: bb2, unwind: bb1]; // bb0[9]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2
+      }
+  
+      bb1 (cleanup): {
+          resume;                          // bb1[0]: scope 0 at $DIR/inline-into-box-place.rs:7:1: 9:2
+      }
+  
+      bb2: {
+-         _1 = move _2;                    // bb2[0]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43
+-         StorageDead(_2);                 // bb2[1]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43
+-         _0 = ();                         // bb2[2]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2
+-         drop(_1) -> [return: bb3, unwind: bb1]; // bb2[3]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2
+-     }
+- 
+-     bb3: {
+-         StorageDead(_1);                 // bb3[0]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2
+-         return;                          // bb3[1]: scope 0 at $DIR/inline-into-box-place.rs:9:2: 9:2
+-     }
+- 
+-     bb4 (cleanup): {
+-         _3 = const alloc::alloc::box_free::<std::vec::Vec<u32>>(move (_2.0: std::ptr::Unique<std::vec::Vec<u32>>)) -> bb1; // bb4[0]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43
+-                                          // ty::Const
+-                                          // + ty: unsafe fn(std::ptr::Unique<std::vec::Vec<u32>>) {alloc::alloc::box_free::<std::vec::Vec<u32>>}
+-                                          // + val: Value(Scalar(<ZST>))
+-                                          // mir::Constant
+-                                          // + span: $DIR/inline-into-box-place.rs:8:42: 8:43
+-                                          // + literal: Const { ty: unsafe fn(std::ptr::Unique<std::vec::Vec<u32>>) {alloc::alloc::box_free::<std::vec::Vec<u32>>}, val: Value(Scalar(<ZST>)) }
++         StorageDead(_1);                 // bb2[0]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2
++         return;                          // bb2[1]: scope 0 at $DIR/inline-into-box-place.rs:9:2: 9:2
+      }
+  }
+  
index 7b78fc339f2c1309d2deb204593d1c8f477a38ed..d7e425ec6586fe0cda38fb2d108985189764fa25 100644 (file)
@@ -6,6 +6,7 @@ fn main() {
     println!("{}", bar());
 }
 
+// EMIT_MIR rustc.bar.Inline.after.mir
 fn bar() -> bool {
     let f = foo;
     f(&1, &-1)
@@ -15,23 +16,3 @@ fn bar() -> bool {
 fn foo(x: &i32, y: &i32) -> bool {
     *x == *y
 }
-
-// END RUST SOURCE
-// START rustc.bar.Inline.after.mir
-// ...
-//     bb0: {
-//         ...
-//         Retag(_3);
-//         ...
-//         Retag(_3);
-//         Retag(_6);
-//         StorageLive(_11);
-//         _11 = (*_3);
-//         StorageLive(_12);
-//         _12 = (*_6);
-//         _0 = Eq(move _11, move _12);
-//         ...
-//         return;
-//     }
-// ...
-// END rustc.bar.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir b/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir
new file mode 100644 (file)
index 0000000..ae2226b
--- /dev/null
@@ -0,0 +1,81 @@
+// MIR for `bar` after Inline
+
+fn bar() -> bool {
+    let mut _0: bool;                    // return place in scope 0 at $DIR/inline-retag.rs:10:13: 10:17
+    let _1: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:11:9: 11:10
+    let mut _2: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:12:5: 12:6
+    let mut _3: &i32;                    // in scope 0 at $DIR/inline-retag.rs:12:7: 12:9
+    let _4: &i32;                        // in scope 0 at $DIR/inline-retag.rs:12:7: 12:9
+    let _5: i32;                         // in scope 0 at $DIR/inline-retag.rs:12:8: 12:9
+    let mut _6: &i32;                    // in scope 0 at $DIR/inline-retag.rs:12:11: 12:14
+    let _7: &i32;                        // in scope 0 at $DIR/inline-retag.rs:12:11: 12:14
+    let _8: i32;                         // in scope 0 at $DIR/inline-retag.rs:12:12: 12:14
+    scope 1 {
+        debug f => _1;                   // in scope 1 at $DIR/inline-retag.rs:11:9: 11:10
+        let mut _9: &i32;                // in scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+        let mut _10: &i32;               // in scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+        scope 2 {
+            debug x => _3;               // in scope 2 at $DIR/inline-retag.rs:16:8: 16:9
+            debug y => _6;               // in scope 2 at $DIR/inline-retag.rs:16:17: 16:18
+            let mut _11: i32;            // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15
+            let mut _12: i32;            // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/inline-retag.rs:11:9: 11:10
+        _1 = const foo;                  // bb0[1]: scope 0 at $DIR/inline-retag.rs:11:13: 11:16
+                                         // ty::Const
+                                         // + ty: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/inline-retag.rs:11:13: 11:16
+                                         // + literal: Const { ty: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}, val: Value(Scalar(<ZST>)) }
+        StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/inline-retag.rs:12:5: 12:6
+        _2 = _1;                         // bb0[3]: scope 1 at $DIR/inline-retag.rs:12:5: 12:6
+        StorageLive(_3);                 // bb0[4]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+        StorageLive(_4);                 // bb0[5]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+        _10 = const bar::promoted[1];    // bb0[6]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+                                         // ty::Const
+                                         // + ty: &i32
+                                         // + val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[1]))
+                                         // mir::Constant
+                                         // + span: $DIR/inline-retag.rs:12:7: 12:9
+                                         // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[1])) }
+        Retag(_10);                      // bb0[7]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+        _4 = &(*_10);                    // bb0[8]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+        Retag(_4);                       // bb0[9]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+        _3 = &(*_4);                     // bb0[10]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+        Retag(_3);                       // bb0[11]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9
+        StorageLive(_6);                 // bb0[12]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+        StorageLive(_7);                 // bb0[13]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+        _9 = const bar::promoted[0];     // bb0[14]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+                                         // ty::Const
+                                         // + ty: &i32
+                                         // + val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[0]))
+                                         // mir::Constant
+                                         // + span: $DIR/inline-retag.rs:12:11: 12:14
+                                         // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[0])) }
+        Retag(_9);                       // bb0[15]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+        _7 = &(*_9);                     // bb0[16]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+        Retag(_7);                       // bb0[17]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+        _6 = &(*_7);                     // bb0[18]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+        Retag(_6);                       // bb0[19]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14
+        Retag(_3);                       // bb0[20]: scope 2 at $DIR/inline-retag.rs:16:1: 18:2
+        Retag(_6);                       // bb0[21]: scope 2 at $DIR/inline-retag.rs:16:1: 18:2
+        StorageLive(_11);                // bb0[22]: scope 2 at $DIR/inline-retag.rs:17:5: 17:7
+        _11 = (*_3);                     // bb0[23]: scope 2 at $DIR/inline-retag.rs:17:5: 17:7
+        StorageLive(_12);                // bb0[24]: scope 2 at $DIR/inline-retag.rs:17:11: 17:13
+        _12 = (*_6);                     // bb0[25]: scope 2 at $DIR/inline-retag.rs:17:11: 17:13
+        _0 = Eq(move _11, move _12);     // bb0[26]: scope 2 at $DIR/inline-retag.rs:17:5: 17:13
+        StorageDead(_12);                // bb0[27]: scope 2 at $DIR/inline-retag.rs:17:12: 17:13
+        StorageDead(_11);                // bb0[28]: scope 2 at $DIR/inline-retag.rs:17:12: 17:13
+        StorageDead(_6);                 // bb0[29]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15
+        StorageDead(_3);                 // bb0[30]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15
+        StorageDead(_2);                 // bb0[31]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15
+        StorageDead(_1);                 // bb0[32]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2
+        StorageDead(_7);                 // bb0[33]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2
+        StorageDead(_4);                 // bb0[34]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2
+        return;                          // bb0[35]: scope 0 at $DIR/inline-retag.rs:13:2: 13:2
+    }
+}
index 9591019bb4f70670f84d2cae174d9ce7a8cef9e6..fcdaca460a9dead810898b7222a9651ccdda223f 100644 (file)
@@ -1,5 +1,6 @@
 #![feature(specialization)]
 
+// EMIT_MIR rustc.main.Inline.diff
 fn main() {
     let x = <Vec::<()> as Foo>::bar();
 }
@@ -12,37 +13,3 @@ impl<T> Foo for Vec<T> {
     #[inline(always)]
     default fn bar() -> u32 { 123 }
 }
-
-// END RUST SOURCE
-// START rustc.main.Inline.before.mir
-// let mut _0: ();
-// let _1: u32;
-// scope 1 {
-//   debug x => _1;
-// }
-// bb0: {
-//   StorageLive(_1);
-//   _1 = const <std::vec::Vec<()> as Foo>::bar() -> bb1;
-// }
-// bb1: {
-//   _0 = ();
-//   StorageDead(_1);
-//   return;
-// }
-// END rustc.main.Inline.before.mir
-// START rustc.main.Inline.after.mir
-// let mut _0: ();
-// let _1: u32;
-// scope 1 {
-//   debug x => _1;
-// }
-// scope 2 {
-// }
-// bb0: {
-//   StorageLive(_1);
-//   _1 = const 123u32;
-//   _0 = ();
-//   StorageDead(_1);
-//   return;
-// }
-// END rustc.main.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff
new file mode 100644 (file)
index 0000000..98d03b1
--- /dev/null
@@ -0,0 +1,38 @@
+- // MIR for `main` before Inline
++ // MIR for `main` after Inline
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/inline-specialization.rs:4:11: 4:11
+      let _1: u32;                         // in scope 0 at $DIR/inline-specialization.rs:5:9: 5:10
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/inline-specialization.rs:5:9: 5:10
+      }
++     scope 2 {
++     }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/inline-specialization.rs:5:9: 5:10
+-         _1 = const <std::vec::Vec<()> as Foo>::bar() -> bb1; // bb0[1]: scope 0 at $DIR/inline-specialization.rs:5:13: 5:38
++         _1 = const 123u32;               // bb0[1]: scope 2 at $DIR/inline-specialization.rs:14:31: 14:34
+                                           // ty::Const
+-                                          // + ty: fn() -> u32 {<std::vec::Vec<()> as Foo>::bar}
+-                                          // + val: Value(Scalar(<ZST>))
++                                          // + ty: u32
++                                          // + val: Value(Scalar(0x0000007b))
+                                           // mir::Constant
+-                                          // + span: $DIR/inline-specialization.rs:5:13: 5:36
+-                                          // + literal: Const { ty: fn() -> u32 {<std::vec::Vec<()> as Foo>::bar}, val: Value(Scalar(<ZST>)) }
+-     }
+- 
+-     bb1: {
+-         _0 = ();                         // bb1[0]: scope 0 at $DIR/inline-specialization.rs:4:11: 6:2
+-         StorageDead(_1);                 // bb1[1]: scope 0 at $DIR/inline-specialization.rs:6:1: 6:2
+-         return;                          // bb1[2]: scope 0 at $DIR/inline-specialization.rs:6:2: 6:2
++                                          // + span: $DIR/inline-specialization.rs:14:31: 14:34
++                                          // + literal: Const { ty: u32, val: Value(Scalar(0x0000007b)) }
++         _0 = ();                         // bb0[2]: scope 0 at $DIR/inline-specialization.rs:4:11: 6:2
++         StorageDead(_1);                 // bb0[3]: scope 0 at $DIR/inline-specialization.rs:6:1: 6:2
++         return;                          // bb0[4]: scope 0 at $DIR/inline-specialization.rs:6:2: 6:2
+      }
+  }
+  
index a2c5fb920cd30ff872b844aea5807f0c62a79dd3..cb3db9b55924607b21a86ac6587b780873414f7f 100644 (file)
@@ -4,6 +4,7 @@ fn main() {
     println!("{}", test(&()));
 }
 
+// EMIT_MIR rustc.test.Inline.after.mir
 fn test(x: &dyn X) -> u32 {
     x.y()
 }
@@ -19,13 +20,3 @@ fn y(&self) -> u32 {
         2
     }
 }
-
-// END RUST SOURCE
-// START rustc.test.Inline.after.mir
-// ...
-// bb0: {
-// ...
-//     _0 = const <dyn X as X>::y(move _2) -> bb1;
-// }
-// ...
-// END rustc.test.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir b/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir
new file mode 100644 (file)
index 0000000..488303e
--- /dev/null
@@ -0,0 +1,24 @@
+// MIR for `test` after Inline
+
+fn test(_1: &dyn X) -> u32 {
+    debug x => _1;                       // in scope 0 at $DIR/inline-trait-method.rs:8:9: 8:10
+    let mut _0: u32;                     // return place in scope 0 at $DIR/inline-trait-method.rs:8:23: 8:26
+    let mut _2: &dyn X;                  // in scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6
+
+    bb0: {
+        StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6
+        _2 = &(*_1);                     // bb0[1]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6
+        _0 = const <dyn X as X>::y(move _2) -> bb1; // bb0[2]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:10
+                                         // ty::Const
+                                         // + ty: for<'r> fn(&'r dyn X) -> u32 {<dyn X as X>::y}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/inline-trait-method.rs:9:7: 9:8
+                                         // + literal: Const { ty: for<'r> fn(&'r dyn X) -> u32 {<dyn X as X>::y}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1: {
+        StorageDead(_2);                 // bb1[0]: scope 0 at $DIR/inline-trait-method.rs:9:9: 9:10
+        return;                          // bb1[1]: scope 0 at $DIR/inline-trait-method.rs:10:2: 10:2
+    }
+}
index 4ad4311113a3ad0ec39c6d8ca5c67c2aa46a1faa..e37f091c5cd2b115eec6b30fbf77b6130b133bf0 100644 (file)
@@ -1,5 +1,6 @@
 // compile-flags: -Z span_free_formats -Z mir-opt-level=3
 
+// EMIT_MIR rustc.test2.Inline.after.mir
 fn test2(x: &dyn X) -> bool {
     test(x)
 }
@@ -24,13 +25,3 @@ fn y(&self) -> bool {
 fn main() {
     println!("Should be true: {}", test2(&()));
 }
-
-// END RUST SOURCE
-// START rustc.test2.Inline.after.mir
-// ...
-// bb0: {
-// ...
-//     _0 = const <dyn X as X>::y(move _2) -> bb1;
-// }
-// ...
-// END rustc.test2.Inline.after.mir
diff --git a/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir b/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir
new file mode 100644 (file)
index 0000000..aca4719
--- /dev/null
@@ -0,0 +1,31 @@
+// MIR for `test2` after Inline
+
+fn test2(_1: &dyn X) -> bool {
+    debug x => _1;                       // in scope 0 at $DIR/inline-trait-method_2.rs:4:10: 4:11
+    let mut _0: bool;                    // return place in scope 0 at $DIR/inline-trait-method_2.rs:4:24: 4:28
+    let mut _2: &dyn X;                  // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11
+    let mut _3: &dyn X;                  // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11
+    scope 1 {
+        debug x => _2;                   // in scope 1 at $DIR/inline-trait-method_2.rs:9:9: 9:10
+    }
+
+    bb0: {
+        StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11
+        StorageLive(_3);                 // bb0[1]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11
+        _3 = &(*_1);                     // bb0[2]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11
+        _2 = move _3 as &dyn X (Pointer(Unsize)); // bb0[3]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11
+        StorageDead(_3);                 // bb0[4]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11
+        _0 = const <dyn X as X>::y(move _2) -> bb1; // bb0[5]: scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10
+                                         // ty::Const
+                                         // + ty: for<'r> fn(&'r dyn X) -> bool {<dyn X as X>::y}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8
+                                         // + literal: Const { ty: for<'r> fn(&'r dyn X) -> bool {<dyn X as X>::y}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1: {
+        StorageDead(_2);                 // bb1[0]: scope 0 at $DIR/inline-trait-method_2.rs:5:11: 5:12
+        return;                          // bb1[1]: scope 0 at $DIR/inline-trait-method_2.rs:6:2: 6:2
+    }
+}
index d980cc891dc40c740d9aa1e6b241aa9183767194..f6883ac80861e5e6200959805a089e434b1aed7f 100644 (file)
@@ -1,5 +1,6 @@
 // check that we don't StorageDead booleans before they are used
 
+// EMIT_MIR rustc.main.SimplifyCfg-initial.after.mir
 fn main() {
     let mut should_break = false;
     loop {
@@ -9,42 +10,3 @@ fn main() {
         should_break = true;
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyCfg-initial.after.mir
-//     bb0: {
-//         StorageLive(_1);
-//         _1 = const false;
-//         FakeRead(ForLet, _1);
-//         goto -> bb2;
-//     }
-//     bb1 (cleanup): {
-//         resume;
-//     }
-//     bb2: {
-//         falseUnwind -> [real: bb3, cleanup: bb1];
-//     }
-//     bb3: {
-//         StorageLive(_3);
-//         StorageLive(_4);
-//         _4 = _1;
-//         FakeRead(ForMatchedPlace, _4);
-//         switchInt(_4) -> [false: bb5, otherwise: bb4];
-//     }
-//     ...
-//     bb5: {
-//         _3 = ();
-//         StorageDead(_4);
-//         StorageDead(_3);
-//         _1 = const true;
-//         _2 = ();
-//         goto -> bb2;
-//     }
-//     bb6: {
-//         _0 = ();
-//         StorageDead(_4);
-//         StorageDead(_3);
-//         StorageDead(_1);
-//         return;
-//     }
-// END rustc.main.SimplifyCfg-initial.after.mir
diff --git a/src/test/mir-opt/issue-38669/rustc.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/issue-38669/rustc.main.SimplifyCfg-initial.after.mir
new file mode 100644 (file)
index 0000000..5144cdd
--- /dev/null
@@ -0,0 +1,69 @@
+// MIR for `main` after SimplifyCfg-initial
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue-38669.rs:4:11: 4:11
+    let mut _1: bool;                    // in scope 0 at $DIR/issue-38669.rs:5:9: 5:25
+    let mut _2: ();                      // in scope 0 at $DIR/issue-38669.rs:4:1: 12:2
+    let _3: ();                          // in scope 0 at $DIR/issue-38669.rs:7:9: 9:10
+    let mut _4: bool;                    // in scope 0 at $DIR/issue-38669.rs:7:12: 7:24
+    let mut _5: !;                       // in scope 0 at $DIR/issue-38669.rs:7:25: 9:10
+    scope 1 {
+        debug should_break => _1;        // in scope 1 at $DIR/issue-38669.rs:5:9: 5:25
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/issue-38669.rs:5:9: 5:25
+        _1 = const false;                // bb0[1]: scope 0 at $DIR/issue-38669.rs:5:28: 5:33
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-38669.rs:5:28: 5:33
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        FakeRead(ForLet, _1);            // bb0[2]: scope 0 at $DIR/issue-38669.rs:5:9: 5:25
+        goto -> bb2;                     // bb0[3]: scope 1 at $DIR/issue-38669.rs:6:5: 11:6
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/issue-38669.rs:4:1: 12:2
+    }
+
+    bb2: {
+        falseUnwind -> [real: bb3, cleanup: bb1]; // bb2[0]: scope 1 at $DIR/issue-38669.rs:6:5: 11:6
+    }
+
+    bb3: {
+        StorageLive(_3);                 // bb3[0]: scope 1 at $DIR/issue-38669.rs:7:9: 9:10
+        StorageLive(_4);                 // bb3[1]: scope 1 at $DIR/issue-38669.rs:7:12: 7:24
+        _4 = _1;                         // bb3[2]: scope 1 at $DIR/issue-38669.rs:7:12: 7:24
+        FakeRead(ForMatchedPlace, _4);   // bb3[3]: scope 1 at $DIR/issue-38669.rs:7:12: 7:24
+        switchInt(_4) -> [false: bb5, otherwise: bb4]; // bb3[4]: scope 1 at $DIR/issue-38669.rs:7:9: 9:10
+    }
+
+    bb4: {
+        falseEdges -> [real: bb6, imaginary: bb5]; // bb4[0]: scope 1 at $DIR/issue-38669.rs:7:9: 9:10
+    }
+
+    bb5: {
+        _3 = ();                         // bb5[0]: scope 1 at $DIR/issue-38669.rs:7:9: 9:10
+        StorageDead(_4);                 // bb5[1]: scope 1 at $DIR/issue-38669.rs:9:9: 9:10
+        StorageDead(_3);                 // bb5[2]: scope 1 at $DIR/issue-38669.rs:9:9: 9:10
+        _1 = const true;                 // bb5[3]: scope 1 at $DIR/issue-38669.rs:10:9: 10:28
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-38669.rs:10:24: 10:28
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _2 = ();                         // bb5[4]: scope 1 at $DIR/issue-38669.rs:6:10: 11:6
+        goto -> bb2;                     // bb5[5]: scope 1 at $DIR/issue-38669.rs:6:5: 11:6
+    }
+
+    bb6: {
+        _0 = ();                         // bb6[0]: scope 1 at $DIR/issue-38669.rs:8:13: 8:18
+        StorageDead(_4);                 // bb6[1]: scope 1 at $DIR/issue-38669.rs:9:9: 9:10
+        StorageDead(_3);                 // bb6[2]: scope 1 at $DIR/issue-38669.rs:9:9: 9:10
+        StorageDead(_1);                 // bb6[3]: scope 0 at $DIR/issue-38669.rs:12:1: 12:2
+        return;                          // bb6[4]: scope 0 at $DIR/issue-38669.rs:12:2: 12:2
+    }
+}
index 5ba54f98d00da7fcf15e559cda3569b594f4ea79..cc35b8785a733da20878bf29720140d3c8552b37 100644 (file)
@@ -2,12 +2,15 @@
 
 // check that we don't emit multiple drop flags when they are not needed.
 
+
+// EMIT_MIR rustc.main.ElaborateDrops.after.mir
 fn main() {
     let x = S.other(S.id());
 }
 
 // no_mangle to make sure this gets instantiated even in an executable.
 #[no_mangle]
+// EMIT_MIR rustc.test.ElaborateDrops.after.mir
 pub fn test() {
     let u = S;
     let mut v = S;
@@ -25,34 +28,3 @@ impl S {
     fn id(self) -> Self { self }
     fn other(self, s: Self) {}
 }
-
-// END RUST SOURCE
-// START rustc.main.ElaborateDrops.after.mir
-//    let mut _0: ();
-//    let _1: ();
-//    let mut _2: S;
-//    let mut _3: S;
-//    let mut _4: S;
-//    let mut _5: bool;
-//    scope 1 {
-//        debug x => _1;
-//    }
-//    ...
-//    bb0: {
-// END rustc.main.ElaborateDrops.after.mir
-// START rustc.test.ElaborateDrops.after.mir
-//    let mut _0: ();
-//    let _1: S;
-//    let _3: ();
-//    let mut _4: S;
-//    let mut _5: S;
-//    let mut _6: bool;
-//    ...
-//    debug u => _1;
-//    ...
-//    let mut _2: S;
-//    ...
-//    debug v => _2;
-//    ...
-//    bb0: {
-// END rustc.test.ElaborateDrops.after.mir
diff --git a/src/test/mir-opt/issue-41110/rustc.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue-41110/rustc.main.ElaborateDrops.after.mir
new file mode 100644 (file)
index 0000000..0499054
--- /dev/null
@@ -0,0 +1,111 @@
+// MIR for `main` after ElaborateDrops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue-41110.rs:7:11: 7:11
+    let _1: ();                          // in scope 0 at $DIR/issue-41110.rs:8:9: 8:10
+    let mut _2: S;                       // in scope 0 at $DIR/issue-41110.rs:8:13: 8:14
+    let mut _3: S;                       // in scope 0 at $DIR/issue-41110.rs:8:21: 8:27
+    let mut _4: S;                       // in scope 0 at $DIR/issue-41110.rs:8:21: 8:22
+    let mut _5: bool;                    // in scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/issue-41110.rs:8:9: 8:10
+    }
+
+    bb0: {
+        _5 = const false;                // bb0[0]: scope 0 at $DIR/issue-41110.rs:8:9: 8:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:8:9: 8:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        StorageLive(_1);                 // bb0[1]: scope 0 at $DIR/issue-41110.rs:8:9: 8:10
+        StorageLive(_2);                 // bb0[2]: scope 0 at $DIR/issue-41110.rs:8:13: 8:14
+        _5 = const true;                 // bb0[3]: scope 0 at $DIR/issue-41110.rs:8:13: 8:14
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:8:13: 8:14
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _2 = S;                          // bb0[4]: scope 0 at $DIR/issue-41110.rs:8:13: 8:14
+        StorageLive(_3);                 // bb0[5]: scope 0 at $DIR/issue-41110.rs:8:21: 8:27
+        StorageLive(_4);                 // bb0[6]: scope 0 at $DIR/issue-41110.rs:8:21: 8:22
+        _4 = S;                          // bb0[7]: scope 0 at $DIR/issue-41110.rs:8:21: 8:22
+        _3 = const S::id(move _4) -> [return: bb2, unwind: bb4]; // bb0[8]: scope 0 at $DIR/issue-41110.rs:8:21: 8:27
+                                         // ty::Const
+                                         // + ty: fn(S) -> S {S::id}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:8:23: 8:25
+                                         // + literal: Const { ty: fn(S) -> S {S::id}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/issue-41110.rs:7:1: 9:2
+    }
+
+    bb2: {
+        StorageDead(_4);                 // bb2[0]: scope 0 at $DIR/issue-41110.rs:8:26: 8:27
+        _5 = const false;                // bb2[1]: scope 0 at $DIR/issue-41110.rs:8:13: 8:28
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:8:13: 8:28
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        _1 = const S::other(move _2, move _3) -> [return: bb6, unwind: bb5]; // bb2[2]: scope 0 at $DIR/issue-41110.rs:8:13: 8:28
+                                         // ty::Const
+                                         // + ty: fn(S, S) {S::other}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:8:15: 8:20
+                                         // + literal: Const { ty: fn(S, S) {S::other}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb3 (cleanup): {
+        goto -> bb9;                     // bb3[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+    }
+
+    bb4 (cleanup): {
+        goto -> bb3;                     // bb4[0]: scope 0 at $DIR/issue-41110.rs:8:26: 8:27
+    }
+
+    bb5 (cleanup): {
+        goto -> bb3;                     // bb5[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+    }
+
+    bb6: {
+        StorageDead(_3);                 // bb6[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+        _5 = const false;                // bb6[1]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:8:27: 8:28
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        StorageDead(_2);                 // bb6[2]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+        _0 = ();                         // bb6[3]: scope 0 at $DIR/issue-41110.rs:7:11: 9:2
+        StorageDead(_1);                 // bb6[4]: scope 0 at $DIR/issue-41110.rs:9:1: 9:2
+        return;                          // bb6[5]: scope 0 at $DIR/issue-41110.rs:9:2: 9:2
+    }
+
+    bb7 (cleanup): {
+        drop(_2) -> bb1;                 // bb7[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+    }
+
+    bb8 (cleanup): {
+        _5 = const false;                // bb8[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:8:27: 8:28
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        goto -> bb7;                     // bb8[1]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+    }
+
+    bb9 (cleanup): {
+        switchInt(_5) -> [false: bb1, otherwise: bb8]; // bb9[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28
+    }
+}
diff --git a/src/test/mir-opt/issue-41110/rustc.test.ElaborateDrops.after.mir b/src/test/mir-opt/issue-41110/rustc.test.ElaborateDrops.after.mir
new file mode 100644 (file)
index 0000000..b6623fc
--- /dev/null
@@ -0,0 +1,139 @@
+// MIR for `test` after ElaborateDrops
+
+fn test() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue-41110.rs:14:15: 14:15
+    let _1: S;                           // in scope 0 at $DIR/issue-41110.rs:15:9: 15:10
+    let _3: ();                          // in scope 0 at $DIR/issue-41110.rs:17:5: 17:12
+    let mut _4: S;                       // in scope 0 at $DIR/issue-41110.rs:17:10: 17:11
+    let mut _5: S;                       // in scope 0 at $DIR/issue-41110.rs:18:9: 18:10
+    let mut _6: bool;                    // in scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+    scope 1 {
+        debug u => _1;                   // in scope 1 at $DIR/issue-41110.rs:15:9: 15:10
+        let mut _2: S;                   // in scope 1 at $DIR/issue-41110.rs:16:9: 16:14
+        scope 2 {
+            debug v => _2;               // in scope 2 at $DIR/issue-41110.rs:16:9: 16:14
+        }
+    }
+
+    bb0: {
+        _6 = const false;                // bb0[0]: scope 0 at $DIR/issue-41110.rs:15:9: 15:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:15:9: 15:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        StorageLive(_1);                 // bb0[1]: scope 0 at $DIR/issue-41110.rs:15:9: 15:10
+        _6 = const true;                 // bb0[2]: scope 0 at $DIR/issue-41110.rs:15:13: 15:14
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:15:13: 15:14
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _1 = S;                          // bb0[3]: scope 0 at $DIR/issue-41110.rs:15:13: 15:14
+        StorageLive(_2);                 // bb0[4]: scope 1 at $DIR/issue-41110.rs:16:9: 16:14
+        _2 = S;                          // bb0[5]: scope 1 at $DIR/issue-41110.rs:16:17: 16:18
+        StorageLive(_3);                 // bb0[6]: scope 2 at $DIR/issue-41110.rs:17:5: 17:12
+        StorageLive(_4);                 // bb0[7]: scope 2 at $DIR/issue-41110.rs:17:10: 17:11
+        _4 = move _2;                    // bb0[8]: scope 2 at $DIR/issue-41110.rs:17:10: 17:11
+        _3 = const std::mem::drop::<S>(move _4) -> [return: bb2, unwind: bb5]; // bb0[9]: scope 2 at $DIR/issue-41110.rs:17:5: 17:12
+                                         // ty::Const
+                                         // + ty: fn(S) {std::mem::drop::<S>}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:17:5: 17:9
+                                         // + literal: Const { ty: fn(S) {std::mem::drop::<S>}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/issue-41110.rs:14:1: 19:2
+    }
+
+    bb2: {
+        StorageDead(_4);                 // bb2[0]: scope 2 at $DIR/issue-41110.rs:17:11: 17:12
+        StorageDead(_3);                 // bb2[1]: scope 2 at $DIR/issue-41110.rs:17:12: 17:13
+        StorageLive(_5);                 // bb2[2]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10
+        _6 = const false;                // bb2[3]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:18:9: 18:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        _5 = move _1;                    // bb2[4]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10
+        goto -> bb12;                    // bb2[5]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6
+    }
+
+    bb3 (cleanup): {
+        goto -> bb15;                    // bb3[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+    }
+
+    bb4 (cleanup): {
+        goto -> bb3;                     // bb4[0]: scope 1 at $DIR/issue-41110.rs:19:1: 19:2
+    }
+
+    bb5 (cleanup): {
+        goto -> bb4;                     // bb5[0]: scope 2 at $DIR/issue-41110.rs:17:11: 17:12
+    }
+
+    bb6: {
+        goto -> bb8;                     // bb6[0]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10
+    }
+
+    bb7 (cleanup): {
+        goto -> bb4;                     // bb7[0]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10
+    }
+
+    bb8: {
+        StorageDead(_5);                 // bb8[0]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10
+        _0 = ();                         // bb8[1]: scope 0 at $DIR/issue-41110.rs:14:15: 19:2
+        drop(_2) -> [return: bb9, unwind: bb3]; // bb8[2]: scope 1 at $DIR/issue-41110.rs:19:1: 19:2
+    }
+
+    bb9: {
+        StorageDead(_2);                 // bb9[0]: scope 1 at $DIR/issue-41110.rs:19:1: 19:2
+        goto -> bb10;                    // bb9[1]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+    }
+
+    bb10: {
+        _6 = const false;                // bb10[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:19:1: 19:2
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        StorageDead(_1);                 // bb10[1]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+        return;                          // bb10[2]: scope 0 at $DIR/issue-41110.rs:19:2: 19:2
+    }
+
+    bb11 (cleanup): {
+        _2 = move _5;                    // bb11[0]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6
+        goto -> bb7;                     // bb11[1]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6
+    }
+
+    bb12: {
+        _2 = move _5;                    // bb12[0]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6
+        goto -> bb6;                     // bb12[1]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6
+    }
+
+    bb13 (cleanup): {
+        drop(_1) -> bb1;                 // bb13[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+    }
+
+    bb14 (cleanup): {
+        _6 = const false;                // bb14[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41110.rs:19:1: 19:2
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        goto -> bb13;                    // bb14[1]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+    }
+
+    bb15 (cleanup): {
+        switchInt(_6) -> [false: bb1, otherwise: bb14]; // bb15[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2
+    }
+}
index 5a461d61482546f65e1b121418ec474f5eed64a7..07b9d175677caefe6e44588c95cfaeb499473c5d 100644 (file)
@@ -13,7 +13,9 @@ trait Foo {
     fn get(&self) -> [u8; 2];
 }
 
-impl Foo for [u8; 2] {
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir
+impl Foo for [u8; 1+1] {
     fn get(&self) -> [u8; 2] {
         *self
     }
diff --git a/src/test/mir-opt/issue-41697/32bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir b/src/test/mir-opt/issue-41697/32bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir
new file mode 100644 (file)
index 0000000..072ca4c
--- /dev/null
@@ -0,0 +1,32 @@
+// MIR for `<impl at $DIR/issue-41697.rs:18:1: 22:2>::{{constant}}#0` after SimplifyCfg-qualify-consts
+
+<impl at $DIR/issue-41697.rs:18:1: 22:2>::{{constant}}#0: usize = {
+    let mut _0: usize;                   // return place in scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+    let mut _1: (usize, bool);           // in scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+
+    bb0: {
+        _1 = CheckedAdd(const 1usize, const 1usize); // bb0[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41697.rs:18:19: 18:20
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41697.rs:18:21: 18:22
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+        assert(!move (_1.1: bool), "attempt to add with overflow") -> [success: bb2, unwind: bb1]; // bb0[1]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+    }
+
+    bb2: {
+        _0 = move (_1.0: usize);         // bb2[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+        return;                          // bb2[1]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+    }
+}
diff --git a/src/test/mir-opt/issue-41697/64bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir b/src/test/mir-opt/issue-41697/64bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir
new file mode 100644 (file)
index 0000000..5a9d157
--- /dev/null
@@ -0,0 +1,32 @@
+// MIR for `<impl at $DIR/issue-41697.rs:18:1: 22:2>::{{constant}}#0` after SimplifyCfg-qualify-consts
+
+<impl at $DIR/issue-41697.rs:18:1: 22:2>::{{constant}}#0: usize = {
+    let mut _0: usize;                   // return place in scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+    let mut _1: (usize, bool);           // in scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+
+    bb0: {
+        _1 = CheckedAdd(const 1usize, const 1usize); // bb0[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000001))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41697.rs:18:19: 18:20
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000001))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41697.rs:18:21: 18:22
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+        assert(!move (_1.1: bool), "attempt to add with overflow") -> [success: bb2, unwind: bb1]; // bb0[1]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+    }
+
+    bb2: {
+        _0 = move (_1.0: usize);         // bb2[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+        return;                          // bb2[1]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+    }
+}
index efe2b249d4a8653237651d337af3b2afb3987d50..6caaa59d0af34334e3ae9640f4aab56873beeaa8 100644 (file)
@@ -1,6 +1,8 @@
+// ignore-wasm32-bare compiled with panic=abort by default
 // check that we clear the "ADT master drop flag" even when there are
 // no fields to be dropped.
 
+// EMIT_MIR rustc.main.ElaborateDrops.after.mir
 fn main() {
     let e;
     if cond() {
@@ -20,159 +22,3 @@ enum E {
     F(K),
     G(Box<E>)
 }
-
-// END RUST SOURCE
-// fn main() -> () {
-//     let mut _0: ();
-//     scope 1 {
-//         let _1: E;
-//         debug e => _1;
-//         scope 2 {
-//             let _6: K;
-//             debug _k => _6;
-//         }
-//     }
-//     let mut _2: bool;
-//     let mut _3: ();
-//     let mut _4: E;
-//     let mut _5: K;
-//     let mut _7: isize;
-//     let mut _8: bool; // drop flag for `e`
-//     let mut _9: bool;
-//     let mut _10: bool;
-//     let mut _11: isize;
-//     let mut _12: isize;
-//
-//     bb0: {
-//         _8 = const false;
-//         _10 = const false;
-//         _9 = const false;
-//         StorageLive(_1);
-//         StorageLive(_2);
-//         _2 = const cond() -> [return: bb3, unwind: bb2];
-//     }
-//
-//     bb1: {
-//         resume;
-//     }
-//
-//     bb2: {
-//         goto -> bb1;
-//     }
-//
-//     bb3: {
-//         switchInt(_2) -> [0u8: bb5, otherwise: bb4];
-//     }
-//
-//     bb4: {
-//         StorageLive(_4);
-//         StorageLive(_5);
-//         _5 = K::{{constructor}};
-//         _4 = E::F(_5,);
-//         StorageDead(_5);
-//         goto -> bb15;
-//     }
-//
-//     bb5: {
-//         _0 = ();
-//         goto -> bb12;
-//     }
-//
-//     bb6: {
-//         goto -> bb2;
-//     }
-//
-//     bb7: {
-//         goto -> bb8;
-//     }
-//
-//     bb8: {
-//         StorageDead(_4);
-//         _7 = discriminant(_1);
-//         switchInt(_7) -> [0isize: bb10, otherwise: bb9];
-//     }
-//
-//     bb9: {
-//         _0 = ();
-//         goto -> bb11;
-//     }
-//
-//     bb10: {
-//         StorageLive(_6);
-//         _10 = const false;
-//         _6 = ((_1 as F).0: K);
-//         _0 = ();
-//         goto -> bb11;
-//     }
-//
-//     bb11: {
-//         StorageDead(_6);
-//         goto -> bb12;
-//     }
-//
-//     bb12: {
-//         StorageDead(_2);
-//         goto -> bb22;
-//     }
-//
-//     bb13: {
-//         StorageDead(_1);
-//         return;
-//     }
-//
-//     bb14: {
-//         _8 = const true;
-//         _9 = const true;
-//         _10 = const true;
-//         _1 = _4;
-//         goto -> bb6;
-//     }
-//
-//     bb15: {
-//         _8 = const true;
-//         _9 = const true;
-//         _10 = const true;
-//         _1 = _4;
-//         goto -> bb7;
-//     }
-//
-//     bb16: {
-//         _8 = const false; // clear the drop flag - must always be reached
-//         goto -> bb13;
-//     }
-//
-//     bb17: {
-//         _8 = const false;
-//         goto -> bb1;
-//     }
-//
-//     bb18: {
-//         goto -> bb17;
-//     }
-//
-//     bb19: {
-//         drop(_1) -> [return: bb16, unwind: bb17];
-//     }
-//
-//     bb20: {
-//         drop(_1) -> bb17;
-//     }
-//
-//     bb21: {
-//         _11 = discriminant(_1);
-//         switchInt(_11) -> [0isize: bb16, otherwise: bb19];
-//     }
-//
-//     bb22: {
-//         switchInt(_8) -> [0u8: bb16, otherwise: bb21];
-//     }
-//
-//     bb23: {
-//         _12 = discriminant(_1);
-//         switchInt(_12) -> [0isize: bb18, otherwise: bb20];
-//     }
-//
-//     bb24: {
-//         switchInt(_8) -> [0u8: bb17, otherwise: bb23];
-//     }
-// }
diff --git a/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir
new file mode 100644 (file)
index 0000000..6cd3e2d
--- /dev/null
@@ -0,0 +1,250 @@
+// MIR for `main` after ElaborateDrops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue-41888.rs:6:11: 6:11
+    let _1: E;                           // in scope 0 at $DIR/issue-41888.rs:7:9: 7:10
+    let mut _2: bool;                    // in scope 0 at $DIR/issue-41888.rs:8:8: 8:14
+    let mut _3: E;                       // in scope 0 at $DIR/issue-41888.rs:9:13: 9:20
+    let mut _4: K;                       // in scope 0 at $DIR/issue-41888.rs:9:18: 9:19
+    let mut _5: isize;                   // in scope 0 at $DIR/issue-41888.rs:10:16: 10:24
+    let mut _7: bool;                    // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    let mut _8: bool;                    // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    let mut _9: bool;                    // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    let mut _10: isize;                  // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    let mut _11: isize;                  // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    scope 1 {
+        debug e => _1;                   // in scope 1 at $DIR/issue-41888.rs:7:9: 7:10
+        let _6: K;                       // in scope 1 at $DIR/issue-41888.rs:10:21: 10:23
+        scope 2 {
+            debug _k => _6;              // in scope 2 at $DIR/issue-41888.rs:10:21: 10:23
+        }
+    }
+
+    bb0: {
+        _9 = const false;                // bb0[0]: scope 0 at $DIR/issue-41888.rs:7:9: 7:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:7:9: 7:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        _7 = const false;                // bb0[1]: scope 0 at $DIR/issue-41888.rs:7:9: 7:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:7:9: 7:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        _8 = const false;                // bb0[2]: scope 0 at $DIR/issue-41888.rs:7:9: 7:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:7:9: 7:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        StorageLive(_1);                 // bb0[3]: scope 0 at $DIR/issue-41888.rs:7:9: 7:10
+        StorageLive(_2);                 // bb0[4]: scope 1 at $DIR/issue-41888.rs:8:8: 8:14
+        _2 = const cond() -> [return: bb2, unwind: bb3]; // bb0[5]: scope 1 at $DIR/issue-41888.rs:8:8: 8:14
+                                         // ty::Const
+                                         // + ty: fn() -> bool {cond}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:8:8: 8:12
+                                         // + literal: Const { ty: fn() -> bool {cond}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/issue-41888.rs:6:1: 15:2
+    }
+
+    bb2: {
+        switchInt(_2) -> [false: bb4, otherwise: bb5]; // bb2[0]: scope 1 at $DIR/issue-41888.rs:8:5: 14:6
+    }
+
+    bb3 (cleanup): {
+        goto -> bb1;                     // bb3[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb4: {
+        _0 = ();                         // bb4[0]: scope 1 at $DIR/issue-41888.rs:8:5: 14:6
+        goto -> bb11;                    // bb4[1]: scope 1 at $DIR/issue-41888.rs:8:5: 14:6
+    }
+
+    bb5: {
+        StorageLive(_3);                 // bb5[0]: scope 1 at $DIR/issue-41888.rs:9:13: 9:20
+        StorageLive(_4);                 // bb5[1]: scope 1 at $DIR/issue-41888.rs:9:18: 9:19
+        _4 = K;                          // bb5[2]: scope 1 at $DIR/issue-41888.rs:9:18: 9:19
+        _3 = E::F(move _4,);             // bb5[3]: scope 1 at $DIR/issue-41888.rs:9:13: 9:20
+        StorageDead(_4);                 // bb5[4]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20
+        goto -> bb14;                    // bb5[5]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+    }
+
+    bb6: {
+        goto -> bb8;                     // bb6[0]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20
+    }
+
+    bb7 (cleanup): {
+        goto -> bb3;                     // bb7[0]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20
+    }
+
+    bb8: {
+        StorageDead(_3);                 // bb8[0]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20
+        _5 = discriminant(_1);           // bb8[1]: scope 1 at $DIR/issue-41888.rs:10:16: 10:24
+        switchInt(move _5) -> [0isize: bb10, otherwise: bb9]; // bb8[2]: scope 1 at $DIR/issue-41888.rs:10:16: 10:24
+    }
+
+    bb9: {
+        _0 = ();                         // bb9[0]: scope 1 at $DIR/issue-41888.rs:10:9: 13:10
+        goto -> bb11;                    // bb9[1]: scope 1 at $DIR/issue-41888.rs:10:9: 13:10
+    }
+
+    bb10: {
+        StorageLive(_6);                 // bb10[0]: scope 1 at $DIR/issue-41888.rs:10:21: 10:23
+        _9 = const false;                // bb10[1]: scope 1 at $DIR/issue-41888.rs:10:21: 10:23
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:10:21: 10:23
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        _6 = move ((_1 as F).0: K);      // bb10[2]: scope 1 at $DIR/issue-41888.rs:10:21: 10:23
+        _0 = ();                         // bb10[3]: scope 2 at $DIR/issue-41888.rs:10:29: 13:10
+        StorageDead(_6);                 // bb10[4]: scope 1 at $DIR/issue-41888.rs:13:9: 13:10
+        goto -> bb11;                    // bb10[5]: scope 1 at $DIR/issue-41888.rs:10:9: 13:10
+    }
+
+    bb11: {
+        goto -> bb21;                    // bb11[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb12: {
+        _7 = const false;                // bb12[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:15:1: 15:2
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        _8 = const false;                // bb12[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:15:1: 15:2
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        _9 = const false;                // bb12[2]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:15:1: 15:2
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        StorageDead(_1);                 // bb12[3]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+        StorageDead(_2);                 // bb12[4]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+        return;                          // bb12[5]: scope 0 at $DIR/issue-41888.rs:15:2: 15:2
+    }
+
+    bb13 (cleanup): {
+        _7 = const true;                 // bb13[0]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:9:9: 9:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _8 = const true;                 // bb13[1]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:9:9: 9:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _9 = const true;                 // bb13[2]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:9:9: 9:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _1 = move _3;                    // bb13[3]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+        goto -> bb7;                     // bb13[4]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+    }
+
+    bb14: {
+        _7 = const true;                 // bb14[0]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:9:9: 9:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _8 = const true;                 // bb14[1]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:9:9: 9:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _9 = const true;                 // bb14[2]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:9:9: 9:10
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        _1 = move _3;                    // bb14[3]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+        goto -> bb6;                     // bb14[4]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10
+    }
+
+    bb15: {
+        _7 = const false;                // bb15[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:15:1: 15:2
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        goto -> bb12;                    // bb15[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb16 (cleanup): {
+        _7 = const false;                // bb16[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x00))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-41888.rs:15:1: 15:2
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+        goto -> bb1;                     // bb16[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb17 (cleanup): {
+        goto -> bb16;                    // bb17[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb18: {
+        drop(_1) -> [return: bb15, unwind: bb16]; // bb18[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb19 (cleanup): {
+        drop(_1) -> bb16;                // bb19[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb20: {
+        _10 = discriminant(_1);          // bb20[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+        switchInt(move _10) -> [0isize: bb15, otherwise: bb18]; // bb20[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb21: {
+        switchInt(_7) -> [false: bb15, otherwise: bb20]; // bb21[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb22 (cleanup): {
+        _11 = discriminant(_1);          // bb22[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+        switchInt(move _11) -> [0isize: bb17, otherwise: bb19]; // bb22[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+
+    bb23 (cleanup): {
+        switchInt(_7) -> [false: bb16, otherwise: bb22]; // bb23[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2
+    }
+}
index 54c89b85f42d7945062310d3065c64fbb6366c7c..7d308980b9071947aa4f6cd5a9cc4c2c100c568c 100644 (file)
@@ -1,6 +1,7 @@
 // We must mark a variable whose initialization fails due to an
 // abort statement as StorageDead.
 
+// EMIT_MIR rustc.main.mir_map.0.mir
 fn main() {
     loop {
         let beacon = {
@@ -12,82 +13,3 @@ fn main() {
         drop(&beacon);
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.mir_map.0.mir
-// fn main() -> (){
-//     let mut _0: ();
-//     let mut _1: ();
-//     let _2: i32;
-//     let mut _3: bool;
-//     let mut _4: !;
-//     let _5: ();
-//     let mut _6: &i32;
-//     scope 1 {
-//         debug beacon => _2;
-//     }
-//     bb0: {
-//         goto -> bb1;
-//     }
-//     bb1: {
-//         falseUnwind -> [real: bb3, cleanup: bb4];
-//     }
-//     bb2: {
-//         goto -> bb14;
-//     }
-//     bb3: {
-//         StorageLive(_2);
-//         StorageLive(_3);
-//         _3 = const true;
-//         FakeRead(ForMatchedPlace, _3);
-//         switchInt(_3) -> [false: bb5, otherwise: bb6];
-//     }
-//     bb4 (cleanup): {
-//         resume;
-//     }
-//     bb5: {
-//         falseEdges -> [real: bb7, imaginary: bb6];
-//     }
-//     bb6: {
-//         _0 = ();
-//         goto -> bb8;
-//     }
-//     bb7: {
-//         _2 = const 4i32;
-//         goto -> bb12;
-//     }
-//     bb8: {
-//         StorageDead(_3);
-//         goto -> bb9;
-//     }
-//     bb9: {
-//         StorageDead(_2);
-//         goto -> bb2;
-//     }
-//     bb10: {
-//         _4 = ();
-//         unreachable;
-//     }
-//     bb11: {
-//         goto -> bb12;
-//     }
-//     bb12: {
-//         FakeRead(ForLet, _2);
-//         StorageDead(_3);
-//         StorageLive(_5);
-//         StorageLive(_6);
-//         _6 = &_2;
-//         _5 = const std::mem::drop::<&i32>(move _6) -> [return: bb13, unwind: bb4];
-//     }
-//     bb13: {
-//         StorageDead(_6);
-//         StorageDead(_5);
-//         _1 = ();
-//         StorageDead(_2);
-//         goto -> bb1;
-//     }
-//     bb14: {
-//         return;
-//     }
-// }
-// END rustc.main.mir_map.0.mir
diff --git a/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir b/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir
new file mode 100644 (file)
index 0000000..03815d5
--- /dev/null
@@ -0,0 +1,110 @@
+// MIR for `main` 0 mir_map
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/issue-49232.rs:5:11: 5:11
+    let mut _1: ();                      // in scope 0 at $DIR/issue-49232.rs:5:1: 15:2
+    let _2: i32;                         // in scope 0 at $DIR/issue-49232.rs:7:13: 7:19
+    let mut _3: bool;                    // in scope 0 at $DIR/issue-49232.rs:8:19: 8:23
+    let mut _4: !;                       // in scope 0 at $DIR/issue-49232.rs:10:25: 10:30
+    let _5: ();                          // in scope 0 at $DIR/issue-49232.rs:13:9: 13:22
+    let mut _6: &i32;                    // in scope 0 at $DIR/issue-49232.rs:13:14: 13:21
+    scope 1 {
+        debug beacon => _2;              // in scope 1 at $DIR/issue-49232.rs:7:13: 7:19
+    }
+
+    bb0: {
+        goto -> bb1;                     // bb0[0]: scope 0 at $DIR/issue-49232.rs:6:5: 14:6
+    }
+
+    bb1: {
+        falseUnwind -> [real: bb3, cleanup: bb4]; // bb1[0]: scope 0 at $DIR/issue-49232.rs:6:5: 14:6
+    }
+
+    bb2: {
+        goto -> bb14;                    // bb2[0]: scope 0 at $DIR/issue-49232.rs:15:2: 15:2
+    }
+
+    bb3: {
+        StorageLive(_2);                 // bb3[0]: scope 0 at $DIR/issue-49232.rs:7:13: 7:19
+        StorageLive(_3);                 // bb3[1]: scope 0 at $DIR/issue-49232.rs:8:19: 8:23
+        _3 = const true;                 // bb3[2]: scope 0 at $DIR/issue-49232.rs:8:19: 8:23
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-49232.rs:8:19: 8:23
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        FakeRead(ForMatchedPlace, _3);   // bb3[3]: scope 0 at $DIR/issue-49232.rs:8:19: 8:23
+        switchInt(_3) -> [false: bb5, otherwise: bb6]; // bb3[4]: scope 0 at $DIR/issue-49232.rs:9:17: 9:22
+    }
+
+    bb4 (cleanup): {
+        resume;                          // bb4[0]: scope 0 at $DIR/issue-49232.rs:5:1: 15:2
+    }
+
+    bb5: {
+        falseEdges -> [real: bb7, imaginary: bb6]; // bb5[0]: scope 0 at $DIR/issue-49232.rs:9:17: 9:22
+    }
+
+    bb6: {
+        _0 = ();                         // bb6[0]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30
+        goto -> bb8;                     // bb6[1]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30
+    }
+
+    bb7: {
+        _2 = const 4i32;                 // bb7[0]: scope 0 at $DIR/issue-49232.rs:9:26: 9:27
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000004))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-49232.rs:9:26: 9:27
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+        goto -> bb12;                    // bb7[1]: scope 0 at $DIR/issue-49232.rs:8:13: 11:14
+    }
+
+    bb8: {
+        StorageDead(_3);                 // bb8[0]: scope 0 at $DIR/issue-49232.rs:12:10: 12:11
+        goto -> bb9;                     // bb8[1]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30
+    }
+
+    bb9: {
+        StorageDead(_2);                 // bb9[0]: scope 0 at $DIR/issue-49232.rs:14:5: 14:6
+        goto -> bb2;                     // bb9[1]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30
+    }
+
+    bb10: {
+        _4 = ();                         // bb10[0]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30
+        unreachable;                     // bb10[1]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30
+    }
+
+    bb11: {
+        goto -> bb12;                    // bb11[0]: scope 0 at $DIR/issue-49232.rs:8:13: 11:14
+    }
+
+    bb12: {
+        FakeRead(ForLet, _2);            // bb12[0]: scope 0 at $DIR/issue-49232.rs:7:13: 7:19
+        StorageDead(_3);                 // bb12[1]: scope 0 at $DIR/issue-49232.rs:12:10: 12:11
+        StorageLive(_5);                 // bb12[2]: scope 1 at $DIR/issue-49232.rs:13:9: 13:22
+        StorageLive(_6);                 // bb12[3]: scope 1 at $DIR/issue-49232.rs:13:14: 13:21
+        _6 = &_2;                        // bb12[4]: scope 1 at $DIR/issue-49232.rs:13:14: 13:21
+        _5 = const std::mem::drop::<&i32>(move _6) -> [return: bb13, unwind: bb4]; // bb12[5]: scope 1 at $DIR/issue-49232.rs:13:9: 13:22
+                                         // ty::Const
+                                         // + ty: fn(&i32) {std::mem::drop::<&i32>}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-49232.rs:13:9: 13:13
+                                         // + literal: Const { ty: fn(&i32) {std::mem::drop::<&i32>}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb13: {
+        StorageDead(_6);                 // bb13[0]: scope 1 at $DIR/issue-49232.rs:13:21: 13:22
+        StorageDead(_5);                 // bb13[1]: scope 1 at $DIR/issue-49232.rs:13:22: 13:23
+        _1 = ();                         // bb13[2]: scope 0 at $DIR/issue-49232.rs:6:10: 14:6
+        StorageDead(_2);                 // bb13[3]: scope 0 at $DIR/issue-49232.rs:14:5: 14:6
+        goto -> bb1;                     // bb13[4]: scope 0 at $DIR/issue-49232.rs:6:5: 14:6
+    }
+
+    bb14: {
+        return;                          // bb14[0]: scope 0 at $DIR/issue-49232.rs:15:2: 15:2
+    }
+}
index 8e619ffdf8b96c14c174750fbe758f174fb7e990..f0d57c572b343d80422d95bd0898deddb529681d 100644 (file)
@@ -1,10 +1,10 @@
 // check that we don't forget to drop the Box if we early return before
 // initializing it
-// ignore-tidy-linelength
 // ignore-wasm32-bare compiled with panic=abort by default
 
 #![feature(box_syntax)]
 
+// EMIT_MIR rustc.test.ElaborateDrops.before.mir
 fn test() -> Option<Box<u32>> {
     Some(box (None?))
 }
@@ -12,80 +12,3 @@ fn test() -> Option<Box<u32>> {
 fn main() {
     test();
 }
-
-// END RUST SOURCE
-// START rustc.test.ElaborateDrops.before.mir
-// fn test() -> std::option::Option<std::boxed::Box<u32>> {
-//     ...
-//     bb0: {
-//         StorageLive(_1);
-//         StorageLive(_2);
-//         _2 = Box(u32);
-//         StorageLive(_3);
-//         StorageLive(_4);
-//         _4 = std::option::Option::<u32>::None;
-//         _3 = const <std::option::Option<u32> as std::ops::Try>::into_result(move _4) -> [return: bb2, unwind: bb3];
-//     }
-//     bb1 (cleanup): {
-//         resume;
-//     }
-//     bb2: {
-//         StorageDead(_4);
-//         _5 = discriminant(_3);
-//         switchInt(move _5) -> [0isize: bb4, 1isize: bb6, otherwise: bb5];
-//     }
-//     bb3 (cleanup): {
-//         drop(_2) -> bb1;
-//     }
-//     bb4: {
-//         StorageLive(_10);
-//         _10 = ((_3 as Ok).0: u32);
-//         (*_2) = _10;
-//         StorageDead(_10);
-//         _1 = move _2;
-//         drop(_2) -> [return: bb12, unwind: bb11];
-//     }
-//     bb5: {
-//         unreachable;
-//     }
-//     bb6: {
-//         StorageLive(_6);
-//         _6 = ((_3 as Err).0: std::option::NoneError);
-//         StorageLive(_8);
-//         StorageLive(_9);
-//         _9 = _6;
-//         _8 = const <std::option::NoneError as std::convert::From<std::option::NoneError>>::from(move _9) -> [return: bb8, unwind: bb3];
-//     }
-//     bb7: {
-//         return;
-//     }
-//     bb8: {
-//         StorageDead(_9);
-//         _0 = const <std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error(move _8) -> [return: bb9, unwind: bb3];
-//     }
-//     bb9: {
-//         StorageDead(_8);
-//         StorageDead(_6);
-//         drop(_2) -> bb10;
-//     }
-//     bb10: {
-//         StorageDead(_2);
-//         StorageDead(_1);
-//         StorageDead(_3);
-//         goto -> bb7;
-//     }
-//     bb11 (cleanup): {
-//         drop(_1) -> bb1;
-//     }
-//     bb12: {
-//         StorageDead(_2);
-//         _0 = std::option::Option::<std::boxed::Box<u32>>::Some(move _1,);
-//         drop(_1) -> bb13;
-//     }
-//     bb13: {
-//         StorageDead(_1);
-//         StorageDead(_3);
-//         goto -> bb7;
-//     }
-// }
-// END rustc.test.ElaborateDrops.before.mir
diff --git a/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir b/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir
new file mode 100644 (file)
index 0000000..c2f9198
--- /dev/null
@@ -0,0 +1,127 @@
+// MIR for `test` before ElaborateDrops
+
+fn test() -> std::option::Option<std::boxed::Box<u32>> {
+    let mut _0: std::option::Option<std::boxed::Box<u32>>; // return place in scope 0 at $DIR/issue-62289.rs:8:14: 8:30
+    let mut _1: std::boxed::Box<u32>;    // in scope 0 at $DIR/issue-62289.rs:9:10: 9:21
+    let mut _2: std::boxed::Box<u32>;    // in scope 0 at $DIR/issue-62289.rs:9:10: 9:21
+    let mut _3: std::result::Result<u32, std::option::NoneError>; // in scope 0 at $DIR/issue-62289.rs:9:15: 9:20
+    let mut _4: std::option::Option<u32>; // in scope 0 at $DIR/issue-62289.rs:9:15: 9:19
+    let mut _5: isize;                   // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+    let _6: std::option::NoneError;      // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+    let mut _7: !;                       // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+    let mut _8: std::option::NoneError;  // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+    let mut _9: std::option::NoneError;  // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+    let _10: u32;                        // in scope 0 at $DIR/issue-62289.rs:9:15: 9:20
+    scope 1 {
+        debug err => _6;                 // in scope 1 at $DIR/issue-62289.rs:9:19: 9:20
+        scope 2 {
+        }
+    }
+    scope 3 {
+        debug val => _10;                // in scope 3 at $DIR/issue-62289.rs:9:15: 9:20
+        scope 4 {
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/issue-62289.rs:9:10: 9:21
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/issue-62289.rs:9:10: 9:21
+        _2 = Box(u32);                   // bb0[2]: scope 0 at $DIR/issue-62289.rs:9:10: 9:21
+        StorageLive(_3);                 // bb0[3]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20
+        StorageLive(_4);                 // bb0[4]: scope 0 at $DIR/issue-62289.rs:9:15: 9:19
+        _4 = std::option::Option::<u32>::None; // bb0[5]: scope 0 at $DIR/issue-62289.rs:9:15: 9:19
+        _3 = const <std::option::Option<u32> as std::ops::Try>::into_result(move _4) -> [return: bb2, unwind: bb3]; // bb0[6]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20
+                                         // ty::Const
+                                         // + ty: fn(std::option::Option<u32>) -> std::result::Result<<std::option::Option<u32> as std::ops::Try>::Ok, <std::option::Option<u32> as std::ops::Try>::Error> {<std::option::Option<u32> as std::ops::Try>::into_result}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-62289.rs:9:15: 9:20
+                                         // + literal: Const { ty: fn(std::option::Option<u32>) -> std::result::Result<<std::option::Option<u32> as std::ops::Try>::Ok, <std::option::Option<u32> as std::ops::Try>::Error> {<std::option::Option<u32> as std::ops::Try>::into_result}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/issue-62289.rs:8:1: 10:2
+    }
+
+    bb2: {
+        StorageDead(_4);                 // bb2[0]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+        _5 = discriminant(_3);           // bb2[1]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+        switchInt(move _5) -> [0isize: bb4, 1isize: bb6, otherwise: bb5]; // bb2[2]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+    }
+
+    bb3 (cleanup): {
+        drop(_2) -> bb1;                 // bb3[0]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21
+    }
+
+    bb4: {
+        StorageLive(_10);                // bb4[0]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20
+        _10 = ((_3 as Ok).0: u32);       // bb4[1]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20
+        (*_2) = _10;                     // bb4[2]: scope 4 at $DIR/issue-62289.rs:9:15: 9:20
+        StorageDead(_10);                // bb4[3]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+        _1 = move _2;                    // bb4[4]: scope 0 at $DIR/issue-62289.rs:9:10: 9:21
+        drop(_2) -> [return: bb12, unwind: bb11]; // bb4[5]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21
+    }
+
+    bb5: {
+        unreachable;                     // bb5[0]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20
+    }
+
+    bb6: {
+        StorageLive(_6);                 // bb6[0]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+        _6 = ((_3 as Err).0: std::option::NoneError); // bb6[1]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+        StorageLive(_8);                 // bb6[2]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20
+        StorageLive(_9);                 // bb6[3]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20
+        _9 = _6;                         // bb6[4]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20
+        _8 = const <std::option::NoneError as std::convert::From<std::option::NoneError>>::from(move _9) -> [return: bb8, unwind: bb3]; // bb6[5]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20
+                                         // ty::Const
+                                         // + ty: fn(std::option::NoneError) -> std::option::NoneError {<std::option::NoneError as std::convert::From<std::option::NoneError>>::from}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-62289.rs:9:19: 9:20
+                                         // + literal: Const { ty: fn(std::option::NoneError) -> std::option::NoneError {<std::option::NoneError as std::convert::From<std::option::NoneError>>::from}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb7: {
+        return;                          // bb7[0]: scope 0 at $DIR/issue-62289.rs:10:2: 10:2
+    }
+
+    bb8: {
+        StorageDead(_9);                 // bb8[0]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20
+        _0 = const <std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error(move _8) -> [return: bb9, unwind: bb3]; // bb8[1]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20
+                                         // ty::Const
+                                         // + ty: fn(<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::Error) -> std::option::Option<std::boxed::Box<u32>> {<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/issue-62289.rs:9:15: 9:20
+                                         // + literal: Const { ty: fn(<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::Error) -> std::option::Option<std::boxed::Box<u32>> {<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb9: {
+        StorageDead(_8);                 // bb9[0]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20
+        StorageDead(_6);                 // bb9[1]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+        drop(_2) -> bb10;                // bb9[2]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21
+    }
+
+    bb10: {
+        StorageDead(_2);                 // bb10[0]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21
+        StorageDead(_1);                 // bb10[1]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22
+        StorageDead(_3);                 // bb10[2]: scope 0 at $DIR/issue-62289.rs:10:1: 10:2
+        goto -> bb7;                     // bb10[3]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20
+    }
+
+    bb11 (cleanup): {
+        drop(_1) -> bb1;                 // bb11[0]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22
+    }
+
+    bb12: {
+        StorageDead(_2);                 // bb12[0]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21
+        _0 = std::option::Option::<std::boxed::Box<u32>>::Some(move _1,); // bb12[1]: scope 0 at $DIR/issue-62289.rs:9:5: 9:22
+        drop(_1) -> bb13;                // bb12[2]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22
+    }
+
+    bb13: {
+        StorageDead(_1);                 // bb13[0]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22
+        StorageDead(_3);                 // bb13[1]: scope 0 at $DIR/issue-62289.rs:10:1: 10:2
+        goto -> bb7;                     // bb13[2]: scope 0 at $DIR/issue-62289.rs:10:2: 10:2
+    }
+}
index 418febbdc01ebc8b5a59fb8c6997d51ad17fa0e6..cb23a4c671b2248f4804b4ca63b536d40849b941 100644 (file)
@@ -2,6 +2,7 @@
 
 // Tests to make sure we correctly generate falseUnwind edges in loops
 
+// EMIT_MIR rustc.main.SimplifyCfg-qualify-consts.after.mir
 fn main() {
     // Exit early at runtime. Since only care about the generated MIR
     // and not the runtime behavior (which is exercised by other tests)
@@ -14,31 +15,3 @@ fn main() {
         continue;
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyCfg-qualify-consts.after.mir
-//    ...
-//    bb1 (cleanup): {
-//        resume;
-//    }
-//    ...
-//    bb3: { // Entry into the loop
-//        _1 = ();
-//        StorageDead(_2);
-//        StorageDead(_1);
-//        StorageLive(_4);
-//        goto -> bb5;
-//    }
-//    ...
-//    bb5: { // The loop_block
-//        falseUnwind -> [real: bb6, cleanup: bb1];
-//    }
-//    bb6: { // The loop body (body_block)
-//        StorageLive(_6);
-//        _6 = const 1i32;
-//        FakeRead(ForLet, _6);
-//        StorageDead(_6);
-//        goto -> bb5;
-//    }
-//    ...
-// END rustc.main.SimplifyCfg-qualify-consts.after.mir
diff --git a/src/test/mir-opt/loop_test/rustc.main.SimplifyCfg-qualify-consts.after.mir b/src/test/mir-opt/loop_test/rustc.main.SimplifyCfg-qualify-consts.after.mir
new file mode 100644 (file)
index 0000000..c458592
--- /dev/null
@@ -0,0 +1,69 @@
+// MIR for `main` after SimplifyCfg-qualify-consts
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/loop_test.rs:6:11: 6:11
+    let _1: ();                          // in scope 0 at $DIR/loop_test.rs:10:5: 12:6
+    let mut _2: bool;                    // in scope 0 at $DIR/loop_test.rs:10:8: 10:12
+    let mut _3: !;                       // in scope 0 at $DIR/loop_test.rs:10:13: 12:6
+    let mut _4: !;                       // in scope 0 at $DIR/loop_test.rs:13:5: 16:6
+    let mut _5: ();                      // in scope 0 at $DIR/loop_test.rs:6:1: 17:2
+    let _6: i32;                         // in scope 0 at $DIR/loop_test.rs:14:13: 14:14
+    scope 1 {
+        debug x => _6;                   // in scope 1 at $DIR/loop_test.rs:14:13: 14:14
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/loop_test.rs:10:5: 12:6
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/loop_test.rs:10:8: 10:12
+        _2 = const true;                 // bb0[2]: scope 0 at $DIR/loop_test.rs:10:8: 10:12
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/loop_test.rs:10:8: 10:12
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        FakeRead(ForMatchedPlace, _2);   // bb0[3]: scope 0 at $DIR/loop_test.rs:10:8: 10:12
+        switchInt(_2) -> [false: bb3, otherwise: bb2]; // bb0[4]: scope 0 at $DIR/loop_test.rs:10:5: 12:6
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/loop_test.rs:6:1: 17:2
+    }
+
+    bb2: {
+        falseEdges -> [real: bb4, imaginary: bb3]; // bb2[0]: scope 0 at $DIR/loop_test.rs:10:5: 12:6
+    }
+
+    bb3: {
+        _1 = ();                         // bb3[0]: scope 0 at $DIR/loop_test.rs:10:5: 12:6
+        StorageDead(_2);                 // bb3[1]: scope 0 at $DIR/loop_test.rs:12:5: 12:6
+        StorageDead(_1);                 // bb3[2]: scope 0 at $DIR/loop_test.rs:12:5: 12:6
+        StorageLive(_4);                 // bb3[3]: scope 0 at $DIR/loop_test.rs:13:5: 16:6
+        goto -> bb5;                     // bb3[4]: scope 0 at $DIR/loop_test.rs:13:5: 16:6
+    }
+
+    bb4: {
+        _0 = ();                         // bb4[0]: scope 0 at $DIR/loop_test.rs:11:9: 11:15
+        StorageDead(_2);                 // bb4[1]: scope 0 at $DIR/loop_test.rs:12:5: 12:6
+        StorageDead(_1);                 // bb4[2]: scope 0 at $DIR/loop_test.rs:12:5: 12:6
+        return;                          // bb4[3]: scope 0 at $DIR/loop_test.rs:17:2: 17:2
+    }
+
+    bb5: {
+        falseUnwind -> [real: bb6, cleanup: bb1]; // bb5[0]: scope 0 at $DIR/loop_test.rs:13:5: 16:6
+    }
+
+    bb6: {
+        StorageLive(_6);                 // bb6[0]: scope 0 at $DIR/loop_test.rs:14:13: 14:14
+        _6 = const 1i32;                 // bb6[1]: scope 0 at $DIR/loop_test.rs:14:17: 14:18
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/loop_test.rs:14:17: 14:18
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        FakeRead(ForLet, _6);            // bb6[2]: scope 0 at $DIR/loop_test.rs:14:13: 14:14
+        StorageDead(_6);                 // bb6[3]: scope 0 at $DIR/loop_test.rs:16:5: 16:6
+        goto -> bb5;                     // bb6[4]: scope 0 at $DIR/loop_test.rs:15:9: 15:17
+    }
+}
index 7afc3bbd6fae86c035f57a1de1eafb39848717df..0e30a15671528437870fb905b0e0f1e671b41ff5 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-wasm32-bare compiled with panic=abort by default
 // Test that StorageDead and Drops are generated properly for bindings in
 // matches:
 // * The MIR should only contain a single drop of `s` and `t`: at the end
@@ -8,6 +9,8 @@
 //   all of the bindings for that scope.
 // * No drop flags are used.
 
+// EMIT_MIR rustc.complicated_match.SimplifyCfg-initial.after.mir
+// EMIT_MIR rustc.complicated_match.ElaborateDrops.after.mir
 fn complicated_match(cond: bool, items: (bool, bool, String)) -> i32 {
     match items {
         (false, a, s) | (a, false, s) if if cond { return 3 } else { a } => 1,
@@ -31,199 +34,3 @@ fn main() {
         assert_eq!(complicated_match(cond, (items_1, items_2, String::new())), result,);
     }
 }
-
-// END RUST SOURCE
-// START rustc.complicated_match.SimplifyCfg-initial.after.mir
-// let mut _0: i32;
-// let mut _3: &bool;                   // Temp for fake borrow of `items.0`
-// let mut _4: &bool;                   // Temp for fake borrow of `items.1`
-// let _5: bool;                        // `a` in arm
-// let _6: &bool;                       // `a` in guard
-// let _7: std::string::String;         // `s` in arm
-// let _8: &std::string::String;        // `s` in guard
-// let mut _9: bool;                    // `if cond { return 3 } else { a }`
-// let mut _10: bool;                   // `cond`
-// let mut _11: !;                      // `return 3`
-// let mut _12: bool;                   // `if cond { return 3 } else { a }`
-// let mut _13: bool;                   // `cond`
-// let mut _14: !;                      // `return 3`
-// let _15: bool;                       // `b`
-// let _16: std::string::String;        // `t`
-// scope 1 {
-//     debug a => _5;
-//     debug a => _6;
-//     debug s => _7;
-//     debug s => _8;
-// }
-// scope 2 {
-//     debug b => _15;
-//     debug t => _16;
-// }
-// bb0: {
-//     FakeRead(ForMatchedPlace, _2);
-//     switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3];
-// }
-// bb1 (cleanup): {
-//     resume;
-// }
-// bb2: {                               // pre-binding for arm 1 first pattern
-//     falseEdges -> [real: bb9, imaginary: bb4];
-// }
-// bb3: {
-//     switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5];
-// }
-// bb4: {                               // pre-binding for arm 1 second pattern
-//     falseEdges -> [real: bb18, imaginary: bb6];
-// }
-// bb5: {
-//     switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6];
-// }
-// bb6: {                               // pre-binding for arm 2 first pattern
-//     falseEdges -> [real: bb26, imaginary: bb7];
-// }
-// bb7: {                               // bindings for arm 2 - second pattern
-//     StorageLive(_15);
-//     _15 = (_2.1: bool);
-//     StorageLive(_16);
-//     _16 = move (_2.2: std::string::String);
-//     goto -> bb25;
-// }
-// bb8: {                               // arm 1
-//     _0 = const 1i32;
-//     drop(_7) -> [return: bb24, unwind: bb14];
-// }
-// bb9: {                               // guard - first time
-//     StorageLive(_6);
-//     _6 = &(_2.1: bool);
-//     StorageLive(_8);
-//     _8 = &(_2.2: std::string::String);
-//     _3 = &shallow (_2.0: bool);
-//     _4 = &shallow (_2.1: bool);
-//     StorageLive(_9);
-//     StorageLive(_10);
-//     _10 = _1;
-//     FakeRead(ForMatchedPlace, _10);
-//     switchInt(_10) -> [false: bb11, otherwise: bb10];
-// }
-// bb10: {
-//     falseEdges -> [real: bb12, imaginary: bb11];
-// }
-// bb11: {                              // `else` block - first time
-//     _9 = (*_6);
-//     StorageDead(_10);
-//     switchInt(move _9) -> [false: bb17, otherwise: bb16];
-// }
-// bb12: {                              // `return 3` - first time
-//     _0 = const 3i32;
-//     StorageDead(_10);
-//     StorageDead(_9);
-//     StorageDead(_8);
-//     StorageDead(_6);
-//     goto -> bb15;
-// }
-// bb13: {
-//     return;
-// }
-// bb14 (cleanup): {
-//     drop(_2) -> bb1;
-// }
-// bb15: {
-//     drop(_2) -> [return: bb13, unwind: bb1];
-// }
-// bb16: {
-//     StorageDead(_9);
-//     FakeRead(ForMatchGuard, _3);
-//     FakeRead(ForMatchGuard, _4);
-//     FakeRead(ForGuardBinding, _6);
-//     FakeRead(ForGuardBinding, _8);
-//     StorageLive(_5);
-//     _5 = (_2.1: bool);
-//     StorageLive(_7);
-//     _7 = move (_2.2: std::string::String);
-//     goto -> bb8;
-// }
-// bb17: {                              // guard otherwise case - first time
-//     StorageDead(_9);
-//     StorageDead(_8);
-//     StorageDead(_6);
-//     falseEdges -> [real: bb3, imaginary: bb4];
-// }
-// bb18: {                              // guard - second time
-//     StorageLive(_6);
-//     _6 = &(_2.0: bool);
-//     StorageLive(_8);
-//     _8 = &(_2.2: std::string::String);
-//     _3 = &shallow (_2.0: bool);
-//     _4 = &shallow (_2.1: bool);
-//     StorageLive(_12);
-//     StorageLive(_13);
-//     _13 = _1;
-//     FakeRead(ForMatchedPlace, _13);
-//     switchInt(_13) -> [false: bb20, otherwise: bb19];
-// }
-// bb19: {
-//     falseEdges -> [real: bb21, imaginary: bb20];
-// }
-// bb20: {                              // `else` block - second time
-//     _12 = (*_6);
-//     StorageDead(_13);
-//     switchInt(move _12) -> [false: bb23, otherwise: bb22];
-// }
-// bb21: {
-//     _0 = const 3i32;
-//     StorageDead(_13);
-//     StorageDead(_12);
-//     StorageDead(_8);
-//     StorageDead(_6);
-//     goto -> bb15;
-// }
-// bb22: {                              // bindings for arm 1
-//     StorageDead(_12);
-//     FakeRead(ForMatchGuard, _3);
-//     FakeRead(ForMatchGuard, _4);
-//     FakeRead(ForGuardBinding, _6);
-//     FakeRead(ForGuardBinding, _8);
-//     StorageLive(_5);
-//     _5 = (_2.0: bool);
-//     StorageLive(_7);
-//     _7 = move (_2.2: std::string::String);
-//     goto -> bb8;
-// }
-// bb23: {                              // Guard otherwise case - second time
-//     StorageDead(_12);
-//     StorageDead(_8);
-//     StorageDead(_6);
-//     falseEdges -> [real: bb5, imaginary: bb6];
-// }
-// bb24: {                              // rest of arm 1
-//     StorageDead(_7);
-//     StorageDead(_5);
-//     StorageDead(_8);
-//     StorageDead(_6);
-//     goto -> bb28;
-// }
-// bb25: {                              // arm 2
-//     _0 = const 2i32;
-//     drop(_16) -> [return: bb27, unwind: bb14];
-// }
-// bb26: {                              // bindings for arm 2 - first pattern
-//     StorageLive(_15);
-//     _15 = (_2.1: bool);
-//     StorageLive(_16);
-//     _16 = move (_2.2: std::string::String);
-//     goto -> bb25;
-// }
-
-// bb27: {                              // rest of arm 2
-//     StorageDead(_16);
-//     StorageDead(_15);
-//     goto -> bb28;
-// }
-// bb28: {
-//     drop(_2) -> [return: bb13, unwind: bb1];
-// }
-// END rustc.complicated_match.SimplifyCfg-initial.after.mir
-// START rustc.complicated_match.ElaborateDrops.after.mir
-// let _16: std::string::String;      // No drop flags, which would come after this.
-// scope 1 {
-// END rustc.complicated_match.ElaborateDrops.after.mir
diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir
new file mode 100644 (file)
index 0000000..0b60f4f
--- /dev/null
@@ -0,0 +1,235 @@
+// MIR for `complicated_match` after ElaborateDrops
+
+fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 {
+    debug cond => _1;                    // in scope 0 at $DIR/match-arm-scopes.rs:14:22: 14:26
+    debug items => _2;                   // in scope 0 at $DIR/match-arm-scopes.rs:14:34: 14:39
+    let mut _0: i32;                     // return place in scope 0 at $DIR/match-arm-scopes.rs:14:66: 14:69
+    let mut _3: &bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+    let mut _4: &bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+    let _5: bool;                        // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+    let _6: &bool;                       // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+    let _7: std::string::String;         // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+    let _8: &std::string::String;        // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+    let mut _9: bool;                    // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    let mut _10: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+    let mut _11: !;                      // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60
+    let mut _12: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    let mut _13: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+    let mut _14: !;                      // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60
+    let _15: bool;                       // in scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17
+    let _16: std::string::String;        // in scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20
+    scope 1 {
+        debug a => _5;                   // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        debug a => _6;                   // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        debug s => _7;                   // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        debug s => _8;                   // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21
+    }
+    scope 2 {
+        debug b => _15;                  // in scope 2 at $DIR/match-arm-scopes.rs:17:16: 17:17
+        debug t => _16;                  // in scope 2 at $DIR/match-arm-scopes.rs:17:19: 17:20
+    }
+
+    bb0: {
+        switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb2]; // bb0[0]: scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:15
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/match-arm-scopes.rs:14:1: 19:2
+    }
+
+    bb2: {
+        switchInt((_2.1: bool)) -> [false: bb14, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/match-arm-scopes.rs:16:29: 16:34
+    }
+
+    bb3: {
+        switchInt((_2.0: bool)) -> [false: bb4, otherwise: bb21]; // bb3[0]: scope 0 at $DIR/match-arm-scopes.rs:17:10: 17:14
+    }
+
+    bb4: {
+        StorageLive(_15);                // bb4[0]: scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33
+        _15 = (_2.1: bool);              // bb4[1]: scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33
+        StorageLive(_16);                // bb4[2]: scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36
+        _16 = move (_2.2: std::string::String); // bb4[3]: scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36
+        goto -> bb20;                    // bb4[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb5: {
+        _0 = const 1i32;                 // bb5[0]: scope 1 at $DIR/match-arm-scopes.rs:16:77: 16:78
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/match-arm-scopes.rs:16:77: 16:78
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        drop(_7) -> [return: bb19, unwind: bb10]; // bb5[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+    }
+
+    bb6: {
+        StorageLive(_6);                 // bb6[0]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        _6 = &(_2.1: bool);              // bb6[1]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        StorageLive(_8);                 // bb6[2]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        _8 = &(_2.2: std::string::String); // bb6[3]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        StorageLive(_9);                 // bb6[4]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+        StorageLive(_10);                // bb6[5]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        _10 = _1;                        // bb6[6]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        switchInt(_10) -> [false: bb7, otherwise: bb8]; // bb6[7]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb7: {
+        _9 = (*_6);                      // bb7[0]: scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71
+        StorageDead(_10);                // bb7[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        switchInt(move _9) -> [false: bb13, otherwise: bb12]; // bb7[2]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb8: {
+        _0 = const 3i32;                 // bb8[0]: scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match-arm-scopes.rs:16:59: 16:60
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        StorageDead(_10);                // bb8[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        StorageDead(_9);                 // bb8[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb8[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb8[4]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        goto -> bb11;                    // bb8[5]: scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60
+    }
+
+    bb9: {
+        return;                          // bb9[0]: scope 0 at $DIR/match-arm-scopes.rs:19:2: 19:2
+    }
+
+    bb10 (cleanup): {
+        goto -> bb25;                    // bb10[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb11: {
+        drop(_2) -> [return: bb9, unwind: bb1]; // bb11[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb12: {
+        StorageDead(_9);                 // bb12[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageLive(_5);                 // bb12[1]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        _5 = (_2.1: bool);               // bb12[2]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        StorageLive(_7);                 // bb12[3]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        _7 = move (_2.2: std::string::String); // bb12[4]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        goto -> bb5;                     // bb12[5]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb13: {
+        StorageDead(_9);                 // bb13[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb13[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb13[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        goto -> bb2;                     // bb13[3]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb14: {
+        StorageLive(_6);                 // bb14[0]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27
+        _6 = &(_2.0: bool);              // bb14[1]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27
+        StorageLive(_8);                 // bb14[2]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37
+        _8 = &(_2.2: std::string::String); // bb14[3]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37
+        StorageLive(_12);                // bb14[4]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+        StorageLive(_13);                // bb14[5]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        _13 = _1;                        // bb14[6]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        switchInt(_13) -> [false: bb15, otherwise: bb16]; // bb14[7]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb15: {
+        _12 = (*_6);                     // bb15[0]: scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71
+        StorageDead(_13);                // bb15[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        switchInt(move _12) -> [false: bb18, otherwise: bb17]; // bb15[2]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb16: {
+        _0 = const 3i32;                 // bb16[0]: scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match-arm-scopes.rs:16:59: 16:60
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        StorageDead(_13);                // bb16[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        StorageDead(_12);                // bb16[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb16[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb16[4]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        goto -> bb11;                    // bb16[5]: scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60
+    }
+
+    bb17: {
+        StorageDead(_12);                // bb17[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageLive(_5);                 // bb17[1]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27
+        _5 = (_2.0: bool);               // bb17[2]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27
+        StorageLive(_7);                 // bb17[3]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37
+        _7 = move (_2.2: std::string::String); // bb17[4]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37
+        goto -> bb5;                     // bb17[5]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb18: {
+        StorageDead(_12);                // bb18[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb18[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb18[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        goto -> bb3;                     // bb18[3]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb19: {
+        StorageDead(_7);                 // bb19[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_5);                 // bb19[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb19[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb19[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        goto -> bb23;                    // bb19[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb20: {
+        _0 = const 2i32;                 // bb20[0]: scope 2 at $DIR/match-arm-scopes.rs:17:41: 17:42
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/match-arm-scopes.rs:17:41: 17:42
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        drop(_16) -> [return: bb22, unwind: bb10]; // bb20[1]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43
+    }
+
+    bb21: {
+        StorageLive(_15);                // bb21[0]: scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17
+        _15 = (_2.1: bool);              // bb21[1]: scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17
+        StorageLive(_16);                // bb21[2]: scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20
+        _16 = move (_2.2: std::string::String); // bb21[3]: scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20
+        goto -> bb20;                    // bb21[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb22: {
+        StorageDead(_16);                // bb22[0]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43
+        StorageDead(_15);                // bb22[1]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43
+        goto -> bb23;                    // bb22[2]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb23: {
+        goto -> bb29;                    // bb23[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb24 (cleanup): {
+        goto -> bb1;                     // bb24[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb25 (cleanup): {
+        goto -> bb24;                    // bb25[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb26: {
+        goto -> bb9;                     // bb26[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb27 (cleanup): {
+        goto -> bb1;                     // bb27[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb28 (cleanup): {
+        goto -> bb27;                    // bb28[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb29: {
+        goto -> bb26;                    // bb29[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+}
diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir
new file mode 100644 (file)
index 0000000..80ce94a
--- /dev/null
@@ -0,0 +1,246 @@
+// MIR for `complicated_match` after SimplifyCfg-initial
+
+fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 {
+    debug cond => _1;                    // in scope 0 at $DIR/match-arm-scopes.rs:14:22: 14:26
+    debug items => _2;                   // in scope 0 at $DIR/match-arm-scopes.rs:14:34: 14:39
+    let mut _0: i32;                     // return place in scope 0 at $DIR/match-arm-scopes.rs:14:66: 14:69
+    let mut _3: &bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+    let mut _4: &bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+    let _5: bool;                        // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+    let _6: &bool;                       // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+    let _7: std::string::String;         // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+    let _8: &std::string::String;        // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+    let mut _9: bool;                    // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    let mut _10: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+    let mut _11: !;                      // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60
+    let mut _12: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    let mut _13: bool;                   // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+    let mut _14: !;                      // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60
+    let _15: bool;                       // in scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17
+    let _16: std::string::String;        // in scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20
+    scope 1 {
+        debug a => _5;                   // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        debug a => _6;                   // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        debug s => _7;                   // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        debug s => _8;                   // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21
+    }
+    scope 2 {
+        debug b => _15;                  // in scope 2 at $DIR/match-arm-scopes.rs:17:16: 17:17
+        debug t => _16;                  // in scope 2 at $DIR/match-arm-scopes.rs:17:19: 17:20
+    }
+
+    bb0: {
+        FakeRead(ForMatchedPlace, _2);   // bb0[0]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+        switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3]; // bb0[1]: scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:15
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/match-arm-scopes.rs:14:1: 19:2
+    }
+
+    bb2: {
+        falseEdges -> [real: bb9, imaginary: bb4]; // bb2[0]: scope 0 at $DIR/match-arm-scopes.rs:16:9: 16:22
+    }
+
+    bb3: {
+        switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5]; // bb3[0]: scope 0 at $DIR/match-arm-scopes.rs:16:29: 16:34
+    }
+
+    bb4: {
+        falseEdges -> [real: bb18, imaginary: bb6]; // bb4[0]: scope 0 at $DIR/match-arm-scopes.rs:16:25: 16:38
+    }
+
+    bb5: {
+        switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6]; // bb5[0]: scope 0 at $DIR/match-arm-scopes.rs:17:10: 17:14
+    }
+
+    bb6: {
+        falseEdges -> [real: bb26, imaginary: bb7]; // bb6[0]: scope 0 at $DIR/match-arm-scopes.rs:17:9: 17:21
+    }
+
+    bb7: {
+        StorageLive(_15);                // bb7[0]: scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33
+        _15 = (_2.1: bool);              // bb7[1]: scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33
+        StorageLive(_16);                // bb7[2]: scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36
+        _16 = move (_2.2: std::string::String); // bb7[3]: scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36
+        goto -> bb25;                    // bb7[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb8: {
+        _0 = const 1i32;                 // bb8[0]: scope 1 at $DIR/match-arm-scopes.rs:16:77: 16:78
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/match-arm-scopes.rs:16:77: 16:78
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        drop(_7) -> [return: bb24, unwind: bb14]; // bb8[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+    }
+
+    bb9: {
+        StorageLive(_6);                 // bb9[0]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        _6 = &(_2.1: bool);              // bb9[1]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        StorageLive(_8);                 // bb9[2]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        _8 = &(_2.2: std::string::String); // bb9[3]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        _3 = &shallow (_2.0: bool);      // bb9[4]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+        _4 = &shallow (_2.1: bool);      // bb9[5]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+        StorageLive(_9);                 // bb9[6]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+        StorageLive(_10);                // bb9[7]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        _10 = _1;                        // bb9[8]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        FakeRead(ForMatchedPlace, _10);  // bb9[9]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        switchInt(_10) -> [false: bb11, otherwise: bb10]; // bb9[10]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb10: {
+        falseEdges -> [real: bb12, imaginary: bb11]; // bb10[0]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb11: {
+        _9 = (*_6);                      // bb11[0]: scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71
+        StorageDead(_10);                // bb11[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        switchInt(move _9) -> [false: bb17, otherwise: bb16]; // bb11[2]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb12: {
+        _0 = const 3i32;                 // bb12[0]: scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match-arm-scopes.rs:16:59: 16:60
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        StorageDead(_10);                // bb12[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        StorageDead(_9);                 // bb12[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb12[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb12[4]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        goto -> bb15;                    // bb12[5]: scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60
+    }
+
+    bb13: {
+        return;                          // bb13[0]: scope 0 at $DIR/match-arm-scopes.rs:19:2: 19:2
+    }
+
+    bb14 (cleanup): {
+        drop(_2) -> bb1;                 // bb14[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb15: {
+        drop(_2) -> [return: bb13, unwind: bb1]; // bb15[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+
+    bb16: {
+        StorageDead(_9);                 // bb16[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        FakeRead(ForMatchGuard, _3);     // bb16[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        FakeRead(ForMatchGuard, _4);     // bb16[2]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        FakeRead(ForGuardBinding, _6);   // bb16[3]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        FakeRead(ForGuardBinding, _8);   // bb16[4]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        StorageLive(_5);                 // bb16[5]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        _5 = (_2.1: bool);               // bb16[6]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18
+        StorageLive(_7);                 // bb16[7]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        _7 = move (_2.2: std::string::String); // bb16[8]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21
+        goto -> bb8;                     // bb16[9]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb17: {
+        StorageDead(_9);                 // bb17[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb17[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb17[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        falseEdges -> [real: bb3, imaginary: bb4]; // bb17[3]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb18: {
+        StorageLive(_6);                 // bb18[0]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27
+        _6 = &(_2.0: bool);              // bb18[1]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27
+        StorageLive(_8);                 // bb18[2]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37
+        _8 = &(_2.2: std::string::String); // bb18[3]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37
+        _3 = &shallow (_2.0: bool);      // bb18[4]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+        _4 = &shallow (_2.1: bool);      // bb18[5]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16
+        StorageLive(_12);                // bb18[6]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+        StorageLive(_13);                // bb18[7]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        _13 = _1;                        // bb18[8]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        FakeRead(ForMatchedPlace, _13);  // bb18[9]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49
+        switchInt(_13) -> [false: bb20, otherwise: bb19]; // bb18[10]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb19: {
+        falseEdges -> [real: bb21, imaginary: bb20]; // bb19[0]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb20: {
+        _12 = (*_6);                     // bb20[0]: scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71
+        StorageDead(_13);                // bb20[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        switchInt(move _12) -> [false: bb23, otherwise: bb22]; // bb20[2]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb21: {
+        _0 = const 3i32;                 // bb21[0]: scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match-arm-scopes.rs:16:59: 16:60
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        StorageDead(_13);                // bb21[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        StorageDead(_12);                // bb21[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb21[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb21[4]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        goto -> bb15;                    // bb21[5]: scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60
+    }
+
+    bb22: {
+        StorageDead(_12);                // bb22[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        FakeRead(ForMatchGuard, _3);     // bb22[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        FakeRead(ForMatchGuard, _4);     // bb22[2]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        FakeRead(ForGuardBinding, _6);   // bb22[3]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        FakeRead(ForGuardBinding, _8);   // bb22[4]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73
+        StorageLive(_5);                 // bb22[5]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27
+        _5 = (_2.0: bool);               // bb22[6]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27
+        StorageLive(_7);                 // bb22[7]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37
+        _7 = move (_2.2: std::string::String); // bb22[8]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37
+        goto -> bb8;                     // bb22[9]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb23: {
+        StorageDead(_12);                // bb23[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb23[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb23[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        falseEdges -> [real: bb5, imaginary: bb6]; // bb23[3]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73
+    }
+
+    bb24: {
+        StorageDead(_7);                 // bb24[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_5);                 // bb24[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_8);                 // bb24[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        StorageDead(_6);                 // bb24[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79
+        goto -> bb28;                    // bb24[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb25: {
+        _0 = const 2i32;                 // bb25[0]: scope 2 at $DIR/match-arm-scopes.rs:17:41: 17:42
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/match-arm-scopes.rs:17:41: 17:42
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        drop(_16) -> [return: bb27, unwind: bb14]; // bb25[1]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43
+    }
+
+    bb26: {
+        StorageLive(_15);                // bb26[0]: scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17
+        _15 = (_2.1: bool);              // bb26[1]: scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17
+        StorageLive(_16);                // bb26[2]: scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20
+        _16 = move (_2.2: std::string::String); // bb26[3]: scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20
+        goto -> bb25;                    // bb26[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb27: {
+        StorageDead(_16);                // bb27[0]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43
+        StorageDead(_15);                // bb27[1]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43
+        goto -> bb28;                    // bb27[2]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6
+    }
+
+    bb28: {
+        drop(_2) -> [return: bb13, unwind: bb1]; // bb28[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2
+    }
+}
index 237828d9020dbd25efef8d5317e7238e4a3577b5..91f4aad165edd13f7cbe9397fa29e09252aa5e57 100644 (file)
@@ -10,6 +10,7 @@ fn guard2(_: i32) -> bool {
 
 // no_mangle to make sure this gets instantiated even in an executable.
 #[no_mangle]
+// EMIT_MIR rustc.full_tested_match.PromoteTemps.after.mir
 pub fn full_tested_match() {
     let _ = match Some(42) {
         Some(x) if guard() => (1, x),
@@ -20,6 +21,7 @@ pub fn full_tested_match() {
 
 // no_mangle to make sure this gets instantiated even in an executable.
 #[no_mangle]
+// EMIT_MIR rustc.full_tested_match2.PromoteTemps.before.mir
 pub fn full_tested_match2() {
     let _ = match Some(42) {
         Some(x) if guard() => (1, x),
@@ -28,6 +30,7 @@ pub fn full_tested_match2() {
     };
 }
 
+// EMIT_MIR rustc.main.PromoteTemps.before.mir
 fn main() {
     let _ = match Some(1) {
         Some(_w) if guard() => 1,
@@ -36,245 +39,3 @@ fn main() {
         _z => 4,
     };
 }
-
-// END RUST SOURCE
-//
-// START rustc.full_tested_match.PromoteTemps.after.mir
-//  bb0: {
-//      ...
-//      _2 = std::option::Option::<i32>::Some(const 42i32,);
-//      FakeRead(ForMatchedPlace, _2);
-//      _3 = discriminant(_2);
-//      switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5];
-//  }
-//  bb1 (cleanup): {
-//      resume;
-//  }
-//  bb2: {  // pre_binding3 and arm3
-//      _1 = (const 3i32, const 3i32);
-//      goto -> bb11;
-//  }
-//  bb3: {
-//      falseEdges -> [real: bb6, imaginary: bb4]; //pre_binding1
-//  }
-//  bb4: {
-//      falseEdges -> [real: bb10, imaginary: bb2]; //pre_binding2
-//  }
-//  bb5: {
-//      unreachable;
-//  }
-//  bb6: { // binding1 and guard
-//      StorageLive(_6);
-//      _11 = const full_tested_match::promoted[0];
-//      _6 = &(((*_11) as Some).0: i32);
-//      _4 = &shallow _2;
-//      StorageLive(_7);
-//      _7 = const guard() -> [return: bb7, unwind: bb1];
-//  }
-//  bb7: { // end of guard
-//      switchInt(move _7) -> [false: bb9, otherwise: bb8];
-//  }
-//  bb8: { // arm1
-//      StorageDead(_7);
-//      FakeRead(ForMatchGuard, _4);
-//      FakeRead(ForGuardBinding, _6);
-//      StorageLive(_5);
-//      _5 = ((_2 as Some).0: i32);
-//      StorageLive(_8);
-//      _8 = _5;
-//      _1 = (const 1i32, move _8);
-//      StorageDead(_8);
-//      StorageDead(_5);
-//      StorageDead(_6);
-//      goto -> bb11;
-//  }
-//  bb9: { // to pre_binding2
-//      StorageDead(_7);
-//      StorageDead(_6);
-//      goto -> bb4;
-//  }
-//  bb10: { // arm2
-//      StorageLive(_9);
-//      _9 = ((_2 as Some).0: i32);
-//      StorageLive(_10);
-//      _10 = _9;
-//      _1 = (const 2i32, move _10);
-//      StorageDead(_10);
-//      StorageDead(_9);
-//      goto -> bb11;
-//  }
-//  bb11: {
-//      StorageDead(_2);
-//      StorageDead(_1);
-//      _0 = ();
-//      return;
-//  }
-// END rustc.full_tested_match.PromoteTemps.after.mir
-//
-// START rustc.full_tested_match2.PromoteTemps.before.mir
-//  bb0: {
-//      ...
-//      _2 = std::option::Option::<i32>::Some(const 42i32,);
-//      FakeRead(ForMatchedPlace, _2);
-//      _3 = discriminant(_2);
-//      switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5];
-//  }
-//  bb1 (cleanup): {
-//      resume;
-//  }
-//  bb2: { // pre_binding2
-//      falseEdges -> [real: bb10, imaginary: bb4];
-//  }
-//  bb3: { // pre_binding1
-//      falseEdges -> [real: bb6, imaginary: bb2];
-//  }
-//  bb4: { // binding3 and arm3
-//      StorageLive(_9);
-//      _9 = ((_2 as Some).0: i32);
-//      StorageLive(_10);
-//      _10 = _9;
-//      _1 = (const 2i32, move _10);
-//      StorageDead(_10);
-//      StorageDead(_9);
-//      goto -> bb11;
-//  }
-//  bb5: {
-//      unreachable;
-//  }
-//  bb6: {
-//      StorageLive(_6);
-//      _6 = &((_2 as Some).0: i32);
-//      _4 = &shallow _2;
-//      StorageLive(_7);
-//      _7 = const guard() -> [return: bb7, unwind: bb1];
-//  }
-//  bb7: { // end of guard
-//      switchInt(move _7) -> [false: bb9, otherwise: bb8];
-//  }
-//  bb8: {
-//      StorageDead(_7);
-//      FakeRead(ForMatchGuard, _4);
-//      FakeRead(ForGuardBinding, _6);
-//      StorageLive(_5);
-//      _5 = ((_2 as Some).0: i32);
-//      StorageLive(_8);
-//      _8 = _5;
-//      _1 = (const 1i32, move _8);
-//      StorageDead(_8);
-//      StorageDead(_5);
-//      StorageDead(_6);
-//      goto -> bb11;
-//  }
-//  bb9: { // to pre_binding3 (can skip 2 since this is `Some`)
-//      StorageDead(_7);
-//      StorageDead(_6);
-//      falseEdges -> [real: bb4, imaginary: bb2];
-//  }
-//  bb10: { // arm2
-//      _1 = (const 3i32, const 3i32);
-//      goto -> bb11;
-//  }
-//  bb11: {
-//      StorageDead(_2);
-//      StorageDead(_1);
-//      _0 = ();
-//      return;
-//  }
-// END rustc.full_tested_match2.PromoteTemps.before.mir
-//
-// START rustc.main.PromoteTemps.before.mir
-//  bb0: {
-//     ...
-//      _2 = std::option::Option::<i32>::Some(const 1i32,);
-//      FakeRead(ForMatchedPlace, _2);
-//      _4 = discriminant(_2);
-//      switchInt(move _4) -> [1isize: bb3, otherwise: bb2];
-//  }
-//  bb1 (cleanup): {
-//      resume;
-//  }
-//  bb2: {
-//      falseEdges -> [real: bb10, imaginary: bb5];
-//  }
-//  bb3: {
-//      falseEdges -> [real: bb6, imaginary: bb2];
-//  }
-//  bb4: {
-//      StorageLive(_14);
-//      _14 = _2;
-//      _1 = const 4i32;
-//      StorageDead(_14);
-//      goto -> bb15;
-//  }
-//  bb5: {
-//      falseEdges -> [real: bb11, imaginary: bb4];
-//  }
-//  bb6: { //end of guard1
-//      StorageLive(_7);
-//      _7 = &((_2 as Some).0: i32);
-//      _5 = &shallow _2;
-//      StorageLive(_8);
-//      _8 = const guard() -> [return: bb7, unwind: bb1];
-//  }
-//  bb7: {
-//      switchInt(move _8) -> [false: bb9, otherwise: bb8];
-//  }
-//  bb8: {
-//      StorageDead(_8);
-//      FakeRead(ForMatchGuard, _5);
-//      FakeRead(ForGuardBinding, _7);
-//      StorageLive(_6);
-//      _6 = ((_2 as Some).0: i32);
-//      _1 = const 1i32;
-//      StorageDead(_6);
-//      StorageDead(_7);
-//      goto -> bb15;
-//  }
-//  bb9: {
-//      StorageDead(_8);
-//      StorageDead(_7);
-//      falseEdges -> [real: bb2, imaginary: bb2];
-//  }
-//  bb10: {  // binding2 & arm2
-//      StorageLive(_9);
-//      _9 = _2;
-//      _1 = const 2i32;
-//      StorageDead(_9);
-//      goto -> bb15;
-//  }
-//  bb11: { // binding3: Some(y) if guard2(y)
-//      StorageLive(_11);
-//      _11 = &((_2 as Some).0: i32);
-//      _5 = &shallow _2;
-//      StorageLive(_12);
-//      StorageLive(_13);
-//      _13 = (*_11);
-//      _12 = const guard2(move _13) -> [return: bb12, unwind: bb1];
-//  }
-//  bb12: { // end of guard2
-//      StorageDead(_13);
-//      switchInt(move _12) -> [false: bb14, otherwise: bb13];
-//  }
-//  bb13: { // binding4 & arm4
-//      StorageDead(_12);
-//      FakeRead(ForMatchGuard, _5);
-//      FakeRead(ForGuardBinding, _11);
-//      StorageLive(_10);
-//      _10 = ((_2 as Some).0: i32);
-//      _1 = const 3i32;
-//      StorageDead(_10);
-//      StorageDead(_11);
-//      goto -> bb15;
-//  }
-//  bb14: {
-//      StorageDead(_12);
-//      StorageDead(_11);
-//      falseEdges -> [real: bb4, imaginary: bb4];
-//  }
-//  bb15: {
-//      StorageDead(_2);
-//      StorageDead(_1);
-//      _0 = ();
-//      return;
-//  }
-// END rustc.main.PromoteTemps.before.mir
diff --git a/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir b/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir
new file mode 100644 (file)
index 0000000..acc03cc
--- /dev/null
@@ -0,0 +1,149 @@
+// MIR for `full_tested_match` after PromoteTemps
+
+fn full_tested_match() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/match_false_edges.rs:14:28: 14:28
+    let mut _1: (i32, i32);              // in scope 0 at $DIR/match_false_edges.rs:15:13: 19:6
+    let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:15:19: 15:27
+    let mut _3: isize;                   // in scope 0 at $DIR/match_false_edges.rs:16:9: 16:16
+    let mut _4: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:15:19: 15:27
+    let _5: i32;                         // in scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
+    let _6: &i32;                        // in scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
+    let mut _7: bool;                    // in scope 0 at $DIR/match_false_edges.rs:16:20: 16:27
+    let mut _8: i32;                     // in scope 0 at $DIR/match_false_edges.rs:16:35: 16:36
+    let _9: i32;                         // in scope 0 at $DIR/match_false_edges.rs:17:14: 17:15
+    let mut _10: i32;                    // in scope 0 at $DIR/match_false_edges.rs:17:24: 17:25
+    let mut _11: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
+    scope 1 {
+    }
+    scope 2 {
+        debug x => _5;                   // in scope 2 at $DIR/match_false_edges.rs:16:14: 16:15
+        debug x => _6;                   // in scope 2 at $DIR/match_false_edges.rs:16:14: 16:15
+    }
+    scope 3 {
+        debug y => _9;                   // in scope 3 at $DIR/match_false_edges.rs:17:14: 17:15
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27
+        _2 = std::option::Option::<i32>::Some(const 42i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x0000002a))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:15:24: 15:26
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
+        FakeRead(ForMatchedPlace, _2);   // bb0[3]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27
+        _3 = discriminant(_2);           // bb0[4]: scope 0 at $DIR/match_false_edges.rs:16:9: 16:16
+        switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5]; // bb0[5]: scope 0 at $DIR/match_false_edges.rs:16:9: 16:16
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/match_false_edges.rs:14:1: 20:2
+    }
+
+    bb2: {
+        _1 = (const 3i32, const 3i32);   // bb2[0]: scope 0 at $DIR/match_false_edges.rs:18:17: 18:23
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:18:18: 18:19
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:18:21: 18:22
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        goto -> bb11;                    // bb2[1]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6
+    }
+
+    bb3: {
+        falseEdges -> [real: bb6, imaginary: bb4]; // bb3[0]: scope 0 at $DIR/match_false_edges.rs:16:9: 16:16
+    }
+
+    bb4: {
+        falseEdges -> [real: bb10, imaginary: bb2]; // bb4[0]: scope 0 at $DIR/match_false_edges.rs:17:9: 17:16
+    }
+
+    bb5: {
+        unreachable;                     // bb5[0]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27
+    }
+
+    bb6: {
+        StorageLive(_6);                 // bb6[0]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
+        _11 = const full_tested_match::promoted[0]; // bb6[1]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
+                                         // ty::Const
+                                         // + ty: &std::option::Option<i32>
+                                         // + val: Unevaluated(DefId(0:5 ~ match_false_edges[317d]::full_tested_match[0]), [], Some(promoted[0]))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:16:14: 16:15
+                                         // + literal: Const { ty: &std::option::Option<i32>, val: Unevaluated(DefId(0:5 ~ match_false_edges[317d]::full_tested_match[0]), [], Some(promoted[0])) }
+        _6 = &(((*_11) as Some).0: i32); // bb6[2]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
+        _4 = &shallow _2;                // bb6[3]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27
+        StorageLive(_7);                 // bb6[4]: scope 0 at $DIR/match_false_edges.rs:16:20: 16:27
+        _7 = const guard() -> [return: bb7, unwind: bb1]; // bb6[5]: scope 0 at $DIR/match_false_edges.rs:16:20: 16:27
+                                         // ty::Const
+                                         // + ty: fn() -> bool {guard}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:16:20: 16:25
+                                         // + literal: Const { ty: fn() -> bool {guard}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb7: {
+        switchInt(move _7) -> [false: bb9, otherwise: bb8]; // bb7[0]: scope 0 at $DIR/match_false_edges.rs:16:20: 16:27
+    }
+
+    bb8: {
+        StorageDead(_7);                 // bb8[0]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38
+        FakeRead(ForMatchGuard, _4);     // bb8[1]: scope 0 at $DIR/match_false_edges.rs:16:26: 16:27
+        FakeRead(ForGuardBinding, _6);   // bb8[2]: scope 0 at $DIR/match_false_edges.rs:16:26: 16:27
+        StorageLive(_5);                 // bb8[3]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
+        _5 = ((_2 as Some).0: i32);      // bb8[4]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
+        StorageLive(_8);                 // bb8[5]: scope 2 at $DIR/match_false_edges.rs:16:35: 16:36
+        _8 = _5;                         // bb8[6]: scope 2 at $DIR/match_false_edges.rs:16:35: 16:36
+        _1 = (const 1i32, move _8);      // bb8[7]: scope 2 at $DIR/match_false_edges.rs:16:31: 16:37
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:16:32: 16:33
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        StorageDead(_8);                 // bb8[8]: scope 2 at $DIR/match_false_edges.rs:16:36: 16:37
+        StorageDead(_5);                 // bb8[9]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38
+        StorageDead(_6);                 // bb8[10]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38
+        goto -> bb11;                    // bb8[11]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6
+    }
+
+    bb9: {
+        StorageDead(_7);                 // bb9[0]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38
+        StorageDead(_6);                 // bb9[1]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38
+        goto -> bb4;                     // bb9[2]: scope 0 at $DIR/match_false_edges.rs:16:20: 16:27
+    }
+
+    bb10: {
+        StorageLive(_9);                 // bb10[0]: scope 0 at $DIR/match_false_edges.rs:17:14: 17:15
+        _9 = ((_2 as Some).0: i32);      // bb10[1]: scope 0 at $DIR/match_false_edges.rs:17:14: 17:15
+        StorageLive(_10);                // bb10[2]: scope 3 at $DIR/match_false_edges.rs:17:24: 17:25
+        _10 = _9;                        // bb10[3]: scope 3 at $DIR/match_false_edges.rs:17:24: 17:25
+        _1 = (const 2i32, move _10);     // bb10[4]: scope 3 at $DIR/match_false_edges.rs:17:20: 17:26
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:17:21: 17:22
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        StorageDead(_10);                // bb10[5]: scope 3 at $DIR/match_false_edges.rs:17:25: 17:26
+        StorageDead(_9);                 // bb10[6]: scope 0 at $DIR/match_false_edges.rs:17:26: 17:27
+        goto -> bb11;                    // bb10[7]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6
+    }
+
+    bb11: {
+        StorageDead(_2);                 // bb11[0]: scope 0 at $DIR/match_false_edges.rs:19:6: 19:7
+        StorageDead(_1);                 // bb11[1]: scope 0 at $DIR/match_false_edges.rs:19:6: 19:7
+        _0 = ();                         // bb11[2]: scope 0 at $DIR/match_false_edges.rs:14:28: 20:2
+        return;                          // bb11[3]: scope 0 at $DIR/match_false_edges.rs:20:2: 20:2
+    }
+}
diff --git a/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir
new file mode 100644 (file)
index 0000000..cc1fa56
--- /dev/null
@@ -0,0 +1,141 @@
+// MIR for `full_tested_match2` before PromoteTemps
+
+fn full_tested_match2() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/match_false_edges.rs:25:29: 25:29
+    let mut _1: (i32, i32);              // in scope 0 at $DIR/match_false_edges.rs:26:13: 30:6
+    let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:26:19: 26:27
+    let mut _3: isize;                   // in scope 0 at $DIR/match_false_edges.rs:27:9: 27:16
+    let mut _4: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:26:19: 26:27
+    let _5: i32;                         // in scope 0 at $DIR/match_false_edges.rs:27:14: 27:15
+    let _6: &i32;                        // in scope 0 at $DIR/match_false_edges.rs:27:14: 27:15
+    let mut _7: bool;                    // in scope 0 at $DIR/match_false_edges.rs:27:20: 27:27
+    let mut _8: i32;                     // in scope 0 at $DIR/match_false_edges.rs:27:35: 27:36
+    let _9: i32;                         // in scope 0 at $DIR/match_false_edges.rs:29:14: 29:15
+    let mut _10: i32;                    // in scope 0 at $DIR/match_false_edges.rs:29:24: 29:25
+    scope 1 {
+    }
+    scope 2 {
+        debug x => _5;                   // in scope 2 at $DIR/match_false_edges.rs:27:14: 27:15
+        debug x => _6;                   // in scope 2 at $DIR/match_false_edges.rs:27:14: 27:15
+    }
+    scope 3 {
+        debug y => _9;                   // in scope 3 at $DIR/match_false_edges.rs:29:14: 29:15
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27
+        _2 = std::option::Option::<i32>::Some(const 42i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x0000002a))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:26:24: 26:26
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
+        FakeRead(ForMatchedPlace, _2);   // bb0[3]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27
+        _3 = discriminant(_2);           // bb0[4]: scope 0 at $DIR/match_false_edges.rs:27:9: 27:16
+        switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5]; // bb0[5]: scope 0 at $DIR/match_false_edges.rs:27:9: 27:16
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/match_false_edges.rs:25:1: 31:2
+    }
+
+    bb2: {
+        falseEdges -> [real: bb10, imaginary: bb4]; // bb2[0]: scope 0 at $DIR/match_false_edges.rs:28:9: 28:13
+    }
+
+    bb3: {
+        falseEdges -> [real: bb6, imaginary: bb2]; // bb3[0]: scope 0 at $DIR/match_false_edges.rs:27:9: 27:16
+    }
+
+    bb4: {
+        StorageLive(_9);                 // bb4[0]: scope 0 at $DIR/match_false_edges.rs:29:14: 29:15
+        _9 = ((_2 as Some).0: i32);      // bb4[1]: scope 0 at $DIR/match_false_edges.rs:29:14: 29:15
+        StorageLive(_10);                // bb4[2]: scope 3 at $DIR/match_false_edges.rs:29:24: 29:25
+        _10 = _9;                        // bb4[3]: scope 3 at $DIR/match_false_edges.rs:29:24: 29:25
+        _1 = (const 2i32, move _10);     // bb4[4]: scope 3 at $DIR/match_false_edges.rs:29:20: 29:26
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:29:21: 29:22
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        StorageDead(_10);                // bb4[5]: scope 3 at $DIR/match_false_edges.rs:29:25: 29:26
+        StorageDead(_9);                 // bb4[6]: scope 0 at $DIR/match_false_edges.rs:29:26: 29:27
+        goto -> bb11;                    // bb4[7]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6
+    }
+
+    bb5: {
+        unreachable;                     // bb5[0]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27
+    }
+
+    bb6: {
+        StorageLive(_6);                 // bb6[0]: scope 0 at $DIR/match_false_edges.rs:27:14: 27:15
+        _6 = &((_2 as Some).0: i32);     // bb6[1]: scope 0 at $DIR/match_false_edges.rs:27:14: 27:15
+        _4 = &shallow _2;                // bb6[2]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27
+        StorageLive(_7);                 // bb6[3]: scope 0 at $DIR/match_false_edges.rs:27:20: 27:27
+        _7 = const guard() -> [return: bb7, unwind: bb1]; // bb6[4]: scope 0 at $DIR/match_false_edges.rs:27:20: 27:27
+                                         // ty::Const
+                                         // + ty: fn() -> bool {guard}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:27:20: 27:25
+                                         // + literal: Const { ty: fn() -> bool {guard}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb7: {
+        switchInt(move _7) -> [false: bb9, otherwise: bb8]; // bb7[0]: scope 0 at $DIR/match_false_edges.rs:27:20: 27:27
+    }
+
+    bb8: {
+        StorageDead(_7);                 // bb8[0]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38
+        FakeRead(ForMatchGuard, _4);     // bb8[1]: scope 0 at $DIR/match_false_edges.rs:27:26: 27:27
+        FakeRead(ForGuardBinding, _6);   // bb8[2]: scope 0 at $DIR/match_false_edges.rs:27:26: 27:27
+        StorageLive(_5);                 // bb8[3]: scope 0 at $DIR/match_false_edges.rs:27:14: 27:15
+        _5 = ((_2 as Some).0: i32);      // bb8[4]: scope 0 at $DIR/match_false_edges.rs:27:14: 27:15
+        StorageLive(_8);                 // bb8[5]: scope 2 at $DIR/match_false_edges.rs:27:35: 27:36
+        _8 = _5;                         // bb8[6]: scope 2 at $DIR/match_false_edges.rs:27:35: 27:36
+        _1 = (const 1i32, move _8);      // bb8[7]: scope 2 at $DIR/match_false_edges.rs:27:31: 27:37
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:27:32: 27:33
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        StorageDead(_8);                 // bb8[8]: scope 2 at $DIR/match_false_edges.rs:27:36: 27:37
+        StorageDead(_5);                 // bb8[9]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38
+        StorageDead(_6);                 // bb8[10]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38
+        goto -> bb11;                    // bb8[11]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6
+    }
+
+    bb9: {
+        StorageDead(_7);                 // bb9[0]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38
+        StorageDead(_6);                 // bb9[1]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38
+        falseEdges -> [real: bb4, imaginary: bb2]; // bb9[2]: scope 0 at $DIR/match_false_edges.rs:27:20: 27:27
+    }
+
+    bb10: {
+        _1 = (const 3i32, const 3i32);   // bb10[0]: scope 0 at $DIR/match_false_edges.rs:28:17: 28:23
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:28:18: 28:19
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:28:21: 28:22
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        goto -> bb11;                    // bb10[1]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6
+    }
+
+    bb11: {
+        StorageDead(_2);                 // bb11[0]: scope 0 at $DIR/match_false_edges.rs:30:6: 30:7
+        StorageDead(_1);                 // bb11[1]: scope 0 at $DIR/match_false_edges.rs:30:6: 30:7
+        _0 = ();                         // bb11[2]: scope 0 at $DIR/match_false_edges.rs:25:29: 31:2
+        return;                          // bb11[3]: scope 0 at $DIR/match_false_edges.rs:31:2: 31:2
+    }
+}
diff --git a/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir
new file mode 100644 (file)
index 0000000..fce497d
--- /dev/null
@@ -0,0 +1,188 @@
+// MIR for `main` before PromoteTemps
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/match_false_edges.rs:34:11: 34:11
+    let mut _1: i32;                     // in scope 0 at $DIR/match_false_edges.rs:35:13: 40:6
+    let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:35:19: 35:26
+    let mut _3: isize;                   // in scope 0 at $DIR/match_false_edges.rs:38:9: 38:16
+    let mut _4: isize;                   // in scope 0 at $DIR/match_false_edges.rs:36:9: 36:17
+    let mut _5: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:35:19: 35:26
+    let _6: i32;                         // in scope 0 at $DIR/match_false_edges.rs:36:14: 36:16
+    let _7: &i32;                        // in scope 0 at $DIR/match_false_edges.rs:36:14: 36:16
+    let mut _8: bool;                    // in scope 0 at $DIR/match_false_edges.rs:36:21: 36:28
+    let _9: std::option::Option<i32>;    // in scope 0 at $DIR/match_false_edges.rs:37:9: 37:11
+    let _10: i32;                        // in scope 0 at $DIR/match_false_edges.rs:38:14: 38:15
+    let _11: &i32;                       // in scope 0 at $DIR/match_false_edges.rs:38:14: 38:15
+    let mut _12: bool;                   // in scope 0 at $DIR/match_false_edges.rs:38:20: 38:29
+    let mut _13: i32;                    // in scope 0 at $DIR/match_false_edges.rs:38:27: 38:28
+    let _14: std::option::Option<i32>;   // in scope 0 at $DIR/match_false_edges.rs:39:9: 39:11
+    scope 1 {
+    }
+    scope 2 {
+        debug _w => _6;                  // in scope 2 at $DIR/match_false_edges.rs:36:14: 36:16
+        debug _w => _7;                  // in scope 2 at $DIR/match_false_edges.rs:36:14: 36:16
+    }
+    scope 3 {
+        debug _x => _9;                  // in scope 3 at $DIR/match_false_edges.rs:37:9: 37:11
+    }
+    scope 4 {
+        debug y => _10;                  // in scope 4 at $DIR/match_false_edges.rs:38:14: 38:15
+        debug y => _11;                  // in scope 4 at $DIR/match_false_edges.rs:38:14: 38:15
+    }
+    scope 5 {
+        debug _z => _14;                 // in scope 5 at $DIR/match_false_edges.rs:39:9: 39:11
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26
+        _2 = std::option::Option::<i32>::Some(const 1i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:35:24: 35:25
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        FakeRead(ForMatchedPlace, _2);   // bb0[3]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26
+        _4 = discriminant(_2);           // bb0[4]: scope 0 at $DIR/match_false_edges.rs:36:9: 36:17
+        switchInt(move _4) -> [1isize: bb3, otherwise: bb2]; // bb0[5]: scope 0 at $DIR/match_false_edges.rs:36:9: 36:17
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/match_false_edges.rs:34:1: 41:2
+    }
+
+    bb2: {
+        falseEdges -> [real: bb10, imaginary: bb5]; // bb2[0]: scope 0 at $DIR/match_false_edges.rs:37:9: 37:11
+    }
+
+    bb3: {
+        falseEdges -> [real: bb6, imaginary: bb2]; // bb3[0]: scope 0 at $DIR/match_false_edges.rs:36:9: 36:17
+    }
+
+    bb4: {
+        StorageLive(_14);                // bb4[0]: scope 0 at $DIR/match_false_edges.rs:39:9: 39:11
+        _14 = _2;                        // bb4[1]: scope 0 at $DIR/match_false_edges.rs:39:9: 39:11
+        _1 = const 4i32;                 // bb4[2]: scope 5 at $DIR/match_false_edges.rs:39:15: 39:16
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000004))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:39:15: 39:16
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
+        StorageDead(_14);                // bb4[3]: scope 0 at $DIR/match_false_edges.rs:39:16: 39:17
+        goto -> bb15;                    // bb4[4]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6
+    }
+
+    bb5: {
+        falseEdges -> [real: bb11, imaginary: bb4]; // bb5[0]: scope 0 at $DIR/match_false_edges.rs:38:9: 38:16
+    }
+
+    bb6: {
+        StorageLive(_7);                 // bb6[0]: scope 0 at $DIR/match_false_edges.rs:36:14: 36:16
+        _7 = &((_2 as Some).0: i32);     // bb6[1]: scope 0 at $DIR/match_false_edges.rs:36:14: 36:16
+        _5 = &shallow _2;                // bb6[2]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26
+        StorageLive(_8);                 // bb6[3]: scope 0 at $DIR/match_false_edges.rs:36:21: 36:28
+        _8 = const guard() -> [return: bb7, unwind: bb1]; // bb6[4]: scope 0 at $DIR/match_false_edges.rs:36:21: 36:28
+                                         // ty::Const
+                                         // + ty: fn() -> bool {guard}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:36:21: 36:26
+                                         // + literal: Const { ty: fn() -> bool {guard}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb7: {
+        switchInt(move _8) -> [false: bb9, otherwise: bb8]; // bb7[0]: scope 0 at $DIR/match_false_edges.rs:36:21: 36:28
+    }
+
+    bb8: {
+        StorageDead(_8);                 // bb8[0]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34
+        FakeRead(ForMatchGuard, _5);     // bb8[1]: scope 0 at $DIR/match_false_edges.rs:36:27: 36:28
+        FakeRead(ForGuardBinding, _7);   // bb8[2]: scope 0 at $DIR/match_false_edges.rs:36:27: 36:28
+        StorageLive(_6);                 // bb8[3]: scope 0 at $DIR/match_false_edges.rs:36:14: 36:16
+        _6 = ((_2 as Some).0: i32);      // bb8[4]: scope 0 at $DIR/match_false_edges.rs:36:14: 36:16
+        _1 = const 1i32;                 // bb8[5]: scope 2 at $DIR/match_false_edges.rs:36:32: 36:33
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:36:32: 36:33
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        StorageDead(_6);                 // bb8[6]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34
+        StorageDead(_7);                 // bb8[7]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34
+        goto -> bb15;                    // bb8[8]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6
+    }
+
+    bb9: {
+        StorageDead(_8);                 // bb9[0]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34
+        StorageDead(_7);                 // bb9[1]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34
+        falseEdges -> [real: bb2, imaginary: bb2]; // bb9[2]: scope 0 at $DIR/match_false_edges.rs:36:21: 36:28
+    }
+
+    bb10: {
+        StorageLive(_9);                 // bb10[0]: scope 0 at $DIR/match_false_edges.rs:37:9: 37:11
+        _9 = _2;                         // bb10[1]: scope 0 at $DIR/match_false_edges.rs:37:9: 37:11
+        _1 = const 2i32;                 // bb10[2]: scope 3 at $DIR/match_false_edges.rs:37:15: 37:16
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:37:15: 37:16
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        StorageDead(_9);                 // bb10[3]: scope 0 at $DIR/match_false_edges.rs:37:16: 37:17
+        goto -> bb15;                    // bb10[4]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6
+    }
+
+    bb11: {
+        StorageLive(_11);                // bb11[0]: scope 0 at $DIR/match_false_edges.rs:38:14: 38:15
+        _11 = &((_2 as Some).0: i32);    // bb11[1]: scope 0 at $DIR/match_false_edges.rs:38:14: 38:15
+        _5 = &shallow _2;                // bb11[2]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26
+        StorageLive(_12);                // bb11[3]: scope 0 at $DIR/match_false_edges.rs:38:20: 38:29
+        StorageLive(_13);                // bb11[4]: scope 0 at $DIR/match_false_edges.rs:38:27: 38:28
+        _13 = (*_11);                    // bb11[5]: scope 0 at $DIR/match_false_edges.rs:38:27: 38:28
+        _12 = const guard2(move _13) -> [return: bb12, unwind: bb1]; // bb11[6]: scope 0 at $DIR/match_false_edges.rs:38:20: 38:29
+                                         // ty::Const
+                                         // + ty: fn(i32) -> bool {guard2}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:38:20: 38:26
+                                         // + literal: Const { ty: fn(i32) -> bool {guard2}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb12: {
+        StorageDead(_13);                // bb12[0]: scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
+        switchInt(move _12) -> [false: bb14, otherwise: bb13]; // bb12[1]: scope 0 at $DIR/match_false_edges.rs:38:20: 38:29
+    }
+
+    bb13: {
+        StorageDead(_12);                // bb13[0]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35
+        FakeRead(ForMatchGuard, _5);     // bb13[1]: scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
+        FakeRead(ForGuardBinding, _11);  // bb13[2]: scope 0 at $DIR/match_false_edges.rs:38:28: 38:29
+        StorageLive(_10);                // bb13[3]: scope 0 at $DIR/match_false_edges.rs:38:14: 38:15
+        _10 = ((_2 as Some).0: i32);     // bb13[4]: scope 0 at $DIR/match_false_edges.rs:38:14: 38:15
+        _1 = const 3i32;                 // bb13[5]: scope 4 at $DIR/match_false_edges.rs:38:33: 38:34
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match_false_edges.rs:38:33: 38:34
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        StorageDead(_10);                // bb13[6]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35
+        StorageDead(_11);                // bb13[7]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35
+        goto -> bb15;                    // bb13[8]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6
+    }
+
+    bb14: {
+        StorageDead(_12);                // bb14[0]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35
+        StorageDead(_11);                // bb14[1]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35
+        falseEdges -> [real: bb4, imaginary: bb4]; // bb14[2]: scope 0 at $DIR/match_false_edges.rs:38:20: 38:29
+    }
+
+    bb15: {
+        StorageDead(_2);                 // bb15[0]: scope 0 at $DIR/match_false_edges.rs:40:6: 40:7
+        StorageDead(_1);                 // bb15[1]: scope 0 at $DIR/match_false_edges.rs:40:6: 40:7
+        _0 = ();                         // bb15[2]: scope 0 at $DIR/match_false_edges.rs:34:11: 41:2
+        return;                          // bb15[3]: scope 0 at $DIR/match_false_edges.rs:41:2: 41:2
+    }
+}
index 5ee3e1447d832d2ee62c08345fb4537a0fe20d75..c3b07d42f5e62b3edb0634f12fd274b2f584af15 100644 (file)
@@ -2,6 +2,7 @@
 
 #![feature(exclusive_range_pattern)]
 
+// EMIT_MIR rustc.main.SimplifyCfg-initial.after.mir
 fn main() {
     let x = 3;
     let b = true;
@@ -15,70 +16,3 @@ fn main() {
         _ => 3,
     };
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyCfg-initial.after.mir
-//    bb0: {
-//        ...
-//        switchInt(move _6) -> [false: bb4, otherwise: bb1];
-//    }
-//    bb1: {
-//        _7 = Lt(_1, const 10i32);
-//        switchInt(move _7) -> [false: bb4, otherwise: bb2];
-//    }
-//    bb2: {
-//        falseEdges -> [real: bb9, imaginary: bb6];
-//    }
-//    bb3: {
-//        _3 = const 3i32;
-//        goto -> bb14;
-//    }
-//    bb4: {
-//        _4 = Le(const 10i32, _1);
-//        switchInt(move _4) -> [false: bb7, otherwise: bb5];
-//    }
-//    bb5: {
-//        _5 = Le(_1, const 20i32);
-//        switchInt(move _5) -> [false: bb7, otherwise: bb6];
-//    }
-//    bb6: {
-//        falseEdges -> [real: bb12, imaginary: bb8];
-//    }
-//    bb7: {
-//        switchInt(_1) -> [-1i32: bb8, otherwise: bb3];
-//    }
-//    bb8: {
-//        falseEdges -> [real: bb13, imaginary: bb3];
-//    }
-//    bb9: {
-//        _8 = &shallow _1;
-//        StorageLive(_9);
-//        _9 = _2;
-//        switchInt(move _9) -> [false: bb11, otherwise: bb10];
-//    }
-//    bb10: {
-//        StorageDead(_9);
-//        FakeRead(ForMatchGuard, _8);
-//        _3 = const 0i32;
-//        goto -> bb14;
-//    }
-//    bb11: {
-//        StorageDead(_9);
-//        falseEdges -> [real: bb3, imaginary: bb6];
-//    }
-//    bb12: {
-//        _3 = const 1i32;
-//        goto -> bb14;
-//    }
-//    bb13: {
-//        _3 = const 2i32;
-//        goto -> bb14;
-//    }
-//    bb14: {
-//        StorageDead(_3);
-//        _0 = ();
-//        StorageDead(_2);
-//        StorageDead(_1);
-//        return;
-//    }
-// END rustc.main.SimplifyCfg-initial.after.mir
diff --git a/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir
new file mode 100644 (file)
index 0000000..ef5feb7
--- /dev/null
@@ -0,0 +1,166 @@
+// MIR for `main` after SimplifyCfg-initial
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/match_test.rs:6:11: 6:11
+    let _1: i32;                         // in scope 0 at $DIR/match_test.rs:7:9: 7:10
+    let _3: i32;                         // in scope 0 at $DIR/match_test.rs:12:5: 17:6
+    let mut _4: bool;                    // in scope 0 at $DIR/match_test.rs:14:9: 14:16
+    let mut _5: bool;                    // in scope 0 at $DIR/match_test.rs:14:9: 14:16
+    let mut _6: bool;                    // in scope 0 at $DIR/match_test.rs:13:9: 13:14
+    let mut _7: bool;                    // in scope 0 at $DIR/match_test.rs:13:9: 13:14
+    let mut _8: &i32;                    // in scope 0 at $DIR/match_test.rs:12:11: 12:12
+    let mut _9: bool;                    // in scope 0 at $DIR/match_test.rs:13:18: 13:19
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/match_test.rs:7:9: 7:10
+        let _2: bool;                    // in scope 1 at $DIR/match_test.rs:8:9: 8:10
+        scope 2 {
+            debug b => _2;               // in scope 2 at $DIR/match_test.rs:8:9: 8:10
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/match_test.rs:7:9: 7:10
+        _1 = const 3i32;                 // bb0[1]: scope 0 at $DIR/match_test.rs:7:13: 7:14
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:7:13: 7:14
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        FakeRead(ForLet, _1);            // bb0[2]: scope 0 at $DIR/match_test.rs:7:9: 7:10
+        StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/match_test.rs:8:9: 8:10
+        _2 = const true;                 // bb0[4]: scope 1 at $DIR/match_test.rs:8:13: 8:17
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:8:13: 8:17
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        FakeRead(ForLet, _2);            // bb0[5]: scope 1 at $DIR/match_test.rs:8:9: 8:10
+        StorageLive(_3);                 // bb0[6]: scope 2 at $DIR/match_test.rs:12:5: 17:6
+        FakeRead(ForMatchedPlace, _1);   // bb0[7]: scope 2 at $DIR/match_test.rs:12:11: 12:12
+        _6 = Le(const 0i32, _1);         // bb0[8]: scope 2 at $DIR/match_test.rs:13:9: 13:14
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:13:9: 13:14
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+        switchInt(move _6) -> [false: bb4, otherwise: bb1]; // bb0[9]: scope 2 at $DIR/match_test.rs:13:9: 13:14
+    }
+
+    bb1: {
+        _7 = Lt(_1, const 10i32);        // bb1[0]: scope 2 at $DIR/match_test.rs:13:9: 13:14
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x0000000a))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:13:9: 13:14
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) }
+        switchInt(move _7) -> [false: bb4, otherwise: bb2]; // bb1[1]: scope 2 at $DIR/match_test.rs:13:9: 13:14
+    }
+
+    bb2: {
+        falseEdges -> [real: bb9, imaginary: bb6]; // bb2[0]: scope 2 at $DIR/match_test.rs:13:9: 13:14
+    }
+
+    bb3: {
+        _3 = const 3i32;                 // bb3[0]: scope 2 at $DIR/match_test.rs:16:14: 16:15
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:16:14: 16:15
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
+        goto -> bb14;                    // bb3[1]: scope 2 at $DIR/match_test.rs:12:5: 17:6
+    }
+
+    bb4: {
+        _4 = Le(const 10i32, _1);        // bb4[0]: scope 2 at $DIR/match_test.rs:14:9: 14:16
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x0000000a))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:14:9: 14:16
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) }
+        switchInt(move _4) -> [false: bb7, otherwise: bb5]; // bb4[1]: scope 2 at $DIR/match_test.rs:14:9: 14:16
+    }
+
+    bb5: {
+        _5 = Le(_1, const 20i32);        // bb5[0]: scope 2 at $DIR/match_test.rs:14:9: 14:16
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000014))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:14:9: 14:16
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000014)) }
+        switchInt(move _5) -> [false: bb7, otherwise: bb6]; // bb5[1]: scope 2 at $DIR/match_test.rs:14:9: 14:16
+    }
+
+    bb6: {
+        falseEdges -> [real: bb12, imaginary: bb8]; // bb6[0]: scope 2 at $DIR/match_test.rs:14:9: 14:16
+    }
+
+    bb7: {
+        switchInt(_1) -> [-1i32: bb8, otherwise: bb3]; // bb7[0]: scope 2 at $DIR/match_test.rs:15:9: 15:11
+    }
+
+    bb8: {
+        falseEdges -> [real: bb13, imaginary: bb3]; // bb8[0]: scope 2 at $DIR/match_test.rs:15:9: 15:11
+    }
+
+    bb9: {
+        _8 = &shallow _1;                // bb9[0]: scope 2 at $DIR/match_test.rs:12:11: 12:12
+        StorageLive(_9);                 // bb9[1]: scope 2 at $DIR/match_test.rs:13:18: 13:19
+        _9 = _2;                         // bb9[2]: scope 2 at $DIR/match_test.rs:13:18: 13:19
+        switchInt(move _9) -> [false: bb11, otherwise: bb10]; // bb9[3]: scope 2 at $DIR/match_test.rs:13:18: 13:19
+    }
+
+    bb10: {
+        StorageDead(_9);                 // bb10[0]: scope 2 at $DIR/match_test.rs:13:24: 13:25
+        FakeRead(ForMatchGuard, _8);     // bb10[1]: scope 2 at $DIR/match_test.rs:13:18: 13:19
+        _3 = const 0i32;                 // bb10[2]: scope 2 at $DIR/match_test.rs:13:23: 13:24
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:13:23: 13:24
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+        goto -> bb14;                    // bb10[3]: scope 2 at $DIR/match_test.rs:12:5: 17:6
+    }
+
+    bb11: {
+        StorageDead(_9);                 // bb11[0]: scope 2 at $DIR/match_test.rs:13:24: 13:25
+        falseEdges -> [real: bb3, imaginary: bb6]; // bb11[1]: scope 2 at $DIR/match_test.rs:13:18: 13:19
+    }
+
+    bb12: {
+        _3 = const 1i32;                 // bb12[0]: scope 2 at $DIR/match_test.rs:14:20: 14:21
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:14:20: 14:21
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        goto -> bb14;                    // bb12[1]: scope 2 at $DIR/match_test.rs:12:5: 17:6
+    }
+
+    bb13: {
+        _3 = const 2i32;                 // bb13[0]: scope 2 at $DIR/match_test.rs:15:15: 15:16
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/match_test.rs:15:15: 15:16
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        goto -> bb14;                    // bb13[1]: scope 2 at $DIR/match_test.rs:12:5: 17:6
+    }
+
+    bb14: {
+        StorageDead(_3);                 // bb14[0]: scope 2 at $DIR/match_test.rs:17:6: 17:7
+        _0 = ();                         // bb14[1]: scope 0 at $DIR/match_test.rs:6:11: 18:2
+        StorageDead(_2);                 // bb14[2]: scope 1 at $DIR/match_test.rs:18:1: 18:2
+        StorageDead(_1);                 // bb14[3]: scope 0 at $DIR/match_test.rs:18:1: 18:2
+        return;                          // bb14[4]: scope 0 at $DIR/match_test.rs:18:2: 18:2
+    }
+}
index 2a6c2db03bec14abff7b5cfb629f5c8ec06f331c..073ccf7e6c643e723405108c39c12e54036dfee6 100644 (file)
@@ -8,31 +8,8 @@
 
 #![allow(warnings)]
 
+// EMIT_MIR rustc.use_x.nll.0.mir
 fn use_x<'a, 'b: 'a, 'c>(w: &'a mut i32, x: &'b u32, y: &'a u32, z: &'c u32) -> bool { true }
 
 fn main() {
 }
-
-// END RUST SOURCE
-// START rustc.use_x.nll.0.mir
-// | Free Region Mapping
-// | '_#0r    | Global   | ['_#2r, '_#1r, '_#0r, '_#4r, '_#3r]
-// | '_#1r    | External | ['_#1r, '_#4r]
-// | '_#2r    | External | ['_#2r, '_#1r, '_#4r]
-// | '_#3r    | Local    | ['_#4r, '_#3r]
-// | '_#4r    | Local    | ['_#4r]
-// |
-// | Inferred Region Values
-// | '_#0r    | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r}
-// | '_#1r    | U0 | {bb0[0..=1], '_#1r}
-// | '_#2r    | U0 | {bb0[0..=1], '_#2r}
-// | '_#3r    | U0 | {bb0[0..=1], '_#3r}
-// | '_#4r    | U0 | {bb0[0..=1], '_#4r}
-// | '_#5r    | U0 | {bb0[0..=1], '_#1r}
-// | '_#6r    | U0 | {bb0[0..=1], '_#2r}
-// | '_#7r    | U0 | {bb0[0..=1], '_#1r}
-// | '_#8r    | U0 | {bb0[0..=1], '_#3r}
-// |
-// ...
-// fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool {
-// END rustc.use_x.nll.0.mir
diff --git a/src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir b/src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir
new file mode 100644 (file)
index 0000000..a486af6
--- /dev/null
@@ -0,0 +1,53 @@
+// MIR for `use_x` 0 nll
+
+| Free Region Mapping
+| '_#0r | Global | ['_#2r, '_#1r, '_#0r, '_#4r, '_#3r]
+| '_#1r | External | ['_#1r, '_#4r]
+| '_#2r | External | ['_#2r, '_#1r, '_#4r]
+| '_#3r | Local | ['_#4r, '_#3r]
+| '_#4r | Local | ['_#4r]
+|
+| Inferred Region Values
+| '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r}
+| '_#1r | U0 | {bb0[0..=1], '_#1r}
+| '_#2r | U0 | {bb0[0..=1], '_#2r}
+| '_#3r | U0 | {bb0[0..=1], '_#3r}
+| '_#4r | U0 | {bb0[0..=1], '_#4r}
+| '_#5r | U0 | {bb0[0..=1], '_#1r}
+| '_#6r | U0 | {bb0[0..=1], '_#2r}
+| '_#7r | U0 | {bb0[0..=1], '_#1r}
+| '_#8r | U0 | {bb0[0..=1], '_#3r}
+|
+| Inference Constraints
+| '_#0r live at {bb0[0..=1]}
+| '_#1r live at {bb0[0..=1]}
+| '_#2r live at {bb0[0..=1]}
+| '_#3r live at {bb0[0..=1]}
+| '_#4r live at {bb0[0..=1]}
+| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27)
+| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55)
+| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43)
+| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67)
+| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27)
+| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43)
+| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55)
+| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67)
+|
+fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool {
+    debug w => _1;                       // in scope 0 at $DIR/named-lifetimes-basic.rs:12:26: 12:27
+    debug x => _2;                       // in scope 0 at $DIR/named-lifetimes-basic.rs:12:42: 12:43
+    debug y => _3;                       // in scope 0 at $DIR/named-lifetimes-basic.rs:12:54: 12:55
+    debug z => _4;                       // in scope 0 at $DIR/named-lifetimes-basic.rs:12:66: 12:67
+    let mut _0: bool;                    // return place in scope 0 at $DIR/named-lifetimes-basic.rs:12:81: 12:85
+
+    bb0: {
+        _0 = const Const(Value(Scalar(0x01)): bool); // bb0[0]: scope 0 at $DIR/named-lifetimes-basic.rs:12:88: 12:92
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/named-lifetimes-basic.rs:12:88: 12:92
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        return;                          // bb0[1]: scope 0 at $DIR/named-lifetimes-basic.rs:12:94: 12:94
+    }
+}
index 16e357fc162559e9cf9bc5c6b7eeb5f545577107..740cb1c5e969a2d4bf2f0635067f12e3c21567e9 100644 (file)
@@ -9,6 +9,8 @@
 
 fn use_x(_: usize) -> bool { true }
 
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.main.nll.0.mir
 fn main() {
     let mut v = [1, 2, 3];
     let p = &v[0];
@@ -19,23 +21,3 @@ fn main() {
         use_x(22);
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.nll.0.mir
-// | '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=2]}
-// | '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=2]}
-// | '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=2]}
-// END rustc.main.nll.0.mir
-// START rustc.main.nll.0.mir
-// let _2: &'_#3r usize;
-// ...
-// debug p => _2;
-// ...
-// let _6: &'_#4r usize;
-// ...
-// debug q => _6;
-// ...
-// _2 = &'_#2r _1[_3];
-// ...
-// _6 = _2;
-// END rustc.main.nll.0.mir
diff --git a/src/test/mir-opt/nll/region-subtyping-basic/32bit/rustc.main.nll.0.mir b/src/test/mir-opt/nll/region-subtyping-basic/32bit/rustc.main.nll.0.mir
new file mode 100644 (file)
index 0000000..f6ec2d9
--- /dev/null
@@ -0,0 +1,158 @@
+// MIR for `main` 0 nll
+
+| Free Region Mapping
+| '_#0r | Global | ['_#0r, '_#1r]
+| '_#1r | Local | ['_#1r]
+|
+| Inferred Region Values
+| '_#0r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#0r, '_#1r}
+| '_#1r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#1r}
+| '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=2]}
+| '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=2]}
+| '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=2]}
+|
+| Inference Constraints
+| '_#0r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]}
+| '_#1r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]}
+| '_#2r live at {bb2[0]}
+| '_#3r live at {bb2[1..=3]}
+| '_#4r live at {bb2[4..=8], bb3[0], bb5[0..=2]}
+| '_#2r: '_#3r due to Assignment at Single(bb2[0])
+| '_#3r: '_#4r due to Assignment at Single(bb2[3])
+|
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/region-subtyping-basic.rs:14:11: 14:11
+    let mut _1: [usize; Const { ty: usize, val: Value(Scalar(0x00000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14
+    let _3: usize;                       // in scope 0 at $DIR/region-subtyping-basic.rs:16:16: 16:17
+    let mut _4: usize;                   // in scope 0 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+    let mut _5: bool;                    // in scope 0 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+    let mut _7: bool;                    // in scope 0 at $DIR/region-subtyping-basic.rs:18:8: 18:12
+    let _8: bool;                        // in scope 0 at $DIR/region-subtyping-basic.rs:19:9: 19:18
+    let mut _9: usize;                   // in scope 0 at $DIR/region-subtyping-basic.rs:19:15: 19:17
+    let _10: bool;                       // in scope 0 at $DIR/region-subtyping-basic.rs:21:9: 21:18
+    scope 1 {
+        debug v => _1;                   // in scope 1 at $DIR/region-subtyping-basic.rs:15:9: 15:14
+        let _2: &'_#3r usize;            // in scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10
+        scope 2 {
+            debug p => _2;               // in scope 2 at $DIR/region-subtyping-basic.rs:16:9: 16:10
+            let _6: &'_#4r usize;        // in scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10
+            scope 3 {
+                debug q => _6;           // in scope 3 at $DIR/region-subtyping-basic.rs:17:9: 17:10
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14
+        _1 = [const Const(Value(Scalar(0x00000001)): usize), const Const(Value(Scalar(0x00000002)): usize), const Const(Value(Scalar(0x00000003)): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:15:17: 15:26
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:15:18: 15:19
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:15:21: 15:22
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) }
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:15:24: 15:25
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000003)) }
+        FakeRead(ForLet, _1);            // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14
+        StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10
+        StorageLive(_3);                 // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:16:16: 16:17
+        _3 = const Const(Value(Scalar(0x00000000)): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:16:16: 16:17
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:16:16: 16:17
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) }
+        _4 = Len(_1);                    // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+        _5 = Lt(_3, _4);                 // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+        assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> [success: bb2, unwind: bb1]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/region-subtyping-basic.rs:14:1: 23:2
+    }
+
+    bb2: {
+        _2 = &'_#2r _1[_3];              // bb2[0]: scope 1 at $DIR/region-subtyping-basic.rs:16:13: 16:18
+        FakeRead(ForLet, _2);            // bb2[1]: scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10
+        StorageLive(_6);                 // bb2[2]: scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10
+        _6 = _2;                         // bb2[3]: scope 2 at $DIR/region-subtyping-basic.rs:17:13: 17:14
+        FakeRead(ForLet, _6);            // bb2[4]: scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10
+        StorageLive(_7);                 // bb2[5]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12
+        _7 = const Const(Value(Scalar(0x01)): bool); // bb2[6]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:18:8: 18:12
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        FakeRead(ForMatchedPlace, _7);   // bb2[7]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12
+        switchInt(_7) -> [Const(Value(Scalar(0x00)): bool): bb4, otherwise: bb3]; // bb2[8]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6
+    }
+
+    bb3: {
+        falseEdges -> [real: bb5, imaginary: bb4]; // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6
+    }
+
+    bb4: {
+        StorageLive(_10);                // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18
+        _10 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x00000016)): usize)) -> [return: bb7, unwind: bb1]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18
+                                         // ty::Const
+                                         // + ty: fn(usize) -> bool {use_x}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14
+                                         // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) }
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000016))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:21:15: 21:17
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000016)) }
+    }
+
+    bb5: {
+        StorageLive(_8);                 // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:19:9: 19:18
+        StorageLive(_9);                 // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:15: 19:17
+        _9 = (*_6);                      // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:19:15: 19:17
+        _8 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(move _9) -> [return: bb6, unwind: bb1]; // bb5[3]: scope 3 at $DIR/region-subtyping-basic.rs:19:9: 19:18
+                                         // ty::Const
+                                         // + ty: fn(usize) -> bool {use_x}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:19:9: 19:14
+                                         // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb6: {
+        StorageDead(_9);                 // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:19:17: 19:18
+        StorageDead(_8);                 // bb6[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:18: 19:19
+        _0 = ();                         // bb6[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:13: 20:6
+        goto -> bb8;                     // bb6[3]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6
+    }
+
+    bb7: {
+        StorageDead(_10);                // bb7[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:18: 21:19
+        _0 = ();                         // bb7[1]: scope 3 at $DIR/region-subtyping-basic.rs:20:12: 22:6
+        goto -> bb8;                     // bb7[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6
+    }
+
+    bb8: {
+        StorageDead(_6);                 // bb8[0]: scope 2 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        StorageDead(_3);                 // bb8[1]: scope 1 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        StorageDead(_2);                 // bb8[2]: scope 1 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        StorageDead(_1);                 // bb8[3]: scope 0 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        StorageDead(_7);                 // bb8[4]: scope 0 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        return;                          // bb8[5]: scope 0 at $DIR/region-subtyping-basic.rs:23:2: 23:2
+    }
+}
diff --git a/src/test/mir-opt/nll/region-subtyping-basic/64bit/rustc.main.nll.0.mir b/src/test/mir-opt/nll/region-subtyping-basic/64bit/rustc.main.nll.0.mir
new file mode 100644 (file)
index 0000000..fa3a9a0
--- /dev/null
@@ -0,0 +1,158 @@
+// MIR for `main` 0 nll
+
+| Free Region Mapping
+| '_#0r | Global | ['_#0r, '_#1r]
+| '_#1r | Local | ['_#1r]
+|
+| Inferred Region Values
+| '_#0r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#0r, '_#1r}
+| '_#1r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#1r}
+| '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=2]}
+| '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=2]}
+| '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=2]}
+|
+| Inference Constraints
+| '_#0r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]}
+| '_#1r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]}
+| '_#2r live at {bb2[0]}
+| '_#3r live at {bb2[1..=3]}
+| '_#4r live at {bb2[4..=8], bb3[0], bb5[0..=2]}
+| '_#2r: '_#3r due to Assignment at Single(bb2[0])
+| '_#3r: '_#4r due to Assignment at Single(bb2[3])
+|
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/region-subtyping-basic.rs:14:11: 14:11
+    let mut _1: [usize; Const { ty: usize, val: Value(Scalar(0x0000000000000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14
+    let _3: usize;                       // in scope 0 at $DIR/region-subtyping-basic.rs:16:16: 16:17
+    let mut _4: usize;                   // in scope 0 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+    let mut _5: bool;                    // in scope 0 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+    let mut _7: bool;                    // in scope 0 at $DIR/region-subtyping-basic.rs:18:8: 18:12
+    let _8: bool;                        // in scope 0 at $DIR/region-subtyping-basic.rs:19:9: 19:18
+    let mut _9: usize;                   // in scope 0 at $DIR/region-subtyping-basic.rs:19:15: 19:17
+    let _10: bool;                       // in scope 0 at $DIR/region-subtyping-basic.rs:21:9: 21:18
+    scope 1 {
+        debug v => _1;                   // in scope 1 at $DIR/region-subtyping-basic.rs:15:9: 15:14
+        let _2: &'_#3r usize;            // in scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10
+        scope 2 {
+            debug p => _2;               // in scope 2 at $DIR/region-subtyping-basic.rs:16:9: 16:10
+            let _6: &'_#4r usize;        // in scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10
+            scope 3 {
+                debug q => _6;           // in scope 3 at $DIR/region-subtyping-basic.rs:17:9: 17:10
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14
+        _1 = [const Const(Value(Scalar(0x0000000000000001)): usize), const Const(Value(Scalar(0x0000000000000002)): usize), const Const(Value(Scalar(0x0000000000000003)): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:15:17: 15:26
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000001))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:15:18: 15:19
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000002))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:15:21: 15:22
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) }
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000003))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:15:24: 15:25
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) }
+        FakeRead(ForLet, _1);            // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14
+        StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10
+        StorageLive(_3);                 // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:16:16: 16:17
+        _3 = const Const(Value(Scalar(0x0000000000000000)): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:16:16: 16:17
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000000))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:16:16: 16:17
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
+        _4 = Len(_1);                    // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+        _5 = Lt(_3, _4);                 // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+        assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> [success: bb2, unwind: bb1]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/region-subtyping-basic.rs:14:1: 23:2
+    }
+
+    bb2: {
+        _2 = &'_#2r _1[_3];              // bb2[0]: scope 1 at $DIR/region-subtyping-basic.rs:16:13: 16:18
+        FakeRead(ForLet, _2);            // bb2[1]: scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10
+        StorageLive(_6);                 // bb2[2]: scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10
+        _6 = _2;                         // bb2[3]: scope 2 at $DIR/region-subtyping-basic.rs:17:13: 17:14
+        FakeRead(ForLet, _6);            // bb2[4]: scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10
+        StorageLive(_7);                 // bb2[5]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12
+        _7 = const Const(Value(Scalar(0x01)): bool); // bb2[6]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12
+                                         // ty::Const
+                                         // + ty: bool
+                                         // + val: Value(Scalar(0x01))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:18:8: 18:12
+                                         // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+        FakeRead(ForMatchedPlace, _7);   // bb2[7]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12
+        switchInt(_7) -> [Const(Value(Scalar(0x00)): bool): bb4, otherwise: bb3]; // bb2[8]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6
+    }
+
+    bb3: {
+        falseEdges -> [real: bb5, imaginary: bb4]; // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6
+    }
+
+    bb4: {
+        StorageLive(_10);                // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18
+        _10 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x0000000000000016)): usize)) -> [return: bb7, unwind: bb1]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18
+                                         // ty::Const
+                                         // + ty: fn(usize) -> bool {use_x}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14
+                                         // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) }
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000016))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:21:15: 21:17
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000016)) }
+    }
+
+    bb5: {
+        StorageLive(_8);                 // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:19:9: 19:18
+        StorageLive(_9);                 // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:15: 19:17
+        _9 = (*_6);                      // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:19:15: 19:17
+        _8 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(move _9) -> [return: bb6, unwind: bb1]; // bb5[3]: scope 3 at $DIR/region-subtyping-basic.rs:19:9: 19:18
+                                         // ty::Const
+                                         // + ty: fn(usize) -> bool {use_x}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/region-subtyping-basic.rs:19:9: 19:14
+                                         // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb6: {
+        StorageDead(_9);                 // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:19:17: 19:18
+        StorageDead(_8);                 // bb6[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:18: 19:19
+        _0 = ();                         // bb6[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:13: 20:6
+        goto -> bb8;                     // bb6[3]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6
+    }
+
+    bb7: {
+        StorageDead(_10);                // bb7[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:18: 21:19
+        _0 = ();                         // bb7[1]: scope 3 at $DIR/region-subtyping-basic.rs:20:12: 22:6
+        goto -> bb8;                     // bb7[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6
+    }
+
+    bb8: {
+        StorageDead(_6);                 // bb8[0]: scope 2 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        StorageDead(_3);                 // bb8[1]: scope 1 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        StorageDead(_2);                 // bb8[2]: scope 1 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        StorageDead(_1);                 // bb8[3]: scope 0 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        StorageDead(_7);                 // bb8[4]: scope 0 at $DIR/region-subtyping-basic.rs:23:1: 23:2
+        return;                          // bb8[5]: scope 0 at $DIR/region-subtyping-basic.rs:23:2: 23:2
+    }
+}
index 74a606af28fc1cb222c25c1a7c888d790ec13aca..cf6426b878a3c1a0d0101e08aa21b52503990560 100644 (file)
@@ -3,6 +3,7 @@
 // Ensure that there are no drop terminators in `unwrap<T>` (except the one along the cleanup
 // path).
 
+// EMIT_MIR rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir
 fn unwrap<T>(opt: Option<T>) -> T {
     match opt {
         Some(x) => x,
@@ -13,31 +14,3 @@ fn unwrap<T>(opt: Option<T>) -> T {
 fn main() {
     let _ = unwrap(Some(1i32));
 }
-
-// END RUST SOURCE
-// START rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir
-// fn unwrap(_1: std::option::Option<T>) -> T {
-//     ...
-//     bb0: {
-//         ...
-//         switchInt(move _2) -> [0isize: bb2, 1isize: bb4, otherwise: bb3];
-//     }
-//     bb1 (cleanup): {
-//         resume;
-//     }
-//     bb2: {
-//         ...
-//         const std::rt::begin_panic::<&str>(const "explicit panic") -> bb5;
-//     }
-//     bb3: {
-//         unreachable;
-//     }
-//     bb4: {
-//         ...
-//         return;
-//     }
-//     bb5 (cleanup): {
-//         drop(_1) -> bb1;
-//     }
-// }
-// END rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir
diff --git a/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..3830241
--- /dev/null
@@ -0,0 +1,57 @@
+// MIR for `unwrap` after SimplifyCfg-elaborate-drops
+
+fn unwrap(_1: std::option::Option<T>) -> T {
+    debug opt => _1;                     // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:7:14: 7:17
+    let mut _0: T;                       // return place in scope 0 at $DIR/no-drop-for-inactive-variant.rs:7:33: 7:34
+    let mut _2: isize;                   // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:9: 9:16
+    let _3: T;                           // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15
+    let mut _4: !;                       // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL
+    let mut _5: isize;                   // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2
+    let mut _6: isize;                   // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2
+    scope 1 {
+        debug x => _3;                   // in scope 1 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15
+    }
+
+    bb0: {
+        _2 = discriminant(_1);           // bb0[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:9: 9:16
+        switchInt(move _2) -> [0isize: bb2, 1isize: bb4, otherwise: bb3]; // bb0[1]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:9: 9:16
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:7:1: 12:2
+    }
+
+    bb2: {
+        StorageLive(_4);                 // bb2[0]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL
+        const std::rt::begin_panic::<&str>(const "explicit panic") -> bb5; // bb2[1]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libstd/macros.rs:LL:COL
+                                         // + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }
+                                         // ty::Const
+                                         // + ty: &str
+                                         // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 })
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libstd/macros.rs:LL:COL
+                                         // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
+    }
+
+    bb3: {
+        unreachable;                     // bb3[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:8:11: 8:14
+    }
+
+    bb4: {
+        StorageLive(_3);                 // bb4[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15
+        _3 = move ((_1 as Some).0: T);   // bb4[1]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15
+        _0 = move _3;                    // bb4[2]: scope 1 at $DIR/no-drop-for-inactive-variant.rs:9:20: 9:21
+        StorageDead(_3);                 // bb4[3]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:21: 9:22
+        _5 = discriminant(_1);           // bb4[4]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2
+        return;                          // bb4[5]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:2: 12:2
+    }
+
+    bb5 (cleanup): {
+        drop(_1) -> bb1;                 // bb5[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2
+    }
+}
index 782bc31186ca5fb8eb8a4931bc077d8579e4d351..ab58654e07c0520d3a20787bdef8e8f9ef5396e9 100644 (file)
@@ -4,21 +4,7 @@
 // MIR drop of the argument. (We used to have a `DROP(_2)` in the code
 // below, as part of bb3.)
 
+// EMIT_MIR rustc.main.ElaborateDrops.before.mir
 fn main() {
     std::mem::drop("".to_string());
 }
-
-// END RUST SOURCE
-// START rustc.main.ElaborateDrops.before.mir
-//    bb2: {
-//        StorageDead(_3);
-//        _1 = const std::mem::drop::<std::string::String>(move _2) -> [return: bb3, unwind: bb4];
-//    }
-//    bb3: {
-//        StorageDead(_2);
-//        StorageDead(_4);
-//        StorageDead(_1);
-//        _0 = ();
-//        return;
-//    }
-// END rustc.main.ElaborateDrops.before.mir
diff --git a/src/test/mir-opt/no-spurious-drop-after-call/rustc.main.ElaborateDrops.before.mir b/src/test/mir-opt/no-spurious-drop-after-call/rustc.main.ElaborateDrops.before.mir
new file mode 100644 (file)
index 0000000..b65bc76
--- /dev/null
@@ -0,0 +1,58 @@
+// MIR for `main` before ElaborateDrops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/no-spurious-drop-after-call.rs:8:11: 8:11
+    let _1: ();                          // in scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35
+    let mut _2: std::string::String;     // in scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:34
+    let mut _3: &str;                    // in scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
+    let _4: &str;                        // in scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:34
+        StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
+        StorageLive(_4);                 // bb0[3]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
+        _4 = const "";                   // bb0[4]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
+                                         // ty::Const
+                                         // + ty: &str
+                                         // + val: Value(Slice { data: Allocation { bytes: [], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [], len: Size { raw: 0 } }, size: Size { raw: 0 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 0 })
+                                         // mir::Constant
+                                         // + span: $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
+                                         // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [], len: Size { raw: 0 } }, size: Size { raw: 0 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 0 }) }
+        _3 = &(*_4);                     // bb0[5]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22
+        _2 = const <str as std::string::ToString>::to_string(move _3) -> bb2; // bb0[6]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:34
+                                         // ty::Const
+                                         // + ty: for<'r> fn(&'r str) -> std::string::String {<str as std::string::ToString>::to_string}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/no-spurious-drop-after-call.rs:9:23: 9:32
+                                         // + literal: Const { ty: for<'r> fn(&'r str) -> std::string::String {<str as std::string::ToString>::to_string}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:8:1: 10:2
+    }
+
+    bb2: {
+        StorageDead(_3);                 // bb2[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:33: 9:34
+        _1 = const std::mem::drop::<std::string::String>(move _2) -> [return: bb3, unwind: bb4]; // bb2[1]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35
+                                         // ty::Const
+                                         // + ty: fn(std::string::String) {std::mem::drop::<std::string::String>}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/no-spurious-drop-after-call.rs:9:5: 9:19
+                                         // + literal: Const { ty: fn(std::string::String) {std::mem::drop::<std::string::String>}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb3: {
+        StorageDead(_2);                 // bb3[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:34: 9:35
+        StorageDead(_4);                 // bb3[1]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:35: 9:36
+        StorageDead(_1);                 // bb3[2]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:35: 9:36
+        _0 = ();                         // bb3[3]: scope 0 at $DIR/no-spurious-drop-after-call.rs:8:11: 10:2
+        return;                          // bb3[4]: scope 0 at $DIR/no-spurious-drop-after-call.rs:10:2: 10:2
+    }
+
+    bb4 (cleanup): {
+        drop(_2) -> bb1;                 // bb4[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:34: 9:35
+    }
+}
index 39b9006017958c5d59c301a14fcf50c261737c3a..daf397c3d9c14bc7ddf68ed7b053dde5b5551956 100644 (file)
@@ -1,5 +1,7 @@
 // ignore-wasm32-bare compiled with panic=abort by default
 
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir
 fn main() {
     let mut x = Packed(Aligned(Droppy(0)));
     x.0 = Aligned(Droppy(0));
@@ -13,47 +15,3 @@ fn main() {
 impl Drop for Droppy {
     fn drop(&mut self) {}
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyCfg-elaborate-drops.after.mir
-// fn main() -> () {
-//     let mut _0: ();
-//     let mut _1: Packed;
-//     let mut _2: Aligned;
-//     let mut _3: Droppy;
-//     let mut _4: Aligned;
-//     let mut _5: Droppy;
-//     let mut _6: Aligned;
-//     scope 1 {
-//         debug x => _1;
-//     }
-//
-//     bb0: {
-//         StorageLive(_1);
-//         ...
-//         _1 = Packed(move _2,);
-//         ...
-//         StorageLive(_6);
-//         _6 = move (_1.0: Aligned);
-//         drop(_6) -> [return: bb4, unwind: bb3];
-//     }
-//     bb1 (cleanup): {
-//         resume;
-//     }
-//     bb2: {
-//         StorageDead(_1);
-//         return;
-//     }
-//     bb3 (cleanup): {
-//         (_1.0: Aligned) = move _4;
-//         drop(_1) -> bb1;
-//     }
-//     bb4: {
-//         StorageDead(_6);
-//         (_1.0: Aligned) = move _4;
-//         StorageDead(_4);
-//         _0 = ();
-//         drop(_1) -> [return: bb2, unwind: bb1];
-//     }
-// }
-// END rustc.main.SimplifyCfg-elaborate-drops.after.mir
diff --git a/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..03265c6
--- /dev/null
@@ -0,0 +1,67 @@
+// MIR for `main` after SimplifyCfg-elaborate-drops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/packed-struct-drop-aligned.rs:5:11: 5:11
+    let mut _1: Packed;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14
+    let mut _2: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42
+    let mut _3: Droppy;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41
+    let mut _4: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29
+    let mut _5: Droppy;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28
+    let mut _6: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42
+        StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41
+        _3 = Droppy(const 0usize,);      // bb0[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/packed-struct-drop-aligned.rs:6:39: 6:40
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) }
+        _2 = Aligned(move _3,);          // bb0[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42
+        StorageDead(_3);                 // bb0[5]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:41: 6:42
+        _1 = Packed(move _2,);           // bb0[6]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:17: 6:43
+        StorageDead(_2);                 // bb0[7]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:42: 6:43
+        StorageLive(_4);                 // bb0[8]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29
+        StorageLive(_5);                 // bb0[9]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28
+        _5 = Droppy(const 0usize,);      // bb0[10]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/packed-struct-drop-aligned.rs:7:26: 7:27
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) }
+        _4 = Aligned(move _5,);          // bb0[11]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29
+        StorageDead(_5);                 // bb0[12]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29
+        StorageLive(_6);                 // bb0[13]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        _6 = move (_1.0: Aligned);       // bb0[14]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        drop(_6) -> [return: bb4, unwind: bb3]; // bb0[15]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:5:1: 8:2
+    }
+
+    bb2: {
+        StorageDead(_1);                 // bb2[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2
+        return;                          // bb2[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:2: 8:2
+    }
+
+    bb3 (cleanup): {
+        (_1.0: Aligned) = move _4;       // bb3[0]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        drop(_1) -> bb1;                 // bb3[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2
+    }
+
+    bb4: {
+        StorageDead(_6);                 // bb4[0]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        (_1.0: Aligned) = move _4;       // bb4[1]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        StorageDead(_4);                 // bb4[2]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29
+        _0 = ();                         // bb4[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:5:11: 8:2
+        drop(_1) -> [return: bb2, unwind: bb1]; // bb4[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2
+    }
+}
diff --git a/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..a1424d0
--- /dev/null
@@ -0,0 +1,67 @@
+// MIR for `main` after SimplifyCfg-elaborate-drops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/packed-struct-drop-aligned.rs:5:11: 5:11
+    let mut _1: Packed;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14
+    let mut _2: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42
+    let mut _3: Droppy;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41
+    let mut _4: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29
+    let mut _5: Droppy;                  // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28
+    let mut _6: Aligned;                 // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42
+        StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41
+        _3 = Droppy(const 0usize,);      // bb0[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000000))
+                                         // mir::Constant
+                                         // + span: $DIR/packed-struct-drop-aligned.rs:6:39: 6:40
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
+        _2 = Aligned(move _3,);          // bb0[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42
+        StorageDead(_3);                 // bb0[5]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:41: 6:42
+        _1 = Packed(move _2,);           // bb0[6]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:17: 6:43
+        StorageDead(_2);                 // bb0[7]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:42: 6:43
+        StorageLive(_4);                 // bb0[8]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29
+        StorageLive(_5);                 // bb0[9]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28
+        _5 = Droppy(const 0usize,);      // bb0[10]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000000))
+                                         // mir::Constant
+                                         // + span: $DIR/packed-struct-drop-aligned.rs:7:26: 7:27
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
+        _4 = Aligned(move _5,);          // bb0[11]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29
+        StorageDead(_5);                 // bb0[12]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29
+        StorageLive(_6);                 // bb0[13]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        _6 = move (_1.0: Aligned);       // bb0[14]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        drop(_6) -> [return: bb4, unwind: bb3]; // bb0[15]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:5:1: 8:2
+    }
+
+    bb2: {
+        StorageDead(_1);                 // bb2[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2
+        return;                          // bb2[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:2: 8:2
+    }
+
+    bb3 (cleanup): {
+        (_1.0: Aligned) = move _4;       // bb3[0]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        drop(_1) -> bb1;                 // bb3[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2
+    }
+
+    bb4: {
+        StorageDead(_6);                 // bb4[0]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        (_1.0: Aligned) = move _4;       // bb4[1]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8
+        StorageDead(_4);                 // bb4[2]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29
+        _0 = ();                         // bb4[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:5:11: 8:2
+        drop(_1) -> [return: bb2, unwind: bb1]; // bb4[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2
+    }
+}
index ea106eaf595292d0d5b28baa180bbe207cfd777e..fd2f1d0dbffc6c584f5b5e5236f040b24907cf5e 100644 (file)
@@ -2,6 +2,7 @@
 
 // ignore-wasm32-bare compiled with panic=abort by default
 
+// EMIT_MIR rustc.match_guard.CleanupNonCodegenStatements.diff
 fn match_guard(x: Option<&&i32>, c: bool) -> i32 {
     match x {
         Some(0) if c => 0,
@@ -12,97 +13,3 @@ fn match_guard(x: Option<&&i32>, c: bool) -> i32 {
 fn main() {
     match_guard(None, true);
 }
-
-// END RUST SOURCE
-
-// START rustc.match_guard.CleanupNonCodegenStatements.before.mir
-// bb0: {
-//     FakeRead(ForMatchedPlace, _1);
-//     _3 = discriminant(_1);
-//     switchInt(move _3) -> [1isize: bb2, otherwise: bb1];
-// }
-// bb1: {
-//     _0 = const 1i32;
-//     goto -> bb7;
-// }
-// bb2: {
-//     switchInt((*(*((_1 as Some).0: &&i32)))) -> [0i32: bb3, otherwise: bb1];
-// }
-// bb3: {
-//     goto -> bb4;
-// }
-// bb4: {
-//     _4 = &shallow _1;
-//     _5 = &shallow ((_1 as Some).0: &&i32);
-//     _6 = &shallow (*((_1 as Some).0: &&i32));
-//     _7 = &shallow (*(*((_1 as Some).0: &&i32)));
-//     StorageLive(_8);
-//     _8 = _2;
-//     switchInt(move _8) -> [false: bb6, otherwise: bb5];
-// }
-// bb5: {
-//     StorageDead(_8);
-//     FakeRead(ForMatchGuard, _4);
-//     FakeRead(ForMatchGuard, _5);
-//     FakeRead(ForMatchGuard, _6);
-//     FakeRead(ForMatchGuard, _7);
-//     _0 = const 0i32;
-//     goto -> bb7;
-// }
-// bb6: {
-//     StorageDead(_8);
-//     goto -> bb1;
-// }
-// bb7: {
-//     return;
-// }
-// bb8 (cleanup): {
-//     resume;
-// }
-// END rustc.match_guard.CleanupNonCodegenStatements.before.mir
-
-// START rustc.match_guard.CleanupNonCodegenStatements.after.mir
-// bb0: {
-//     nop;
-//     _3 = discriminant(_1);
-//     switchInt(move _3) -> [1isize: bb2, otherwise: bb1];
-// }
-// bb1: {
-//     _0 = const 1i32;
-//     goto -> bb7;
-// }
-// bb2: {
-//     switchInt((*(*((_1 as Some).0: &&i32)))) -> [0i32: bb3, otherwise: bb1];
-// }
-// bb3: {
-//     goto -> bb4;
-// }
-// bb4: {
-//     nop;
-//     nop;
-//     nop;
-//     nop;
-//     StorageLive(_8);
-//     _8 = _2;
-//     switchInt(move _8) -> [false: bb6, otherwise: bb5];
-// }
-// bb5: {
-//     StorageDead(_8);
-//     nop;
-//     nop;
-//     nop;
-//     nop;
-//     _0 = const 0i32;
-//     goto -> bb7;
-// }
-// bb6: {
-//     StorageDead(_8);
-//     goto -> bb1;
-// }
-// bb7: {
-//     return;
-// }
-// bb8 (cleanup): {
-//     resume;
-// }
-// END rustc.match_guard.CleanupNonCodegenStatements.after.mir
diff --git a/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff b/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff
new file mode 100644 (file)
index 0000000..c915554
--- /dev/null
@@ -0,0 +1,88 @@
+- // MIR for `match_guard` before CleanupNonCodegenStatements
++ // MIR for `match_guard` after CleanupNonCodegenStatements
+  
+  fn match_guard(_1: std::option::Option<&&i32>, _2: bool) -> i32 {
+      debug x => _1;                       // in scope 0 at $DIR/remove_fake_borrows.rs:6:16: 6:17
+      debug c => _2;                       // in scope 0 at $DIR/remove_fake_borrows.rs:6:34: 6:35
+      let mut _0: i32;                     // return place in scope 0 at $DIR/remove_fake_borrows.rs:6:46: 6:49
+      let mut _3: isize;                   // in scope 0 at $DIR/remove_fake_borrows.rs:8:9: 8:16
+      let mut _4: &std::option::Option<&&i32>; // in scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+      let mut _5: &&&i32;                  // in scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+      let mut _6: &&i32;                   // in scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+      let mut _7: &i32;                    // in scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+      let mut _8: bool;                    // in scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+  
+      bb0: {
+-         FakeRead(ForMatchedPlace, _1);   // bb0[0]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
++         nop;                             // bb0[0]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+          _3 = discriminant(_1);           // bb0[1]: scope 0 at $DIR/remove_fake_borrows.rs:8:9: 8:16
+          switchInt(move _3) -> [1isize: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/remove_fake_borrows.rs:8:9: 8:16
+      }
+  
+      bb1: {
+          _0 = const 1i32;                 // bb1[0]: scope 0 at $DIR/remove_fake_borrows.rs:9:14: 9:15
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000001))
+                                           // mir::Constant
+                                           // + span: $DIR/remove_fake_borrows.rs:9:14: 9:15
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+          goto -> bb7;                     // bb1[1]: scope 0 at $DIR/remove_fake_borrows.rs:7:5: 10:6
+      }
+  
+      bb2: {
+          switchInt((*(*((_1 as Some).0: &&i32)))) -> [0i32: bb3, otherwise: bb1]; // bb2[0]: scope 0 at $DIR/remove_fake_borrows.rs:8:14: 8:15
+      }
+  
+      bb3: {
+          goto -> bb4;                     // bb3[0]: scope 0 at $DIR/remove_fake_borrows.rs:8:9: 8:16
+      }
+  
+      bb4: {
+-         _4 = &shallow _1;                // bb4[0]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+-         _5 = &shallow ((_1 as Some).0: &&i32); // bb4[1]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+-         _6 = &shallow (*((_1 as Some).0: &&i32)); // bb4[2]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+-         _7 = &shallow (*(*((_1 as Some).0: &&i32))); // bb4[3]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
++         nop;                             // bb4[0]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
++         nop;                             // bb4[1]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
++         nop;                             // bb4[2]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
++         nop;                             // bb4[3]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12
+          StorageLive(_8);                 // bb4[4]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+          _8 = _2;                         // bb4[5]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+          switchInt(move _8) -> [false: bb6, otherwise: bb5]; // bb4[6]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+      }
+  
+      bb5: {
+          StorageDead(_8);                 // bb5[0]: scope 0 at $DIR/remove_fake_borrows.rs:8:26: 8:27
+-         FakeRead(ForMatchGuard, _4);     // bb5[1]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+-         FakeRead(ForMatchGuard, _5);     // bb5[2]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+-         FakeRead(ForMatchGuard, _6);     // bb5[3]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+-         FakeRead(ForMatchGuard, _7);     // bb5[4]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
++         nop;                             // bb5[1]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
++         nop;                             // bb5[2]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
++         nop;                             // bb5[3]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
++         nop;                             // bb5[4]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+          _0 = const 0i32;                 // bb5[5]: scope 0 at $DIR/remove_fake_borrows.rs:8:25: 8:26
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000000))
+                                           // mir::Constant
+                                           // + span: $DIR/remove_fake_borrows.rs:8:25: 8:26
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+          goto -> bb7;                     // bb5[6]: scope 0 at $DIR/remove_fake_borrows.rs:7:5: 10:6
+      }
+  
+      bb6: {
+          StorageDead(_8);                 // bb6[0]: scope 0 at $DIR/remove_fake_borrows.rs:8:26: 8:27
+          goto -> bb1;                     // bb6[1]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21
+      }
+  
+      bb7: {
+          return;                          // bb7[0]: scope 0 at $DIR/remove_fake_borrows.rs:11:2: 11:2
+      }
+  
+      bb8 (cleanup): {
+          resume;                          // bb8[0]: scope 0 at $DIR/remove_fake_borrows.rs:6:1: 11:2
+      }
+  }
+  
index a0a7a760c2da5576b8dc834c67c6076b5609a3a9..eba0f567c4a0897e901b483c4f482d5619bf4a67 100644 (file)
@@ -6,6 +6,8 @@
 
 struct Test(i32);
 
+// EMIT_MIR rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir
+// EMIT_MIR rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
 impl Test {
     // Make sure we run the pass on a method, not just on bare functions.
     fn foo<'x>(&self, x: &'x mut i32) -> &'x mut i32 {
@@ -16,10 +18,14 @@ fn foo_shr<'x>(&self, x: &'x i32) -> &'x i32 {
     }
 }
 
+// EMIT_MIR rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
+
 impl Drop for Test {
     fn drop(&mut self) {}
 }
 
+// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir
+// EMIT_MIR rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir
 fn main() {
     let mut x = 0;
     {
@@ -43,94 +49,3 @@ fn main() {
     // escape-to-raw (shr)
     let _w = _w as *const _;
 }
-
-// END RUST SOURCE
-// START rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir
-//     bb0: {
-//         Retag([fn entry] _1);
-//         Retag([fn entry] _2);
-//         ...
-//         _0 = &mut (*_3);
-//         Retag(_0);
-//         ...
-//         return;
-//     }
-// END rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir
-// START rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
-//     bb0: {
-//         Retag([fn entry] _1);
-//         Retag([fn entry] _2);
-//         ...
-//         _0 = _2;
-//         Retag(_0);
-//         ...
-//         return;
-//     }
-// END rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
-// START rustc.main.SimplifyCfg-elaborate-drops.after.mir
-// fn main() -> () {
-//     ...
-//     bb0: {
-//         ...
-//         _3 = const Test::foo(move _4, move _6) -> [return: bb2, unwind: bb3];
-//     }
-//
-//     ...
-//
-//     bb2: {
-//         Retag(_3);
-//         ...
-//         _9 = move _3;
-//         Retag(_9);
-//         _8 = &mut (*_9);
-//         Retag(_8);
-//         StorageDead(_9);
-//         StorageLive(_10);
-//         _10 = move _8;
-//         Retag(_10);
-//         ...
-//         _12 = &raw mut (*_10);
-//         Retag([raw] _12);
-//         ...
-//         _15 = move _16(move _17) -> bb5;
-//     }
-//
-//     bb5: {
-//         Retag(_15);
-//         ...
-//         _19 = const Test::foo_shr(move _20, move _22) -> [return: bb6, unwind: bb7];
-//     }
-//
-//     ...
-// }
-// END rustc.main.SimplifyCfg-elaborate-drops.after.mir
-// START rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir
-// fn main::{{closure}}#0(_1: &[closure@main::{{closure}}#0], _2: &i32) -> &i32 {
-//     ...
-//     bb0: {
-//         Retag([fn entry] _1);
-//         Retag([fn entry] _2);
-//         StorageLive(_3);
-//         _3 = _2;
-//         Retag(_3);
-//         _0 = _2;
-//         Retag(_0);
-//         StorageDead(_3);
-//         return;
-//     }
-// }
-// END rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir
-// START rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
-// fn std::intrinsics::drop_in_place(_1: *mut Test) -> () {
-//     ...
-//     bb0: {
-//         Retag([raw] _1);
-//         _2 = &mut (*_1);
-//         _3 = const <Test as std::ops::Drop>::drop(move _2) -> bb1;
-//     }
-//
-//     bb1: {
-//         return;
-//     }
-// }
-// END rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
diff --git a/src/test/mir-opt/retag/rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..5aa2510
--- /dev/null
@@ -0,0 +1,22 @@
+// MIR for `main::{{closure}}#0` after SimplifyCfg-elaborate-drops
+
+fn main::{{closure}}#0(_1: &[closure@main::{{closure}}#0], _2: &i32) -> &i32 {
+    debug x => _2;                       // in scope 0 at $DIR/retag.rs:40:32: 40:33
+    let mut _0: &i32;                    // return place in scope 0 at $DIR/retag.rs:40:44: 40:48
+    let _3: &i32;                        // in scope 0 at $DIR/retag.rs:41:13: 41:15
+    scope 1 {
+        debug _y => _3;                  // in scope 1 at $DIR/retag.rs:41:13: 41:15
+    }
+
+    bb0: {
+        Retag([fn entry] _1);            // bb0[0]: scope 0 at $DIR/retag.rs:40:31: 43:6
+        Retag([fn entry] _2);            // bb0[1]: scope 0 at $DIR/retag.rs:40:31: 43:6
+        StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/retag.rs:41:13: 41:15
+        _3 = _2;                         // bb0[3]: scope 0 at $DIR/retag.rs:41:18: 41:19
+        Retag(_3);                       // bb0[4]: scope 0 at $DIR/retag.rs:41:18: 41:19
+        _0 = _2;                         // bb0[5]: scope 1 at $DIR/retag.rs:42:9: 42:10
+        Retag(_0);                       // bb0[6]: scope 1 at $DIR/retag.rs:42:9: 42:10
+        StorageDead(_3);                 // bb0[7]: scope 0 at $DIR/retag.rs:43:5: 43:6
+        return;                          // bb0[8]: scope 0 at $DIR/retag.rs:43:6: 43:6
+    }
+}
diff --git a/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..780cb9d
--- /dev/null
@@ -0,0 +1,227 @@
+// MIR for `main` after SimplifyCfg-elaborate-drops
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/retag.rs:29:11: 29:11
+    let mut _1: i32;                     // in scope 0 at $DIR/retag.rs:30:9: 30:14
+    let _2: ();                          // in scope 0 at $DIR/retag.rs:31:5: 37:6
+    let mut _4: &Test;                   // in scope 0 at $DIR/retag.rs:32:17: 32:24
+    let _5: Test;                        // in scope 0 at $DIR/retag.rs:32:17: 32:24
+    let mut _6: &mut i32;                // in scope 0 at $DIR/retag.rs:32:29: 32:35
+    let mut _7: &mut i32;                // in scope 0 at $DIR/retag.rs:32:29: 32:35
+    let mut _9: &mut i32;                // in scope 0 at $DIR/retag.rs:33:19: 33:20
+    let mut _12: *mut i32;               // in scope 0 at $DIR/retag.rs:36:18: 36:29
+    let mut _14: [closure@main::{{closure}}#0]; // in scope 0 at $DIR/retag.rs:40:31: 43:6
+    let mut _16: for<'r> fn(&'r i32) -> &'r i32; // in scope 0 at $DIR/retag.rs:44:14: 44:15
+    let mut _17: &i32;                   // in scope 0 at $DIR/retag.rs:44:16: 44:18
+    let _18: &i32;                       // in scope 0 at $DIR/retag.rs:44:16: 44:18
+    let _19: &i32;                       // in scope 0 at $DIR/retag.rs:47:5: 47:24
+    let mut _20: &Test;                  // in scope 0 at $DIR/retag.rs:47:5: 47:12
+    let _21: Test;                       // in scope 0 at $DIR/retag.rs:47:5: 47:12
+    let mut _22: &i32;                   // in scope 0 at $DIR/retag.rs:47:21: 47:23
+    let _23: &i32;                       // in scope 0 at $DIR/retag.rs:47:21: 47:23
+    let _24: i32;                        // in scope 0 at $DIR/retag.rs:47:22: 47:23
+    let mut _26: *const i32;             // in scope 0 at $DIR/retag.rs:50:14: 50:28
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/retag.rs:30:9: 30:14
+        let _3: &mut i32;                // in scope 1 at $DIR/retag.rs:32:13: 32:14
+        let _13: for<'r> fn(&'r i32) -> &'r i32 as UserTypeProjection { base: UserType(1), projs: [] }; // in scope 1 at $DIR/retag.rs:40:9: 40:10
+        scope 2 {
+            debug v => _3;               // in scope 2 at $DIR/retag.rs:32:13: 32:14
+            let _8: &mut i32;            // in scope 2 at $DIR/retag.rs:33:13: 33:14
+            scope 3 {
+                debug w => _8;           // in scope 3 at $DIR/retag.rs:33:13: 33:14
+                let _10: &mut i32;       // in scope 3 at $DIR/retag.rs:34:13: 34:14
+                scope 4 {
+                    debug w => _10;      // in scope 4 at $DIR/retag.rs:34:13: 34:14
+                    let _11: *mut i32;   // in scope 4 at $DIR/retag.rs:36:13: 36:15
+                    scope 5 {
+                        debug _w => _11; // in scope 5 at $DIR/retag.rs:36:13: 36:15
+                    }
+                }
+            }
+        }
+        scope 6 {
+            debug c => _13;              // in scope 6 at $DIR/retag.rs:40:9: 40:10
+            let _15: &i32;               // in scope 6 at $DIR/retag.rs:44:9: 44:11
+            scope 7 {
+                debug _w => _15;         // in scope 7 at $DIR/retag.rs:44:9: 44:11
+                let _25: *const i32;     // in scope 7 at $DIR/retag.rs:50:9: 50:11
+                let mut _27: &i32;       // in scope 7 at $DIR/retag.rs:47:21: 47:23
+                scope 8 {
+                    debug _w => _25;     // in scope 8 at $DIR/retag.rs:50:9: 50:11
+                }
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/retag.rs:30:9: 30:14
+        _1 = const 0i32;                 // bb0[1]: scope 0 at $DIR/retag.rs:30:17: 30:18
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:30:17: 30:18
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+        StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/retag.rs:31:5: 37:6
+        StorageLive(_3);                 // bb0[3]: scope 1 at $DIR/retag.rs:32:13: 32:14
+        StorageLive(_4);                 // bb0[4]: scope 1 at $DIR/retag.rs:32:17: 32:24
+        StorageLive(_5);                 // bb0[5]: scope 1 at $DIR/retag.rs:32:17: 32:24
+        _5 = Test(const 0i32,);          // bb0[6]: scope 1 at $DIR/retag.rs:32:17: 32:24
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:32:22: 32:23
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+        _4 = &_5;                        // bb0[7]: scope 1 at $DIR/retag.rs:32:17: 32:24
+        Retag(_4);                       // bb0[8]: scope 1 at $DIR/retag.rs:32:17: 32:24
+        StorageLive(_6);                 // bb0[9]: scope 1 at $DIR/retag.rs:32:29: 32:35
+        StorageLive(_7);                 // bb0[10]: scope 1 at $DIR/retag.rs:32:29: 32:35
+        _7 = &mut _1;                    // bb0[11]: scope 1 at $DIR/retag.rs:32:29: 32:35
+        Retag(_7);                       // bb0[12]: scope 1 at $DIR/retag.rs:32:29: 32:35
+        _6 = &mut (*_7);                 // bb0[13]: scope 1 at $DIR/retag.rs:32:29: 32:35
+        Retag([2phase] _6);              // bb0[14]: scope 1 at $DIR/retag.rs:32:29: 32:35
+        _3 = const Test::foo(move _4, move _6) -> [return: bb2, unwind: bb3]; // bb0[15]: scope 1 at $DIR/retag.rs:32:17: 32:36
+                                         // ty::Const
+                                         // + ty: for<'r, 'x> fn(&'r Test, &'x mut i32) -> &'x mut i32 {Test::foo}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:32:25: 32:28
+                                         // + literal: Const { ty: for<'r, 'x> fn(&'r Test, &'x mut i32) -> &'x mut i32 {Test::foo}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/retag.rs:29:1: 51:2
+    }
+
+    bb2: {
+        Retag(_3);                       // bb2[0]: scope 1 at $DIR/retag.rs:32:17: 32:36
+        StorageDead(_6);                 // bb2[1]: scope 1 at $DIR/retag.rs:32:35: 32:36
+        StorageDead(_4);                 // bb2[2]: scope 1 at $DIR/retag.rs:32:35: 32:36
+        StorageDead(_7);                 // bb2[3]: scope 1 at $DIR/retag.rs:32:36: 32:37
+        drop(_5) -> [return: bb4, unwind: bb1]; // bb2[4]: scope 1 at $DIR/retag.rs:32:36: 32:37
+    }
+
+    bb3 (cleanup): {
+        drop(_5) -> bb1;                 // bb3[0]: scope 1 at $DIR/retag.rs:32:36: 32:37
+    }
+
+    bb4: {
+        StorageDead(_5);                 // bb4[0]: scope 1 at $DIR/retag.rs:32:36: 32:37
+        StorageLive(_8);                 // bb4[1]: scope 2 at $DIR/retag.rs:33:13: 33:14
+        StorageLive(_9);                 // bb4[2]: scope 2 at $DIR/retag.rs:33:19: 33:20
+        _9 = move _3;                    // bb4[3]: scope 2 at $DIR/retag.rs:33:19: 33:20
+        Retag(_9);                       // bb4[4]: scope 2 at $DIR/retag.rs:33:19: 33:20
+        _8 = &mut (*_9);                 // bb4[5]: scope 2 at $DIR/retag.rs:33:19: 33:20
+        Retag(_8);                       // bb4[6]: scope 2 at $DIR/retag.rs:33:19: 33:20
+        StorageDead(_9);                 // bb4[7]: scope 2 at $DIR/retag.rs:33:22: 33:23
+        StorageLive(_10);                // bb4[8]: scope 3 at $DIR/retag.rs:34:13: 34:14
+        _10 = move _8;                   // bb4[9]: scope 3 at $DIR/retag.rs:34:17: 34:18
+        Retag(_10);                      // bb4[10]: scope 3 at $DIR/retag.rs:34:17: 34:18
+        StorageLive(_11);                // bb4[11]: scope 4 at $DIR/retag.rs:36:13: 36:15
+        StorageLive(_12);                // bb4[12]: scope 4 at $DIR/retag.rs:36:18: 36:29
+        _12 = &raw mut (*_10);           // bb4[13]: scope 4 at $DIR/retag.rs:36:18: 36:19
+        Retag([raw] _12);                // bb4[14]: scope 4 at $DIR/retag.rs:36:18: 36:19
+        _11 = _12;                       // bb4[15]: scope 4 at $DIR/retag.rs:36:18: 36:29
+        StorageDead(_12);                // bb4[16]: scope 4 at $DIR/retag.rs:36:29: 36:30
+        _2 = ();                         // bb4[17]: scope 1 at $DIR/retag.rs:31:5: 37:6
+        StorageDead(_11);                // bb4[18]: scope 4 at $DIR/retag.rs:37:5: 37:6
+        StorageDead(_10);                // bb4[19]: scope 3 at $DIR/retag.rs:37:5: 37:6
+        StorageDead(_8);                 // bb4[20]: scope 2 at $DIR/retag.rs:37:5: 37:6
+        StorageDead(_3);                 // bb4[21]: scope 1 at $DIR/retag.rs:37:5: 37:6
+        StorageDead(_2);                 // bb4[22]: scope 1 at $DIR/retag.rs:37:5: 37:6
+        StorageLive(_13);                // bb4[23]: scope 1 at $DIR/retag.rs:40:9: 40:10
+        StorageLive(_14);                // bb4[24]: scope 1 at $DIR/retag.rs:40:31: 43:6
+        _14 = [closure@main::{{closure}}#0]; // bb4[25]: scope 1 at $DIR/retag.rs:40:31: 43:6
+                                         // closure
+                                         // + def_id: DefId(0:14 ~ retag[317d]::main[0]::{{closure}}[0])
+                                         // + substs: [
+                                         //     i8,
+                                         //     for<'r> extern "rust-call" fn((&'r i32,)) -> &'r i32,
+                                         //     (),
+                                         // ]
+        Retag(_14);                      // bb4[26]: scope 1 at $DIR/retag.rs:40:31: 43:6
+        _13 = move _14 as for<'r> fn(&'r i32) -> &'r i32 (Pointer(ClosureFnPointer(Normal))); // bb4[27]: scope 1 at $DIR/retag.rs:40:31: 43:6
+        StorageDead(_14);                // bb4[28]: scope 1 at $DIR/retag.rs:43:5: 43:6
+        StorageLive(_15);                // bb4[29]: scope 6 at $DIR/retag.rs:44:9: 44:11
+        StorageLive(_16);                // bb4[30]: scope 6 at $DIR/retag.rs:44:14: 44:15
+        _16 = _13;                       // bb4[31]: scope 6 at $DIR/retag.rs:44:14: 44:15
+        StorageLive(_17);                // bb4[32]: scope 6 at $DIR/retag.rs:44:16: 44:18
+        StorageLive(_18);                // bb4[33]: scope 6 at $DIR/retag.rs:44:16: 44:18
+        _18 = &_1;                       // bb4[34]: scope 6 at $DIR/retag.rs:44:16: 44:18
+        Retag(_18);                      // bb4[35]: scope 6 at $DIR/retag.rs:44:16: 44:18
+        _17 = &(*_18);                   // bb4[36]: scope 6 at $DIR/retag.rs:44:16: 44:18
+        Retag(_17);                      // bb4[37]: scope 6 at $DIR/retag.rs:44:16: 44:18
+        _15 = move _16(move _17) -> bb5; // bb4[38]: scope 6 at $DIR/retag.rs:44:14: 44:19
+    }
+
+    bb5: {
+        Retag(_15);                      // bb5[0]: scope 6 at $DIR/retag.rs:44:14: 44:19
+        StorageDead(_17);                // bb5[1]: scope 6 at $DIR/retag.rs:44:18: 44:19
+        StorageDead(_16);                // bb5[2]: scope 6 at $DIR/retag.rs:44:18: 44:19
+        StorageDead(_18);                // bb5[3]: scope 6 at $DIR/retag.rs:44:19: 44:20
+        StorageLive(_19);                // bb5[4]: scope 7 at $DIR/retag.rs:47:5: 47:24
+        StorageLive(_20);                // bb5[5]: scope 7 at $DIR/retag.rs:47:5: 47:12
+        StorageLive(_21);                // bb5[6]: scope 7 at $DIR/retag.rs:47:5: 47:12
+        _21 = Test(const 0i32,);         // bb5[7]: scope 7 at $DIR/retag.rs:47:5: 47:12
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:47:10: 47:11
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+        _20 = &_21;                      // bb5[8]: scope 7 at $DIR/retag.rs:47:5: 47:12
+        Retag(_20);                      // bb5[9]: scope 7 at $DIR/retag.rs:47:5: 47:12
+        StorageLive(_22);                // bb5[10]: scope 7 at $DIR/retag.rs:47:21: 47:23
+        StorageLive(_23);                // bb5[11]: scope 7 at $DIR/retag.rs:47:21: 47:23
+        _27 = const main::promoted[0];   // bb5[12]: scope 7 at $DIR/retag.rs:47:21: 47:23
+                                         // ty::Const
+                                         // + ty: &i32
+                                         // + val: Unevaluated(DefId(0:13 ~ retag[317d]::main[0]), [], Some(promoted[0]))
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:47:21: 47:23
+                                         // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:13 ~ retag[317d]::main[0]), [], Some(promoted[0])) }
+        Retag(_27);                      // bb5[13]: scope 7 at $DIR/retag.rs:47:21: 47:23
+        _23 = &(*_27);                   // bb5[14]: scope 7 at $DIR/retag.rs:47:21: 47:23
+        Retag(_23);                      // bb5[15]: scope 7 at $DIR/retag.rs:47:21: 47:23
+        _22 = &(*_23);                   // bb5[16]: scope 7 at $DIR/retag.rs:47:21: 47:23
+        Retag(_22);                      // bb5[17]: scope 7 at $DIR/retag.rs:47:21: 47:23
+        _19 = const Test::foo_shr(move _20, move _22) -> [return: bb6, unwind: bb7]; // bb5[18]: scope 7 at $DIR/retag.rs:47:5: 47:24
+                                         // ty::Const
+                                         // + ty: for<'r, 'x> fn(&'r Test, &'x i32) -> &'x i32 {Test::foo_shr}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:47:13: 47:20
+                                         // + literal: Const { ty: for<'r, 'x> fn(&'r Test, &'x i32) -> &'x i32 {Test::foo_shr}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb6: {
+        Retag(_19);                      // bb6[0]: scope 7 at $DIR/retag.rs:47:5: 47:24
+        StorageDead(_22);                // bb6[1]: scope 7 at $DIR/retag.rs:47:23: 47:24
+        StorageDead(_20);                // bb6[2]: scope 7 at $DIR/retag.rs:47:23: 47:24
+        StorageDead(_23);                // bb6[3]: scope 7 at $DIR/retag.rs:47:24: 47:25
+        drop(_21) -> [return: bb8, unwind: bb1]; // bb6[4]: scope 7 at $DIR/retag.rs:47:24: 47:25
+    }
+
+    bb7 (cleanup): {
+        drop(_21) -> bb1;                // bb7[0]: scope 7 at $DIR/retag.rs:47:24: 47:25
+    }
+
+    bb8: {
+        StorageDead(_21);                // bb8[0]: scope 7 at $DIR/retag.rs:47:24: 47:25
+        StorageDead(_19);                // bb8[1]: scope 7 at $DIR/retag.rs:47:24: 47:25
+        StorageLive(_25);                // bb8[2]: scope 7 at $DIR/retag.rs:50:9: 50:11
+        StorageLive(_26);                // bb8[3]: scope 7 at $DIR/retag.rs:50:14: 50:28
+        _26 = &raw const (*_15);         // bb8[4]: scope 7 at $DIR/retag.rs:50:14: 50:16
+        Retag([raw] _26);                // bb8[5]: scope 7 at $DIR/retag.rs:50:14: 50:16
+        _25 = _26;                       // bb8[6]: scope 7 at $DIR/retag.rs:50:14: 50:28
+        StorageDead(_26);                // bb8[7]: scope 7 at $DIR/retag.rs:50:28: 50:29
+        _0 = ();                         // bb8[8]: scope 0 at $DIR/retag.rs:29:11: 51:2
+        StorageDead(_25);                // bb8[9]: scope 7 at $DIR/retag.rs:51:1: 51:2
+        StorageDead(_15);                // bb8[10]: scope 6 at $DIR/retag.rs:51:1: 51:2
+        StorageDead(_13);                // bb8[11]: scope 1 at $DIR/retag.rs:51:1: 51:2
+        StorageDead(_1);                 // bb8[12]: scope 0 at $DIR/retag.rs:51:1: 51:2
+        return;                          // bb8[13]: scope 0 at $DIR/retag.rs:51:2: 51:2
+    }
+}
diff --git a/src/test/mir-opt/retag/rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir b/src/test/mir-opt/retag/rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
new file mode 100644 (file)
index 0000000..306d305
--- /dev/null
@@ -0,0 +1,23 @@
+// MIR for `std::intrinsics::drop_in_place` after SimplifyCfg-make_shim
+
+fn std::intrinsics::drop_in_place(_1: *mut Test) -> () {
+    let mut _0: ();                      // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _2: &mut Test;               // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _3: ();                      // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+
+    bb0: {
+        Retag([raw] _1);                 // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _2 = &mut (*_1);                 // bb0[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _3 = const <Test as std::ops::Drop>::drop(move _2) -> bb1; // bb0[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: for<'r> fn(&'r mut Test) {<Test as std::ops::Drop>::drop}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: for<'r> fn(&'r mut Test) {<Test as std::ops::Drop>::drop}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1: {
+        return;                          // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+}
diff --git a/src/test/mir-opt/retag/rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..265a4bd
--- /dev/null
@@ -0,0 +1,20 @@
+// MIR for `<impl at $DIR/retag.rs:11:1: 19:2>::foo` after SimplifyCfg-elaborate-drops
+
+fn <impl at $DIR/retag.rs:11:1: 19:2>::foo(_1: &Test, _2: &mut i32) -> &mut i32 {
+    debug self => _1;                    // in scope 0 at $DIR/retag.rs:13:16: 13:21
+    debug x => _2;                       // in scope 0 at $DIR/retag.rs:13:23: 13:24
+    let mut _0: &mut i32;                // return place in scope 0 at $DIR/retag.rs:13:42: 13:53
+    let mut _3: &mut i32;                // in scope 0 at $DIR/retag.rs:14:9: 14:10
+
+    bb0: {
+        Retag([fn entry] _1);            // bb0[0]: scope 0 at $DIR/retag.rs:13:5: 15:6
+        Retag([fn entry] _2);            // bb0[1]: scope 0 at $DIR/retag.rs:13:5: 15:6
+        StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/retag.rs:14:9: 14:10
+        _3 = &mut (*_2);                 // bb0[3]: scope 0 at $DIR/retag.rs:14:9: 14:10
+        Retag(_3);                       // bb0[4]: scope 0 at $DIR/retag.rs:14:9: 14:10
+        _0 = &mut (*_3);                 // bb0[5]: scope 0 at $DIR/retag.rs:14:9: 14:10
+        Retag(_0);                       // bb0[6]: scope 0 at $DIR/retag.rs:14:9: 14:10
+        StorageDead(_3);                 // bb0[7]: scope 0 at $DIR/retag.rs:15:5: 15:6
+        return;                          // bb0[8]: scope 0 at $DIR/retag.rs:15:6: 15:6
+    }
+}
diff --git a/src/test/mir-opt/retag/rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..edf1058
--- /dev/null
@@ -0,0 +1,15 @@
+// MIR for `<impl at $DIR/retag.rs:11:1: 19:2>::foo_shr` after SimplifyCfg-elaborate-drops
+
+fn <impl at $DIR/retag.rs:11:1: 19:2>::foo_shr(_1: &Test, _2: &i32) -> &i32 {
+    debug self => _1;                    // in scope 0 at $DIR/retag.rs:16:20: 16:25
+    debug x => _2;                       // in scope 0 at $DIR/retag.rs:16:27: 16:28
+    let mut _0: &i32;                    // return place in scope 0 at $DIR/retag.rs:16:42: 16:49
+
+    bb0: {
+        Retag([fn entry] _1);            // bb0[0]: scope 0 at $DIR/retag.rs:16:5: 18:6
+        Retag([fn entry] _2);            // bb0[1]: scope 0 at $DIR/retag.rs:16:5: 18:6
+        _0 = _2;                         // bb0[2]: scope 0 at $DIR/retag.rs:17:9: 17:10
+        Retag(_0);                       // bb0[3]: scope 0 at $DIR/retag.rs:17:9: 17:10
+        return;                          // bb0[4]: scope 0 at $DIR/retag.rs:18:6: 18:6
+    }
+}
index 8e9bae8569f196e04cabf92d7c361352e0302193..af1077e6334cc96db16b2dffc70d0e260bf896d7 100644 (file)
@@ -14,17 +14,9 @@ impl<T> PrintName<T> {
     const VOID: ! = panic!();
 }
 
+// EMIT_MIR rustc.no_codegen.PreCodegen.after.mir
 fn no_codegen<T>() {
     let _ = PrintName::<T>::VOID;
 }
 
 fn main() {}
-
-// END RUST SOURCE
-// START rustc.no_codegen.PreCodegen.after.mir
-// bb0: {
-//     StorageLive(_1);
-//     _1 = const PrintName::<T>::VOID;
-//     unreachable;
-// }
-// END rustc.no_codegen.PreCodegen.after.mir
diff --git a/src/test/mir-opt/retain-never-const/rustc.no_codegen.PreCodegen.after.mir b/src/test/mir-opt/retain-never-const/rustc.no_codegen.PreCodegen.after.mir
new file mode 100644 (file)
index 0000000..2d7a79e
--- /dev/null
@@ -0,0 +1,21 @@
+// MIR for `no_codegen` after PreCodegen
+
+fn no_codegen() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/retain-never-const.rs:18:20: 18:20
+    let mut _1: !;                       // in scope 0 at $DIR/retain-never-const.rs:19:13: 19:33
+    scope 1 {
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/retain-never-const.rs:19:13: 19:33
+        _1 = const PrintName::<T>::VOID; // bb0[1]: scope 0 at $DIR/retain-never-const.rs:19:13: 19:33
+                                         // ty::Const
+                                         // + ty: !
+                                         // + val: Unevaluated(DefId(0:9 ~ retain_never_const[317d]::{{impl}}[0]::VOID[0]), [T], None)
+                                         // mir::Constant
+                                         // + span: $DIR/retain-never-const.rs:19:13: 19:33
+                                         // + user_ty: UserType(0)
+                                         // + literal: Const { ty: !, val: Unevaluated(DefId(0:9 ~ retain_never_const[317d]::{{impl}}[0]::VOID[0]), [T], None) }
+        unreachable;                     // bb0[2]: scope 0 at $DIR/retain-never-const.rs:19:13: 19:33
+    }
+}
index fc1a3bb1bf453fde84b2b91b76d9d6cb771bc7c6..c8c7e9188c2ba18d897887abc34c8e041f47f911 100644 (file)
@@ -1,5 +1,7 @@
 // Test that we don't generate unnecessarily large MIR for very simple matches
 
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.match_bool.mir_map.0.mir
 fn match_bool(x: bool) -> usize {
     match x {
         true => 10,
@@ -8,32 +10,3 @@ fn match_bool(x: bool) -> usize {
 }
 
 fn main() {}
-
-
-// END RUST SOURCE
-// START rustc.match_bool.mir_map.0.mir
-// bb0: {
-//     FakeRead(ForMatchedPlace, _1);
-//     switchInt(_1) -> [false: bb3, otherwise: bb2];
-// }
-// bb1 (cleanup): {
-//     resume;
-// }
-// bb2: {
-//     falseEdges -> [real: bb4, imaginary: bb3];
-// }
-// bb3: {
-//     _0 = const 20usize;
-//     goto -> bb5;
-// }
-// bb4: {
-//     _0 = const 10usize;
-//     goto -> bb5;
-// }
-// bb5: {
-//     goto -> bb6;
-// }
-// bb6: {
-//     return;
-// }
-// END rustc.match_bool.mir_map.0.mir
diff --git a/src/test/mir-opt/simple-match/32bit/rustc.match_bool.mir_map.0.mir b/src/test/mir-opt/simple-match/32bit/rustc.match_bool.mir_map.0.mir
new file mode 100644 (file)
index 0000000..b720255
--- /dev/null
@@ -0,0 +1,49 @@
+// MIR for `match_bool` 0 mir_map
+
+fn match_bool(_1: bool) -> usize {
+    debug x => _1;                       // in scope 0 at $DIR/simple-match.rs:5:15: 5:16
+    let mut _0: usize;                   // return place in scope 0 at $DIR/simple-match.rs:5:27: 5:32
+
+    bb0: {
+        FakeRead(ForMatchedPlace, _1);   // bb0[0]: scope 0 at $DIR/simple-match.rs:6:11: 6:12
+        switchInt(_1) -> [false: bb3, otherwise: bb2]; // bb0[1]: scope 0 at $DIR/simple-match.rs:7:9: 7:13
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/simple-match.rs:5:1: 10:2
+    }
+
+    bb2: {
+        falseEdges -> [real: bb4, imaginary: bb3]; // bb2[0]: scope 0 at $DIR/simple-match.rs:7:9: 7:13
+    }
+
+    bb3: {
+        _0 = const 20usize;              // bb3[0]: scope 0 at $DIR/simple-match.rs:8:14: 8:16
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000014))
+                                         // mir::Constant
+                                         // + span: $DIR/simple-match.rs:8:14: 8:16
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000014)) }
+        goto -> bb5;                     // bb3[1]: scope 0 at $DIR/simple-match.rs:6:5: 9:6
+    }
+
+    bb4: {
+        _0 = const 10usize;              // bb4[0]: scope 0 at $DIR/simple-match.rs:7:17: 7:19
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000a))
+                                         // mir::Constant
+                                         // + span: $DIR/simple-match.rs:7:17: 7:19
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000a)) }
+        goto -> bb5;                     // bb4[1]: scope 0 at $DIR/simple-match.rs:6:5: 9:6
+    }
+
+    bb5: {
+        goto -> bb6;                     // bb5[0]: scope 0 at $DIR/simple-match.rs:10:2: 10:2
+    }
+
+    bb6: {
+        return;                          // bb6[0]: scope 0 at $DIR/simple-match.rs:10:2: 10:2
+    }
+}
diff --git a/src/test/mir-opt/simple-match/64bit/rustc.match_bool.mir_map.0.mir b/src/test/mir-opt/simple-match/64bit/rustc.match_bool.mir_map.0.mir
new file mode 100644 (file)
index 0000000..f2fe72d
--- /dev/null
@@ -0,0 +1,49 @@
+// MIR for `match_bool` 0 mir_map
+
+fn match_bool(_1: bool) -> usize {
+    debug x => _1;                       // in scope 0 at $DIR/simple-match.rs:5:15: 5:16
+    let mut _0: usize;                   // return place in scope 0 at $DIR/simple-match.rs:5:27: 5:32
+
+    bb0: {
+        FakeRead(ForMatchedPlace, _1);   // bb0[0]: scope 0 at $DIR/simple-match.rs:6:11: 6:12
+        switchInt(_1) -> [false: bb3, otherwise: bb2]; // bb0[1]: scope 0 at $DIR/simple-match.rs:7:9: 7:13
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/simple-match.rs:5:1: 10:2
+    }
+
+    bb2: {
+        falseEdges -> [real: bb4, imaginary: bb3]; // bb2[0]: scope 0 at $DIR/simple-match.rs:7:9: 7:13
+    }
+
+    bb3: {
+        _0 = const 20usize;              // bb3[0]: scope 0 at $DIR/simple-match.rs:8:14: 8:16
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000014))
+                                         // mir::Constant
+                                         // + span: $DIR/simple-match.rs:8:14: 8:16
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000014)) }
+        goto -> bb5;                     // bb3[1]: scope 0 at $DIR/simple-match.rs:6:5: 9:6
+    }
+
+    bb4: {
+        _0 = const 10usize;              // bb4[0]: scope 0 at $DIR/simple-match.rs:7:17: 7:19
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x000000000000000a))
+                                         // mir::Constant
+                                         // + span: $DIR/simple-match.rs:7:17: 7:19
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x000000000000000a)) }
+        goto -> bb5;                     // bb4[1]: scope 0 at $DIR/simple-match.rs:6:5: 9:6
+    }
+
+    bb5: {
+        goto -> bb6;                     // bb5[0]: scope 0 at $DIR/simple-match.rs:10:2: 10:2
+    }
+
+    bb6: {
+        return;                          // bb6[0]: scope 0 at $DIR/simple-match.rs:10:2: 10:2
+    }
+}
index a8fa64255fb9ae5523a36c6ef26bab2eac28696f..cc6aab7523f009e8064518ecbd79ca142e00bf33 100644 (file)
@@ -12,6 +12,7 @@ enum Dst {
     Foo(u8),
 }
 
+// EMIT_MIR rustc.main.SimplifyArmIdentity.diff
 fn main() {
     let e: Src = Src::Foo(0);
     let _: Dst = match e {
@@ -19,57 +20,3 @@ fn main() {
         Src::Bar => Dst::Foo(0),
     };
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyArmIdentity.before.mir
-// fn main() -> () {
-//     ...
-//     bb0: {
-//         StorageLive(_1);
-//         ((_1 as Foo).0: u8) = const 0u8;
-//         discriminant(_1) = 0;
-//         StorageLive(_2);
-//         _3 = discriminant(_1);
-//         switchInt(move _3) -> [0isize: bb3, 1isize: bb1, otherwise: bb2];
-//     }
-//     bb1: {
-//         ((_2 as Foo).0: u8) = const 0u8;
-//         discriminant(_2) = 0;
-//         goto -> bb4;
-//     }
-//     ...
-//     bb3: {
-//         _4 = ((_1 as Foo).0: u8);
-//         ((_2 as Foo).0: u8) = move _4;
-//         discriminant(_2) = 0;
-//         goto -> bb4;
-//     }
-//     ...
-// }
-// END rustc.main.SimplifyArmIdentity.before.mir
-// START rustc.main.SimplifyArmIdentity.after.mir
-// fn main() -> () {
-//     ...
-//     bb0: {
-//         StorageLive(_1);
-//         ((_1 as Foo).0: u8) = const 0u8;
-//         discriminant(_1) = 0;
-//         StorageLive(_2);
-//         _3 = discriminant(_1);
-//         switchInt(move _3) -> [0isize: bb3, 1isize: bb1, otherwise: bb2];
-//     }
-//     bb1: {
-//         ((_2 as Foo).0: u8) = const 0u8;
-//         discriminant(_2) = 0;
-//         goto -> bb4;
-//     }
-//     ...
-//     bb3: {
-//         _4 = ((_1 as Foo).0: u8);
-//         ((_2 as Foo).0: u8) = move _4;
-//         discriminant(_2) = 0;
-//         goto -> bb4;
-//     }
-//     ...
-// }
-// END rustc.main.SimplifyArmIdentity.after.mir
diff --git a/src/test/mir-opt/simplify-arm-identity/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm-identity/rustc.main.SimplifyArmIdentity.diff
new file mode 100644 (file)
index 0000000..3233812
--- /dev/null
@@ -0,0 +1,64 @@
+- // MIR for `main` before SimplifyArmIdentity
++ // MIR for `main` after SimplifyArmIdentity
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-arm-identity.rs:16:11: 16:11
+      let _1: Src as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/simplify-arm-identity.rs:17:9: 17:10
+      let mut _2: Dst;                     // in scope 0 at $DIR/simplify-arm-identity.rs:18:18: 21:6
+      let mut _3: isize;                   // in scope 0 at $DIR/simplify-arm-identity.rs:19:9: 19:20
+      let mut _5: u8;                      // in scope 0 at $DIR/simplify-arm-identity.rs:19:33: 19:34
+      scope 1 {
+          debug e => _1;                   // in scope 1 at $DIR/simplify-arm-identity.rs:17:9: 17:10
+          let _4: u8;                      // in scope 1 at $DIR/simplify-arm-identity.rs:19:18: 19:19
+          scope 2 {
+          }
+          scope 3 {
+              debug x => _4;               // in scope 3 at $DIR/simplify-arm-identity.rs:19:18: 19:19
+          }
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/simplify-arm-identity.rs:17:9: 17:10
+          ((_1 as Foo).0: u8) = const 0u8; // bb0[1]: scope 0 at $DIR/simplify-arm-identity.rs:17:18: 17:29
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify-arm-identity.rs:17:27: 17:28
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
+          discriminant(_1) = 0;            // bb0[2]: scope 0 at $DIR/simplify-arm-identity.rs:17:18: 17:29
+          StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/simplify-arm-identity.rs:18:18: 21:6
+          _3 = discriminant(_1);           // bb0[4]: scope 1 at $DIR/simplify-arm-identity.rs:19:9: 19:20
+          switchInt(move _3) -> [0isize: bb3, 1isize: bb1, otherwise: bb2]; // bb0[5]: scope 1 at $DIR/simplify-arm-identity.rs:19:9: 19:20
+      }
+  
+      bb1: {
+          ((_2 as Foo).0: u8) = const 0u8; // bb1[0]: scope 1 at $DIR/simplify-arm-identity.rs:20:21: 20:32
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify-arm-identity.rs:20:30: 20:31
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
+          discriminant(_2) = 0;            // bb1[1]: scope 1 at $DIR/simplify-arm-identity.rs:20:21: 20:32
+          goto -> bb4;                     // bb1[2]: scope 1 at $DIR/simplify-arm-identity.rs:18:18: 21:6
+      }
+  
+      bb2: {
+          unreachable;                     // bb2[0]: scope 1 at $DIR/simplify-arm-identity.rs:18:24: 18:25
+      }
+  
+      bb3: {
+          _4 = ((_1 as Foo).0: u8);        // bb3[0]: scope 1 at $DIR/simplify-arm-identity.rs:19:18: 19:19
+          ((_2 as Foo).0: u8) = move _4;   // bb3[1]: scope 3 at $DIR/simplify-arm-identity.rs:19:24: 19:35
+          discriminant(_2) = 0;            // bb3[2]: scope 3 at $DIR/simplify-arm-identity.rs:19:24: 19:35
+          goto -> bb4;                     // bb3[3]: scope 1 at $DIR/simplify-arm-identity.rs:18:18: 21:6
+      }
+  
+      bb4: {
+          StorageDead(_2);                 // bb4[0]: scope 1 at $DIR/simplify-arm-identity.rs:21:6: 21:7
+          StorageDead(_1);                 // bb4[1]: scope 0 at $DIR/simplify-arm-identity.rs:22:1: 22:2
+          return;                          // bb4[2]: scope 0 at $DIR/simplify-arm-identity.rs:22:2: 22:2
+      }
+  }
+  
index e427fd55ad6807a82d9e2cb342ad84e50eddd75b..48cee3c30d2da8e9876f5f547805b135742f864d 100644 (file)
@@ -8,82 +8,10 @@ struct Temp {
 
 fn use_u8(_: u8) {}
 
+// EMIT_MIR rustc.main.SimplifyLocals.diff
 fn main() {
     let ((), ()) = ((), ());
     use_zst(((), ()));
 
     use_u8((Temp { x: 40 }).x + 2);
 }
-
-// END RUST SOURCE
-
-// START rustc.main.SimplifyLocals.before.mir
-// let mut _0: ();
-// let mut _1: ((), ());
-// let mut _2: ();
-// let mut _3: ();
-// let _4: ();
-// let mut _5: ((), ());
-// let mut _6: ();
-// let mut _7: ();
-// let _8: ();
-// let mut _9: u8;
-// let mut _10: u8;
-// let mut _11: Temp;
-// scope 1 {
-// }
-// bb0: {
-//   StorageLive(_1);
-//   StorageLive(_2);
-//   _2 = const ();
-//   StorageLive(_3);
-//   _3 = const ();
-//   _1 = const {transmute(()): ((), ())};
-//   StorageDead(_3);
-//   StorageDead(_2);
-//   StorageDead(_1);
-//   StorageLive(_4);
-//   StorageLive(_6);
-//   _6 = const ();
-//   StorageLive(_7);
-//   _7 = const ();
-//   StorageDead(_7);
-//   StorageDead(_6);
-//   _4 = const use_zst(const {transmute(()): ((), ())}) -> bb1;
-// }
-// bb1: {
-//   StorageDead(_4);
-//   StorageLive(_8);
-//   StorageLive(_10);
-//   StorageLive(_11);
-//   _11 = const {transmute(0x28) : Temp};
-//   _10 = const 40u8;
-//   StorageDead(_10);
-//   _8 = const use_u8(const 42u8) -> bb2;
-// }
-// bb2: {
-//   StorageDead(_11);
-//   StorageDead(_8);
-//   return;
-// }
-// END rustc.main.SimplifyLocals.before.mir
-// START rustc.main.SimplifyLocals.after.mir
-// let mut _0: ();
-// let _1: ();
-// let _2: ();
-// scope 1 {
-// }
-// bb0: {
-//   StorageLive(_1);
-//   _1 = const use_zst(const {transmute(()): ((), ())}) -> bb1;
-// }
-// bb1: {
-//   StorageDead(_1);
-//   StorageLive(_2);
-//   _2 = const use_u8(const 42u8) -> bb2;
-// }
-// bb2: {
-//   StorageDead(_2);
-//   return;
-// }
-// END rustc.main.SimplifyLocals.after.mir
diff --git a/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff b/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff
new file mode 100644 (file)
index 0000000..15deb3e
--- /dev/null
@@ -0,0 +1,132 @@
+- // MIR for `main` before SimplifyLocals
++ // MIR for `main` after SimplifyLocals
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:12:11: 12:11
+-     let mut _1: ((), ());                // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
+-     let mut _2: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
+-     let mut _3: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
+-     let _4: ();                          // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
+-     let mut _5: ((), ());                // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
+-     let mut _6: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
+-     let mut _7: ();                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
+-     let _8: ();                          // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
+-     let mut _9: u8;                      // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:34
+-     let mut _10: u8;                     // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
+-     let mut _11: Temp;                   // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
++     let _1: ();                          // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
++     let _2: ();                          // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
+      scope 1 {
+      }
+  
+      bb0: {
+-         StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
+-         StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
+-         _2 = const ();                   // bb0[2]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
++         StorageLive(_1);                 // bb0[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
++         _1 = const use_zst(const {transmute(()): ((), ())}) -> bb1; // bb0[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
+                                           // ty::Const
+-                                          // + ty: ()
+-                                          // + val: Value(Scalar(<ZST>))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
+-                                          // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
+-         StorageLive(_3);                 // bb0[3]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
+-         _3 = const ();                   // bb0[4]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
+-                                          // ty::Const
+-                                          // + ty: ()
+-                                          // + val: Value(Scalar(<ZST>))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
+-                                          // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
+-         _1 = const {transmute(()): ((), ())}; // bb0[5]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
+-                                          // ty::Const
+-                                          // + ty: ((), ())
+-                                          // + val: Value(Scalar(<ZST>))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
+-                                          // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) }
+-         StorageDead(_3);                 // bb0[6]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28
+-         StorageDead(_2);                 // bb0[7]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28
+-         StorageDead(_1);                 // bb0[8]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:28: 13:29
+-         StorageLive(_4);                 // bb0[9]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
+-         StorageLive(_6);                 // bb0[10]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
+-         _6 = const ();                   // bb0[11]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
+-                                          // ty::Const
+-                                          // + ty: ()
+-                                          // + val: Value(Scalar(<ZST>))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
+-                                          // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
+-         StorageLive(_7);                 // bb0[12]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
+-         _7 = const ();                   // bb0[13]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
+-                                          // ty::Const
+-                                          // + ty: ()
+-                                          // + val: Value(Scalar(<ZST>))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
+-                                          // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
+-         StorageDead(_7);                 // bb0[14]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21
+-         StorageDead(_6);                 // bb0[15]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21
+-         _4 = const use_zst(const {transmute(()): ((), ())}) -> bb1; // bb0[16]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
+-                                          // ty::Const
+                                           // + ty: fn(((), ())) {use_zst}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:12
+                                           // + literal: Const { ty: fn(((), ())) {use_zst}, val: Value(Scalar(<ZST>)) }
+                                           // ty::Const
+                                           // + ty: ((), ())
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
+                                           // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+-         StorageDead(_4);                 // bb1[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:22: 14:23
+-         StorageLive(_8);                 // bb1[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
+-         StorageLive(_10);                // bb1[2]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
+-         StorageLive(_11);                // bb1[3]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
+-         _11 = const {transmute(0x28): Temp}; // bb1[4]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
++         StorageDead(_1);                 // bb1[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:22: 14:23
++         StorageLive(_2);                 // bb1[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
++         _2 = const use_u8(const 42u8) -> bb2; // bb1[2]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
+                                           // ty::Const
+-                                          // + ty: Temp
+-                                          // + val: Value(Scalar(0x28))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
+-                                          // + literal: Const { ty: Temp, val: Value(Scalar(0x28)) }
+-         _10 = const 40u8;                // bb1[5]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
+-                                          // ty::Const
+-                                          // + ty: u8
+-                                          // + val: Value(Scalar(0x28))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
+-                                          // + literal: Const { ty: u8, val: Value(Scalar(0x28)) }
+-         StorageDead(_10);                // bb1[6]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:33: 16:34
+-         _8 = const use_u8(const 42u8) -> bb2; // bb1[7]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
+-                                          // ty::Const
+                                           // + ty: fn(u8) {use_u8}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:11
+                                           // + literal: Const { ty: fn(u8) {use_u8}, val: Value(Scalar(<ZST>)) }
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x2a))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:34
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x2a)) }
+      }
+  
+      bb2: {
+-         StorageDead(_11);                // bb2[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36
+-         StorageDead(_8);                 // bb2[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36
+-         return;                          // bb2[2]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:17:2: 17:2
++         StorageDead(_2);                 // bb2[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36
++         return;                          // bb2[1]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:17:2: 17:2
+      }
+  }
+  
index ef843f7158130b7a326931fd771e66874b4dd8b4..8d588a39d651b1789f739d44e0b38070fd67ae11 100644 (file)
@@ -1,5 +1,7 @@
 // Test that the goto chain starting from bb0 is collapsed.
 
+// EMIT_MIR rustc.main.SimplifyCfg-initial.diff
+// EMIT_MIR rustc.main.SimplifyCfg-early-opt.diff
 fn main() {
     loop {
         if bar() {
@@ -12,43 +14,3 @@ fn main() {
 fn bar() -> bool {
     true
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyCfg-initial.before.mir
-//     bb0: {
-//         goto -> bb1;
-//     }
-//     bb1: {
-//         falseUnwind -> [real: bb3, cleanup: bb4];
-//     }
-//     ...
-//     bb11: {
-//         ...
-//         goto -> bb1;
-//     }
-// END rustc.main.SimplifyCfg-initial.before.mir
-// START rustc.main.SimplifyCfg-initial.after.mir
-//     bb0: {
-//         falseUnwind -> [real: bb1, cleanup: bb2];
-//     }
-//     ...
-//     bb5: {
-//         ...
-//         goto -> bb0;
-//     }
-// END rustc.main.SimplifyCfg-initial.after.mir
-// START rustc.main.SimplifyCfg-early-opt.before.mir
-//     bb0: {
-//         goto -> bb1;
-//     }
-//     bb1: {
-//         StorageLive(_2);
-//         _2 = const bar() -> bb3;
-//     }
-// END rustc.main.SimplifyCfg-early-opt.before.mir
-// START rustc.main.SimplifyCfg-early-opt.after.mir
-//     bb0: {
-//         StorageLive(_2);
-//         _2 = const bar() -> bb1;
-//     }
-// END rustc.main.SimplifyCfg-early-opt.after.mir
diff --git a/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-early-opt.diff b/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-early-opt.diff
new file mode 100644 (file)
index 0000000..9225bcd
--- /dev/null
@@ -0,0 +1,62 @@
+- // MIR for `main` before SimplifyCfg-early-opt
++ // MIR for `main` after SimplifyCfg-early-opt
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_cfg.rs:5:11: 5:11
+      let mut _1: ();                      // in scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
+      let mut _2: bool;                    // in scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
+      let mut _3: !;                       // in scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10
+  
+      bb0: {
+-         goto -> bb1;                     // bb0[0]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
+-     }
+- 
+-     bb1: {
+-         StorageLive(_2);                 // bb1[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
+-         _2 = const bar() -> bb3;         // bb1[1]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
++         StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
++         _2 = const bar() -> bb1;         // bb0[1]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
+                                           // ty::Const
+                                           // + ty: fn() -> bool {bar}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify_cfg.rs:7:12: 7:15
+                                           // + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar(<ZST>)) }
+      }
+  
+-     bb2 (cleanup): {
+-         resume;                          // bb2[0]: scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
++     bb1: {
++         switchInt(_2) -> [false: bb2, otherwise: bb3]; // bb1[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
+      }
+  
+-     bb3: {
+-         nop;                             // bb3[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
+-         switchInt(_2) -> [false: bb5, otherwise: bb4]; // bb3[1]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
++     bb2: {
++         _1 = ();                         // bb2[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
++         StorageDead(_2);                 // bb2[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6
++         goto -> bb0;                     // bb2[2]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
+      }
+  
+-     bb4: {
+-         goto -> bb6;                     // bb4[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
+-     }
+- 
+-     bb5: {
+-         _1 = ();                         // bb5[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
+-         StorageDead(_2);                 // bb5[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6
+-         goto -> bb0;                     // bb5[2]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
+-     }
+- 
+-     bb6: {
+-         _0 = ();                         // bb6[0]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
+-         StorageDead(_2);                 // bb6[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6
+-         return;                          // bb6[2]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2
++     bb3: {
++         _0 = ();                         // bb3[0]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
++         StorageDead(_2);                 // bb3[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6
++         return;                          // bb3[2]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-initial.diff b/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-initial.diff
new file mode 100644 (file)
index 0000000..856ee35
--- /dev/null
@@ -0,0 +1,96 @@
+- // MIR for `main` before SimplifyCfg-initial
++ // MIR for `main` after SimplifyCfg-initial
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_cfg.rs:5:11: 5:11
+      let mut _1: ();                      // in scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
+      let mut _2: bool;                    // in scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
+      let mut _3: !;                       // in scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10
+  
+      bb0: {
+-         goto -> bb1;                     // bb0[0]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
++         falseUnwind -> [real: bb1, cleanup: bb2]; // bb0[0]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
+      }
+  
+      bb1: {
+-         falseUnwind -> [real: bb3, cleanup: bb4]; // bb1[0]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
+-     }
+- 
+-     bb2: {
+-         goto -> bb13;                    // bb2[0]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2
+-     }
+- 
+-     bb3: {
+-         StorageLive(_2);                 // bb3[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
+-         _2 = const bar() -> [return: bb5, unwind: bb4]; // bb3[1]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
++         StorageLive(_2);                 // bb1[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
++         _2 = const bar() -> [return: bb3, unwind: bb2]; // bb1[1]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
+                                           // ty::Const
+                                           // + ty: fn() -> bool {bar}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify_cfg.rs:7:12: 7:15
+                                           // + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar(<ZST>)) }
+      }
+  
+-     bb4 (cleanup): {
+-         resume;                          // bb4[0]: scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
++     bb2 (cleanup): {
++         resume;                          // bb2[0]: scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
+      }
+  
+-     bb5: {
+-         FakeRead(ForMatchedPlace, _2);   // bb5[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
+-         switchInt(_2) -> [false: bb7, otherwise: bb6]; // bb5[1]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
++     bb3: {
++         FakeRead(ForMatchedPlace, _2);   // bb3[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
++         switchInt(_2) -> [false: bb5, otherwise: bb4]; // bb3[1]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
+      }
+  
+-     bb6: {
+-         falseEdges -> [real: bb8, imaginary: bb7]; // bb6[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
++     bb4: {
++         falseEdges -> [real: bb6, imaginary: bb5]; // bb4[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
+      }
+  
+-     bb7: {
+-         _1 = ();                         // bb7[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
+-         goto -> bb12;                    // bb7[1]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
++     bb5: {
++         _1 = ();                         // bb5[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
++         StorageDead(_2);                 // bb5[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6
++         goto -> bb0;                     // bb5[2]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
+      }
+  
+-     bb8: {
+-         _0 = ();                         // bb8[0]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
+-         goto -> bb9;                     // bb8[1]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
+-     }
+- 
+-     bb9: {
+-         StorageDead(_2);                 // bb9[0]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6
+-         goto -> bb2;                     // bb9[1]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
+-     }
+- 
+-     bb10: {
+-         unreachable;                     // bb10[0]: scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10
+-     }
+- 
+-     bb11: {
+-         goto -> bb12;                    // bb11[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
+-     }
+- 
+-     bb12: {
+-         StorageDead(_2);                 // bb12[0]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6
+-         goto -> bb1;                     // bb12[1]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
+-     }
+- 
+-     bb13: {
+-         return;                          // bb13[0]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2
++     bb6: {
++         _0 = ();                         // bb6[0]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
++         StorageDead(_2);                 // bb6[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6
++         return;                          // bb6[2]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2
+      }
+  }
+  
index 471c1df3300f0f7b2f6796e8b49854b27e90a488..e2d3ebe69c4a4e9c31bcc26621c1cfb3c9b80359 100644 (file)
@@ -1,19 +1,9 @@
+#[inline(never)]
+fn noop() {}
+
+// EMIT_MIR rustc.main.SimplifyBranches-after-const-prop.diff
 fn main() {
     if false {
-        println!("hello world!");
+        noop();
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyBranches-after-const-prop.before.mir
-// bb0: {
-//     ...
-//     switchInt(const false) -> [false: bb1, otherwise: bb2];
-// }
-// END rustc.main.SimplifyBranches-after-const-prop.before.mir
-// START rustc.main.SimplifyBranches-after-const-prop.after.mir
-// bb0: {
-//     ...
-//     goto -> bb1;
-// }
-// END rustc.main.SimplifyBranches-after-const-prop.after.mir
diff --git a/src/test/mir-opt/simplify_if/rustc.main.SimplifyBranches-after-const-prop.diff b/src/test/mir-opt/simplify_if/rustc.main.SimplifyBranches-after-const-prop.diff
new file mode 100644 (file)
index 0000000..9e53a0f
--- /dev/null
@@ -0,0 +1,55 @@
+- // MIR for `main` before SimplifyBranches-after-const-prop
++ // MIR for `main` after SimplifyBranches-after-const-prop
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_if.rs:5:11: 5:11
+      let mut _1: bool;                    // in scope 0 at $DIR/simplify_if.rs:6:8: 6:13
+      let _2: ();                          // in scope 0 at $DIR/simplify_if.rs:7:9: 7:15
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/simplify_if.rs:6:8: 6:13
+          _1 = const false;                // bb0[1]: scope 0 at $DIR/simplify_if.rs:6:8: 6:13
+                                           // ty::Const
+                                           // + ty: bool
+                                           // + val: Value(Scalar(0x00))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify_if.rs:6:8: 6:13
+                                           // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+-         switchInt(const false) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6
+-                                          // ty::Const
+-                                          // + ty: bool
+-                                          // + val: Value(Scalar(0x00))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify_if.rs:6:5: 8:6
+-                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
++         goto -> bb1;                     // bb0[2]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6
+      }
+  
+      bb1: {
+          _0 = ();                         // bb1[0]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6
+          goto -> bb4;                     // bb1[1]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6
+      }
+  
+      bb2: {
+          StorageLive(_2);                 // bb2[0]: scope 0 at $DIR/simplify_if.rs:7:9: 7:15
+          _2 = const noop() -> bb3;        // bb2[1]: scope 0 at $DIR/simplify_if.rs:7:9: 7:15
+                                           // ty::Const
+                                           // + ty: fn() {noop}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify_if.rs:7:9: 7:13
+                                           // + literal: Const { ty: fn() {noop}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb3: {
+          StorageDead(_2);                 // bb3[0]: scope 0 at $DIR/simplify_if.rs:7:15: 7:16
+          _0 = ();                         // bb3[1]: scope 0 at $DIR/simplify_if.rs:6:14: 8:6
+          goto -> bb4;                     // bb3[2]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6
+      }
+  
+      bb4: {
+          StorageDead(_1);                 // bb4[0]: scope 0 at $DIR/simplify_if.rs:9:1: 9:2
+          return;                          // bb4[1]: scope 0 at $DIR/simplify_if.rs:9:2: 9:2
+      }
+  }
+  
index 8624899a0abf25f34a4fc69ab298011ec8792668..233f9ff4c400bb5662a12285b1f72a649d77640e 100644 (file)
@@ -1,22 +1,10 @@
+#[inline(never)]
+fn noop() {}
+
+// EMIT_MIR rustc.main.SimplifyBranches-after-copy-prop.diff
 fn main() {
     match { let x = false; x } {
-        true => println!("hello world!"),
+        true => noop(),
         false => {},
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.SimplifyBranches-after-copy-prop.before.mir
-// bb0: {
-//     ...
-//     switchInt(const false) -> [false: bb1, otherwise: bb2];
-// }
-// bb1: {
-// END rustc.main.SimplifyBranches-after-copy-prop.before.mir
-// START rustc.main.SimplifyBranches-after-copy-prop.after.mir
-// bb0: {
-//     ...
-//     goto -> bb1;
-// }
-// bb1: {
-// END rustc.main.SimplifyBranches-after-copy-prop.after.mir
diff --git a/src/test/mir-opt/simplify_match/rustc.main.SimplifyBranches-after-copy-prop.diff b/src/test/mir-opt/simplify_match/rustc.main.SimplifyBranches-after-copy-prop.diff
new file mode 100644 (file)
index 0000000..5429032
--- /dev/null
@@ -0,0 +1,48 @@
+- // MIR for `main` before SimplifyBranches-after-copy-prop
++ // MIR for `main` after SimplifyBranches-after-copy-prop
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify_match.rs:5:11: 5:11
+      let mut _1: bool;                    // in scope 0 at $DIR/simplify_match.rs:6:11: 6:31
+      let _2: bool;                        // in scope 0 at $DIR/simplify_match.rs:6:17: 6:18
+      scope 1 {
+          debug x => _2;                   // in scope 1 at $DIR/simplify_match.rs:6:17: 6:18
+      }
+  
+      bb0: {
+          nop;                             // bb0[0]: scope 0 at $DIR/simplify_match.rs:6:11: 6:31
+          nop;                             // bb0[1]: scope 0 at $DIR/simplify_match.rs:6:17: 6:18
+          nop;                             // bb0[2]: scope 0 at $DIR/simplify_match.rs:6:21: 6:26
+          nop;                             // bb0[3]: scope 1 at $DIR/simplify_match.rs:6:28: 6:29
+          nop;                             // bb0[4]: scope 0 at $DIR/simplify_match.rs:6:30: 6:31
+-         switchInt(const false) -> [false: bb1, otherwise: bb2]; // bb0[5]: scope 0 at $DIR/simplify_match.rs:7:9: 7:13
+-                                          // ty::Const
+-                                          // + ty: bool
+-                                          // + val: Value(Scalar(0x00))
+-                                          // mir::Constant
+-                                          // + span: $DIR/simplify_match.rs:6:21: 6:26
+-                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
++         goto -> bb1;                     // bb0[5]: scope 0 at $DIR/simplify_match.rs:7:9: 7:13
+      }
+  
+      bb1: {
+          nop;                             // bb1[0]: scope 0 at $DIR/simplify_match.rs:8:18: 8:20
+          goto -> bb3;                     // bb1[1]: scope 0 at $DIR/simplify_match.rs:6:5: 9:6
+      }
+  
+      bb2: {
+          _0 = const noop() -> bb3;        // bb2[0]: scope 0 at $DIR/simplify_match.rs:7:17: 7:23
+                                           // ty::Const
+                                           // + ty: fn() {noop}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify_match.rs:7:17: 7:21
+                                           // + literal: Const { ty: fn() {noop}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb3: {
+          nop;                             // bb3[0]: scope 0 at $DIR/simplify_match.rs:10:1: 10:2
+          return;                          // bb3[1]: scope 0 at $DIR/simplify_match.rs:10:2: 10:2
+      }
+  }
+  
index 78a7f722538edb2c82d54e0d9c8eb2078042d2bc..88a0451a76f67e1b32f7c34d23c85a92b3a0c07f 100644 (file)
@@ -1,3 +1,7 @@
+// EMIT_MIR rustc.try_identity.SimplifyArmIdentity.diff
+// EMIT_MIR rustc.try_identity.SimplifyBranchSame.after.mir
+// EMIT_MIR rustc.try_identity.SimplifyLocals.after.mir
+
 fn try_identity(x: Result<u32, i32>) -> Result<u32, i32> {
     let y = x?;
     Ok(y)
@@ -6,210 +10,3 @@ fn try_identity(x: Result<u32, i32>) -> Result<u32, i32> {
 fn main() {
     let _ = try_identity(Ok(0));
 }
-
-// END RUST SOURCE
-// START rustc.try_identity.SimplifyArmIdentity.before.mir
-// fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
-//     debug x => _1;
-//     let mut _0: std::result::Result<u32, i32>;
-//     let _2: u32;
-//     let mut _3: std::result::Result<u32, i32>;
-//     let mut _4: std::result::Result<u32, i32>;
-//     let mut _5: isize;
-//     let _6: i32;
-//     let mut _7: !;
-//     let mut _8: i32;
-//     let mut _9: i32;
-//     let _10: u32;
-//     let mut _11: u32;
-//     scope 1 {
-//         debug y => _10;
-//     }
-//     scope 2 {
-//         debug err => _6;
-//         scope 3 {
-//             scope 7 {
-//                 debug t => _6;
-//             }
-//             scope 8 {
-//                 debug v => _6;
-//                 let mut _12: i32;
-//             }
-//         }
-//     }
-//     scope 4 {
-//         debug val => _10;
-//         scope 5 {
-//         }
-//     }
-//     scope 6 {
-//         debug self => _1;
-//     }
-//     bb0: {
-//         _5 = discriminant(_1);
-//         switchInt(move _5) -> [0isize: bb1, otherwise: bb2];
-//     }
-//     bb1: {
-//         _10 = ((_1 as Ok).0: u32);
-//         ((_0 as Ok).0: u32) = move _10;
-//         discriminant(_0) = 0;
-//         goto -> bb3;
-//     }
-//     bb2: {
-//         _6 = ((_1 as Err).0: i32);
-//         ((_0 as Err).0: i32) = move _6;
-//         discriminant(_0) = 1;
-//         goto -> bb3;
-//     }
-//     bb3: {
-//         return;
-//     }
-// }
-// END rustc.try_identity.SimplifyArmIdentity.before.mir
-
-// START rustc.try_identity.SimplifyArmIdentity.after.mir
-// fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
-//     debug x => _1;
-//     let mut _0: std::result::Result<u32, i32>;
-//     let _2: u32;
-//     let mut _3: std::result::Result<u32, i32>;
-//     let mut _4: std::result::Result<u32, i32>;
-//     let mut _5: isize;
-//     let _6: i32;
-//     let mut _7: !;
-//     let mut _8: i32;
-//     let mut _9: i32;
-//     let _10: u32;
-//     let mut _11: u32;
-//     scope 1 {
-//         debug y => _10;
-//     }
-//     scope 2 {
-//         debug err => _6;
-//         scope 3 {
-//             scope 7 {
-//                 debug t => _6;
-//             }
-//             scope 8 {
-//                 debug v => _6;
-//                 let mut _12: i32;
-//             }
-//         }
-//     }
-//     scope 4 {
-//         debug val => _10;
-//         scope 5 {
-//         }
-//     }
-//     scope 6 {
-//         debug self => _1;
-//     }
-//     bb0: {
-//         _5 = discriminant(_1);
-//         switchInt(move _5) -> [0isize: bb1, otherwise: bb2];
-//     }
-//     bb1: {
-//         _0 = move _1;
-//         nop;
-//         nop;
-//         goto -> bb3;
-//     }
-//     bb2: {
-//         _0 = move _1;
-//         nop;
-//         nop;
-//         goto -> bb3;
-//     }
-//     bb3: {
-//         return;
-//     }
-// }
-// END rustc.try_identity.SimplifyArmIdentity.after.mir
-
-// START rustc.try_identity.SimplifyBranchSame.after.mir
-// fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
-//     debug x => _1;
-//     let mut _0: std::result::Result<u32, i32>;
-//     let _2: u32;
-//     let mut _3: std::result::Result<u32, i32>;
-//     let mut _4: std::result::Result<u32, i32>;
-//     let mut _5: isize;
-//     let _6: i32;
-//     let mut _7: !;
-//     let mut _8: i32;
-//     let mut _9: i32;
-//     let _10: u32;
-//     let mut _11: u32;
-//     scope 1 {
-//         debug y => _10;
-//     }
-//     scope 2 {
-//         debug err => _6;
-//         scope 3 {
-//             scope 7 {
-//                 debug t => _6;
-//             }
-//             scope 8 {
-//                 debug v => _6;
-//                 let mut _12: i32;
-//             }
-//         }
-//     }
-//     scope 4 {
-//         debug val => _10;
-//         scope 5 {
-//         }
-//     }
-//     scope 6 {
-//         debug self => _1;
-//     }
-//     bb0: {
-//         _5 = discriminant(_1);
-//         goto -> bb1;
-//     }
-//     bb1: {
-//         _0 = move _1;
-//         nop;
-//         nop;
-//         goto -> bb2;
-//     }
-//     bb2: {
-//         return;
-//     }
-// }
-// END rustc.try_identity.SimplifyBranchSame.after.mir
-
-// START rustc.try_identity.SimplifyLocals.after.mir
-// fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
-//     debug x => _1;
-//     let mut _0: std::result::Result<u32, i32>;
-//     let _2: i32;
-//     let _3: u32;
-//     scope 1 {
-//         debug y => _3;
-//     }
-//     scope 2 {
-//         debug err => _2;
-//         scope 3 {
-//             scope 7 {
-//                 debug t => _2;
-//             }
-//             scope 8 {
-//                 debug v => _2;
-//             }
-//         }
-//     }
-//     scope 4 {
-//         debug val => _3;
-//         scope 5 {
-//         }
-//     }
-//     scope 6 {
-//         debug self => _1;
-//     }
-//     bb0: {
-//         _0 = move _1;
-//         return;
-//     }
-// }
-// END rustc.try_identity.SimplifyLocals.after.mir
diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff
new file mode 100644 (file)
index 0000000..a4cc6b8
--- /dev/null
@@ -0,0 +1,70 @@
+- // MIR for `try_identity` before SimplifyArmIdentity
++ // MIR for `try_identity` after SimplifyArmIdentity
+  
+  fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
+      debug x => _1;                       // in scope 0 at $DIR/simplify_try.rs:5:17: 5:18
+      let mut _0: std::result::Result<u32, i32>; // return place in scope 0 at $DIR/simplify_try.rs:5:41: 5:57
+      let _2: u32;                         // in scope 0 at $DIR/simplify_try.rs:6:9: 6:10
+      let mut _3: std::result::Result<u32, i32>; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15
+      let mut _4: std::result::Result<u32, i32>; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:14
+      let mut _5: isize;                   // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+      let _6: i32;                         // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+      let mut _7: !;                       // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+      let mut _8: i32;                     // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+      let mut _9: i32;                     // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+      let _10: u32;                        // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15
+      let mut _11: u32;                    // in scope 0 at $DIR/simplify_try.rs:7:8: 7:9
+      scope 1 {
+          debug y => _10;                  // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10
+      }
+      scope 2 {
+          debug err => _6;                 // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15
+          scope 3 {
+              scope 7 {
+                  debug t => _6;           // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL
+              }
+              scope 8 {
+                  debug v => _6;           // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
+                  let mut _12: i32;        // in scope 8 at $DIR/simplify_try.rs:6:14: 6:15
+              }
+          }
+      }
+      scope 4 {
+          debug val => _10;                // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15
+          scope 5 {
+          }
+      }
+      scope 6 {
+          debug self => _1;                // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL
+      }
+  
+      bb0: {
+          _5 = discriminant(_1);           // bb0[0]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+          switchInt(move _5) -> [0isize: bb1, otherwise: bb2]; // bb0[1]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+      }
+  
+      bb1: {
+-         _10 = ((_1 as Ok).0: u32);       // bb1[0]: scope 0 at $DIR/simplify_try.rs:6:13: 6:15
+-         ((_0 as Ok).0: u32) = move _10;  // bb1[1]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
+-         discriminant(_0) = 0;            // bb1[2]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
++         _0 = move _1;                    // bb1[0]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
++         nop;                             // bb1[1]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
++         nop;                             // bb1[2]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
+          goto -> bb3;                     // bb1[3]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2
+      }
+  
+      bb2: {
+-         _6 = ((_1 as Err).0: i32);       // bb2[0]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+-         ((_0 as Err).0: i32) = move _6;  // bb2[1]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
+-         discriminant(_0) = 1;            // bb2[2]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
++         _0 = move _1;                    // bb2[0]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
++         nop;                             // bb2[1]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
++         nop;                             // bb2[2]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
+          goto -> bb3;                     // bb2[3]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+      }
+  
+      bb3: {
+          return;                          // bb3[0]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir
new file mode 100644 (file)
index 0000000..a18fb64
--- /dev/null
@@ -0,0 +1,55 @@
+// MIR for `try_identity` after SimplifyBranchSame
+
+fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
+    debug x => _1;                       // in scope 0 at $DIR/simplify_try.rs:5:17: 5:18
+    let mut _0: std::result::Result<u32, i32>; // return place in scope 0 at $DIR/simplify_try.rs:5:41: 5:57
+    let _2: u32;                         // in scope 0 at $DIR/simplify_try.rs:6:9: 6:10
+    let mut _3: std::result::Result<u32, i32>; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15
+    let mut _4: std::result::Result<u32, i32>; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:14
+    let mut _5: isize;                   // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+    let _6: i32;                         // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+    let mut _7: !;                       // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+    let mut _8: i32;                     // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+    let mut _9: i32;                     // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+    let _10: u32;                        // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15
+    let mut _11: u32;                    // in scope 0 at $DIR/simplify_try.rs:7:8: 7:9
+    scope 1 {
+        debug y => _10;                  // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10
+    }
+    scope 2 {
+        debug err => _6;                 // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15
+        scope 3 {
+            scope 7 {
+                debug t => _6;           // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL
+            }
+            scope 8 {
+                debug v => _6;           // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
+                let mut _12: i32;        // in scope 8 at $DIR/simplify_try.rs:6:14: 6:15
+            }
+        }
+    }
+    scope 4 {
+        debug val => _10;                // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15
+        scope 5 {
+        }
+    }
+    scope 6 {
+        debug self => _1;                // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL
+    }
+
+    bb0: {
+        _5 = discriminant(_1);           // bb0[0]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+        goto -> bb1;                     // bb0[1]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+    }
+
+    bb1: {
+        _0 = move _1;                    // bb1[0]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
+        nop;                             // bb1[1]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
+        nop;                             // bb1[2]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
+        goto -> bb2;                     // bb1[3]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2
+    }
+
+    bb2: {
+        return;                          // bb2[0]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2
+    }
+}
diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir
new file mode 100644 (file)
index 0000000..b7ed760
--- /dev/null
@@ -0,0 +1,35 @@
+// MIR for `try_identity` after SimplifyLocals
+
+fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
+    debug x => _1;                       // in scope 0 at $DIR/simplify_try.rs:5:17: 5:18
+    let mut _0: std::result::Result<u32, i32>; // return place in scope 0 at $DIR/simplify_try.rs:5:41: 5:57
+    let _2: i32;                         // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15
+    let _3: u32;                         // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15
+    scope 1 {
+        debug y => _3;                   // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10
+    }
+    scope 2 {
+        debug err => _2;                 // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15
+        scope 3 {
+            scope 7 {
+                debug t => _2;           // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL
+            }
+            scope 8 {
+                debug v => _2;           // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL
+            }
+        }
+    }
+    scope 4 {
+        debug val => _3;                 // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15
+        scope 5 {
+        }
+    }
+    scope 6 {
+        debug self => _1;                // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL
+    }
+
+    bb0: {
+        _0 = move _1;                    // bb0[0]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10
+        return;                          // bb0[1]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2
+    }
+}
index a25375594d3e17c413d3974f381a92fd4266e09c..5d8d37e0bc50fb2c137b8dac096a8b7dbf8bea45 100644 (file)
@@ -1,90 +1,7 @@
 // compile-flags: -Zmir-opt-level=0
 
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir
 fn main() {
     let _fn = std::ptr::drop_in_place::<[String]> as unsafe fn(_);
 }
-
-// END RUST SOURCE
-
-// START rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir
-// let mut _2: usize;
-// let mut _3: usize;
-// let mut _4: usize;
-// let mut _5: *mut std::string::String;
-// let mut _6: bool;
-// let mut _7: *mut std::string::String;
-// let mut _8: bool;
-// let mut _9: *mut std::string::String;
-// let mut _10: *mut std::string::String;
-// let mut _11: *mut std::string::String;
-// let mut _12: bool;
-// let mut _13: *mut std::string::String;
-// let mut _14: bool;
-// let mut _15: *mut [std::string::String];
-// bb0: {
-//     goto -> bb15;
-// }
-// bb1: {
-//     return;
-// }
-// bb2 (cleanup): {
-//     resume;
-// }
-// bb3 (cleanup): {
-//     _5 = &raw mut (*_1)[_4];
-//     _4 = Add(move _4, const 1usize);
-//     drop((*_5)) -> bb4;
-// }
-// bb4 (cleanup): {
-//     _6 = Eq(_4, _3);
-//     switchInt(move _6) -> [false: bb3, otherwise: bb2];
-// }
-// bb5: {
-//     _7 = &raw mut (*_1)[_4];
-//     _4 = Add(move _4, const 1usize);
-//     drop((*_7)) -> [return: bb6, unwind: bb4];
-// }
-// bb6: {
-//     _8 = Eq(_4, _3);
-//     switchInt(move _8) -> [false: bb5, otherwise: bb1];
-// }
-// bb7: {
-//     _4 = const 0usize;
-//     goto -> bb6;
-// }
-// bb8: {
-//     goto -> bb7;
-// }
-// bb9 (cleanup): {
-//     _11 = _9;
-//     _9 = Offset(move _9, const 1usize);
-//     drop((*_11)) -> bb10;
-// }
-// bb10 (cleanup): {
-//     _12 = Eq(_9, _10);
-//     switchInt(move _12) -> [false: bb9, otherwise: bb2];
-// }
-// bb11: {
-//     _13 = _9;
-//     _9 = Offset(move _9, const 1usize);
-//     drop((*_13)) -> [return: bb12, unwind: bb10];
-// }
-// bb12: {
-//     _14 = Eq(_9, _10);
-//     switchInt(move _14) -> [false: bb11, otherwise: bb1];
-// }
-// bb13: {
-//     _15 = &raw mut (*_1);
-//     _9 = move _15 as *mut std::string::String (Misc);
-//     _10 = Offset(_9, move _3);
-//     goto -> bb12;
-// }
-// bb14: {
-//     goto -> bb13;
-// }
-// bb15: {
-//     _2 = SizeOf(std::string::String);
-//     _3 = Len((*_1));
-//     switchInt(move _2) -> [0usize: bb8, otherwise: bb14];
-// }
-// END rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir
diff --git a/src/test/mir-opt/slice-drop-shim/32bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir b/src/test/mir-opt/slice-drop-shim/32bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir
new file mode 100644 (file)
index 0000000..e397adc
--- /dev/null
@@ -0,0 +1,131 @@
+// MIR for `std::intrinsics::drop_in_place` before AddMovesForPackedDrops
+
+fn std::intrinsics::drop_in_place(_1: *mut [std::string::String]) -> () {
+    let mut _0: ();                      // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _2: usize;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _3: usize;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _4: usize;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _5: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _6: bool;                    // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _7: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _8: bool;                    // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _9: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _10: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _11: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _12: bool;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _13: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _14: bool;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _15: *mut [std::string::String]; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+
+    bb0: {
+        goto -> bb15;                    // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb1: {
+        return;                          // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb2 (cleanup): {
+        resume;                          // bb2[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb3 (cleanup): {
+        _5 = &raw mut (*_1)[_4];         // bb3[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _4 = Add(move _4, const 1usize); // bb3[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+        drop((*_5)) -> bb4;              // bb3[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb4 (cleanup): {
+        _6 = Eq(_4, _3);                 // bb4[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _6) -> [false: bb3, otherwise: bb2]; // bb4[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb5: {
+        _7 = &raw mut (*_1)[_4];         // bb5[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _4 = Add(move _4, const 1usize); // bb5[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+        drop((*_7)) -> [return: bb6, unwind: bb4]; // bb5[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb6: {
+        _8 = Eq(_4, _3);                 // bb6[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _8) -> [false: bb5, otherwise: bb1]; // bb6[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb7: {
+        _4 = const 0usize;               // bb7[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) }
+        goto -> bb6;                     // bb7[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb8: {
+        goto -> bb7;                     // bb8[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb9 (cleanup): {
+        _11 = _9;                        // bb9[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _9 = Offset(move _9, const 1usize); // bb9[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+        drop((*_11)) -> bb10;            // bb9[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb10 (cleanup): {
+        _12 = Eq(_9, _10);               // bb10[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _12) -> [false: bb9, otherwise: bb2]; // bb10[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb11: {
+        _13 = _9;                        // bb11[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _9 = Offset(move _9, const 1usize); // bb11[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
+        drop((*_13)) -> [return: bb12, unwind: bb10]; // bb11[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb12: {
+        _14 = Eq(_9, _10);               // bb12[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _14) -> [false: bb11, otherwise: bb1]; // bb12[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb13: {
+        _15 = &raw mut (*_1);            // bb13[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _9 = move _15 as *mut std::string::String (Misc); // bb13[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _10 = Offset(_9, move _3);       // bb13[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        goto -> bb12;                    // bb13[3]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb14: {
+        goto -> bb13;                    // bb14[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb15: {
+        _2 = SizeOf(std::string::String); // bb15[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _3 = Len((*_1));                 // bb15[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _2) -> [0usize: bb8, otherwise: bb14]; // bb15[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+}
diff --git a/src/test/mir-opt/slice-drop-shim/64bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir b/src/test/mir-opt/slice-drop-shim/64bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir
new file mode 100644 (file)
index 0000000..fd2bfe4
--- /dev/null
@@ -0,0 +1,131 @@
+// MIR for `std::intrinsics::drop_in_place` before AddMovesForPackedDrops
+
+fn std::intrinsics::drop_in_place(_1: *mut [std::string::String]) -> () {
+    let mut _0: ();                      // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _2: usize;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _3: usize;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _4: usize;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _5: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _6: bool;                    // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _7: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _8: bool;                    // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _9: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _10: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _11: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _12: bool;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _13: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _14: bool;                   // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _15: *mut [std::string::String]; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+
+    bb0: {
+        goto -> bb15;                    // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb1: {
+        return;                          // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb2 (cleanup): {
+        resume;                          // bb2[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb3 (cleanup): {
+        _5 = &raw mut (*_1)[_4];         // bb3[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _4 = Add(move _4, const 1usize); // bb3[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000001))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+        drop((*_5)) -> bb4;              // bb3[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb4 (cleanup): {
+        _6 = Eq(_4, _3);                 // bb4[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _6) -> [false: bb3, otherwise: bb2]; // bb4[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb5: {
+        _7 = &raw mut (*_1)[_4];         // bb5[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _4 = Add(move _4, const 1usize); // bb5[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000001))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+        drop((*_7)) -> [return: bb6, unwind: bb4]; // bb5[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb6: {
+        _8 = Eq(_4, _3);                 // bb6[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _8) -> [false: bb5, otherwise: bb1]; // bb6[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb7: {
+        _4 = const 0usize;               // bb7[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000000))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
+        goto -> bb6;                     // bb7[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb8: {
+        goto -> bb7;                     // bb8[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb9 (cleanup): {
+        _11 = _9;                        // bb9[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _9 = Offset(move _9, const 1usize); // bb9[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000001))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+        drop((*_11)) -> bb10;            // bb9[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb10 (cleanup): {
+        _12 = Eq(_9, _10);               // bb10[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _12) -> [false: bb9, otherwise: bb2]; // bb10[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb11: {
+        _13 = _9;                        // bb11[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _9 = Offset(move _9, const 1usize); // bb11[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: usize
+                                         // + val: Value(Scalar(0x0000000000000001))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+        drop((*_13)) -> [return: bb12, unwind: bb10]; // bb11[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb12: {
+        _14 = Eq(_9, _10);               // bb12[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _14) -> [false: bb11, otherwise: bb1]; // bb12[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb13: {
+        _15 = &raw mut (*_1);            // bb13[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _9 = move _15 as *mut std::string::String (Misc); // bb13[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _10 = Offset(_9, move _3);       // bb13[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        goto -> bb12;                    // bb13[3]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb14: {
+        goto -> bb13;                    // bb14[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb15: {
+        _2 = SizeOf(std::string::String); // bb15[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _3 = Len((*_1));                 // bb15[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        switchInt(move _2) -> [0usize: bb8, otherwise: bb14]; // bb15[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+}
index 1c98766b9685c254a4d6f71fe1359c3430e3d574..a269914f2620d7b332ee774813342758ac36405e 100644 (file)
@@ -1,8 +1,7 @@
 // Check that when we compile the static `XXX` into MIR, we do not
 // generate `StorageStart` or `StorageEnd` statements.
 
-// ignore-tidy-linelength
-
+// EMIT_MIR rustc.XXX.mir_map.0.mir
 static XXX: &'static Foo = &Foo {
     tup: "hi",
     data: &[
@@ -32,159 +31,3 @@ struct Foo {
 fn main() {
     println!("{:?}", XXX);
 }
-
-// END RUST SOURCE
-// START rustc.XXX.mir_map.0.mir
-//    let mut _0: &Foo;
-//    let _1: &Foo;
-//    let _2: Foo;
-//    let mut _3: &[(u32, u32)];
-//    let mut _4: &[(u32, u32); 42];
-//    let _5: &[(u32, u32); 42];
-//    let _6: [(u32, u32); 42];
-//    let mut _7: (u32, u32);
-//    let mut _8: (u32, u32);
-//    let mut _9: (u32, u32);
-//    let mut _10: (u32, u32);
-//    let mut _11: (u32, u32);
-//    let mut _12: (u32, u32);
-//    let mut _13: (u32, u32);
-//    let mut _14: (u32, u32);
-//    let mut _15: (u32, u32);
-//    let mut _16: (u32, u32);
-//    let mut _17: (u32, u32);
-//    let mut _18: (u32, u32);
-//    let mut _19: (u32, u32);
-//    let mut _20: (u32, u32);
-//    let mut _21: (u32, u32);
-//    let mut _22: (u32, u32);
-//    let mut _23: (u32, u32);
-//    let mut _24: (u32, u32);
-//    let mut _25: (u32, u32);
-//    let mut _26: (u32, u32);
-//    let mut _27: (u32, u32);
-//    let mut _28: (u32, u32);
-//    let mut _29: (u32, u32);
-//    let mut _30: (u32, u32);
-//    let mut _31: (u32, u32);
-//    let mut _32: (u32, u32);
-//    let mut _33: (u32, u32);
-//    let mut _34: (u32, u32);
-//    let mut _35: (u32, u32);
-//    let mut _36: (u32, u32);
-//    let mut _37: (u32, u32);
-//    let mut _38: (u32, u32);
-//    let mut _39: (u32, u32);
-//    let mut _40: (u32, u32);
-//    let mut _41: (u32, u32);
-//    let mut _42: (u32, u32);
-//    let mut _43: (u32, u32);
-//    let mut _44: (u32, u32);
-//    let mut _45: (u32, u32);
-//    let mut _46: (u32, u32);
-//    let mut _47: (u32, u32);
-//    let mut _48: (u32, u32);
-//    bb0: {
-//        StorageLive(_1);
-//        StorageLive(_2);
-//        StorageLive(_3);
-//        StorageLive(_4);
-//        StorageLive(_5);
-//        StorageLive(_6);
-//        StorageLive(_7);
-//        _7 = (const 0u32, const 1u32);
-//        StorageLive(_8);
-//        _8 = (const 0u32, const 2u32);
-//        StorageLive(_9);
-//        _9 = (const 0u32, const 3u32);
-//        StorageLive(_10);
-//        _10 = (const 0u32, const 1u32);
-//        StorageLive(_11);
-//        _11 = (const 0u32, const 2u32);
-//        StorageLive(_12);
-//        _12 = (const 0u32, const 3u32);
-//        StorageLive(_13);
-//        _13 = (const 0u32, const 1u32);
-//        StorageLive(_14);
-//        _14 = (const 0u32, const 2u32);
-//        StorageLive(_15);
-//        _15 = (const 0u32, const 3u32);
-//        StorageLive(_16);
-//        _16 = (const 0u32, const 1u32);
-//        StorageLive(_17);
-//        _17 = (const 0u32, const 2u32);
-//        StorageLive(_18);
-//        _18 = (const 0u32, const 3u32);
-//        StorageLive(_19);
-//        _19 = (const 0u32, const 1u32);
-//        StorageLive(_20);
-//        _20 = (const 0u32, const 2u32);
-//        StorageLive(_21);
-//        _21 = (const 0u32, const 3u32);
-//        StorageLive(_22);
-//        _22 = (const 0u32, const 1u32);
-//        StorageLive(_23);
-//        _23 = (const 0u32, const 2u32);
-//        StorageLive(_24);
-//        _24 = (const 0u32, const 3u32);
-//        StorageLive(_25);
-//        _25 = (const 0u32, const 1u32);
-//        StorageLive(_26);
-//        _26 = (const 0u32, const 2u32);
-//        StorageLive(_27);
-//        _27 = (const 0u32, const 3u32);
-//        StorageLive(_28);
-//        _28 = (const 0u32, const 1u32);
-//        StorageLive(_29);
-//        _29 = (const 0u32, const 2u32);
-//        StorageLive(_30);
-//        _30 = (const 0u32, const 3u32);
-//        StorageLive(_31);
-//        _31 = (const 0u32, const 1u32);
-//        StorageLive(_32);
-//        _32 = (const 0u32, const 2u32);
-//        StorageLive(_33);
-//        _33 = (const 0u32, const 3u32);
-//        StorageLive(_34);
-//        _34 = (const 0u32, const 1u32);
-//        StorageLive(_35);
-//        _35 = (const 0u32, const 2u32);
-//        StorageLive(_36);
-//        _36 = (const 0u32, const 3u32);
-//        StorageLive(_37);
-//        _37 = (const 0u32, const 1u32);
-//        StorageLive(_38);
-//        _38 = (const 0u32, const 2u32);
-//        StorageLive(_39);
-//        _39 = (const 0u32, const 3u32);
-//        StorageLive(_40);
-//        _40 = (const 0u32, const 1u32);
-//        StorageLive(_41);
-//        _41 = (const 0u32, const 2u32);
-//        StorageLive(_42);
-//        _42 = (const 0u32, const 3u32);
-//        StorageLive(_43);
-//        _43 = (const 0u32, const 1u32);
-//        StorageLive(_44);
-//        _44 = (const 0u32, const 2u32);
-//        StorageLive(_45);
-//        _45 = (const 0u32, const 3u32);
-//        StorageLive(_46);
-//        _46 = (const 0u32, const 1u32);
-//        StorageLive(_47);
-//        _47 = (const 0u32, const 2u32);
-//        StorageLive(_48);
-//        _48 = (const 0u32, const 3u32);
-//        _6 = [move _7, move _8, move _9, move _10, move _11, move _12, move _13, move _14, move _15, move _16, move _17, move _18, move _19, move _20, move _21, move _22, move _23, move _24, move _25, move _26, move _27, move _28, move _29, move _30, move _31, move _32, move _33, move _34, move _35, move _36, move _37, move _38, move _39, move _40, move _41, move _42, move _43, move _44, move _45, move _46, move _47, move _48];
-//        _5 = &_6;
-//        _4 = &(*_5);
-//        _3 = move _4 as &[(u32, u32)] (Pointer(Unsize));
-//        _2 = Foo { tup: const "hi", data: move _3 };
-//        _1 = &_2;
-//        _0 = &(*_1);
-//        StorageDead(_5);
-//        StorageDead(_1);
-//        return;
-//    }
-//}
-// END rustc.XXX.mir_map.0.mir
diff --git a/src/test/mir-opt/storage_live_dead_in_statics/rustc.XXX.mir_map.0.mir b/src/test/mir-opt/storage_live_dead_in_statics/rustc.XXX.mir_map.0.mir
new file mode 100644 (file)
index 0000000..5ea1e43
--- /dev/null
@@ -0,0 +1,670 @@
+// MIR for `XXX` 0 mir_map
+
+static XXX: &Foo = {
+    let mut _0: &Foo;                    // return place in scope 0 at $DIR/storage_live_dead_in_statics.rs:5:13: 5:25
+    let _1: &Foo;                        // in scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2
+    let _2: Foo;                         // in scope 0 at $DIR/storage_live_dead_in_statics.rs:5:29: 23:2
+    let mut _3: &[(u32, u32)];           // in scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+    let mut _4: &[(u32, u32); 42];       // in scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+    let _5: &[(u32, u32); 42];           // in scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+    let _6: [(u32, u32); 42];            // in scope 0 at $DIR/storage_live_dead_in_statics.rs:7:12: 22:6
+    let mut _7: (u32, u32);              // in scope 0 at $DIR/storage_live_dead_in_statics.rs:8:9: 8:15
+    let mut _8: (u32, u32);              // in scope 0 at $DIR/storage_live_dead_in_statics.rs:8:17: 8:23
+    let mut _9: (u32, u32);              // in scope 0 at $DIR/storage_live_dead_in_statics.rs:8:25: 8:31
+    let mut _10: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:9:9: 9:15
+    let mut _11: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:9:17: 9:23
+    let mut _12: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:9:25: 9:31
+    let mut _13: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:10:9: 10:15
+    let mut _14: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:10:17: 10:23
+    let mut _15: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:10:25: 10:31
+    let mut _16: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:11:9: 11:15
+    let mut _17: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:11:17: 11:23
+    let mut _18: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:11:25: 11:31
+    let mut _19: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:12:9: 12:15
+    let mut _20: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:12:17: 12:23
+    let mut _21: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:12:25: 12:31
+    let mut _22: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:13:9: 13:15
+    let mut _23: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:13:17: 13:23
+    let mut _24: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:13:25: 13:31
+    let mut _25: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:14:9: 14:15
+    let mut _26: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:14:17: 14:23
+    let mut _27: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:14:25: 14:31
+    let mut _28: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:15:9: 15:15
+    let mut _29: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:15:17: 15:23
+    let mut _30: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:15:25: 15:31
+    let mut _31: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:16:9: 16:15
+    let mut _32: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:16:17: 16:23
+    let mut _33: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:16:25: 16:31
+    let mut _34: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:17:9: 17:15
+    let mut _35: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:17:17: 17:23
+    let mut _36: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:17:25: 17:31
+    let mut _37: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:18:9: 18:15
+    let mut _38: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:18:17: 18:23
+    let mut _39: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:18:25: 18:31
+    let mut _40: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:19:9: 19:15
+    let mut _41: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:19:17: 19:23
+    let mut _42: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:19:25: 19:31
+    let mut _43: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:20:9: 20:15
+    let mut _44: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:20:17: 20:23
+    let mut _45: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:20:25: 20:31
+    let mut _46: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:21:9: 21:15
+    let mut _47: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:21:17: 21:23
+    let mut _48: (u32, u32);             // in scope 0 at $DIR/storage_live_dead_in_statics.rs:21:25: 21:31
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:29: 23:2
+        StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+        StorageLive(_4);                 // bb0[3]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+        StorageLive(_5);                 // bb0[4]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+        StorageLive(_6);                 // bb0[5]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:12: 22:6
+        StorageLive(_7);                 // bb0[6]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:9: 8:15
+        _7 = (const 0u32, const 1u32);   // bb0[7]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:9: 8:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:8:10: 8:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:8:13: 8:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_8);                 // bb0[8]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:17: 8:23
+        _8 = (const 0u32, const 2u32);   // bb0[9]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:17: 8:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:8:18: 8:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:8:21: 8:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_9);                 // bb0[10]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:25: 8:31
+        _9 = (const 0u32, const 3u32);   // bb0[11]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:25: 8:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:8:26: 8:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:8:29: 8:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_10);                // bb0[12]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:9: 9:15
+        _10 = (const 0u32, const 1u32);  // bb0[13]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:9: 9:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:9:10: 9:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:9:13: 9:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_11);                // bb0[14]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:17: 9:23
+        _11 = (const 0u32, const 2u32);  // bb0[15]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:17: 9:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:9:18: 9:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:9:21: 9:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_12);                // bb0[16]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:25: 9:31
+        _12 = (const 0u32, const 3u32);  // bb0[17]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:25: 9:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:9:26: 9:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:9:29: 9:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_13);                // bb0[18]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:9: 10:15
+        _13 = (const 0u32, const 1u32);  // bb0[19]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:9: 10:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:10:10: 10:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:10:13: 10:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_14);                // bb0[20]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:17: 10:23
+        _14 = (const 0u32, const 2u32);  // bb0[21]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:17: 10:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:10:18: 10:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:10:21: 10:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_15);                // bb0[22]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:25: 10:31
+        _15 = (const 0u32, const 3u32);  // bb0[23]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:25: 10:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:10:26: 10:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:10:29: 10:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_16);                // bb0[24]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:9: 11:15
+        _16 = (const 0u32, const 1u32);  // bb0[25]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:9: 11:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:11:10: 11:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:11:13: 11:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_17);                // bb0[26]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:17: 11:23
+        _17 = (const 0u32, const 2u32);  // bb0[27]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:17: 11:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:11:18: 11:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:11:21: 11:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_18);                // bb0[28]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:25: 11:31
+        _18 = (const 0u32, const 3u32);  // bb0[29]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:25: 11:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:11:26: 11:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:11:29: 11:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_19);                // bb0[30]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:9: 12:15
+        _19 = (const 0u32, const 1u32);  // bb0[31]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:9: 12:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:12:10: 12:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:12:13: 12:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_20);                // bb0[32]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:17: 12:23
+        _20 = (const 0u32, const 2u32);  // bb0[33]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:17: 12:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:12:18: 12:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:12:21: 12:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_21);                // bb0[34]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:25: 12:31
+        _21 = (const 0u32, const 3u32);  // bb0[35]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:25: 12:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:12:26: 12:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:12:29: 12:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_22);                // bb0[36]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:9: 13:15
+        _22 = (const 0u32, const 1u32);  // bb0[37]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:9: 13:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:13:10: 13:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:13:13: 13:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_23);                // bb0[38]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:17: 13:23
+        _23 = (const 0u32, const 2u32);  // bb0[39]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:17: 13:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:13:18: 13:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:13:21: 13:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_24);                // bb0[40]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:25: 13:31
+        _24 = (const 0u32, const 3u32);  // bb0[41]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:25: 13:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:13:26: 13:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:13:29: 13:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_25);                // bb0[42]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:9: 14:15
+        _25 = (const 0u32, const 1u32);  // bb0[43]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:9: 14:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:14:10: 14:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:14:13: 14:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_26);                // bb0[44]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:17: 14:23
+        _26 = (const 0u32, const 2u32);  // bb0[45]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:17: 14:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:14:18: 14:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:14:21: 14:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_27);                // bb0[46]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:25: 14:31
+        _27 = (const 0u32, const 3u32);  // bb0[47]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:25: 14:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:14:26: 14:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:14:29: 14:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_28);                // bb0[48]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:9: 15:15
+        _28 = (const 0u32, const 1u32);  // bb0[49]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:9: 15:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:15:10: 15:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:15:13: 15:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_29);                // bb0[50]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:17: 15:23
+        _29 = (const 0u32, const 2u32);  // bb0[51]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:17: 15:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:15:18: 15:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:15:21: 15:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_30);                // bb0[52]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:25: 15:31
+        _30 = (const 0u32, const 3u32);  // bb0[53]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:25: 15:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:15:26: 15:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:15:29: 15:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_31);                // bb0[54]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:9: 16:15
+        _31 = (const 0u32, const 1u32);  // bb0[55]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:9: 16:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:16:10: 16:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:16:13: 16:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_32);                // bb0[56]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:17: 16:23
+        _32 = (const 0u32, const 2u32);  // bb0[57]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:17: 16:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:16:18: 16:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:16:21: 16:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_33);                // bb0[58]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:25: 16:31
+        _33 = (const 0u32, const 3u32);  // bb0[59]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:25: 16:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:16:26: 16:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:16:29: 16:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_34);                // bb0[60]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:9: 17:15
+        _34 = (const 0u32, const 1u32);  // bb0[61]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:9: 17:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:17:10: 17:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:17:13: 17:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_35);                // bb0[62]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:17: 17:23
+        _35 = (const 0u32, const 2u32);  // bb0[63]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:17: 17:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:17:18: 17:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:17:21: 17:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_36);                // bb0[64]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:25: 17:31
+        _36 = (const 0u32, const 3u32);  // bb0[65]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:25: 17:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:17:26: 17:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:17:29: 17:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_37);                // bb0[66]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:9: 18:15
+        _37 = (const 0u32, const 1u32);  // bb0[67]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:9: 18:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:18:10: 18:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:18:13: 18:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_38);                // bb0[68]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:17: 18:23
+        _38 = (const 0u32, const 2u32);  // bb0[69]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:17: 18:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:18:18: 18:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:18:21: 18:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_39);                // bb0[70]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:25: 18:31
+        _39 = (const 0u32, const 3u32);  // bb0[71]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:25: 18:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:18:26: 18:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:18:29: 18:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_40);                // bb0[72]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:9: 19:15
+        _40 = (const 0u32, const 1u32);  // bb0[73]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:9: 19:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:19:10: 19:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:19:13: 19:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_41);                // bb0[74]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:17: 19:23
+        _41 = (const 0u32, const 2u32);  // bb0[75]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:17: 19:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:19:18: 19:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:19:21: 19:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_42);                // bb0[76]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:25: 19:31
+        _42 = (const 0u32, const 3u32);  // bb0[77]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:25: 19:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:19:26: 19:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:19:29: 19:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_43);                // bb0[78]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:9: 20:15
+        _43 = (const 0u32, const 1u32);  // bb0[79]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:9: 20:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:20:10: 20:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:20:13: 20:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_44);                // bb0[80]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:17: 20:23
+        _44 = (const 0u32, const 2u32);  // bb0[81]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:17: 20:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:20:18: 20:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:20:21: 20:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_45);                // bb0[82]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:25: 20:31
+        _45 = (const 0u32, const 3u32);  // bb0[83]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:25: 20:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:20:26: 20:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:20:29: 20:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        StorageLive(_46);                // bb0[84]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:9: 21:15
+        _46 = (const 0u32, const 1u32);  // bb0[85]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:9: 21:15
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:21:10: 21:11
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:21:13: 21:14
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+        StorageLive(_47);                // bb0[86]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:17: 21:23
+        _47 = (const 0u32, const 2u32);  // bb0[87]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:17: 21:23
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:21:18: 21:19
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:21:21: 21:22
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+        StorageLive(_48);                // bb0[88]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:25: 21:31
+        _48 = (const 0u32, const 3u32);  // bb0[89]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:25: 21:31
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:21:26: 21:27
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
+                                         // ty::Const
+                                         // + ty: u32
+                                         // + val: Value(Scalar(0x00000003))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:21:29: 21:30
+                                         // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
+        _6 = [move _7, move _8, move _9, move _10, move _11, move _12, move _13, move _14, move _15, move _16, move _17, move _18, move _19, move _20, move _21, move _22, move _23, move _24, move _25, move _26, move _27, move _28, move _29, move _30, move _31, move _32, move _33, move _34, move _35, move _36, move _37, move _38, move _39, move _40, move _41, move _42, move _43, move _44, move _45, move _46, move _47, move _48]; // bb0[90]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:12: 22:6
+        _5 = &_6;                        // bb0[91]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+        _4 = &(*_5);                     // bb0[92]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+        _3 = move _4 as &[(u32, u32)] (Pointer(Unsize)); // bb0[93]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6
+        _2 = Foo { tup: const "hi", data: move _3 }; // bb0[94]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:29: 23:2
+                                         // ty::Const
+                                         // + ty: &str
+                                         // + val: Value(Slice { data: Allocation { bytes: [104, 105], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 })
+                                         // mir::Constant
+                                         // + span: $DIR/storage_live_dead_in_statics.rs:6:10: 6:14
+                                         // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [104, 105], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) }
+        _1 = &_2;                        // bb0[95]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2
+        _0 = &(*_1);                     // bb0[96]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2
+        StorageDead(_5);                 // bb0[97]: scope 0 at $DIR/storage_live_dead_in_statics.rs:23:1: 23:2
+        StorageDead(_1);                 // bb0[98]: scope 0 at $DIR/storage_live_dead_in_statics.rs:23:1: 23:2
+        return;                          // bb0[99]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:1: 23:3
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:1: 23:3
+    }
+}
index 95570ff76a6d0a9770ca5012b19405a492a525df..7b3c77aca27ebe0561557b4a09f1118c25af57dd 100644 (file)
@@ -1,3 +1,5 @@
+// EMIT_MIR rustc.main.nll.0.mir
+
 fn main() {
     let a = 0;
     {
@@ -5,32 +7,3 @@ fn main() {
     }
     let c = 1;
 }
-
-// END RUST SOURCE
-// START rustc.main.nll.0.mir
-//     bb0: {
-//         StorageLive(_1);
-//         _1 = const 0i32;
-//         FakeRead(ForLet, _1);
-//         StorageLive(_2);
-//         StorageLive(_3);
-//         StorageLive(_4);
-//         StorageLive(_5);
-//         _5 = _1;
-//         _4 = std::option::Option::<i32>::Some(move _5,);
-//         StorageDead(_5);
-//         _3 = &_4;
-//         FakeRead(ForLet, _3);
-//         _2 = ();
-//         StorageDead(_4);
-//         StorageDead(_3);
-//         StorageDead(_2);
-//         StorageLive(_6);
-//         _6 = const 1i32;
-//         FakeRead(ForLet, _6);
-//         _0 = ();
-//         StorageDead(_6);
-//         StorageDead(_1);
-//         return;
-//      }
-// END rustc.main.nll.0.mir
diff --git a/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir b/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir
new file mode 100644 (file)
index 0000000..57ec473
--- /dev/null
@@ -0,0 +1,75 @@
+// MIR for `main` 0 nll
+
+| Free Region Mapping
+| '_#0r | Global | ['_#0r, '_#1r]
+| '_#1r | Local | ['_#1r]
+|
+| Inferred Region Values
+| '_#0r | U0 | {bb0[0..=22], '_#0r, '_#1r}
+| '_#1r | U0 | {bb0[0..=22], '_#1r}
+| '_#2r | U0 | {bb0[10..=11]}
+| '_#3r | U0 | {bb0[11]}
+|
+| Inference Constraints
+| '_#0r live at {bb0[0..=22]}
+| '_#1r live at {bb0[0..=22]}
+| '_#2r live at {bb0[10]}
+| '_#3r live at {bb0[11]}
+| '_#2r: '_#3r due to Assignment at Single(bb0[10])
+|
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/storage_ranges.rs:3:11: 3:11
+    let _1: i32;                         // in scope 0 at $DIR/storage_ranges.rs:4:9: 4:10
+    let _2: ();                          // in scope 0 at $DIR/storage_ranges.rs:5:5: 7:6
+    let _4: std::option::Option<i32>;    // in scope 0 at $DIR/storage_ranges.rs:6:18: 6:25
+    let mut _5: i32;                     // in scope 0 at $DIR/storage_ranges.rs:6:23: 6:24
+    scope 1 {
+        debug a => _1;                   // in scope 1 at $DIR/storage_ranges.rs:4:9: 4:10
+        let _3: &std::option::Option<i32>; // in scope 1 at $DIR/storage_ranges.rs:6:13: 6:14
+        let _6: i32;                     // in scope 1 at $DIR/storage_ranges.rs:8:9: 8:10
+        scope 2 {
+            debug b => _3;               // in scope 2 at $DIR/storage_ranges.rs:6:13: 6:14
+        }
+        scope 3 {
+            debug c => _6;               // in scope 3 at $DIR/storage_ranges.rs:8:9: 8:10
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/storage_ranges.rs:4:9: 4:10
+        _1 = const 0i32;                 // bb0[1]: scope 0 at $DIR/storage_ranges.rs:4:13: 4:14
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000000))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_ranges.rs:4:13: 4:14
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+        FakeRead(ForLet, _1);            // bb0[2]: scope 0 at $DIR/storage_ranges.rs:4:9: 4:10
+        StorageLive(_2);                 // bb0[3]: scope 1 at $DIR/storage_ranges.rs:5:5: 7:6
+        StorageLive(_3);                 // bb0[4]: scope 1 at $DIR/storage_ranges.rs:6:13: 6:14
+        StorageLive(_4);                 // bb0[5]: scope 1 at $DIR/storage_ranges.rs:6:18: 6:25
+        StorageLive(_5);                 // bb0[6]: scope 1 at $DIR/storage_ranges.rs:6:23: 6:24
+        _5 = _1;                         // bb0[7]: scope 1 at $DIR/storage_ranges.rs:6:23: 6:24
+        _4 = std::option::Option::<i32>::Some(move _5,); // bb0[8]: scope 1 at $DIR/storage_ranges.rs:6:18: 6:25
+        StorageDead(_5);                 // bb0[9]: scope 1 at $DIR/storage_ranges.rs:6:24: 6:25
+        _3 = &_4;                        // bb0[10]: scope 1 at $DIR/storage_ranges.rs:6:17: 6:25
+        FakeRead(ForLet, _3);            // bb0[11]: scope 1 at $DIR/storage_ranges.rs:6:13: 6:14
+        _2 = ();                         // bb0[12]: scope 1 at $DIR/storage_ranges.rs:5:5: 7:6
+        StorageDead(_4);                 // bb0[13]: scope 1 at $DIR/storage_ranges.rs:7:5: 7:6
+        StorageDead(_3);                 // bb0[14]: scope 1 at $DIR/storage_ranges.rs:7:5: 7:6
+        StorageDead(_2);                 // bb0[15]: scope 1 at $DIR/storage_ranges.rs:7:5: 7:6
+        StorageLive(_6);                 // bb0[16]: scope 1 at $DIR/storage_ranges.rs:8:9: 8:10
+        _6 = const 1i32;                 // bb0[17]: scope 1 at $DIR/storage_ranges.rs:8:13: 8:14
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/storage_ranges.rs:8:13: 8:14
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        FakeRead(ForLet, _6);            // bb0[18]: scope 1 at $DIR/storage_ranges.rs:8:9: 8:10
+        _0 = ();                         // bb0[19]: scope 0 at $DIR/storage_ranges.rs:3:11: 9:2
+        StorageDead(_6);                 // bb0[20]: scope 1 at $DIR/storage_ranges.rs:9:1: 9:2
+        StorageDead(_1);                 // bb0[21]: scope 0 at $DIR/storage_ranges.rs:9:1: 9:2
+        return;                          // bb0[22]: scope 0 at $DIR/storage_ranges.rs:9:2: 9:2
+    }
+}
index d587d237227ad0b632ff5b64ea4f541ce2182eb3..c1b7ebdbc3ab97952de3ae3b5b3712717050504f 100644 (file)
@@ -1,10 +1,12 @@
 #![feature(box_syntax)]
 
+// EMIT_MIR rustc.move_out_from_end.mir_map.0.mir
 fn move_out_from_end() {
     let a = [box 1, box 2];
     let [.., _y] = a;
 }
 
+// EMIT_MIR rustc.move_out_by_subslice.mir_map.0.mir
 fn move_out_by_subslice() {
     let a = [box 1, box 2];
     let [_y @ ..] = a;
@@ -14,15 +16,3 @@ fn main() {
     move_out_by_subslice();
     move_out_from_end();
 }
-
-// END RUST SOURCE
-
-// START rustc.move_out_from_end.mir_map.0.mir
-//      _6 = move _1[1 of 2];
-//      _0 = ();
-// END rustc.move_out_from_end.mir_map.0.mir
-
-// START rustc.move_out_by_subslice.mir_map.0.mir
-//     _6 = move _1[0..2];
-//     _0 = ();
-// END rustc.move_out_by_subslice.mir_map.0.mir
diff --git a/src/test/mir-opt/uniform_array_move_out/rustc.move_out_by_subslice.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out/rustc.move_out_by_subslice.mir_map.0.mir
new file mode 100644 (file)
index 0000000..5dbee8f
--- /dev/null
@@ -0,0 +1,111 @@
+// MIR for `move_out_by_subslice` 0 mir_map
+
+fn move_out_by_subslice() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/uniform_array_move_out.rs:10:27: 10:27
+    let _1: [std::boxed::Box<i32>; 2];   // in scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10
+    let mut _2: std::boxed::Box<i32>;    // in scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19
+    let mut _3: std::boxed::Box<i32>;    // in scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19
+    let mut _4: std::boxed::Box<i32>;    // in scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
+    let mut _5: std::boxed::Box<i32>;    // in scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
+    scope 1 {
+        debug a => _1;                   // in scope 1 at $DIR/uniform_array_move_out.rs:11:9: 11:10
+        let _6: [std::boxed::Box<i32>; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17
+        scope 2 {
+            debug _y => _6;              // in scope 2 at $DIR/uniform_array_move_out.rs:12:10: 12:17
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19
+        StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19
+        _3 = Box(i32);                   // bb0[3]: scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19
+        (*_3) = const 1i32;              // bb0[4]: scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/uniform_array_move_out.rs:11:18: 11:19
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        _2 = move _3;                    // bb0[5]: scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19
+        drop(_3) -> [return: bb4, unwind: bb2]; // bb0[6]: scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/uniform_array_move_out.rs:10:1: 13:2
+    }
+
+    bb2 (cleanup): {
+        drop(_2) -> bb1;                 // bb2[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
+    }
+
+    bb3 (cleanup): {
+        drop(_3) -> bb2;                 // bb3[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19
+    }
+
+    bb4: {
+        StorageDead(_3);                 // bb4[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19
+        StorageLive(_4);                 // bb4[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
+        StorageLive(_5);                 // bb4[2]: scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
+        _5 = Box(i32);                   // bb4[3]: scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
+        (*_5) = const 2i32;              // bb4[4]: scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/uniform_array_move_out.rs:11:25: 11:26
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        _4 = move _5;                    // bb4[5]: scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
+        drop(_5) -> [return: bb7, unwind: bb5]; // bb4[6]: scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26
+    }
+
+    bb5 (cleanup): {
+        drop(_4) -> bb2;                 // bb5[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
+    }
+
+    bb6 (cleanup): {
+        drop(_5) -> bb5;                 // bb6[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26
+    }
+
+    bb7: {
+        StorageDead(_5);                 // bb7[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26
+        _1 = [move _2, move _4];         // bb7[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:13: 11:27
+        drop(_4) -> [return: bb8, unwind: bb2]; // bb7[2]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
+    }
+
+    bb8: {
+        StorageDead(_4);                 // bb8[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
+        drop(_2) -> [return: bb9, unwind: bb1]; // bb8[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
+    }
+
+    bb9: {
+        StorageDead(_2);                 // bb9[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
+        FakeRead(ForLet, _1);            // bb9[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10
+        StorageLive(_6);                 // bb9[2]: scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17
+        _6 = move _1[0..2];              // bb9[3]: scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17
+        _0 = ();                         // bb9[4]: scope 0 at $DIR/uniform_array_move_out.rs:10:27: 13:2
+        drop(_6) -> [return: bb12, unwind: bb10]; // bb9[5]: scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2
+    }
+
+    bb10 (cleanup): {
+        drop(_1) -> bb1;                 // bb10[0]: scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2
+    }
+
+    bb11 (cleanup): {
+        drop(_6) -> bb10;                // bb11[0]: scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2
+    }
+
+    bb12: {
+        StorageDead(_6);                 // bb12[0]: scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2
+        drop(_1) -> [return: bb13, unwind: bb1]; // bb12[1]: scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2
+    }
+
+    bb13: {
+        StorageDead(_1);                 // bb13[0]: scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2
+        goto -> bb14;                    // bb13[1]: scope 0 at $DIR/uniform_array_move_out.rs:13:2: 13:2
+    }
+
+    bb14: {
+        return;                          // bb14[0]: scope 0 at $DIR/uniform_array_move_out.rs:13:2: 13:2
+    }
+}
diff --git a/src/test/mir-opt/uniform_array_move_out/rustc.move_out_from_end.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out/rustc.move_out_from_end.mir_map.0.mir
new file mode 100644 (file)
index 0000000..4a5cd62
--- /dev/null
@@ -0,0 +1,111 @@
+// MIR for `move_out_from_end` 0 mir_map
+
+fn move_out_from_end() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/uniform_array_move_out.rs:4:24: 4:24
+    let _1: [std::boxed::Box<i32>; 2];   // in scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10
+    let mut _2: std::boxed::Box<i32>;    // in scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19
+    let mut _3: std::boxed::Box<i32>;    // in scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19
+    let mut _4: std::boxed::Box<i32>;    // in scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
+    let mut _5: std::boxed::Box<i32>;    // in scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
+    scope 1 {
+        debug a => _1;                   // in scope 1 at $DIR/uniform_array_move_out.rs:5:9: 5:10
+        let _6: std::boxed::Box<i32>;    // in scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16
+        scope 2 {
+            debug _y => _6;              // in scope 2 at $DIR/uniform_array_move_out.rs:6:14: 6:16
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19
+        StorageLive(_3);                 // bb0[2]: scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19
+        _3 = Box(i32);                   // bb0[3]: scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19
+        (*_3) = const 1i32;              // bb0[4]: scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000001))
+                                         // mir::Constant
+                                         // + span: $DIR/uniform_array_move_out.rs:5:18: 5:19
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+        _2 = move _3;                    // bb0[5]: scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19
+        drop(_3) -> [return: bb4, unwind: bb2]; // bb0[6]: scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/uniform_array_move_out.rs:4:1: 7:2
+    }
+
+    bb2 (cleanup): {
+        drop(_2) -> bb1;                 // bb2[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
+    }
+
+    bb3 (cleanup): {
+        drop(_3) -> bb2;                 // bb3[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19
+    }
+
+    bb4: {
+        StorageDead(_3);                 // bb4[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19
+        StorageLive(_4);                 // bb4[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
+        StorageLive(_5);                 // bb4[2]: scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
+        _5 = Box(i32);                   // bb4[3]: scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
+        (*_5) = const 2i32;              // bb4[4]: scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/uniform_array_move_out.rs:5:25: 5:26
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        _4 = move _5;                    // bb4[5]: scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
+        drop(_5) -> [return: bb7, unwind: bb5]; // bb4[6]: scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26
+    }
+
+    bb5 (cleanup): {
+        drop(_4) -> bb2;                 // bb5[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
+    }
+
+    bb6 (cleanup): {
+        drop(_5) -> bb5;                 // bb6[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26
+    }
+
+    bb7: {
+        StorageDead(_5);                 // bb7[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26
+        _1 = [move _2, move _4];         // bb7[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:13: 5:27
+        drop(_4) -> [return: bb8, unwind: bb2]; // bb7[2]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
+    }
+
+    bb8: {
+        StorageDead(_4);                 // bb8[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
+        drop(_2) -> [return: bb9, unwind: bb1]; // bb8[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
+    }
+
+    bb9: {
+        StorageDead(_2);                 // bb9[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
+        FakeRead(ForLet, _1);            // bb9[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10
+        StorageLive(_6);                 // bb9[2]: scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16
+        _6 = move _1[1 of 2];            // bb9[3]: scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16
+        _0 = ();                         // bb9[4]: scope 0 at $DIR/uniform_array_move_out.rs:4:24: 7:2
+        drop(_6) -> [return: bb12, unwind: bb10]; // bb9[5]: scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2
+    }
+
+    bb10 (cleanup): {
+        drop(_1) -> bb1;                 // bb10[0]: scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2
+    }
+
+    bb11 (cleanup): {
+        drop(_6) -> bb10;                // bb11[0]: scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2
+    }
+
+    bb12: {
+        StorageDead(_6);                 // bb12[0]: scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2
+        drop(_1) -> [return: bb13, unwind: bb1]; // bb12[1]: scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2
+    }
+
+    bb13: {
+        StorageDead(_1);                 // bb13[0]: scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2
+        goto -> bb14;                    // bb13[1]: scope 0 at $DIR/uniform_array_move_out.rs:7:2: 7:2
+    }
+
+    bb14: {
+        return;                          // bb14[0]: scope 0 at $DIR/uniform_array_move_out.rs:7:2: 7:2
+    }
+}
index 904a9c43c1bccc7487b2053c017ae88369f731e1..6503e193608365105b09c2ca580c91f71683246d 100644 (file)
@@ -2,11 +2,13 @@
 
 pub enum Void {}
 
+// EMIT_MIR rustc.process_never.SimplifyLocals.after.mir
 #[no_mangle]
 pub fn process_never(input: *const !) {
    let _input = unsafe { &*input };
 }
 
+// EMIT_MIR rustc.process_void.SimplifyLocals.after.mir
 #[no_mangle]
 pub fn process_void(input: *const Void) {
    let _input = unsafe { &*input };
@@ -15,23 +17,3 @@ pub fn process_void(input: *const Void) {
 }
 
 fn main() {}
-
-// END RUST SOURCE
-//
-// START rustc.process_never.SimplifyLocals.after.mir
-// bb0: {
-//     StorageLive(_2);
-//     _2 = &(*_1);
-//     StorageDead(_2);
-//     unreachable;
-// }
-// END rustc.process_never.SimplifyLocals.after.mir
-//
-// START rustc.process_void.SimplifyLocals.after.mir
-// bb0: {
-//     StorageLive(_2);
-//     _2 = &(*_1);
-//     StorageDead(_2);
-//     return;
-// }
-// END rustc.process_void.SimplifyLocals.after.mir
diff --git a/src/test/mir-opt/uninhabited-enum/rustc.process_never.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited-enum/rustc.process_never.SimplifyLocals.after.mir
new file mode 100644 (file)
index 0000000..f2c8733
--- /dev/null
@@ -0,0 +1,19 @@
+// MIR for `process_never` after SimplifyLocals
+
+fn process_never(_1: *const !) -> () {
+    debug input => _1;                   // in scope 0 at $DIR/uninhabited-enum.rs:7:22: 7:27
+    let mut _0: ();                      // return place in scope 0 at $DIR/uninhabited-enum.rs:7:39: 7:39
+    let _2: &!;                          // in scope 0 at $DIR/uninhabited-enum.rs:8:8: 8:14
+    scope 1 {
+        debug _input => _2;              // in scope 1 at $DIR/uninhabited-enum.rs:8:8: 8:14
+    }
+    scope 2 {
+    }
+
+    bb0: {
+        StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/uninhabited-enum.rs:8:8: 8:14
+        _2 = &(*_1);                     // bb0[1]: scope 2 at $DIR/uninhabited-enum.rs:8:26: 8:33
+        StorageDead(_2);                 // bb0[2]: scope 0 at $DIR/uninhabited-enum.rs:9:1: 9:2
+        unreachable;                     // bb0[3]: scope 0 at $DIR/uninhabited-enum.rs:7:39: 9:2
+    }
+}
diff --git a/src/test/mir-opt/uninhabited-enum/rustc.process_void.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited-enum/rustc.process_void.SimplifyLocals.after.mir
new file mode 100644 (file)
index 0000000..2eb820b
--- /dev/null
@@ -0,0 +1,19 @@
+// MIR for `process_void` after SimplifyLocals
+
+fn process_void(_1: *const Void) -> () {
+    debug input => _1;                   // in scope 0 at $DIR/uninhabited-enum.rs:13:21: 13:26
+    let mut _0: ();                      // return place in scope 0 at $DIR/uninhabited-enum.rs:13:41: 13:41
+    let _2: &Void;                       // in scope 0 at $DIR/uninhabited-enum.rs:14:8: 14:14
+    scope 1 {
+        debug _input => _2;              // in scope 1 at $DIR/uninhabited-enum.rs:14:8: 14:14
+    }
+    scope 2 {
+    }
+
+    bb0: {
+        StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/uninhabited-enum.rs:14:8: 14:14
+        _2 = &(*_1);                     // bb0[1]: scope 2 at $DIR/uninhabited-enum.rs:14:26: 14:33
+        StorageDead(_2);                 // bb0[2]: scope 0 at $DIR/uninhabited-enum.rs:17:1: 17:2
+        return;                          // bb0[3]: scope 0 at $DIR/uninhabited-enum.rs:17:2: 17:2
+    }
+}
index dda5fd4fb7577000d5aeb0a04af37bfca11112ed..daf1156d20ebf9994af05d9522654d38e2038e96 100644 (file)
@@ -14,6 +14,8 @@ enum Test2 {
     E = 5,
 }
 
+// EMIT_MIR rustc.main.UninhabitedEnumBranching.diff
+// EMIT_MIR rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
 fn main() {
     match Test1::C {
         Test1::A(_) => "A(Empty)",
@@ -26,178 +28,3 @@ fn main() {
         Test2::E => "E",
     };
 }
-
-// END RUST SOURCE
-//
-// START rustc.main.UninhabitedEnumBranching.before.mir
-// let mut _0: ();
-// let _1: &str;
-// let mut _2: Test1;
-// let mut _3: isize;
-// let _4: &str;
-// let _5: &str;
-// let _6: &str;
-// let mut _7: Test2;
-// let mut _8: isize;
-// let _9: &str;
-// bb0: {
-//   StorageLive(_1);
-//   StorageLive(_2);
-//   _2 = Test1::C;
-//   _3 = discriminant(_2);
-//   switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb1];
-// }
-// bb1: {
-//   StorageLive(_5);
-//   _5 = const "C";
-//   _1 = &(*_5);
-//   StorageDead(_5);
-//   goto -> bb4;
-// }
-// bb2: {
-//   _1 = const "A(Empty)";
-//   goto -> bb4;
-// }
-// bb3: {
-//   StorageLive(_4);
-//   _4 = const "B(Empty)";
-//   _1 = &(*_4);
-//   StorageDead(_4);
-//   goto -> bb4;
-// }
-// bb4: {
-//   StorageDead(_2);
-//   StorageDead(_1);
-//   StorageLive(_6);
-//   StorageLive(_7);
-//   _7 = Test2::D;
-//   _8 = discriminant(_7);
-//   switchInt(move _8) -> [4isize: bb6, otherwise: bb5];
-// }
-// bb5: {
-//   StorageLive(_9);
-//   _9 = const "E";
-//   _6 = &(*_9);
-//   StorageDead(_9);
-//   goto -> bb7;
-// }
-// bb6: {
-//   _6 = const "D";
-//   goto -> bb7;
-// }
-// bb7: {
-//   StorageDead(_7);
-//   StorageDead(_6);
-//   _0 = ();
-//   return;
-// }
-// END rustc.main.UninhabitedEnumBranching.before.mir
-// START rustc.main.UninhabitedEnumBranching.after.mir
-// let mut _0: ();
-// let _1: &str;
-// let mut _2: Test1;
-// let mut _3: isize;
-// let _4: &str;
-// let _5: &str;
-// let _6: &str;
-// let mut _7: Test2;
-// let mut _8: isize;
-// let _9: &str;
-// bb0: {
-//   StorageLive(_1);
-//   StorageLive(_2);
-//   _2 = Test1::C;
-//   _3 = discriminant(_2);
-//   switchInt(move _3) -> bb1;
-// }
-// bb1: {
-//   StorageLive(_5);
-//   _5 = const "C";
-//   _1 = &(*_5);
-//   StorageDead(_5);
-//   goto -> bb4;
-// }
-// bb2: {
-//   _1 = const "A(Empty)";
-//   goto -> bb4;
-// }
-// bb3: {
-//   StorageLive(_4);
-//   _4 = const "B(Empty)";
-//   _1 = &(*_4);
-//   StorageDead(_4);
-//   goto -> bb4;
-// }
-// bb4: {
-//   StorageDead(_2);
-//   StorageDead(_1);
-//   StorageLive(_6);
-//   StorageLive(_7);
-//   _7 = Test2::D;
-//   _8 = discriminant(_7);
-//   switchInt(move _8) -> [4isize: bb6, otherwise: bb5];
-// }
-// bb5: {
-//   StorageLive(_9);
-//   _9 = const "E";
-//   _6 = &(*_9);
-//   StorageDead(_9);
-//   goto -> bb7;
-// }
-// bb6: {
-//   _6 = const "D";
-//   goto -> bb7;
-// }
-// bb7: {
-//   StorageDead(_7);
-//   StorageDead(_6);
-//   _0 = ();
-//   return;
-// }
-// END rustc.main.UninhabitedEnumBranching.after.mir
-// START rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
-// let mut _0: ();
-// let _1: &str;
-// let mut _2: Test1;
-// let mut _3: isize;
-// let _4: &str;
-// let _5: &str;
-// let _6: &str;
-// let mut _7: Test2;
-// let mut _8: isize;
-// let _9: &str;
-// bb0: {
-//   StorageLive(_1);
-//   StorageLive(_2);
-//   _2 = Test1::C;
-//   _3 = discriminant(_2);
-//   StorageLive(_5);
-//   _5 = const "C";
-//   _1 = &(*_5);
-//   StorageDead(_5);
-//   StorageDead(_2);
-//   StorageDead(_1);
-//   StorageLive(_6);
-//   StorageLive(_7);
-//   _7 = Test2::D;
-//   _8 = discriminant(_7);
-//   switchInt(move _8) -> [4isize: bb2, otherwise: bb1];
-// }
-// bb1: {
-//   StorageLive(_9);
-//   _9 = const "E";
-//   _6 = &(*_9);
-//   StorageDead(_9);
-//   goto -> bb3;
-// }
-// bb2: {
-//   _6 = const "D";
-//   goto -> bb3;
-// }
-// bb3: {
-//   StorageDead(_7);
-//   StorageDead(_6);
-//   _0 = ();
-//   return;
-// }
-// END rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
diff --git a/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
new file mode 100644 (file)
index 0000000..c8dde4d
--- /dev/null
@@ -0,0 +1,70 @@
+// MIR for `main` after SimplifyCfg-after-uninhabited-enum-branching
+
+fn main() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/uninhabited_enum_branching.rs:19:11: 19:11
+    let _1: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
+    let mut _2: Test1;                   // in scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
+    let mut _3: isize;                   // in scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
+    let _4: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34
+    let _5: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+    let _6: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
+    let mut _7: Test2;                   // in scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
+    let mut _8: isize;                   // in scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
+    let _9: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+
+    bb0: {
+        StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
+        StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
+        _2 = Test1::C;                   // bb0[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
+        _3 = discriminant(_2);           // bb0[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
+        StorageLive(_5);                 // bb0[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+        _5 = const "C";                  // bb0[5]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+                                         // ty::Const
+                                         // + ty: &str
+                                         // + val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                         // mir::Constant
+                                         // + span: $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+                                         // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+        _1 = &(*_5);                     // bb0[6]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+        StorageDead(_5);                 // bb0[7]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:23: 23:24
+        StorageDead(_2);                 // bb0[8]: scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7
+        StorageDead(_1);                 // bb0[9]: scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7
+        StorageLive(_6);                 // bb0[10]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
+        StorageLive(_7);                 // bb0[11]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
+        _7 = Test2::D;                   // bb0[12]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
+        _8 = discriminant(_7);           // bb0[13]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
+        switchInt(move _8) -> [4isize: bb2, otherwise: bb1]; // bb0[14]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
+    }
+
+    bb1: {
+        StorageLive(_9);                 // bb1[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+        _9 = const "E";                  // bb1[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+                                         // ty::Const
+                                         // + ty: &str
+                                         // + val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                         // mir::Constant
+                                         // + span: $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+                                         // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+        _6 = &(*_9);                     // bb1[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+        StorageDead(_9);                 // bb1[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:23: 28:24
+        goto -> bb3;                     // bb1[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
+    }
+
+    bb2: {
+        _6 = const "D";                  // bb2[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:21: 27:24
+                                         // ty::Const
+                                         // + ty: &str
+                                         // + val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                         // mir::Constant
+                                         // + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24
+                                         // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+        goto -> bb3;                     // bb2[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
+    }
+
+    bb3: {
+        StorageDead(_7);                 // bb3[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:29:6: 29:7
+        StorageDead(_6);                 // bb3[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:29:6: 29:7
+        _0 = ();                         // bb3[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:19:11: 30:2
+        return;                          // bb3[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:30:2: 30:2
+    }
+}
diff --git a/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff
new file mode 100644 (file)
index 0000000..cccd6aa
--- /dev/null
@@ -0,0 +1,106 @@
+- // MIR for `main` before UninhabitedEnumBranching
++ // MIR for `main` after UninhabitedEnumBranching
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/uninhabited_enum_branching.rs:19:11: 19:11
+      let _1: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
+      let mut _2: Test1;                   // in scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
+      let mut _3: isize;                   // in scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
+      let _4: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34
+      let _5: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+      let _6: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
+      let mut _7: Test2;                   // in scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
+      let mut _8: isize;                   // in scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
+      let _9: &str;                        // in scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
+          _2 = Test1::C;                   // bb0[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
+          _3 = discriminant(_2);           // bb0[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
+-         switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb1]; // bb0[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
++         switchInt(move _3) -> bb1;       // bb0[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
+      }
+  
+      bb1: {
+          StorageLive(_5);                 // bb1[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+          _5 = const "C";                  // bb1[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+                                           // ty::Const
+                                           // + ty: &str
+                                           // + val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                           // mir::Constant
+                                           // + span: $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+                                           // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+          _1 = &(*_5);                     // bb1[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
+          StorageDead(_5);                 // bb1[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:23: 23:24
+          goto -> bb4;                     // bb1[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
+      }
+  
+      bb2: {
+          _1 = const "A(Empty)";           // bb2[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:24: 21:34
+                                           // ty::Const
+                                           // + ty: &str
+                                           // + val: Value(Slice { data: Allocation { bytes: [65, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 })
+                                           // mir::Constant
+                                           // + span: $DIR/uninhabited_enum_branching.rs:21:24: 21:34
+                                           // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [65, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) }
+          goto -> bb4;                     // bb2[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
+      }
+  
+      bb3: {
+          StorageLive(_4);                 // bb3[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34
+          _4 = const "B(Empty)";           // bb3[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34
+                                           // ty::Const
+                                           // + ty: &str
+                                           // + val: Value(Slice { data: Allocation { bytes: [66, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 })
+                                           // mir::Constant
+                                           // + span: $DIR/uninhabited_enum_branching.rs:22:24: 22:34
+                                           // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [66, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) }
+          _1 = &(*_4);                     // bb3[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34
+          StorageDead(_4);                 // bb3[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:33: 22:34
+          goto -> bb4;                     // bb3[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
+      }
+  
+      bb4: {
+          StorageDead(_2);                 // bb4[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7
+          StorageDead(_1);                 // bb4[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7
+          StorageLive(_6);                 // bb4[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
+          StorageLive(_7);                 // bb4[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
+          _7 = Test2::D;                   // bb4[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
+          _8 = discriminant(_7);           // bb4[5]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
+          switchInt(move _8) -> [4isize: bb6, otherwise: bb5]; // bb4[6]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
+      }
+  
+      bb5: {
+          StorageLive(_9);                 // bb5[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+          _9 = const "E";                  // bb5[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+                                           // ty::Const
+                                           // + ty: &str
+                                           // + val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                           // mir::Constant
+                                           // + span: $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+                                           // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+          _6 = &(*_9);                     // bb5[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24
+          StorageDead(_9);                 // bb5[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:23: 28:24
+          goto -> bb7;                     // bb5[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
+      }
+  
+      bb6: {
+          _6 = const "D";                  // bb6[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:21: 27:24
+                                           // ty::Const
+                                           // + ty: &str
+                                           // + val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 })
+                                           // mir::Constant
+                                           // + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24
+                                           // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) }
+          goto -> bb7;                     // bb6[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
+      }
+  
+      bb7: {
+          StorageDead(_7);                 // bb7[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:29:6: 29:7
+          StorageDead(_6);                 // bb7[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:29:6: 29:7
+          _0 = ();                         // bb7[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:19:11: 30:2
+          return;                          // bb7[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:30:2: 30:2
+      }
+  }
+  
index fa5c1a074ee15d5f24ac5ed6704a31cd12868b1d..6f0c4ca3cf5aea64afa6708ac69a934d1dd3e9ff 100644 (file)
@@ -4,6 +4,7 @@ fn empty() -> Option<Empty> {
     None
 }
 
+// EMIT_MIR rustc.main.UnreachablePropagation.diff
 fn main() {
     if let Some(_x) = empty() {
         let mut _y;
@@ -17,62 +18,3 @@ fn main() {
         match _x { }
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.UnreachablePropagation.before.mir
-//      bb0: {
-//          StorageLive(_1);
-//          _1 = const empty() -> bb1;
-//      }
-//      bb1: {
-//          _2 = discriminant(_1);
-//          switchInt(move _2) -> [1isize: bb3, otherwise: bb2];
-//      }
-//      bb2: {
-//          _0 = ();
-//          StorageDead(_1);
-//          return;
-//      }
-//      bb3: {
-//          StorageLive(_3);
-//          _3 = move ((_1 as Some).0: Empty);
-//          StorageLive(_4);
-//          StorageLive(_5);
-//          StorageLive(_6);
-//          _6 = const true;
-//          switchInt(_6) -> [false: bb4, otherwise: bb5];
-//      }
-//      bb4: {
-//          _4 = const 42i32;
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//      bb5: {
-//          _4 = const 21i32;
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//      bb6: {
-//          StorageDead(_6);
-//          StorageDead(_5);
-//          StorageLive(_7);
-//          unreachable;
-//      }
-//  }
-// END rustc.main.UnreachablePropagation.before.mir
-// START rustc.main.UnreachablePropagation.after.mir
-//      bb0: {
-//          StorageLive(_1);
-//          _1 = const empty() -> bb1;
-//      }
-//      bb1: {
-//          _2 = discriminant(_1);
-//          goto -> bb2;
-//      }
-//      bb2: {
-//          _0 = ();
-//          StorageDead(_1);
-//          return;
-//      }
-//  }
-// END rustc.main.UnreachablePropagation.after.mir
diff --git a/src/test/mir-opt/unreachable/rustc.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable/rustc.main.UnreachablePropagation.diff
new file mode 100644 (file)
index 0000000..3a239c6
--- /dev/null
@@ -0,0 +1,90 @@
+- // MIR for `main` before UnreachablePropagation
++ // MIR for `main` after UnreachablePropagation
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/unreachable.rs:8:11: 8:11
+      let mut _1: std::option::Option<Empty>; // in scope 0 at $DIR/unreachable.rs:9:23: 9:30
+      let mut _2: isize;                   // in scope 0 at $DIR/unreachable.rs:9:12: 9:20
+      let _3: Empty;                       // in scope 0 at $DIR/unreachable.rs:9:17: 9:19
+      let _5: ();                          // in scope 0 at $DIR/unreachable.rs:12:9: 16:10
+      let mut _6: bool;                    // in scope 0 at $DIR/unreachable.rs:12:12: 12:16
+      let mut _7: !;                       // in scope 0 at $DIR/unreachable.rs:18:9: 18:21
+      scope 1 {
+          debug _x => _3;                  // in scope 1 at $DIR/unreachable.rs:9:17: 9:19
+          let mut _4: i32;                 // in scope 1 at $DIR/unreachable.rs:10:13: 10:19
+          scope 2 {
+              debug _y => _4;              // in scope 2 at $DIR/unreachable.rs:10:13: 10:19
+          }
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/unreachable.rs:9:23: 9:30
+          _1 = const empty() -> bb1;       // bb0[1]: scope 0 at $DIR/unreachable.rs:9:23: 9:30
+                                           // ty::Const
+                                           // + ty: fn() -> std::option::Option<Empty> {empty}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable.rs:9:23: 9:28
+                                           // + literal: Const { ty: fn() -> std::option::Option<Empty> {empty}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          _2 = discriminant(_1);           // bb1[0]: scope 0 at $DIR/unreachable.rs:9:12: 9:20
+-         switchInt(move _2) -> [1isize: bb3, otherwise: bb2]; // bb1[1]: scope 0 at $DIR/unreachable.rs:9:12: 9:20
++         goto -> bb2;                     // bb1[1]: scope 0 at $DIR/unreachable.rs:9:12: 9:20
+      }
+  
+      bb2: {
+          _0 = ();                         // bb2[0]: scope 0 at $DIR/unreachable.rs:9:5: 19:6
+          StorageDead(_1);                 // bb2[1]: scope 0 at $DIR/unreachable.rs:20:1: 20:2
+          return;                          // bb2[2]: scope 0 at $DIR/unreachable.rs:20:2: 20:2
+-     }
+- 
+-     bb3: {
+-         StorageLive(_3);                 // bb3[0]: scope 0 at $DIR/unreachable.rs:9:17: 9:19
+-         _3 = move ((_1 as Some).0: Empty); // bb3[1]: scope 0 at $DIR/unreachable.rs:9:17: 9:19
+-         StorageLive(_4);                 // bb3[2]: scope 1 at $DIR/unreachable.rs:10:13: 10:19
+-         StorageLive(_5);                 // bb3[3]: scope 2 at $DIR/unreachable.rs:12:9: 16:10
+-         StorageLive(_6);                 // bb3[4]: scope 2 at $DIR/unreachable.rs:12:12: 12:16
+-         _6 = const true;                 // bb3[5]: scope 2 at $DIR/unreachable.rs:12:12: 12:16
+-                                          // ty::Const
+-                                          // + ty: bool
+-                                          // + val: Value(Scalar(0x01))
+-                                          // mir::Constant
+-                                          // + span: $DIR/unreachable.rs:12:12: 12:16
+-                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+-         switchInt(_6) -> [false: bb4, otherwise: bb5]; // bb3[6]: scope 2 at $DIR/unreachable.rs:12:9: 16:10
+-     }
+- 
+-     bb4: {
+-         _4 = const 42i32;                // bb4[0]: scope 2 at $DIR/unreachable.rs:15:13: 15:20
+-                                          // ty::Const
+-                                          // + ty: i32
+-                                          // + val: Value(Scalar(0x0000002a))
+-                                          // mir::Constant
+-                                          // + span: $DIR/unreachable.rs:15:18: 15:20
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
+-         _5 = ();                         // bb4[1]: scope 2 at $DIR/unreachable.rs:14:16: 16:10
+-         goto -> bb6;                     // bb4[2]: scope 2 at $DIR/unreachable.rs:12:9: 16:10
+-     }
+- 
+-     bb5: {
+-         _4 = const 21i32;                // bb5[0]: scope 2 at $DIR/unreachable.rs:13:13: 13:20
+-                                          // ty::Const
+-                                          // + ty: i32
+-                                          // + val: Value(Scalar(0x00000015))
+-                                          // mir::Constant
+-                                          // + span: $DIR/unreachable.rs:13:18: 13:20
+-                                          // + literal: Const { ty: i32, val: Value(Scalar(0x00000015)) }
+-         _5 = ();                         // bb5[1]: scope 2 at $DIR/unreachable.rs:12:17: 14:10
+-         goto -> bb6;                     // bb5[2]: scope 2 at $DIR/unreachable.rs:12:9: 16:10
+-     }
+- 
+-     bb6: {
+-         StorageDead(_6);                 // bb6[0]: scope 2 at $DIR/unreachable.rs:16:9: 16:10
+-         StorageDead(_5);                 // bb6[1]: scope 2 at $DIR/unreachable.rs:16:9: 16:10
+-         StorageLive(_7);                 // bb6[2]: scope 2 at $DIR/unreachable.rs:18:9: 18:21
+-         unreachable;                     // bb6[3]: scope 2 at $DIR/unreachable.rs:18:15: 18:17
+      }
+  }
+  
index 990141657f467bf7df83cafce279a0648a2901dc..4bbf22b82275642d9871445deb15f37f1c84a073 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-tidy-linelength
 #![feature(llvm_asm)]
 
 enum Empty {}
@@ -7,6 +6,7 @@ fn empty() -> Option<Empty> {
     None
 }
 
+// EMIT_MIR rustc.main.UnreachablePropagation.diff
 fn main() {
     if let Some(_x) = empty() {
         let mut _y;
@@ -22,51 +22,3 @@ fn main() {
         match _x { }
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.UnreachablePropagation.before.mir
-//      bb4: {
-//          _4 = const 42i32;
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//      bb5: {
-//          _4 = const 21i32;
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//      bb6: {
-//          StorageDead(_6);
-//          StorageDead(_5);
-//          StorageLive(_7);
-//          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
-//          _7 = ();
-//          StorageDead(_7);
-//          StorageLive(_8);
-//          unreachable;
-//      }
-//  }
-// END rustc.main.UnreachablePropagation.before.mir
-// START rustc.main.UnreachablePropagation.after.mir
-//      bb4: {
-//          _4 = const 42i32;
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//      bb5: {
-//          _4 = const 21i32;
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//      bb6: {
-//          StorageDead(_6);
-//          StorageDead(_5);
-//          StorageLive(_7);
-//          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
-//          _7 = ();
-//          StorageDead(_7);
-//          StorageLive(_8);
-//          unreachable;
-//      }
-//  }
-// END rustc.main.UnreachablePropagation.after.mir
diff --git a/src/test/mir-opt/unreachable_asm/rustc.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_asm/rustc.main.UnreachablePropagation.diff
new file mode 100644 (file)
index 0000000..c32165a
--- /dev/null
@@ -0,0 +1,96 @@
+- // MIR for `main` before UnreachablePropagation
++ // MIR for `main` after UnreachablePropagation
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/unreachable_asm.rs:10:11: 10:11
+      let mut _1: std::option::Option<Empty>; // in scope 0 at $DIR/unreachable_asm.rs:11:23: 11:30
+      let mut _2: isize;                   // in scope 0 at $DIR/unreachable_asm.rs:11:12: 11:20
+      let _3: Empty;                       // in scope 0 at $DIR/unreachable_asm.rs:11:17: 11:19
+      let _5: ();                          // in scope 0 at $DIR/unreachable_asm.rs:14:9: 18:10
+      let mut _6: bool;                    // in scope 0 at $DIR/unreachable_asm.rs:14:12: 14:16
+      let _7: ();                          // in scope 0 at $DIR/unreachable_asm.rs:21:9: 21:37
+      let mut _8: !;                       // in scope 0 at $DIR/unreachable_asm.rs:22:9: 22:21
+      scope 1 {
+          debug _x => _3;                  // in scope 1 at $DIR/unreachable_asm.rs:11:17: 11:19
+          let mut _4: i32;                 // in scope 1 at $DIR/unreachable_asm.rs:12:13: 12:19
+          scope 2 {
+              debug _y => _4;              // in scope 2 at $DIR/unreachable_asm.rs:12:13: 12:19
+              scope 3 {
+              }
+          }
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/unreachable_asm.rs:11:23: 11:30
+          _1 = const empty() -> bb1;       // bb0[1]: scope 0 at $DIR/unreachable_asm.rs:11:23: 11:30
+                                           // ty::Const
+                                           // + ty: fn() -> std::option::Option<Empty> {empty}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_asm.rs:11:23: 11:28
+                                           // + literal: Const { ty: fn() -> std::option::Option<Empty> {empty}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          _2 = discriminant(_1);           // bb1[0]: scope 0 at $DIR/unreachable_asm.rs:11:12: 11:20
+          switchInt(move _2) -> [1isize: bb3, otherwise: bb2]; // bb1[1]: scope 0 at $DIR/unreachable_asm.rs:11:12: 11:20
+      }
+  
+      bb2: {
+          _0 = ();                         // bb2[0]: scope 0 at $DIR/unreachable_asm.rs:11:5: 23:6
+          StorageDead(_1);                 // bb2[1]: scope 0 at $DIR/unreachable_asm.rs:24:1: 24:2
+          return;                          // bb2[2]: scope 0 at $DIR/unreachable_asm.rs:24:2: 24:2
+      }
+  
+      bb3: {
+          StorageLive(_3);                 // bb3[0]: scope 0 at $DIR/unreachable_asm.rs:11:17: 11:19
+          _3 = move ((_1 as Some).0: Empty); // bb3[1]: scope 0 at $DIR/unreachable_asm.rs:11:17: 11:19
+          StorageLive(_4);                 // bb3[2]: scope 1 at $DIR/unreachable_asm.rs:12:13: 12:19
+          StorageLive(_5);                 // bb3[3]: scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10
+          StorageLive(_6);                 // bb3[4]: scope 2 at $DIR/unreachable_asm.rs:14:12: 14:16
+          _6 = const true;                 // bb3[5]: scope 2 at $DIR/unreachable_asm.rs:14:12: 14:16
+                                           // ty::Const
+                                           // + ty: bool
+                                           // + val: Value(Scalar(0x01))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_asm.rs:14:12: 14:16
+                                           // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+          switchInt(_6) -> [false: bb4, otherwise: bb5]; // bb3[6]: scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10
+      }
+  
+      bb4: {
+          _4 = const 42i32;                // bb4[0]: scope 2 at $DIR/unreachable_asm.rs:17:13: 17:20
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_asm.rs:17:18: 17:20
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
+          _5 = ();                         // bb4[1]: scope 2 at $DIR/unreachable_asm.rs:16:16: 18:10
+          goto -> bb6;                     // bb4[2]: scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10
+      }
+  
+      bb5: {
+          _4 = const 21i32;                // bb5[0]: scope 2 at $DIR/unreachable_asm.rs:15:13: 15:20
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000015))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_asm.rs:15:18: 15:20
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000015)) }
+          _5 = ();                         // bb5[1]: scope 2 at $DIR/unreachable_asm.rs:14:17: 16:10
+          goto -> bb6;                     // bb5[2]: scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10
+      }
+  
+      bb6: {
+          StorageDead(_6);                 // bb6[0]: scope 2 at $DIR/unreachable_asm.rs:18:9: 18:10
+          StorageDead(_5);                 // bb6[1]: scope 2 at $DIR/unreachable_asm.rs:18:9: 18:10
+          StorageLive(_7);                 // bb6[2]: scope 2 at $DIR/unreachable_asm.rs:21:9: 21:37
+          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // bb6[3]: scope 3 at $DIR/unreachable_asm.rs:21:18: 21:35
+          _7 = ();                         // bb6[4]: scope 3 at $DIR/unreachable_asm.rs:21:9: 21:37
+          StorageDead(_7);                 // bb6[5]: scope 2 at $DIR/unreachable_asm.rs:21:36: 21:37
+          StorageLive(_8);                 // bb6[6]: scope 2 at $DIR/unreachable_asm.rs:22:9: 22:21
+          unreachable;                     // bb6[7]: scope 2 at $DIR/unreachable_asm.rs:22:15: 22:17
+      }
+  }
+  
index 0851e24d410e72d82c81e76c2fdd1702504c8aaa..f1610db999ecb7418424e67abd9db7b657835705 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-tidy-linelength
 #![feature(llvm_asm)]
 
 enum Empty {}
@@ -7,6 +6,7 @@ fn empty() -> Option<Empty> {
     None
 }
 
+// EMIT_MIR rustc.main.UnreachablePropagation.diff
 fn main() {
     if let Some(_x) = empty() {
         let mut _y;
@@ -24,61 +24,3 @@ fn main() {
         match _x { }
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.UnreachablePropagation.before.mir
-//      bb3: {
-//          ...
-//          switchInt(_6) -> [false: bb4, otherwise: bb5];
-//      }
-//      bb4: {
-//          StorageLive(_8);
-//          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
-//          _8 = ();
-//          StorageDead(_8);
-//          _4 = const 42i32;
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//          bb5: {
-//          StorageLive(_7);
-//          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
-//          _7 = ();
-//          StorageDead(_7);
-//          _4 = const 21i32;
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//      bb6: {
-//          StorageDead(_6);
-//          StorageDead(_5);
-//          StorageLive(_9);
-//          unreachable;
-//      }
-//  }
-// END rustc.main.UnreachablePropagation.before.mir
-// START rustc.main.UnreachablePropagation.after.mir
-//      bb3: {
-//          ...
-//          switchInt(_6) -> [false: bb4, otherwise: bb5];
-//      }
-//      bb4: {
-//          StorageLive(_8);
-//          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
-//          _8 = ();
-//          StorageDead(_8);
-//          _4 = const 42i32;
-//          _5 = ();
-//          unreachable;
-//      }
-//          bb5: {
-//          StorageLive(_7);
-//          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []);
-//          _7 = ();
-//          StorageDead(_7);
-//          _4 = const 21i32;
-//          _5 = ();
-//          unreachable;
-//      }
-//  }
-// END rustc.main.UnreachablePropagation.after.mir
diff --git a/src/test/mir-opt/unreachable_asm_2/rustc.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_asm_2/rustc.main.UnreachablePropagation.diff
new file mode 100644 (file)
index 0000000..a374178
--- /dev/null
@@ -0,0 +1,105 @@
+- // MIR for `main` before UnreachablePropagation
++ // MIR for `main` after UnreachablePropagation
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/unreachable_asm_2.rs:10:11: 10:11
+      let mut _1: std::option::Option<Empty>; // in scope 0 at $DIR/unreachable_asm_2.rs:11:23: 11:30
+      let mut _2: isize;                   // in scope 0 at $DIR/unreachable_asm_2.rs:11:12: 11:20
+      let _3: Empty;                       // in scope 0 at $DIR/unreachable_asm_2.rs:11:17: 11:19
+      let _5: ();                          // in scope 0 at $DIR/unreachable_asm_2.rs:14:9: 22:10
+      let mut _6: bool;                    // in scope 0 at $DIR/unreachable_asm_2.rs:14:12: 14:16
+      let _7: ();                          // in scope 0 at $DIR/unreachable_asm_2.rs:16:13: 16:41
+      let _8: ();                          // in scope 0 at $DIR/unreachable_asm_2.rs:20:13: 20:41
+      let mut _9: !;                       // in scope 0 at $DIR/unreachable_asm_2.rs:24:9: 24:21
+      scope 1 {
+          debug _x => _3;                  // in scope 1 at $DIR/unreachable_asm_2.rs:11:17: 11:19
+          let mut _4: i32;                 // in scope 1 at $DIR/unreachable_asm_2.rs:12:13: 12:19
+          scope 2 {
+              debug _y => _4;              // in scope 2 at $DIR/unreachable_asm_2.rs:12:13: 12:19
+              scope 3 {
+              }
+              scope 4 {
+              }
+          }
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/unreachable_asm_2.rs:11:23: 11:30
+          _1 = const empty() -> bb1;       // bb0[1]: scope 0 at $DIR/unreachable_asm_2.rs:11:23: 11:30
+                                           // ty::Const
+                                           // + ty: fn() -> std::option::Option<Empty> {empty}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_asm_2.rs:11:23: 11:28
+                                           // + literal: Const { ty: fn() -> std::option::Option<Empty> {empty}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          _2 = discriminant(_1);           // bb1[0]: scope 0 at $DIR/unreachable_asm_2.rs:11:12: 11:20
+          switchInt(move _2) -> [1isize: bb3, otherwise: bb2]; // bb1[1]: scope 0 at $DIR/unreachable_asm_2.rs:11:12: 11:20
+      }
+  
+      bb2: {
+          _0 = ();                         // bb2[0]: scope 0 at $DIR/unreachable_asm_2.rs:11:5: 25:6
+          StorageDead(_1);                 // bb2[1]: scope 0 at $DIR/unreachable_asm_2.rs:26:1: 26:2
+          return;                          // bb2[2]: scope 0 at $DIR/unreachable_asm_2.rs:26:2: 26:2
+      }
+  
+      bb3: {
+          StorageLive(_3);                 // bb3[0]: scope 0 at $DIR/unreachable_asm_2.rs:11:17: 11:19
+          _3 = move ((_1 as Some).0: Empty); // bb3[1]: scope 0 at $DIR/unreachable_asm_2.rs:11:17: 11:19
+          StorageLive(_4);                 // bb3[2]: scope 1 at $DIR/unreachable_asm_2.rs:12:13: 12:19
+          StorageLive(_5);                 // bb3[3]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10
+          StorageLive(_6);                 // bb3[4]: scope 2 at $DIR/unreachable_asm_2.rs:14:12: 14:16
+          _6 = const true;                 // bb3[5]: scope 2 at $DIR/unreachable_asm_2.rs:14:12: 14:16
+                                           // ty::Const
+                                           // + ty: bool
+                                           // + val: Value(Scalar(0x01))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_asm_2.rs:14:12: 14:16
+                                           // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+          switchInt(_6) -> [false: bb4, otherwise: bb5]; // bb3[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10
+      }
+  
+      bb4: {
+          StorageLive(_8);                 // bb4[0]: scope 2 at $DIR/unreachable_asm_2.rs:20:13: 20:41
+          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // bb4[1]: scope 4 at $DIR/unreachable_asm_2.rs:20:22: 20:39
+          _8 = ();                         // bb4[2]: scope 4 at $DIR/unreachable_asm_2.rs:20:13: 20:41
+          StorageDead(_8);                 // bb4[3]: scope 2 at $DIR/unreachable_asm_2.rs:20:40: 20:41
+          _4 = const 42i32;                // bb4[4]: scope 2 at $DIR/unreachable_asm_2.rs:21:13: 21:20
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x0000002a))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_asm_2.rs:21:18: 21:20
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
+          _5 = ();                         // bb4[5]: scope 2 at $DIR/unreachable_asm_2.rs:18:16: 22:10
+-         goto -> bb6;                     // bb4[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10
++         unreachable;                     // bb4[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10
+      }
+  
+      bb5: {
+          StorageLive(_7);                 // bb5[0]: scope 2 at $DIR/unreachable_asm_2.rs:16:13: 16:41
+          llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // bb5[1]: scope 3 at $DIR/unreachable_asm_2.rs:16:22: 16:39
+          _7 = ();                         // bb5[2]: scope 3 at $DIR/unreachable_asm_2.rs:16:13: 16:41
+          StorageDead(_7);                 // bb5[3]: scope 2 at $DIR/unreachable_asm_2.rs:16:40: 16:41
+          _4 = const 21i32;                // bb5[4]: scope 2 at $DIR/unreachable_asm_2.rs:17:13: 17:20
+                                           // ty::Const
+                                           // + ty: i32
+                                           // + val: Value(Scalar(0x00000015))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_asm_2.rs:17:18: 17:20
+                                           // + literal: Const { ty: i32, val: Value(Scalar(0x00000015)) }
+          _5 = ();                         // bb5[5]: scope 2 at $DIR/unreachable_asm_2.rs:14:17: 18:10
+-         goto -> bb6;                     // bb5[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10
+-     }
+- 
+-     bb6: {
+-         StorageDead(_6);                 // bb6[0]: scope 2 at $DIR/unreachable_asm_2.rs:22:9: 22:10
+-         StorageDead(_5);                 // bb6[1]: scope 2 at $DIR/unreachable_asm_2.rs:22:9: 22:10
+-         StorageLive(_9);                 // bb6[2]: scope 2 at $DIR/unreachable_asm_2.rs:24:9: 24:21
+-         unreachable;                     // bb6[3]: scope 2 at $DIR/unreachable_asm_2.rs:24:15: 24:17
++         unreachable;                     // bb5[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10
+      }
+  }
+  
index bf05019d5ced15ffb2c7ecbf4addb241e0052d5d..53c753f717bd0d75b81bae63d4bb51270520cacc 100644 (file)
@@ -8,6 +8,7 @@ fn loop_forever() {
     loop {}
 }
 
+// EMIT_MIR rustc.main.UnreachablePropagation.diff
 fn main() {
     let x = true;
     if let Some(bomb) = empty() {
@@ -17,49 +18,3 @@ fn main() {
         match bomb {}
     }
 }
-
-// END RUST SOURCE
-// START rustc.main.UnreachablePropagation.before.mir
-//      bb3: {
-//          StorageLive(_4);
-//          _4 = move ((_2 as Some).0: Empty);
-//          StorageLive(_5);
-//          StorageLive(_6);
-//          _6 = _1;
-//          switchInt(_6) -> [false: bb4, otherwise: bb5];
-//      }
-//      bb4: {
-//          _5 = ();
-//          goto -> bb6;
-//      }
-//      bb5: {
-//          _5 = const loop_forever() -> bb6;
-//      }
-//      bb6: {
-//          StorageDead(_6);
-//          StorageDead(_5);
-//          StorageLive(_7);
-//          unreachable;
-//      }
-//  }
-// END rustc.main.UnreachablePropagation.before.mir
-// START rustc.main.UnreachablePropagation.after.mir
-//      bb3: {
-//          StorageLive(_4);
-//          _4 = move ((_2 as Some).0: Empty);
-//          StorageLive(_5);
-//          StorageLive(_6);
-//          _6 = _1;
-//          goto -> bb4;
-//      }
-//      bb4: {
-//          _5 = const loop_forever() -> bb5;
-//      }
-//      bb5: {
-//          StorageDead(_6);
-//          StorageDead(_5);
-//          StorageLive(_7);
-//          unreachable;
-//      }
-//  }
-// END rustc.main.UnreachablePropagation.after.mir
diff --git a/src/test/mir-opt/unreachable_diverging/rustc.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_diverging/rustc.main.UnreachablePropagation.diff
new file mode 100644 (file)
index 0000000..8d1d137
--- /dev/null
@@ -0,0 +1,89 @@
+- // MIR for `main` before UnreachablePropagation
++ // MIR for `main` after UnreachablePropagation
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/unreachable_diverging.rs:12:11: 12:11
+      let _1: bool;                        // in scope 0 at $DIR/unreachable_diverging.rs:13:9: 13:10
+      let mut _2: std::option::Option<Empty>; // in scope 0 at $DIR/unreachable_diverging.rs:14:25: 14:32
+      let mut _3: isize;                   // in scope 0 at $DIR/unreachable_diverging.rs:14:12: 14:22
+      let _5: ();                          // in scope 0 at $DIR/unreachable_diverging.rs:15:9: 17:10
+      let mut _6: bool;                    // in scope 0 at $DIR/unreachable_diverging.rs:15:12: 15:13
+      let mut _7: !;                       // in scope 0 at $DIR/unreachable_diverging.rs:18:9: 18:22
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/unreachable_diverging.rs:13:9: 13:10
+          let _4: Empty;                   // in scope 1 at $DIR/unreachable_diverging.rs:14:17: 14:21
+          scope 2 {
+              debug bomb => _4;            // in scope 2 at $DIR/unreachable_diverging.rs:14:17: 14:21
+          }
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/unreachable_diverging.rs:13:9: 13:10
+          _1 = const true;                 // bb0[1]: scope 0 at $DIR/unreachable_diverging.rs:13:13: 13:17
+                                           // ty::Const
+                                           // + ty: bool
+                                           // + val: Value(Scalar(0x01))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_diverging.rs:13:13: 13:17
+                                           // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
+          StorageLive(_2);                 // bb0[2]: scope 1 at $DIR/unreachable_diverging.rs:14:25: 14:32
+          _2 = const empty() -> bb1;       // bb0[3]: scope 1 at $DIR/unreachable_diverging.rs:14:25: 14:32
+                                           // ty::Const
+                                           // + ty: fn() -> std::option::Option<Empty> {empty}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_diverging.rs:14:25: 14:30
+                                           // + literal: Const { ty: fn() -> std::option::Option<Empty> {empty}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb1: {
+          _3 = discriminant(_2);           // bb1[0]: scope 1 at $DIR/unreachable_diverging.rs:14:12: 14:22
+          switchInt(move _3) -> [1isize: bb3, otherwise: bb2]; // bb1[1]: scope 1 at $DIR/unreachable_diverging.rs:14:12: 14:22
+      }
+  
+      bb2: {
+          _0 = ();                         // bb2[0]: scope 1 at $DIR/unreachable_diverging.rs:14:5: 19:6
+          StorageDead(_1);                 // bb2[1]: scope 0 at $DIR/unreachable_diverging.rs:20:1: 20:2
+          StorageDead(_2);                 // bb2[2]: scope 0 at $DIR/unreachable_diverging.rs:20:1: 20:2
+          return;                          // bb2[3]: scope 0 at $DIR/unreachable_diverging.rs:20:2: 20:2
+      }
+  
+      bb3: {
+          StorageLive(_4);                 // bb3[0]: scope 1 at $DIR/unreachable_diverging.rs:14:17: 14:21
+          _4 = move ((_2 as Some).0: Empty); // bb3[1]: scope 1 at $DIR/unreachable_diverging.rs:14:17: 14:21
+          StorageLive(_5);                 // bb3[2]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10
+          StorageLive(_6);                 // bb3[3]: scope 2 at $DIR/unreachable_diverging.rs:15:12: 15:13
+          _6 = _1;                         // bb3[4]: scope 2 at $DIR/unreachable_diverging.rs:15:12: 15:13
+-         switchInt(_6) -> [false: bb4, otherwise: bb5]; // bb3[5]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10
++         goto -> bb4;                     // bb3[5]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10
+      }
+  
+      bb4: {
+-         _5 = ();                         // bb4[0]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10
+-         goto -> bb6;                     // bb4[1]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10
+-     }
+- 
+-     bb5: {
+-         _5 = const loop_forever() -> bb6; // bb5[0]: scope 2 at $DIR/unreachable_diverging.rs:16:13: 16:27
++         _5 = const loop_forever() -> bb5; // bb4[0]: scope 2 at $DIR/unreachable_diverging.rs:16:13: 16:27
+                                           // ty::Const
+                                           // + ty: fn() {loop_forever}
+                                           // + val: Value(Scalar(<ZST>))
+                                           // mir::Constant
+                                           // + span: $DIR/unreachable_diverging.rs:16:13: 16:25
+                                           // + literal: Const { ty: fn() {loop_forever}, val: Value(Scalar(<ZST>)) }
+      }
+  
+-     bb6: {
+-         StorageDead(_6);                 // bb6[0]: scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10
+-         StorageDead(_5);                 // bb6[1]: scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10
+-         StorageLive(_7);                 // bb6[2]: scope 2 at $DIR/unreachable_diverging.rs:18:9: 18:22
+-         unreachable;                     // bb6[3]: scope 2 at $DIR/unreachable_diverging.rs:18:15: 18:19
++     bb5: {
++         StorageDead(_6);                 // bb5[0]: scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10
++         StorageDead(_5);                 // bb5[1]: scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10
++         StorageLive(_7);                 // bb5[2]: scope 2 at $DIR/unreachable_diverging.rs:18:9: 18:22
++         unreachable;                     // bb5[3]: scope 2 at $DIR/unreachable_diverging.rs:18:15: 18:19
+      }
+  }
+  
index 88cfb62a0d0948acb1e35fcf957aad33669cac13..ffe8ca01dfb4abf7d973f22d52f1366ac4fb93ef 100644 (file)
@@ -1,86 +1,29 @@
 // Test that we don't ICE when trying to dump MIR for unusual item types and
 // that we don't create filenames containing `<` and `>`
-// ignore-tidy-linelength
+
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
 
 struct A;
 
+// EMIT_MIR rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir
 impl A {
     const ASSOCIATED_CONSTANT: i32 = 2;
 }
 
 // See #59021
+// EMIT_MIR rustc.Test-X-{{constructor}}.mir_map.0.mir
 enum Test {
     X(usize),
     Y { a: usize },
 }
 
+// EMIT_MIR rustc.E-V-{{constant}}.mir_map.0.mir
 enum E {
     V = 5,
 }
 
 fn main() {
     let f = Test::X as fn(usize) -> Test;
+// EMIT_MIR rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir
     let v = Vec::<i32>::new();
 }
-
-// END RUST SOURCE
-
-// START rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir
-// bb0: {
-//     _0 = const 2i32;
-//     return;
-// }
-// bb1 (cleanup): {
-//     resume;
-// }
-// END rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir
-
-// START rustc.E-V-{{constant}}.mir_map.0.mir
-// bb0: {
-//     _0 = const 5isize;
-//     return;
-// }
-// bb1 (cleanup): {
-//     resume;
-// }
-// END rustc.E-V-{{constant}}.mir_map.0.mir
-
-// START rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir
-//     bb0: {
-//     goto -> bb7;
-// }
-// bb1: {
-//     return;
-// }
-// bb2 (cleanup): {
-//     resume;
-// }
-// bb3: {
-//     goto -> bb1;
-// }
-// bb4 (cleanup): {
-//     goto -> bb2;
-// }
-// bb5 (cleanup): {
-//     drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> bb4;
-// }
-// bb6: {
-//     drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb3, unwind: bb4];
-// }
-// bb7: {
-//     _2 = &mut (*_1);
-//     _3 = const <std::vec::Vec<i32> as std::ops::Drop>::drop(move _2) -> [return: bb6, unwind: bb5];
-// }
-// END rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir
-
-// START rustc.Test-X-{{constructor}}.mir_map.0.mir
-// fn Test::X(_1: usize) -> Test {
-//     let mut _0: Test;
-//
-//     bb0: {
-//         ((_0 as X).0: usize) = move _1;
-//         discriminant(_0) = 0;
-//         return;
-//     }
-// }
-// END rustc.Test-X-{{constructor}}.mir_map.0.mir
diff --git a/src/test/mir-opt/unusual-item-types/32bit/rustc.E-V-{{constant}}.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/32bit/rustc.E-V-{{constant}}.mir_map.0.mir
new file mode 100644 (file)
index 0000000..3dc8cea
--- /dev/null
@@ -0,0 +1,20 @@
+// MIR for `E::V::{{constant}}#0` 0 mir_map
+
+E::V::{{constant}}#0: isize = {
+    let mut _0: isize;                   // return place in scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10
+
+    bb0: {
+        _0 = const 5isize;               // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10
+                                         // ty::Const
+                                         // + ty: isize
+                                         // + val: Value(Scalar(0x00000005))
+                                         // mir::Constant
+                                         // + span: $DIR/unusual-item-types.rs:22:9: 22:10
+                                         // + literal: Const { ty: isize, val: Value(Scalar(0x00000005)) }
+        return;                          // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10
+    }
+}
diff --git a/src/test/mir-opt/unusual-item-types/32bit/rustc.Test-X-{{constructor}}.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/32bit/rustc.Test-X-{{constructor}}.mir_map.0.mir
new file mode 100644 (file)
index 0000000..d6ce062
--- /dev/null
@@ -0,0 +1,11 @@
+// MIR for `Test::X` 0 mir_map
+
+fn Test::X(_1: usize) -> Test {
+    let mut _0: Test;                    // return place in scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13
+
+    bb0: {
+        ((_0 as X).0: usize) = move _1;  // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13
+        discriminant(_0) = 0;            // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13
+        return;                          // bb0[2]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13
+    }
+}
diff --git a/src/test/mir-opt/unusual-item-types/32bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir b/src/test/mir-opt/unusual-item-types/32bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir
new file mode 100644 (file)
index 0000000..b78480e
--- /dev/null
@@ -0,0 +1,46 @@
+// MIR for `std::intrinsics::drop_in_place` before AddMovesForPackedDrops
+
+fn std::intrinsics::drop_in_place(_1: *mut std::vec::Vec<i32>) -> () {
+    let mut _0: ();                      // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _2: &mut std::vec::Vec<i32>; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _3: ();                      // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+
+    bb0: {
+        goto -> bb7;                     // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb1: {
+        return;                          // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb2 (cleanup): {
+        resume;                          // bb2[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb3: {
+        goto -> bb1;                     // bb3[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb4 (cleanup): {
+        goto -> bb2;                     // bb4[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb5 (cleanup): {
+        drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> bb4; // bb5[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb6: {
+        drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb3, unwind: bb4]; // bb6[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb7: {
+        _2 = &mut (*_1);                 // bb7[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _3 = const <std::vec::Vec<i32> as std::ops::Drop>::drop(move _2) -> [return: bb6, unwind: bb5]; // bb7[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: for<'r> fn(&'r mut std::vec::Vec<i32>) {<std::vec::Vec<i32> as std::ops::Drop>::drop}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: for<'r> fn(&'r mut std::vec::Vec<i32>) {<std::vec::Vec<i32> as std::ops::Drop>::drop}, val: Value(Scalar(<ZST>)) }
+    }
+}
diff --git a/src/test/mir-opt/unusual-item-types/32bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/32bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir
new file mode 100644 (file)
index 0000000..9f65819
--- /dev/null
@@ -0,0 +1,20 @@
+// MIR for `<impl at $DIR/unusual-item-types.rs:9:1: 11:2>::ASSOCIATED_CONSTANT` 0 mir_map
+
+const <impl at $DIR/unusual-item-types.rs:9:1: 11:2>::ASSOCIATED_CONSTANT: i32 = {
+    let mut _0: i32;                     // return place in scope 0 at $DIR/unusual-item-types.rs:10:32: 10:35
+
+    bb0: {
+        _0 = const 2i32;                 // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:10:38: 10:39
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/unusual-item-types.rs:10:38: 10:39
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        return;                          // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:10:5: 10:40
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/unusual-item-types.rs:10:5: 10:40
+    }
+}
diff --git a/src/test/mir-opt/unusual-item-types/64bit/rustc.E-V-{{constant}}.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/64bit/rustc.E-V-{{constant}}.mir_map.0.mir
new file mode 100644 (file)
index 0000000..8434ff4
--- /dev/null
@@ -0,0 +1,20 @@
+// MIR for `E::V::{{constant}}#0` 0 mir_map
+
+E::V::{{constant}}#0: isize = {
+    let mut _0: isize;                   // return place in scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10
+
+    bb0: {
+        _0 = const 5isize;               // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10
+                                         // ty::Const
+                                         // + ty: isize
+                                         // + val: Value(Scalar(0x0000000000000005))
+                                         // mir::Constant
+                                         // + span: $DIR/unusual-item-types.rs:22:9: 22:10
+                                         // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000005)) }
+        return;                          // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10
+    }
+}
diff --git a/src/test/mir-opt/unusual-item-types/64bit/rustc.Test-X-{{constructor}}.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/64bit/rustc.Test-X-{{constructor}}.mir_map.0.mir
new file mode 100644 (file)
index 0000000..d6ce062
--- /dev/null
@@ -0,0 +1,11 @@
+// MIR for `Test::X` 0 mir_map
+
+fn Test::X(_1: usize) -> Test {
+    let mut _0: Test;                    // return place in scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13
+
+    bb0: {
+        ((_0 as X).0: usize) = move _1;  // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13
+        discriminant(_0) = 0;            // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13
+        return;                          // bb0[2]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13
+    }
+}
diff --git a/src/test/mir-opt/unusual-item-types/64bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir b/src/test/mir-opt/unusual-item-types/64bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir
new file mode 100644 (file)
index 0000000..b78480e
--- /dev/null
@@ -0,0 +1,46 @@
+// MIR for `std::intrinsics::drop_in_place` before AddMovesForPackedDrops
+
+fn std::intrinsics::drop_in_place(_1: *mut std::vec::Vec<i32>) -> () {
+    let mut _0: ();                      // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _2: &mut std::vec::Vec<i32>; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    let mut _3: ();                      // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+
+    bb0: {
+        goto -> bb7;                     // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb1: {
+        return;                          // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb2 (cleanup): {
+        resume;                          // bb2[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb3: {
+        goto -> bb1;                     // bb3[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb4 (cleanup): {
+        goto -> bb2;                     // bb4[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb5 (cleanup): {
+        drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> bb4; // bb5[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb6: {
+        drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb3, unwind: bb4]; // bb6[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+    }
+
+    bb7: {
+        _2 = &mut (*_1);                 // bb7[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+        _3 = const <std::vec::Vec<i32> as std::ops::Drop>::drop(move _2) -> [return: bb6, unwind: bb5]; // bb7[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: for<'r> fn(&'r mut std::vec::Vec<i32>) {<std::vec::Vec<i32> as std::ops::Drop>::drop}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL
+                                         // + literal: Const { ty: for<'r> fn(&'r mut std::vec::Vec<i32>) {<std::vec::Vec<i32> as std::ops::Drop>::drop}, val: Value(Scalar(<ZST>)) }
+    }
+}
diff --git a/src/test/mir-opt/unusual-item-types/64bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/64bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir
new file mode 100644 (file)
index 0000000..9f65819
--- /dev/null
@@ -0,0 +1,20 @@
+// MIR for `<impl at $DIR/unusual-item-types.rs:9:1: 11:2>::ASSOCIATED_CONSTANT` 0 mir_map
+
+const <impl at $DIR/unusual-item-types.rs:9:1: 11:2>::ASSOCIATED_CONSTANT: i32 = {
+    let mut _0: i32;                     // return place in scope 0 at $DIR/unusual-item-types.rs:10:32: 10:35
+
+    bb0: {
+        _0 = const 2i32;                 // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:10:38: 10:39
+                                         // ty::Const
+                                         // + ty: i32
+                                         // + val: Value(Scalar(0x00000002))
+                                         // mir::Constant
+                                         // + span: $DIR/unusual-item-types.rs:10:38: 10:39
+                                         // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+        return;                          // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:10:5: 10:40
+    }
+
+    bb1 (cleanup): {
+        resume;                          // bb1[0]: scope 0 at $DIR/unusual-item-types.rs:10:5: 10:40
+    }
+}
index 86c3f79d3a70693709eef25f816d1d42bd53d5aa..56f6c3380a719b0c7e2c591939ed723513a4fa2c 100644 (file)
@@ -5,6 +5,7 @@ fn get_bool(c: bool) -> bool {
     c
 }
 
+// EMIT_MIR rustc.while_loop.PreCodegen.after.mir
 fn while_loop(c: bool) {
     while get_bool(c) {
         if get_bool(c) {
@@ -16,41 +17,3 @@ fn while_loop(c: bool) {
 fn main() {
     while_loop(false);
 }
-
-// END RUST SOURCE
-
-// START rustc.while_loop.PreCodegen.after.mir
-// bb0: {
-//     StorageLive(_2);
-//     StorageLive(_3);
-//     _3 = _1;
-//     _2 = const get_bool(move _3) -> bb1;
-// }
-// bb1: {
-//     StorageDead(_3);
-//     switchInt(_2) -> [false: bb6, otherwise: bb2];
-// }
-// bb2: {
-//      StorageLive(_4);
-//      StorageLive(_5);
-//      _5 = _1;
-//      _4 = const get_bool(move _5) -> bb3;
-// }
-// bb3: {
-//      StorageDead(_5);
-//      switchInt(_4) -> [false: bb4, otherwise: bb5];
-// }
-// bb4: {
-//      StorageDead(_4);
-//      StorageDead(_2);
-//      goto -> bb0;
-// }
-//  bb5: {
-//      StorageDead(_4);
-//      goto -> bb6;
-//  }
-//  bb6: {
-//      StorageDead(_2);
-//      return;
-//  }
-// END rustc.while_loop.PreCodegen.after.mir
diff --git a/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir b/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir
new file mode 100644 (file)
index 0000000..8fadcb8
--- /dev/null
@@ -0,0 +1,62 @@
+// MIR for `while_loop` after PreCodegen
+
+fn while_loop(_1: bool) -> () {
+    debug c => _1;                       // in scope 0 at $DIR/while-storage.rs:9:15: 9:16
+    let mut _0: ();                      // return place in scope 0 at $DIR/while-storage.rs:9:24: 9:24
+    let mut _2: bool;                    // in scope 0 at $DIR/while-storage.rs:10:11: 10:22
+    let mut _3: bool;                    // in scope 0 at $DIR/while-storage.rs:10:20: 10:21
+    let mut _4: bool;                    // in scope 0 at $DIR/while-storage.rs:11:12: 11:23
+    let mut _5: bool;                    // in scope 0 at $DIR/while-storage.rs:11:21: 11:22
+
+    bb0: {
+        StorageLive(_2);                 // bb0[0]: scope 0 at $DIR/while-storage.rs:10:11: 10:22
+        StorageLive(_3);                 // bb0[1]: scope 0 at $DIR/while-storage.rs:10:20: 10:21
+        _3 = _1;                         // bb0[2]: scope 0 at $DIR/while-storage.rs:10:20: 10:21
+        _2 = const get_bool(move _3) -> bb1; // bb0[3]: scope 0 at $DIR/while-storage.rs:10:11: 10:22
+                                         // ty::Const
+                                         // + ty: fn(bool) -> bool {get_bool}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/while-storage.rs:10:11: 10:19
+                                         // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1: {
+        StorageDead(_3);                 // bb1[0]: scope 0 at $DIR/while-storage.rs:10:21: 10:22
+        switchInt(_2) -> [false: bb6, otherwise: bb2]; // bb1[1]: scope 0 at $DIR/while-storage.rs:10:5: 14:6
+    }
+
+    bb2: {
+        StorageLive(_4);                 // bb2[0]: scope 0 at $DIR/while-storage.rs:11:12: 11:23
+        StorageLive(_5);                 // bb2[1]: scope 0 at $DIR/while-storage.rs:11:21: 11:22
+        _5 = _1;                         // bb2[2]: scope 0 at $DIR/while-storage.rs:11:21: 11:22
+        _4 = const get_bool(move _5) -> bb3; // bb2[3]: scope 0 at $DIR/while-storage.rs:11:12: 11:23
+                                         // ty::Const
+                                         // + ty: fn(bool) -> bool {get_bool}
+                                         // + val: Value(Scalar(<ZST>))
+                                         // mir::Constant
+                                         // + span: $DIR/while-storage.rs:11:12: 11:20
+                                         // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb3: {
+        StorageDead(_5);                 // bb3[0]: scope 0 at $DIR/while-storage.rs:11:22: 11:23
+        switchInt(_4) -> [false: bb4, otherwise: bb5]; // bb3[1]: scope 0 at $DIR/while-storage.rs:11:9: 13:10
+    }
+
+    bb4: {
+        StorageDead(_4);                 // bb4[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6
+        StorageDead(_2);                 // bb4[1]: scope 0 at $DIR/while-storage.rs:10:21: 10:22
+        goto -> bb0;                     // bb4[2]: scope 0 at $DIR/while-storage.rs:10:5: 14:6
+    }
+
+    bb5: {
+        StorageDead(_4);                 // bb5[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6
+        goto -> bb6;                     // bb5[1]: scope 0 at $DIR/while-storage.rs:12:13: 12:18
+    }
+
+    bb6: {
+        StorageDead(_2);                 // bb6[0]: scope 0 at $DIR/while-storage.rs:10:21: 10:22
+        return;                          // bb6[1]: scope 0 at $DIR/while-storage.rs:15:2: 15:2
+    }
+}
diff --git a/src/test/rustdoc/auxiliary/external-macro-src.rs b/src/test/rustdoc/auxiliary/external-macro-src.rs
new file mode 100644 (file)
index 0000000..ce20ca5
--- /dev/null
@@ -0,0 +1,15 @@
+// compile-flags:--remap-path-prefix={{src-base}}=/does-not-exist
+
+#![doc(html_root_url = "https://example.com/")]
+
+#[macro_export]
+macro_rules! make_foo {
+    () => {
+        pub struct Foo;
+        impl Foo {
+            pub fn new() -> Foo {
+                Foo
+            }
+        }
+    }
+}
diff --git a/src/test/rustdoc/external-macro-src.rs b/src/test/rustdoc/external-macro-src.rs
new file mode 100644 (file)
index 0000000..4394415
--- /dev/null
@@ -0,0 +1,15 @@
+// aux-build:external-macro-src.rs
+// ignore-tidy-linelength
+
+#![crate_name = "foo"]
+
+#[macro_use]
+extern crate external_macro_src;
+
+// @has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#4-15"]' '[src]'
+
+// @has foo/struct.Foo.html
+// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#8"]' '[src]'
+// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#9-13"]' '[src]'
+// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#10-12"]' '[src]'
+make_foo!();
index d2aa4bbbd12511982843df7cd720c9c4f4d7c9c3..c8e9a63ea9f771e2a648ac8afe2c93ffa406e5ce 100644 (file)
@@ -7,5 +7,5 @@
 extern crate issue_26606_macro;
 
 // @has issue_26606/constant.FOO.html
-// @has - '//a/@href' '../src/issue_26606/auxiliary/issue-26606-macro.rs.html#3'
+// @has - '//a/@href' '../src/issue_26606_macro/issue-26606-macro.rs.html#3'
 make_item!(FOO);
diff --git a/src/test/rustdoc/thread-local-src.rs b/src/test/rustdoc/thread-local-src.rs
new file mode 100644 (file)
index 0000000..022d81a
--- /dev/null
@@ -0,0 +1,6 @@
+#![crate_name = "foo"]
+
+// @has foo/index.html '//a[@href="../src/foo/thread-local-src.rs.html#1-6"]' '[src]'
+
+// @has foo/constant.FOO.html '//a/@href' 'https://doc.rust-lang.org/nightly/src/std/'
+thread_local!(pub static FOO: bool = false);
diff --git a/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.rs b/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.rs
new file mode 100644 (file)
index 0000000..fc19bc0
--- /dev/null
@@ -0,0 +1,7 @@
+// aux-build:lint-group-plugin-test.rs
+// compile-flags: -F unused -A unused
+
+fn main() {
+    let x = 1;
+    //~^ ERROR unused variable: `x`
+}
diff --git a/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.stderr b/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.stderr
new file mode 100644 (file)
index 0000000..6bab367
--- /dev/null
@@ -0,0 +1,10 @@
+error: unused variable: `x`
+  --> $DIR/lint-group-forbid-always-trumps-cli.rs:5:9
+   |
+LL |     let x = 1;
+   |         ^ help: if this is intentional, prefix it with an underscore: `_x`
+   |
+   = note: `-F unused-variables` implied by `-F unused`
+
+error: aborting due to previous error
+
index f004b4180ddc9c30fd424f4bfe8b21f66cb76434..605cfdfe747a34412e3635975268d1c66a5b9b43 100644 (file)
@@ -1,12 +1,18 @@
 // edition:2018
 // run-rustfix
 
-fn foo() -> Box<impl std::future::Future<Output = u32>> {
+fn test_boxed() -> Box<impl std::future::Future<Output = u32>> {
     let x = 0u32;
     Box::new(async move { x } )
     //~^ ERROR E0373
 }
 
+fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
+    async move { *x }
+    //~^ ERROR E0373
+}
+
 fn main() {
-    let _foo = foo();
+    let _ = test_boxed();
+    let _ = test_ref(&0u32);
 }
index 4f35fd52ca39beed26bfb01c5becd7ef41c7e593..ec752c15fa28456aac4bace049dcf18bcee9d1f5 100644 (file)
@@ -1,12 +1,18 @@
 // edition:2018
 // run-rustfix
 
-fn foo() -> Box<impl std::future::Future<Output = u32>> {
+fn test_boxed() -> Box<impl std::future::Future<Output = u32>> {
     let x = 0u32;
     Box::new(async { x } )
     //~^ ERROR E0373
 }
 
+fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
+    async { *x }
+    //~^ ERROR E0373
+}
+
 fn main() {
-    let _foo = foo();
+    let _ = test_boxed();
+    let _ = test_ref(&0u32);
 }
index 0eb3971d14a38e8fdd53324a99dc7f7e15d7f16b..193026541d073433629c5f00547375cff6cc1110 100644 (file)
@@ -1,4 +1,4 @@
-error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
+error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
   --> $DIR/async-borrowck-escaping-block-error.rs:6:20
    |
 LL |     Box::new(async { x } )
@@ -7,16 +7,35 @@ LL |     Box::new(async { x } )
    |                    | `x` is borrowed here
    |                    may outlive borrowed value `x`
    |
-note: generator is returned here
-  --> $DIR/async-borrowck-escaping-block-error.rs:4:13
+note: async block is returned here
+  --> $DIR/async-borrowck-escaping-block-error.rs:4:20
    |
-LL | fn foo() -> Box<impl std::future::Future<Output = u32>> {
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | fn test_boxed() -> Box<impl std::future::Future<Output = u32>> {
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword
    |
 LL |     Box::new(async move { x } )
    |                    ^^^^^^^^^^
 
-error: aborting due to previous error
+error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
+  --> $DIR/async-borrowck-escaping-block-error.rs:11:11
+   |
+LL |     async { *x }
+   |           ^^^-^^
+   |           |  |
+   |           |  `x` is borrowed here
+   |           may outlive borrowed value `x`
+   |
+note: async block is returned here
+  --> $DIR/async-borrowck-escaping-block-error.rs:11:5
+   |
+LL |     async { *x }
+   |     ^^^^^^^^^^^^
+help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword
+   |
+LL |     async move { *x }
+   |           ^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0373`.
index d2fa5d0a3d0f189b5507dd4c6c1566f866fbba5c..e667b72aee530616b705ed4354b14c1cacba0a93 100644 (file)
@@ -1,5 +1,5 @@
 // edition:2018
-#![feature(async_closure,async_await)]
+#![feature(async_closure)]
 fn foo() -> Box<dyn std::future::Future<Output = u32>> {
     let x = 0u32;
     Box::new((async || x)())
diff --git a/src/test/ui/async-await/issues/issue-69307-nested.rs b/src/test/ui/async-await/issues/issue-69307-nested.rs
new file mode 100644 (file)
index 0000000..b7cdf39
--- /dev/null
@@ -0,0 +1,30 @@
+// Regression test for #69307
+//
+// Having a `async { .. foo.await .. }` block appear inside of a `+=`
+// expression was causing an ICE due to a failure to save/restore
+// state in the AST numbering pass when entering a nested body.
+//
+// check-pass
+// edition:2018
+
+fn block_on<F>(_: F) -> usize {
+    0
+}
+
+fn main() {}
+
+async fn bar() {
+    let mut sum = 0;
+    sum += {
+        block_on(async {
+            baz().await;
+            let mut inner = 1;
+            inner += block_on(async {
+                baz().await;
+                0
+            })
+        })
+    };
+}
+
+async fn baz() {}
diff --git a/src/test/ui/async-await/issues/issue-69307.rs b/src/test/ui/async-await/issues/issue-69307.rs
new file mode 100644 (file)
index 0000000..4dae96e
--- /dev/null
@@ -0,0 +1,23 @@
+// Regression test for #69307
+//
+// Having a `async { .. foo.await .. }` block appear inside of a `+=`
+// expression was causing an ICE due to a failure to save/restore
+// state in the AST numbering pass when entering a nested body.
+//
+// check-pass
+// edition:2018
+
+fn block_on<F>(_: F) -> usize {
+    0
+}
+
+fn main() {}
+
+async fn bar() {
+    let mut sum = 0;
+    sum += block_on(async {
+        baz().await;
+    });
+}
+
+async fn baz() {}
diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.rs b/src/test/ui/const-generics/issue-61522-array-len-succ.rs
new file mode 100644 (file)
index 0000000..3b627a5
--- /dev/null
@@ -0,0 +1,14 @@
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
+//~^ ERROR constant expression depends on a generic parameter
+
+impl<const COUNT: usize> MyArray<COUNT> {
+    fn inner(&self) -> &[u8; COUNT + 1] {
+        //~^ ERROR constant expression depends on a generic parameter
+        &self.0
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.stderr b/src/test/ui/const-generics/issue-61522-array-len-succ.stderr
new file mode 100644 (file)
index 0000000..0c4bd4a
--- /dev/null
@@ -0,0 +1,26 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/issue-61522-array-len-succ.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
+error: constant expression depends on a generic parameter
+  --> $DIR/issue-61522-array-len-succ.rs:4:40
+   |
+LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
+   |                                        ^^^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: constant expression depends on a generic parameter
+  --> $DIR/issue-61522-array-len-succ.rs:8:24
+   |
+LL |     fn inner(&self) -> &[u8; COUNT + 1] {
+   |                        ^^^^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs
new file mode 100644 (file)
index 0000000..b677dcc
--- /dev/null
@@ -0,0 +1,16 @@
+// check-pass
+
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+trait Trait<const NAME: &'static str> {
+    type Assoc;
+}
+
+impl Trait<"0"> for () {
+    type Assoc = ();
+}
+
+fn main() {
+    let _: <() as Trait<"0">>::Assoc = ();
+}
diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr
new file mode 100644 (file)
index 0000000..8ab28cc
--- /dev/null
@@ -0,0 +1,8 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:3:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
index 6179132b3f6080e0decb74aebfe80b4a49eb702e..d2a345231eb438687fe02d40b38bc2c9edfca400 100644 (file)
@@ -4,7 +4,7 @@ struct List {
 impl List {
     fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> {
         self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref())
-        //~^ ERROR does not live long enough
+        //~^ ERROR E0373
     }
 }
 
index 9cff4bcd8b579df62d664c6f3b3f9cdc17d0833c..468c2f366299c854df01813094270feba4fa7f1a 100644 (file)
@@ -1,21 +1,21 @@
-error[E0597]: `prefix` does not live long enough
-  --> $DIR/does-not-live-long-enough.rs:6:51
+error[E0373]: closure may outlive the current function, but it borrows `prefix`, which is owned by the current function
+  --> $DIR/does-not-live-long-enough.rs:6:33
    |
-LL |     fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> {
-   |                     -- lifetime `'a` defined here     --------------------------- opaque type requires that `prefix` is borrowed for `'a`
 LL |         self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref())
-   |                                 ---               ^^^^^^ borrowed value does not live long enough
+   |                                 ^^^               ------ `prefix` is borrowed here
    |                                 |
-   |                                 value captured here
-LL |
-LL |     }
-   |     - `prefix` dropped here while still borrowed
+   |                                 may outlive borrowed value `prefix`
+   |
+note: closure is returned here
+  --> $DIR/does-not-live-long-enough.rs:5:55
    |
-help: you can add a bound to the opaque type to make it last less than `'static` and match `'a`
+LL |     fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> {
+   |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to force the closure to take ownership of `prefix` (and any other referenced variables), use the `move` keyword
    |
-LL |     fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> + 'a {
-   |                                                                                   ^^^^
+LL |         self.data.iter().filter(move |s| s.starts_with(prefix)).map(|s| s.as_ref())
+   |                                 ^^^^^^^^
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0373`.
index 45752ad4f62b6dba9634fd9b4e1e4aca77716172..70e5bc0192086e3ffb8890a47cab7e1e6ff77b00 100644 (file)
@@ -4,4 +4,6 @@
 
 fn main() {
     0.homura(); //~ ERROR no method named `homura` found
+    // Issue #47759, detect existing method on the fundamental impl:
+    let _ = |x: f64| x * 2.0.exp(); //~ ERROR can't call method `exp` on ambiguous numeric type
 }
index 250b158ab8e33e8bd8c0bc463660e0fee500828b..b66dcb88d00625adcb17534f04743d7a578fb3c5 100644 (file)
@@ -4,6 +4,18 @@ error[E0599]: no method named `homura` found for type `{integer}` in the current
 LL |     0.homura();
    |       ^^^^^^ method not found in `{integer}`
 
-error: aborting due to previous error
+error[E0689]: can't call method `exp` on ambiguous numeric type `{float}`
+  --> $DIR/issue-29181.rs:8:30
+   |
+LL |     let _ = |x: f64| x * 2.0.exp();
+   |                              ^^^
+   |
+help: you must specify a concrete type for this numeric value, like `f32`
+   |
+LL |     let _ = |x: f64| x * 2.0_f32.exp();
+   |                          ^^^^^^^
+
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0599`.
+Some errors have detailed explanations: E0599, E0689.
+For more information about an error, try `rustc --explain E0599`.
index ab60a326cd220808ba2d69bc15b1fbbdb2673118..d2a0329585b71b0d9302f8fafe51d78d5692d4b8 100644 (file)
@@ -131,4 +131,22 @@ fn method<T: Bar>(&self, x: &T) {
     }
 }
 
+// Do not trigger on functions that may diverge instead of self-recursing (#54444)
+
+pub fn loops(x: bool) {
+    if x {
+        loops(x);
+    } else {
+        loop {}
+    }
+}
+
+pub fn panics(x: bool) {
+    if x {
+        panics(!x);
+    } else {
+        panic!("panics");
+    }
+}
+
 fn main() {}
index de456ee6c230cac9a7d4c9872ba1dbde8974386d..952398ef0685bd8f0345eb2ac6aa4fe9e7e5b21b 100644 (file)
@@ -1,29 +1,48 @@
 // check-pass
 #![warn(unused_braces, unused_parens)]
 
+fn consume<T>(_: T) {}
+
 fn main() {
     let _ = (7);
     //~^WARN unnecessary parentheses
 
-    let _ = { 7 };
-    //~^ WARN unnecessary braces
+    // Do not emit a lint in these cases,
+    // as we have to be careful with
+    // `ref` patterns.
+    {
+        let _ = { 7 };
+
+        if let 7 = { 7 } { }
+
+        match { 7 } {
+            _ => (),
+        }
+    }
 
-    if let 7 = { 7 } {
+    if { true } {
+        //~^ WARN unnecessary braces
+    }
+
+    while { false } {
         //~^ WARN unnecessary braces
     }
 
     let _: [u8; { 3 }];
     //~^ WARN unnecessary braces
 
-    // do not emit error for multiline blocks.
+    consume({ 7 });
+    //~^ WARN unnecessary braces
+
+    // Do not emit lint for multiline blocks.
     let _ = {
         7
     };
 
-    // do not emit error for unsafe blocks.
+    // Do not emit lint for unsafe blocks.
     let _ = unsafe { 7 };
 
-    // do not emit error, as the `{` would then
+    // Do not emit lint, as the `{` would then
     // be parsed as part of the `return`.
     if { return } {
 
index 72f425ffc3e01147e88c6cc2b1c529545ded8de2..f195c00241836b375e09a4dc55166b9af42c36e7 100644 (file)
@@ -1,5 +1,5 @@
 warning: unnecessary parentheses around assigned value
-  --> $DIR/unused_braces.rs:5:13
+  --> $DIR/unused_braces.rs:7:13
    |
 LL |     let _ = (7);
    |             ^^^ help: remove these parentheses
@@ -10,11 +10,11 @@ note: the lint level is defined here
 LL | #![warn(unused_braces, unused_parens)]
    |                        ^^^^^^^^^^^^^
 
-warning: unnecessary braces around assigned value
-  --> $DIR/unused_braces.rs:8:13
+warning: unnecessary braces around `if` condition
+  --> $DIR/unused_braces.rs:23:8
    |
-LL |     let _ = { 7 };
-   |             ^^^^^ help: remove these braces
+LL |     if { true } {
+   |        ^^^^^^^^ help: remove these braces
    |
 note: the lint level is defined here
   --> $DIR/unused_braces.rs:2:9
@@ -22,15 +22,21 @@ note: the lint level is defined here
 LL | #![warn(unused_braces, unused_parens)]
    |         ^^^^^^^^^^^^^
 
-warning: unnecessary braces around `let` scrutinee expression
-  --> $DIR/unused_braces.rs:11:16
+warning: unnecessary braces around `while` condition
+  --> $DIR/unused_braces.rs:27:11
    |
-LL |     if let 7 = { 7 } {
-   |                ^^^^^ help: remove these braces
+LL |     while { false } {
+   |           ^^^^^^^^^ help: remove these braces
 
 warning: unnecessary braces around const expression
-  --> $DIR/unused_braces.rs:15:17
+  --> $DIR/unused_braces.rs:31:17
    |
 LL |     let _: [u8; { 3 }];
    |                 ^^^^^ help: remove these braces
 
+warning: unnecessary braces around function argument
+  --> $DIR/unused_braces.rs:34:13
+   |
+LL |     consume({ 7 });
+   |             ^^^^^ help: remove these braces
+
diff --git a/src/test/ui/lint/unused_braces_borrow.rs b/src/test/ui/lint/unused_braces_borrow.rs
new file mode 100644 (file)
index 0000000..d0b0597
--- /dev/null
@@ -0,0 +1,24 @@
+// check-pass
+#![warn(unused_braces)]
+
+// changing `&{ expr }` to `&expr` changes the semantic of the program
+// so we should not warn this case
+
+#[repr(packed)]
+struct A {
+    a: u8,
+    b: u32,
+}
+
+fn consume<T>(_: T) {}
+
+fn main() {
+    let a = A {
+        a: 42,
+        b: 1729,
+    };
+
+    consume(&{ a.b });
+    consume({ a.b });
+    //~^ WARN unnecessary braces
+}
diff --git a/src/test/ui/lint/unused_braces_borrow.stderr b/src/test/ui/lint/unused_braces_borrow.stderr
new file mode 100644 (file)
index 0000000..82fb437
--- /dev/null
@@ -0,0 +1,12 @@
+warning: unnecessary braces around function argument
+  --> $DIR/unused_braces_borrow.rs:22:13
+   |
+LL |     consume({ a.b });
+   |             ^^^^^^^ help: remove these braces
+   |
+note: the lint level is defined here
+  --> $DIR/unused_braces_borrow.rs:2:9
+   |
+LL | #![warn(unused_braces)]
+   |         ^^^^^^^^^^^^^
+
diff --git a/src/test/ui/lint/unused_parens_borrow.rs b/src/test/ui/lint/unused_parens_borrow.rs
deleted file mode 100644 (file)
index 98dbbec..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// check-pass
-#![warn(unused_braces)]
-
-// changing `&{ expr }` to `&expr` changes the semantic of the program
-// so we should not warn this case
-
-#[repr(packed)]
-struct A {
-    a: u8,
-    b: u32,
-}
-
-fn main() {
-    let a = A {
-        a: 42,
-        b: 1729,
-    };
-
-    let _ = &{ a.b };
-    let _ = { a.b };
-    //~^ WARN unnecessary braces
-}
diff --git a/src/test/ui/lint/unused_parens_borrow.stderr b/src/test/ui/lint/unused_parens_borrow.stderr
deleted file mode 100644 (file)
index 7e3839a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-warning: unnecessary braces around assigned value
-  --> $DIR/unused_parens_borrow.rs:20:13
-   |
-LL |     let _ = { a.b };
-   |             ^^^^^^^ help: remove these braces
-   |
-note: the lint level is defined here
-  --> $DIR/unused_parens_borrow.rs:2:9
-   |
-LL | #![warn(unused_braces)]
-   |         ^^^^^^^^^^^^^
-
index 66e9b78f6764a1e1dc7b538073f71646e77e279f..45ca00f55ab596598b61c54ecaae4cf7e267b246 100644 (file)
@@ -63,10 +63,6 @@ LL | use foo2::Bar;
    |
 LL | use foo3::Bar;
    |
-help: you might be missing a type parameter
-   |
-LL | fn test_glob3<Bar>() {
-   |              ^^^^^
 
 error[E0107]: wrong number of const arguments: expected 0, found 1
   --> $DIR/privacy-ns1.rs:35:17
diff --git a/src/test/ui/rfc-2091-track-caller/error-extern-fn.rs b/src/test/ui/rfc-2091-track-caller/error-extern-fn.rs
deleted file mode 100644 (file)
index 9f6a69a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#![feature(track_caller)]
-#![allow(dead_code)]
-
-extern "Rust" {
-    #[track_caller] //~ ERROR: `#[track_caller]` is not supported on foreign functions
-    fn bar();
-}
-
-fn main() {}
diff --git a/src/test/ui/rfc-2091-track-caller/error-extern-fn.stderr b/src/test/ui/rfc-2091-track-caller/error-extern-fn.stderr
deleted file mode 100644 (file)
index b03f5fb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0738]: `#[track_caller]` is not supported on foreign functions
-  --> $DIR/error-extern-fn.rs:5:5
-   |
-LL |     #[track_caller]
-   |     ^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0738`.
index dd9e5d04135851cd4f1fe97c6ed828cae38b11b8..f45738483333599caa3ec2e98354933dfde62561 100644 (file)
@@ -1,8 +1,21 @@
 #![feature(naked_functions, track_caller)]
 
-#[track_caller]
+#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
 #[naked]
 fn f() {}
-//~^^^ ERROR cannot use `#[track_caller]` with `#[naked]`
+
+struct S;
+
+impl S {
+    #[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
+    #[naked]
+    fn g() {}
+}
+
+extern "Rust" {
+    #[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`
+    #[naked]
+    fn h();
+}
 
 fn main() {}
index 2f5003cfdb7a57aab2466517101303f8398d4308..1249d1df07179cbc655ec28fd566acb6b3b1ba2a 100644 (file)
@@ -4,6 +4,18 @@ error[E0736]: cannot use `#[track_caller]` with `#[naked]`
 LL | #[track_caller]
    | ^^^^^^^^^^^^^^^
 
-error: aborting due to previous error
+error[E0736]: cannot use `#[track_caller]` with `#[naked]`
+  --> $DIR/error-with-naked.rs:16:5
+   |
+LL |     #[track_caller]
+   |     ^^^^^^^^^^^^^^^
+
+error[E0736]: cannot use `#[track_caller]` with `#[naked]`
+  --> $DIR/error-with-naked.rs:10:5
+   |
+LL |     #[track_caller]
+   |     ^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0736`.
diff --git a/src/test/ui/rfc-2091-track-caller/track-caller-ffi.rs b/src/test/ui/rfc-2091-track-caller/track-caller-ffi.rs
new file mode 100644 (file)
index 0000000..23c17d7
--- /dev/null
@@ -0,0 +1,50 @@
+// run-pass
+
+#![feature(track_caller)]
+
+use std::panic::Location;
+
+extern "Rust" {
+    #[track_caller]
+    fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static>;
+    fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static>;
+}
+
+fn rust_track_caller_ffi_test_nested_tracked() -> &'static Location<'static> {
+    unsafe { rust_track_caller_ffi_test_tracked() }
+}
+
+mod provides {
+    use std::panic::Location;
+    #[track_caller] // UB if we did not have this!
+    #[no_mangle]
+    fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static> {
+        Location::caller()
+    }
+    #[no_mangle]
+    fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static> {
+        Location::caller()
+    }
+}
+
+fn main() {
+    let location = Location::caller();
+    assert_eq!(location.file(), file!());
+    assert_eq!(location.line(), 31);
+    assert_eq!(location.column(), 20);
+
+    let tracked = unsafe { rust_track_caller_ffi_test_tracked() };
+    assert_eq!(tracked.file(), file!());
+    assert_eq!(tracked.line(), 36);
+    assert_eq!(tracked.column(), 28);
+
+    let untracked = unsafe { rust_track_caller_ffi_test_untracked() };
+    assert_eq!(untracked.file(), file!());
+    assert_eq!(untracked.line(), 26);
+    assert_eq!(untracked.column(), 9);
+
+    let contained = rust_track_caller_ffi_test_nested_tracked();
+    assert_eq!(contained.file(), file!());
+    assert_eq!(contained.line(), 14);
+    assert_eq!(contained.column(), 14);
+}
index 0a73a269134ef6b39ad2227fb6abf3ecee5d9432..22aad3b0a9f584a0e021ee6ceba95464c20f3276 100644 (file)
@@ -8,10 +8,6 @@ help: possible candidate is found in another module, you can import it into scop
    |
 LL | use foo::Foo;
    |
-help: you might be missing a type parameter
-   |
-LL | type Output<Foo> = Option<Foo>;
-   |            ^^^^^
 
 error: aborting due to previous error
 
index 6e07d2dfb7fc87b1c9489de41da4dafa239daf03..390e8f245ef2cd7ac698b8a76abf029f9abcab0d 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 6e07d2dfb7fc87b1c9489de41da4dafa239daf03
+Subproject commit 390e8f245ef2cd7ac698b8a76abf029f9abcab0d
index 7907abea272bbf97812683ce03a1ab9c22f0557b..d342cee78703c46d9df09088f9fb99ba85d021ae 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 7907abea272bbf97812683ce03a1ab9c22f0557b
+Subproject commit d342cee78703c46d9df09088f9fb99ba85d021ae
index 04d34fd0d4a59c15ceb482f840dbd0364c273f7c..26a9cd119978d01d59eea0e73b125f9114505cba 100644 (file)
@@ -21,7 +21,6 @@
 use std::collections::{HashMap, HashSet, VecDeque};
 use std::env;
 use std::ffi::{OsStr, OsString};
-use std::fmt;
 use std::fs::{self, create_dir_all, File, OpenOptions};
 use std::hash::{Hash, Hasher};
 use std::io::prelude::*;
@@ -3156,36 +3155,6 @@ fn check_mir_dump(&self) {
                 }
             }
         }
-
-        if let Some(idx) = test_file_contents.find("// END RUST SOURCE") {
-            let (_, tests_text) = test_file_contents.split_at(idx + "// END_RUST SOURCE".len());
-            let tests_text_str = String::from(tests_text);
-            let mut curr_test: Option<&str> = None;
-            let mut curr_test_contents = vec![ExpectedLine::Elision];
-            for l in tests_text_str.lines() {
-                debug!("line: {:?}", l);
-                if l.starts_with("// START ") {
-                    let (_, t) = l.split_at("// START ".len());
-                    curr_test = Some(t);
-                } else if l.starts_with("// END") {
-                    let (_, t) = l.split_at("// END ".len());
-                    if Some(t) != curr_test {
-                        panic!("mismatched START END test name");
-                    }
-                    self.compare_mir_test_output(curr_test.unwrap(), &curr_test_contents);
-                    curr_test = None;
-                    curr_test_contents.clear();
-                    curr_test_contents.push(ExpectedLine::Elision);
-                } else if l.is_empty() {
-                    // ignore
-                } else if l.starts_with("//") && l.split_at("//".len()).1.trim() == "..." {
-                    curr_test_contents.push(ExpectedLine::Elision)
-                } else if l.starts_with("// ") {
-                    let (_, test_content) = l.split_at("// ".len());
-                    curr_test_contents.push(ExpectedLine::Text(test_content));
-                }
-            }
-        }
     }
 
     fn check_mir_test_timestamp(&self, test_name: &str, output_file: &Path) {
@@ -3203,107 +3172,6 @@ fn check_mir_test_timestamp(&self, test_name: &str, output_file: &Path) {
         }
     }
 
-    fn compare_mir_test_output(&self, test_name: &str, expected_content: &[ExpectedLine<&str>]) {
-        let mut output_file = PathBuf::new();
-        output_file.push(self.get_mir_dump_dir());
-        output_file.push(test_name);
-        debug!("comparing the contents of: {:?}", output_file);
-        debug!("with: {:?}", expected_content);
-        if !output_file.exists() {
-            panic!("Output file `{}` from test does not exist", output_file.display());
-        }
-        self.check_mir_test_timestamp(test_name, &output_file);
-
-        let dumped_string = fs::read_to_string(&output_file).unwrap();
-        let mut dumped_lines =
-            dumped_string.lines().map(|l| nocomment_mir_line(l)).filter(|l| !l.is_empty());
-        let mut expected_lines = expected_content
-            .iter()
-            .filter(|&l| if let &ExpectedLine::Text(l) = l { !l.is_empty() } else { true })
-            .peekable();
-
-        let compare = |expected_line, dumped_line| {
-            let e_norm = normalize_mir_line(expected_line);
-            let d_norm = normalize_mir_line(dumped_line);
-            debug!("found: {:?}", d_norm);
-            debug!("expected: {:?}", e_norm);
-            e_norm == d_norm
-        };
-
-        let error = |expected_line, extra_msg| {
-            let normalize_all = dumped_string
-                .lines()
-                .map(nocomment_mir_line)
-                .filter(|l| !l.is_empty())
-                .collect::<Vec<_>>()
-                .join("\n");
-            let f = |l: &ExpectedLine<_>| match l {
-                &ExpectedLine::Elision => "... (elided)".into(),
-                &ExpectedLine::Text(t) => t,
-            };
-            let expected_content =
-                expected_content.iter().map(|l| f(l)).collect::<Vec<_>>().join("\n");
-            panic!(
-                "Did not find expected line, error: {}\n\
-                 Expected Line: {:?}\n\
-                 Test Name: {}\n\
-                 Expected:\n{}\n\
-                 Actual:\n{}",
-                extra_msg, expected_line, test_name, expected_content, normalize_all
-            );
-        };
-
-        // We expect each non-empty line to appear consecutively, non-consecutive lines
-        // must be separated by at least one Elision
-        let mut start_block_line = None;
-        while let Some(dumped_line) = dumped_lines.next() {
-            match expected_lines.next() {
-                Some(&ExpectedLine::Text(expected_line)) => {
-                    let normalized_expected_line = normalize_mir_line(expected_line);
-                    if normalized_expected_line.contains(":{") {
-                        start_block_line = Some(expected_line);
-                    }
-
-                    if !compare(expected_line, dumped_line) {
-                        error!("{:?}", start_block_line);
-                        error(
-                            expected_line,
-                            format!(
-                                "Mismatch in lines\n\
-                                 Current block: {}\n\
-                                 Actual Line: {:?}",
-                                start_block_line.unwrap_or("None"),
-                                dumped_line
-                            ),
-                        );
-                    }
-                }
-                Some(&ExpectedLine::Elision) => {
-                    // skip any number of elisions in a row.
-                    while let Some(&&ExpectedLine::Elision) = expected_lines.peek() {
-                        expected_lines.next();
-                    }
-                    if let Some(&ExpectedLine::Text(expected_line)) = expected_lines.next() {
-                        let mut found = compare(expected_line, dumped_line);
-                        if found {
-                            continue;
-                        }
-                        while let Some(dumped_line) = dumped_lines.next() {
-                            found = compare(expected_line, dumped_line);
-                            if found {
-                                break;
-                            }
-                        }
-                        if !found {
-                            error(expected_line, "ran out of mir dump to match against".into());
-                        }
-                    }
-                }
-                None => {}
-            }
-        }
-    }
-
     fn get_mir_dump_dir(&self) -> PathBuf {
         let mut mir_dump_dir = PathBuf::from(self.config.build_base.as_path());
         debug!("input_file: {:?}", self.testpaths.file);
@@ -3362,7 +3230,7 @@ fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> S
         // with placeholders as we do not want tests needing updated when compiler source code
         // changes.
         // eg. $SRC_DIR/libcore/mem.rs:323:14 becomes $SRC_DIR/libcore/mem.rs:LL:COL
-        normalized = Regex::new("SRC_DIR(.+):\\d+:\\d+")
+        normalized = Regex::new("SRC_DIR(.+):\\d+:\\d+(: \\d+:\\d+)?")
             .unwrap()
             .replace_all(&normalized, "SRC_DIR$1:LL:COL")
             .into_owned();
@@ -3589,43 +3457,11 @@ enum TargetLocation {
     ThisDirectory(PathBuf),
 }
 
-#[derive(Clone, PartialEq, Eq)]
-enum ExpectedLine<T: AsRef<str>> {
-    Elision,
-    Text(T),
-}
-
 enum AllowUnused {
     Yes,
     No,
 }
 
-impl<T> fmt::Debug for ExpectedLine<T>
-where
-    T: AsRef<str> + fmt::Debug,
-{
-    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
-        if let &ExpectedLine::Text(ref t) = self {
-            write!(formatter, "{:?}", t)
-        } else {
-            write!(formatter, "\"...\" (Elision)")
-        }
-    }
-}
-
-fn normalize_mir_line(line: &str) -> String {
-    nocomment_mir_line(line).replace(char::is_whitespace, "")
-}
-
-fn nocomment_mir_line(line: &str) -> &str {
-    if let Some(idx) = line.find("//") {
-        let (l, _) = line.split_at(idx);
-        l.trim_end()
-    } else {
-        line
-    }
-}
-
 fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
     use crate::read2::read2;
     use std::mem::replace;
index 147ea8f400de3ca529abcb5eb7b65f84a4896ae9..325682ad56d23369059ea93d5a8d44e5782e41cf 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 147ea8f400de3ca529abcb5eb7b65f84a4896ae9
+Subproject commit 325682ad56d23369059ea93d5a8d44e5782e41cf