From 2be0596810bd34e4d50ecda5ad2b71f8370d7e00 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 27 Oct 2020 10:59:09 +0100 Subject: [PATCH 01/39] Use with_no_trimmed_paths Fixes compilation without -Ztrim-diagnostic-paths=no --- src/bin/cg_clif.rs | 3 --- src/bin/cg_clif_build_sysroot.rs | 3 --- src/intrinsics/mod.rs | 13 +++++++------ src/trap.rs | 1 - 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs index 590c9ef0ce191..9a661dcbcc5d6 100644 --- a/src/bin/cg_clif.rs +++ b/src/bin/cg_clif.rs @@ -24,9 +24,6 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks { self.time_passes = config.opts.prints.is_empty() && (config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time); - // FIXME workaround for an ICE - config.opts.debugging_opts.trim_diagnostic_paths = false; - config.opts.cg.panic = Some(PanicStrategy::Abort); config.opts.debugging_opts.panic_abort_tests = true; config.opts.maybe_sysroot = Some( diff --git a/src/bin/cg_clif_build_sysroot.rs b/src/bin/cg_clif_build_sysroot.rs index c207d98d6c197..165d33dcfb509 100644 --- a/src/bin/cg_clif_build_sysroot.rs +++ b/src/bin/cg_clif_build_sysroot.rs @@ -44,9 +44,6 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks { return; } - // FIXME workaround for an ICE - config.opts.debugging_opts.trim_diagnostic_paths = false; - config.opts.cg.panic = Some(PanicStrategy::Abort); config.opts.debugging_opts.panic_abort_tests = true; config.opts.maybe_sysroot = Some( diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 9a3e4c7b56e9c..074fba6b5c33a 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -9,6 +9,7 @@ pub(crate) use cpuid::codegen_cpuid_call; pub(crate) use llvm::codegen_llvm_intrinsic_call; use crate::prelude::*; +use rustc_middle::ty::print::with_no_trimmed_paths; macro intrinsic_pat { (_) => { @@ -819,29 +820,29 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( assert_inhabited | assert_zero_valid | assert_uninit_valid, () { let layout = fx.layout_of(T); if layout.abi.is_uninhabited() { - crate::base::codegen_panic( + with_no_trimmed_paths(|| crate::base::codegen_panic( fx, &format!("attempted to instantiate uninhabited type `{}`", T), span, - ); + )); return; } if intrinsic == "assert_zero_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ true).unwrap() { - crate::base::codegen_panic( + with_no_trimmed_paths(|| crate::base::codegen_panic( fx, &format!("attempted to zero-initialize type `{}`, which is invalid", T), span, - ); + )); return; } if intrinsic == "assert_uninit_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() { - crate::base::codegen_panic( + with_no_trimmed_paths(|| crate::base::codegen_panic( fx, &format!("attempted to leave type `{}` uninitialized, which is invalid", T), span, - ); + )); return; } }; diff --git a/src/trap.rs b/src/trap.rs index 37dca77bdbd09..690d96764a8f5 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -67,4 +67,3 @@ pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg: let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); } - From 4445e465182f13590fb7c938881ee1225175740d Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sat, 19 Sep 2020 17:27:56 +0200 Subject: [PATCH 02/39] Add test where diagnostic span points to just the inlined function's body --- src/test/ui/const_prop/inline_spans.rs | 14 ++++++++++++++ src/test/ui/const_prop/inline_spans.stderr | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/test/ui/const_prop/inline_spans.rs create mode 100644 src/test/ui/const_prop/inline_spans.stderr diff --git a/src/test/ui/const_prop/inline_spans.rs b/src/test/ui/const_prop/inline_spans.rs new file mode 100644 index 0000000000000..b163c1d3c4000 --- /dev/null +++ b/src/test/ui/const_prop/inline_spans.rs @@ -0,0 +1,14 @@ +// build-fail +// compile-flags: -Zmir-opt-level=2 + +#![deny(warnings)] + +fn main() { + let _ = add(u8::MAX, 1); +} + +#[inline(always)] +fn add(x: u8, y: u8) -> u8 { + x + y + //~^ ERROR this arithmetic operation will overflow +} diff --git a/src/test/ui/const_prop/inline_spans.stderr b/src/test/ui/const_prop/inline_spans.stderr new file mode 100644 index 0000000000000..c85c9d3843bb3 --- /dev/null +++ b/src/test/ui/const_prop/inline_spans.stderr @@ -0,0 +1,10 @@ +error: this arithmetic operation will overflow + --> $DIR/inline_spans.rs:12:5 + | +LL | x + y + | ^^^^^ attempt to compute `u8::MAX + 1_u8` which would overflow + | + = note: `#[deny(arithmetic_overflow)]` on by default + +error: aborting due to previous error + From c8a866ea176f1d7250a714647a6ce7a4636f5705 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sat, 19 Sep 2020 18:56:32 +0200 Subject: [PATCH 03/39] Show the inline stack of MIR lints that only occur after inlining --- compiler/rustc_errors/src/emitter.rs | 6 +- compiler/rustc_middle/src/lint.rs | 4 +- compiler/rustc_mir/src/transform/inline.rs | 13 ++ compiler/rustc_save_analysis/src/lib.rs | 4 +- compiler/rustc_span/src/hygiene.rs | 3 + .../cycle.main.DestinationPropagation.diff | 4 +- .../union.main.DestinationPropagation.diff | 4 +- ...anup.main-{closure#0}.generator_drop.0.mir | 4 +- .../inline_any_operand.bar.Inline.after.mir | 22 ++-- .../inline_closure.foo.Inline.after.mir | 6 +- ...e_closure_borrows_arg.foo.Inline.after.mir | 16 +-- ...line_closure_captures.foo.Inline.after.mir | 18 +-- ...patibility.inlined_no_sanitize.Inline.diff | 2 +- ...ibility.inlined_target_feature.Inline.diff | 2 +- ...line_into_box_place.main.Inline.32bit.diff | 6 +- ...line_into_box_place.main.Inline.64bit.diff | 6 +- .../inline/inline_retag.bar.Inline.after.mir | 26 ++-- .../inline_specialization.main.Inline.diff | 2 +- ...line_trait_method_2.test2.Inline.after.mir | 14 +- ...67_inline_as_ref_as_mut.a.Inline.after.mir | 12 +- ...67_inline_as_ref_as_mut.b.Inline.after.mir | 20 +-- ...67_inline_as_ref_as_mut.c.Inline.after.mir | 4 +- ...67_inline_as_ref_as_mut.d.Inline.after.mir | 4 +- ...ine_scopes_parenting.main.Inline.after.mir | 14 +- .../issue_73223.main.PreCodegen.32bit.diff | 70 +++++----- .../issue_73223.main.PreCodegen.64bit.diff | 70 +++++----- ..._73223.main.SimplifyArmIdentity.32bit.diff | 122 +++++++++--------- ..._73223.main.SimplifyArmIdentity.64bit.diff | 122 +++++++++--------- ...annot_opt_generic.RemoveUnneededDrops.diff | 6 +- ...ed_drops.dont_opt.RemoveUnneededDrops.diff | 6 +- ...nneeded_drops.opt.RemoveUnneededDrops.diff | 6 +- ....opt_generic_copy.RemoveUnneededDrops.diff | 6 +- ...mplify_arm.id_try.SimplifyArmIdentity.diff | 28 ++-- ...implify_arm.id_try.SimplifyBranchSame.diff | 12 +- ...y.try_identity.DestinationPropagation.diff | 14 +- ..._try.try_identity.SimplifyArmIdentity.diff | 28 ++-- ....try_identity.SimplifyBranchSame.after.mir | 10 +- ..._try.try_identity.SimplifyLocals.after.mir | 6 +- src/test/ui/const_prop/inline_spans.rs | 2 +- src/test/ui/const_prop/inline_spans.stderr | 7 +- 40 files changed, 378 insertions(+), 353 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index b5155f8e910d7..1922dbef64d67 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -296,7 +296,7 @@ pub trait Emitter { // Skip past non-macro entries, just in case there // are some which do actually involve macros. - ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None, + ExpnKind::Inlined | ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None, ExpnKind::Macro(macro_kind, _) => Some(macro_kind), } @@ -356,7 +356,9 @@ pub trait Emitter { continue; } - if always_backtrace { + if matches!(trace.kind, ExpnKind::Inlined) { + new_labels.push((trace.call_site, "in the inlined copy of this".to_string())); + } else if always_backtrace { new_labels.push(( trace.def_site, format!( diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 91e1d6e0b0b72..8430d162aeca4 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -358,7 +358,9 @@ pub fn struct_lint_level<'s, 'd>( pub fn in_external_macro(sess: &Session, span: Span) -> bool { let expn_data = span.ctxt().outer_expn_data(); match expn_data.kind { - ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop(_)) => false, + ExpnKind::Inlined | ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop(_)) => { + false + } ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external" ExpnKind::Macro(MacroKind::Bang, _) => { // Dummy span for the `def_site` means it's an external macro. diff --git a/compiler/rustc_mir/src/transform/inline.rs b/compiler/rustc_mir/src/transform/inline.rs index 944f41c61a2b5..ee1e99935828c 100644 --- a/compiler/rustc_mir/src/transform/inline.rs +++ b/compiler/rustc_mir/src/transform/inline.rs @@ -8,6 +8,7 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::subst::Subst; use rustc_middle::ty::{self, ConstKind, Instance, InstanceDef, ParamEnv, Ty, TyCtxt}; +use rustc_span::{hygiene::ExpnKind, ExpnData, Span}; use rustc_target::spec::abi::Abi; use super::simplify::{remove_dead_blocks, CfgSimplifier}; @@ -488,6 +489,8 @@ impl Inliner<'tcx> { cleanup_block: cleanup, in_cleanup_block: false, tcx: self.tcx, + callsite_span: callsite.source_info.span, + body_span: callee_body.span, }; // Map all `Local`s, `SourceScope`s and `BasicBlock`s to new ones @@ -699,6 +702,8 @@ struct Integrator<'a, 'tcx> { cleanup_block: Option, in_cleanup_block: bool, tcx: TyCtxt<'tcx>, + callsite_span: Span, + body_span: Span, } impl<'a, 'tcx> Integrator<'a, 'tcx> { @@ -743,6 +748,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { *scope = self.map_scope(*scope); } + fn visit_span(&mut self, span: &mut Span) { + // Make sure that all spans track the fact that they were inlined. + *span = self.callsite_span.fresh_expansion(ExpnData { + def_site: self.body_span, + ..ExpnData::default(ExpnKind::Inlined, *span, self.tcx.sess.edition(), None) + }); + } + fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, location: Location) { // If this is the `RETURN_PLACE`, we need to rebase any projections onto it. let dest_proj_len = self.destination.projection.len(); diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index 48d15370ee320..eed9f2eb74d4f 100644 --- a/compiler/rustc_save_analysis/src/lib.rs +++ b/compiler/rustc_save_analysis/src/lib.rs @@ -799,7 +799,9 @@ impl<'tcx> SaveContext<'tcx> { // These are not macros. // FIXME(eddyb) maybe there is a way to handle them usefully? - ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => return None, + ExpnKind::Inlined | ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => { + return None; + } }; let callee_span = self.span_from_span(callee.def_site); diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 31f3d8e379109..0f82db1d05aa1 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -766,6 +766,8 @@ pub enum ExpnKind { AstPass(AstPass), /// Desugaring done by the compiler during HIR lowering. Desugaring(DesugaringKind), + /// MIR inlining + Inlined, } impl ExpnKind { @@ -779,6 +781,7 @@ impl ExpnKind { }, ExpnKind::AstPass(kind) => kind.descr().to_string(), ExpnKind::Desugaring(kind) => format!("desugaring of {}", kind.descr()), + ExpnKind::Inlined => "inlined source".to_string(), } } } diff --git a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff index bba10f09c3fbb..1fbda50f783e1 100644 --- a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff @@ -19,7 +19,7 @@ - debug z => _3; // in scope 3 at $DIR/cycle.rs:11:9: 11:10 + debug z => _4; // in scope 3 at $DIR/cycle.rs:11:9: 11:10 scope 4 (inlined std::mem::drop::) { // at $DIR/cycle.rs:14:5: 14:12 - debug _x => _6; // in scope 4 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _6; // in scope 4 at $DIR/cycle.rs:14:5: 14:12 } } } @@ -56,7 +56,7 @@ StorageLive(_6); // scope 3 at $DIR/cycle.rs:14:10: 14:11 - _6 = _1; // scope 3 at $DIR/cycle.rs:14:10: 14:11 + _6 = _4; // scope 3 at $DIR/cycle.rs:14:10: 14:11 - _5 = const (); // scope 4 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _5 = const (); // scope 4 at $DIR/cycle.rs:14:5: 14:12 StorageDead(_6); // scope 3 at $DIR/cycle.rs:14:11: 14:12 StorageDead(_5); // scope 3 at $DIR/cycle.rs:14:12: 14:13 _0 = const (); // scope 0 at $DIR/cycle.rs:8:11: 15:2 diff --git a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff index 0028e280516da..0ff3e4b2dcf7d 100644 --- a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff @@ -12,7 +12,7 @@ scope 2 { } scope 3 (inlined std::mem::drop::) { // at $DIR/union.rs:15:5: 15:27 - debug _x => _4; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _4; // in scope 3 at $DIR/union.rs:15:5: 15:27 } } @@ -31,7 +31,7 @@ StorageLive(_3); // scope 1 at $DIR/union.rs:15:5: 15:27 StorageLive(_4); // scope 1 at $DIR/union.rs:15:10: 15:26 _4 = (_1.0: u32); // scope 2 at $DIR/union.rs:15:19: 15:24 - _3 = const (); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _3 = const (); // scope 3 at $DIR/union.rs:15:5: 15:27 StorageDead(_4); // scope 1 at $DIR/union.rs:15:26: 15:27 StorageDead(_3); // scope 1 at $DIR/union.rs:15:27: 15:28 _0 = const (); // scope 0 at $DIR/union.rs:8:11: 16:2 diff --git a/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir b/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir index 164e769e93b02..6da0460286b9a 100644 --- a/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir +++ b/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir @@ -27,8 +27,8 @@ fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 1 debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:11:13: 11:15 } scope 2 (inlined String::new) { // at $DIR/generator-drop-cleanup.rs:11:18: 11:31 - let mut _6: std::vec::Vec; // in scope 2 at $SRC_DIR/alloc/src/string.rs:LL:COL - scope 3 (inlined Vec::::new) { // at $SRC_DIR/alloc/src/string.rs:LL:COL + let mut _6: std::vec::Vec; // in scope 2 at $DIR/generator-drop-cleanup.rs:11:18: 11:31 + scope 3 (inlined Vec::::new) { // at $DIR/generator-drop-cleanup.rs:11:18: 11:31 } } diff --git a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir index b2745a17e9717..815d02c73d1e2 100644 --- a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir @@ -9,10 +9,10 @@ fn bar() -> bool { scope 1 { debug f => _1; // in scope 1 at $DIR/inline-any-operand.rs:11:9: 11:10 scope 2 (inlined foo) { // at $DIR/inline-any-operand.rs:12:5: 12:13 - 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 - let mut _5: i32; // in scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6 - let mut _6: i32; // in scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 + debug x => _3; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + debug y => _4; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + let mut _5: i32; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + let mut _6: i32; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 } } @@ -28,13 +28,13 @@ fn bar() -> bool { _3 = const 1_i32; // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageLive(_4); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 _4 = const -1_i32; // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 - StorageLive(_5); // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6 - _5 = _3; // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6 - StorageLive(_6); // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 - _6 = _4; // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 - _0 = Eq(move _5, move _6); // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:11 - StorageDead(_6); // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 - StorageDead(_5); // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 + StorageLive(_5); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + _5 = _3; // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + StorageLive(_6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + _6 = _4; // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + _0 = Eq(move _5, move _6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + StorageDead(_6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + StorageDead(_5); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_4); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_3); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_2); // scope 1 at $DIR/inline-any-operand.rs:12:12: 12:13 diff --git a/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir index 93a63c8478391..d312369d2af75 100644 --- a/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir @@ -14,8 +14,8 @@ fn foo(_1: T, _2: i32) -> i32 { scope 1 { debug x => _3; // in scope 1 at $DIR/inline-closure.rs:11:9: 11:10 scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure.rs:12:5: 12:12 - 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 + debug _t => _8; // in scope 2 at $DIR/inline-closure.rs:12:5: 12:12 + debug _q => _9; // in scope 2 at $DIR/inline-closure.rs:12:5: 12:12 } } @@ -34,7 +34,7 @@ fn foo(_1: T, _2: i32) -> i32 { _8 = move (_5.0: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 StorageLive(_9); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 _9 = move (_5.1: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 - _0 = _8; // scope 2 at $DIR/inline-closure.rs:11:22: 11:24 + _0 = _8; // scope 2 at $DIR/inline-closure.rs:12:5: 12:12 StorageDead(_9); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 StorageDead(_8); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 StorageDead(_7); // scope 1 at $DIR/inline-closure.rs:12:11: 12:12 diff --git a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index c6893022be60a..db504b416fe1d 100644 --- a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -14,11 +14,11 @@ fn foo(_1: T, _2: &i32) -> i32 { scope 1 { debug x => _3; // in scope 1 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 - 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 - let _10: &i32; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 + debug r => _8; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + debug _s => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + let _10: &i32; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 scope 3 { - debug variable => _10; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 + debug variable => _10; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 } } } @@ -38,10 +38,10 @@ fn foo(_1: T, _2: &i32) -> i32 { _8 = move (_5.0: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageLive(_9); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 _9 = move (_5.1: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 - StorageLive(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 - _10 = _8; // scope 2 at $DIR/inline-closure-borrows-arg.rs:13:24: 13:27 - _0 = (*_8); // scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18 - StorageDead(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:15:5: 15:6 + StorageLive(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _10 = _8; // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _0 = (*_8); // scope 3 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + StorageDead(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_9); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_8); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 diff --git a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index 2950af63d3c60..a861eab39d337 100644 --- a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -14,10 +14,10 @@ fn foo(_1: T, _2: i32) -> (i32, T) { scope 1 { debug x => _3; // in scope 1 at $DIR/inline-closure-captures.rs:11:9: 11:10 scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure-captures.rs:12:5: 12:9 - debug _q => _9; // 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 _10: T; // in scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 + debug _q => _9; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + debug t => (*((*_6).1: &T)); // 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 } } @@ -39,11 +39,11 @@ fn foo(_1: T, _2: i32) -> (i32, T) { (_7.0: i32) = move _8; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageLive(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 _9 = move (_7.0: i32); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 - (_0.0: i32) = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 - StorageLive(_10); // scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 - _10 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 - (_0.1: T) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24 - StorageDead(_10); // scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24 + (_0.0: i32) = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + _10 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + (_0.1: T) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageDead(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_8); // scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 StorageDead(_7); // scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 diff --git a/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff index 2fc908b51f39a..451ec39422fc4 100644 --- a/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff @@ -16,7 +16,7 @@ - } - - bb1: { -+ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:39:29: 39:31 ++ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:25:5: 25:18 StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:25:18: 25:19 _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:24:37: 26:2 return; // scope 0 at $DIR/inline-compatibility.rs:26:2: 26:2 diff --git a/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff index c92594d08de2b..a59ddd344cb26 100644 --- a/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff @@ -16,7 +16,7 @@ - } - - bb1: { -+ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:35:32: 35:34 ++ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:14:5: 14:21 StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:14:21: 14:22 _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:13:40: 15:2 return; // scope 0 at $DIR/inline-compatibility.rs:15:2: 15:2 diff --git a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff index 49fe14babc50f..0fbafd76e209b 100644 --- a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff +++ b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff @@ -19,7 +19,7 @@ _2 = Box(std::vec::Vec); // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 - (*_2) = Vec::::new() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + _4 = &mut (*_2); // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 -+ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: Unique:: { pointer: {0x4 as *const u32}, _marker: PhantomData:: }, cap: 0_usize, alloc: std::alloc::Global }; // scope 2 at $SRC_DIR/alloc/src/vec.rs:LL:COL ++ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: Unique:: { pointer: {0x4 as *const u32}, _marker: PhantomData:: }, cap: 0_usize, alloc: std::alloc::Global }; // scope 2 at $DIR/inline-into-box-place.rs:8:33: 8:43 + // ty::Const + // + ty: alloc::raw_vec::RawVec + // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) @@ -30,10 +30,10 @@ - } - - bb1: { -+ // + span: $SRC_DIR/alloc/src/vec.rs:LL:COL ++ // + span: $DIR/inline-into-box-place.rs:8:33: 8:43 + // + user_ty: UserType(0) + // + literal: Const { ty: alloc::raw_vec::RawVec, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } -+ ((*_4).1: usize) = const 0_usize; // scope 2 at $SRC_DIR/alloc/src/vec.rs:LL:COL ++ ((*_4).1: usize) = const 0_usize; // scope 2 at $DIR/inline-into-box-place.rs:8:33: 8:43 _1 = move _2; // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 StorageDead(_2); // scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 _0 = const (); // scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 diff --git a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff index bb8ebc30cdd88..9277e57134eca 100644 --- a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff +++ b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff @@ -19,7 +19,7 @@ _2 = Box(std::vec::Vec); // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 - (*_2) = Vec::::new() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + _4 = &mut (*_2); // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 -+ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: Unique:: { pointer: {0x4 as *const u32}, _marker: PhantomData:: }, cap: 0_usize, alloc: std::alloc::Global }; // scope 2 at $SRC_DIR/alloc/src/vec.rs:LL:COL ++ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: Unique:: { pointer: {0x4 as *const u32}, _marker: PhantomData:: }, cap: 0_usize, alloc: std::alloc::Global }; // scope 2 at $DIR/inline-into-box-place.rs:8:33: 8:43 + // ty::Const + // + ty: alloc::raw_vec::RawVec + // + 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: [] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) @@ -30,10 +30,10 @@ - } - - bb1: { -+ // + span: $SRC_DIR/alloc/src/vec.rs:LL:COL ++ // + span: $DIR/inline-into-box-place.rs:8:33: 8:43 + // + user_ty: UserType(0) + // + literal: Const { ty: alloc::raw_vec::RawVec, 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: [] }), init_mask: InitMask { 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 0_usize; // scope 2 at $SRC_DIR/alloc/src/vec.rs:LL:COL ++ ((*_4).1: usize) = const 0_usize; // scope 2 at $DIR/inline-into-box-place.rs:8:33: 8:43 _1 = move _2; // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 StorageDead(_2); // scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 _0 = const (); // scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 diff --git a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir index 0cace4e32c405..b9fe84fcd0443 100644 --- a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir @@ -15,10 +15,10 @@ fn bar() -> bool { 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 (inlined foo) { // at $DIR/inline-retag.rs:12:5: 12:15 - 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:17:5: 17:7 - let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:17:11: 17:13 + debug x => _3; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + debug y => _6; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + 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 } } @@ -58,15 +58,15 @@ fn bar() -> bool { Retag(_7); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 _6 = &(*_7); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 Retag(_6); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 - Retag(_3); // scope 2 at $DIR/inline-retag.rs:16:1: 18:2 - Retag(_6); // scope 2 at $DIR/inline-retag.rs:16:1: 18:2 - StorageLive(_11); // scope 2 at $DIR/inline-retag.rs:17:5: 17:7 - _11 = (*_3); // scope 2 at $DIR/inline-retag.rs:17:5: 17:7 - StorageLive(_12); // scope 2 at $DIR/inline-retag.rs:17:11: 17:13 - _12 = (*_6); // scope 2 at $DIR/inline-retag.rs:17:11: 17:13 - _0 = Eq(move _11, move _12); // scope 2 at $DIR/inline-retag.rs:17:5: 17:13 - StorageDead(_12); // scope 2 at $DIR/inline-retag.rs:17:12: 17:13 - StorageDead(_11); // scope 2 at $DIR/inline-retag.rs:17:12: 17:13 + Retag(_3); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + Retag(_6); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + StorageLive(_11); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + _11 = (*_3); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + StorageLive(_12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + _12 = (*_6); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + _0 = Eq(move _11, move _12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + StorageDead(_12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + StorageDead(_11); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 StorageDead(_6); // scope 1 at $DIR/inline-retag.rs:12:14: 12:15 StorageDead(_3); // scope 1 at $DIR/inline-retag.rs:12:14: 12:15 StorageDead(_2); // scope 1 at $DIR/inline-retag.rs:12:14: 12:15 diff --git a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff index 96442842bd598..2a9ce446e307c 100644 --- a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff @@ -19,7 +19,7 @@ - } - - bb1: { -+ _1 = const 123_u32; // scope 2 at $DIR/inline-specialization.rs:14:31: 14:34 ++ _1 = const 123_u32; // scope 2 at $DIR/inline-specialization.rs:5:13: 5:38 _0 = const (); // scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 StorageDead(_1); // scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 return; // scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 diff --git a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir index 907a56d6a0e42..01be1f3907ca2 100644 --- a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir @@ -6,8 +6,8 @@ fn test2(_1: &dyn X) -> bool { 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 (inlined test) { // at $DIR/inline-trait-method_2.rs:5:5: 5:12 - debug x => _2; // in scope 1 at $DIR/inline-trait-method_2.rs:9:9: 9:10 - let mut _4: &dyn X; // in scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:6 + debug x => _2; // in scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 + let mut _4: &dyn X; // in scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 } bb0: { @@ -16,16 +16,16 @@ fn test2(_1: &dyn X) -> bool { _3 = &(*_1); // scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 _2 = move _3 as &dyn X (Pointer(Unsize)); // scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 StorageDead(_3); // scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 - StorageLive(_4); // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:6 - _4 = _2; // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:6 - _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 + StorageLive(_4); // scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 + _4 = _2; // scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 + _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 // mir::Constant - // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8 + // + span: $DIR/inline-trait-method_2.rs:5:5: 5:12 // + literal: Const { ty: for<'r> fn(&'r dyn X) -> bool {::y}, val: Value(Scalar()) } } bb1: { - StorageDead(_4); // scope 1 at $DIR/inline-trait-method_2.rs:10:9: 10:10 + StorageDead(_4); // scope 1 at $DIR/inline-trait-method_2.rs:5:5: 5:12 StorageDead(_2); // scope 0 at $DIR/inline-trait-method_2.rs:5:11: 5:12 return; // scope 0 at $DIR/inline-trait-method_2.rs:6:2: 6:2 } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir index 08f0dac2e9d05..651855f802454 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir @@ -7,8 +7,8 @@ fn a(_1: &mut [T]) -> &mut [T] { let mut _3: &mut [T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 let mut _4: &mut [T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:6 scope 1 (inlined <[T] as AsMut<[T]>>::as_mut) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 - debug self => _4; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - let mut _5: &mut [T]; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug self => _4; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 + let mut _5: &mut [T]; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 } bb0: { @@ -16,10 +16,10 @@ fn a(_1: &mut [T]) -> &mut [T] { StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 StorageLive(_4); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:6 _4 = &mut (*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:6 - StorageLive(_5); // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - _5 = &mut (*_4); // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - _3 = &mut (*_5); // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_5); // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + StorageLive(_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 + _5 = &mut (*_4); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 + _3 = &mut (*_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 + StorageDead(_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 _2 = &mut (*_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 StorageDead(_4); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:14: 3:15 _0 = &mut (*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:3:5: 3:15 diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir index af97434f62929..c67ea7e00b760 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -7,9 +7,9 @@ fn b(_1: &mut Box) -> &mut T { let mut _3: &mut T; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 let mut _4: &mut std::boxed::Box; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:6 scope 1 (inlined as AsMut>::as_mut) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 - debug self => _4; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _5: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _6: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + debug self => _4; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + let mut _5: &mut T; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + let mut _6: &mut T; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 } bb0: { @@ -17,13 +17,13 @@ fn b(_1: &mut Box) -> &mut T { StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 StorageLive(_4); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:6 _4 = &mut (*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:6 - StorageLive(_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - StorageLive(_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _6 = &mut (*(*_4)); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _5 = &mut (*_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _3 = &mut (*_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - StorageDead(_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - StorageDead(_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + StorageLive(_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + StorageLive(_6); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + _6 = &mut (*(*_4)); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + _5 = &mut (*_6); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + _3 = &mut (*_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + StorageDead(_6); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 + StorageDead(_5); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 _2 = &mut (*_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 StorageDead(_4); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:14: 8:15 _0 = &mut (*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:8:5: 8:15 diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir index 670f055dc054b..16fae453ac936 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir @@ -6,14 +6,14 @@ fn c(_1: &[T]) -> &[T] { let _2: &[T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 let mut _3: &[T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:6 scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 - debug self => _3; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug self => _3; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 } bb0: { StorageLive(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:6 _3 = &(*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:6 - _2 = _3; // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + _2 = _3; // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 _0 = &(*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 StorageDead(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:14: 13:15 StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:14:1: 14:2 diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir index c33e859eb6b0c..e9ca7095a43ab 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir @@ -6,14 +6,14 @@ fn d(_1: &Box) -> &T { let _2: &T; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 let mut _3: &std::boxed::Box; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:6 scope 1 (inlined as AsRef>::as_ref) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 - debug self => _3; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + debug self => _3; // in scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 } bb0: { StorageLive(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:6 _3 = &(*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:6 - _2 = &(*(*_3)); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _2 = &(*(*_3)); // scope 1 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 _0 = &(*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 StorageDead(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:14: 18:15 StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:19:1: 19:2 diff --git a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index df5355e905eb0..3d386e3b1756b 100644 --- a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -10,10 +10,10 @@ fn main() -> () { scope 1 { debug f => _1; // in scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:5:9: 5:10 scope 2 (inlined main::{closure#0}) { // at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 - debug x => _5; // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:14: 5:15 - let _6: (); // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:23: 5:24 + debug x => _5; // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 + let _6: (); // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 scope 3 { - debug y => _6; // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:5:23: 5:24 + debug y => _6; // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 } } } @@ -27,10 +27,10 @@ fn main() -> () { (_3.0: ()) = move _4; // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageLive(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 _5 = move (_3.0: ()); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 - StorageLive(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:23: 5:24 - _6 = const (); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:27: 5:28 - _0 = const (); // scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:5:30: 5:31 - StorageDead(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:5:32: 5:33 + StorageLive(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 + _6 = const (); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 + _0 = const (); // scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 + StorageDead(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageDead(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageDead(_4); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:9: 6:10 StorageDead(_3); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:9: 6:10 diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff index 23aefe07892fd..f9f30ccb20e25 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -36,30 +36,30 @@ debug arg0 => _25; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug arg1 => _28; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _25; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _25: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _25; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _24; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _25: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL scope 7 { } } scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _28; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _28: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _28; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _27; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _28: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL scope 9 { } } } scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _31; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _29: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug pieces => _29; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + debug args => _31; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _29: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -139,53 +139,53 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_23); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb3: { - (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb4: { - (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_23); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_26); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb5: { - (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb6: { - (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_26); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL _16 = [move _21, move _22]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL _15 = &_16; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _31 = move _15 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_30) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_30); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + discriminant(_30) = 0; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_30); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL _12 = &_13; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL begin_panic_fmt(move _12); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index 23aefe07892fd..f9f30ccb20e25 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -36,30 +36,30 @@ debug arg0 => _25; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug arg1 => _28; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _25; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _25: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _25; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _24; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _23: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _24: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _25: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL scope 7 { } } scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _28; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _28: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _28; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _27; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _26: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _28: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL scope 9 { } } } scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _31; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _29: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug pieces => _29; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + debug args => _31; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _29: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -139,53 +139,53 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_23); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb3: { - (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb4: { - (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_23); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_26); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb5: { - (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb6: { - (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_26); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL _16 = [move _21, move _22]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL _15 = &_16; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _31 = move _15 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_30) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_30); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + discriminant(_30) = 0; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_30); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL _12 = &_13; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL begin_panic_fmt(move _12); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff index b9cb58e14c45d..a9425224ce475 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff @@ -59,32 +59,32 @@ debug arg0 => _36; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug arg1 => _37; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _39; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _40; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _49: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _39; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _40; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _49: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL scope 7 { } } scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _42; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _43; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _53: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _42; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _43; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _53: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL scope 9 { } } } scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _23; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _27; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _54: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug pieces => _23; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + debug args => _27; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _54: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -217,32 +217,32 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_47); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _47 = _40; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb5: { - StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_47); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_48); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_49); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _49 = _39; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb6: { - StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_49); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_48); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_46); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_40); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_39); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -253,32 +253,32 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_50); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _51 = _43; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb7: { - StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_52); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_53); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _53 = _42; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb8: { - StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_53); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_52); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_50); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_43); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_42); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -290,18 +290,18 @@ _28 = _29; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_28); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _54 = _23; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_55) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _56 = _27; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_54); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + _54 = _23; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_55); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + discriminant(_55) = 0; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_56); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + _56 = _27; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_56); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_55); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_54); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_27); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_23); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _21 = &_22; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index b9cb58e14c45d..a9425224ce475 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -59,32 +59,32 @@ debug arg0 => _36; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug arg1 => _37; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _39; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _40; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _49: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _39; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _40; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _46: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _47: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _49: &&i32; // in scope 6 at $SRC_DIR/std/src/macros.rs:LL:COL scope 7 { } } scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _42; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _43; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _53: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug x => _42; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + debug f => _43; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _50: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _51: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _53: &&i32; // in scope 8 at $SRC_DIR/std/src/macros.rs:LL:COL scope 9 { } } } scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _23; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _27; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _54: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug pieces => _23; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + debug args => _27; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _54: &[&str]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL } } } @@ -217,32 +217,32 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_47); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _47 = _40; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb5: { - StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_47); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_48); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_49); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _49 = _39; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb6: { - StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_49); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_48); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_46); // scope 7 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_40); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_39); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -253,32 +253,32 @@ // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } - StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_50); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _51 = _43; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } bb7: { - StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_52); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_53); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _53 = _42; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL + // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } } bb8: { - StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_53); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_52); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_50); // scope 9 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_43); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_42); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL @@ -290,18 +290,18 @@ _28 = _29; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_28); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _54 = _23; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_55) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _56 = _27; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_54); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + _54 = _23; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_55); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + discriminant(_55) = 0; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_56); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + _56 = _27; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_56); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_55); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_54); // scope 10 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_27); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_23); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _21 = &_22; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff index d84012295e4d3..e55ee287ba34f 100644 --- a/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff @@ -7,15 +7,15 @@ let _2: (); // in scope 0 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 let mut _3: T; // in scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11 scope 1 (inlined std::mem::drop::) { // at $DIR/remove_unneeded_drops.rs:21:5: 21:12 - debug _x => _3; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 } bb0: { StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11 - _2 = const (); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _2 = const (); // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 + drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 } bb1 (cleanup): { diff --git a/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff index b0b1e80e864c4..e5ad8f1ac75a9 100644 --- a/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff @@ -7,15 +7,15 @@ let _2: (); // in scope 0 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 let mut _3: std::vec::Vec; // in scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11 scope 1 (inlined std::mem::drop::>) { // at $DIR/remove_unneeded_drops.rs:9:5: 9:12 - debug _x => _3; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 } bb0: { StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11 - _2 = const (); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _2 = const (); // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 + drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 } bb1 (cleanup): { diff --git a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff index 0984829435b66..bddf0e2103920 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff @@ -7,15 +7,15 @@ let _2: (); // in scope 0 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 let mut _3: bool; // in scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11 scope 1 (inlined std::mem::drop::) { // at $DIR/remove_unneeded_drops.rs:4:5: 4:12 - debug _x => _3; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 } bb0: { StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11 - _2 = const (); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL -- drop(_3) -> bb1; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _2 = const (); // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 +- drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 - } - - bb1: { diff --git a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff index 0b0ce968af076..87fb8a295c6b0 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff @@ -7,15 +7,15 @@ let _2: (); // in scope 0 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 let mut _3: T; // in scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11 scope 1 (inlined std::mem::drop::) { // at $DIR/remove_unneeded_drops.rs:14:5: 14:12 - debug _x => _3; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 } bb0: { StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11 - _2 = const (); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL -- drop(_3) -> bb1; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _2 = const (); // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 +- drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 - } - - bb1: { diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff index 9a9395c3c8891..84d8214122ae1 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff @@ -23,13 +23,13 @@ + debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:24:14: 24:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify-arm.rs:24:14: 24:15 -- debug t => _9; // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL +- debug t => _9; // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 ++ debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15 -- debug v => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- debug v => _8; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 ++ debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 + let mut _12: i32; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 } } } @@ -40,7 +40,7 @@ } } scope 6 (inlined as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15 - debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _4; // in scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 } bb0: { @@ -48,7 +48,7 @@ StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14 _4 = _1; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14 - _3 = move _4; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = move _4; // scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 @@ -80,16 +80,16 @@ - StorageLive(_8); // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 - StorageLive(_9); // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 - _9 = _6; // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 -- _8 = move _9; // scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL +- _8 = move _9; // scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 - StorageDead(_9); // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 -- StorageLive(_12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- _12 = move _8; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- ((_0 as Err).0: i32) = move _12; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- discriminant(_0) = 1; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- StorageDead(_12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- StorageLive(_12); // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 +- _12 = move _8; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 +- ((_0 as Err).0: i32) = move _12; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 +- discriminant(_0) = 1; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 +- StorageDead(_12); // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 - StorageDead(_8); // scope 3 at $DIR/simplify-arm.rs:24:14: 24:15 - StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 -+ _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ _0 = move _3; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16 StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff index ed96a22f8e3d0..aa050655cdaa5 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff @@ -21,11 +21,11 @@ debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:24:14: 24:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify-arm.rs:24:14: 24:15 - debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15 - debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 + let mut _12: i32; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 } } } @@ -35,7 +35,7 @@ } } scope 6 (inlined as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15 - debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _4; // in scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 } bb0: { @@ -43,7 +43,7 @@ StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14 _4 = _1; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14 - _3 = move _4; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = move _4; // scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 @@ -63,7 +63,7 @@ - } - - bb3: { -- _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- _0 = move _3; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 diff --git a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff index 38da3a8a9e8d3..3ba0af991f63b 100644 --- a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff +++ b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff @@ -21,11 +21,11 @@ debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:8:14: 8:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 - debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } @@ -35,8 +35,8 @@ } } scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 -- debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL -+ debug self => _0; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL +- debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 ++ debug self => _0; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } bb0: { @@ -44,13 +44,13 @@ - StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:8:13: 8:15 - StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 - _4 = _1; // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 -- _3 = move _4; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL +- _3 = move _4; // scope 6 at $DIR/simplify_try.rs:8:13: 8:15 - StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 - _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 + nop; // scope 0 at $DIR/simplify_try.rs:8:13: 8:15 + nop; // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 + _0 = _1; // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 -+ nop; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ nop; // scope 6 at $DIR/simplify_try.rs:8:13: 8:15 + nop; // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 + _5 = discriminant(_0); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 goto -> bb1; // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff index 29b338b339b26..9c91762eb4e15 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff @@ -23,13 +23,13 @@ + debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:8:14: 8:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 -- debug t => _9; // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL +- debug t => _9; // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 ++ debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 -- debug v => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- debug v => _8; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 ++ debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } @@ -40,7 +40,7 @@ } } scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } bb0: { @@ -48,7 +48,7 @@ StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:8:13: 8:15 StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 _4 = _1; // scope 0 at $DIR/simplify_try.rs:8:13: 8:14 - _3 = move _4; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = move _4; // scope 6 at $DIR/simplify_try.rs:8:13: 8:15 StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 @@ -76,16 +76,16 @@ - StorageLive(_8); // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 - StorageLive(_9); // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 - _9 = _6; // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 -- _8 = move _9; // scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL +- _8 = move _9; // scope 7 at $DIR/simplify_try.rs:8:14: 8:15 - StorageDead(_9); // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 -- StorageLive(_12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- _12 = move _8; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- ((_0 as Err).0: i32) = move _12; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- discriminant(_0) = 1; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -- StorageDead(_12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL +- StorageLive(_12); // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 +- _12 = move _8; // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 +- ((_0 as Err).0: i32) = move _12; // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 +- discriminant(_0) = 1; // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 +- StorageDead(_12); // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 - StorageDead(_8); // scope 3 at $DIR/simplify_try.rs:8:14: 8:15 - StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 -+ _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ _0 = move _3; // scope 8 at $DIR/simplify_try.rs:8:13: 8:15 StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:8:15: 8:16 StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:10:1: 10:2 return; // scope 0 at $DIR/simplify_try.rs:10:2: 10:2 diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir index e3527b99576fd..cd8436a971ee8 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir @@ -20,11 +20,11 @@ fn try_identity(_1: std::result::Result) -> std::result::Result ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:8:14: 8:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 - debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } @@ -34,7 +34,7 @@ fn try_identity(_1: std::result::Result) -> std::result::Result as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } bb0: { @@ -42,7 +42,7 @@ fn try_identity(_1: std::result::Result) -> std::result::Result bb1; // scope 0 at $DIR/simplify_try.rs:8:14: 8:15 diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir index 51029c3021a8b..73f77f35a2b92 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir @@ -10,10 +10,10 @@ fn try_identity(_1: std::result::Result) -> std::result::Result ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:8:14: 8:15 scope 3 { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 - debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } @@ -23,7 +23,7 @@ fn try_identity(_1: std::result::Result) -> std::result::Result as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug self => _0; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _0; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } bb0: { diff --git a/src/test/ui/const_prop/inline_spans.rs b/src/test/ui/const_prop/inline_spans.rs index b163c1d3c4000..32902b49d0284 100644 --- a/src/test/ui/const_prop/inline_spans.rs +++ b/src/test/ui/const_prop/inline_spans.rs @@ -5,10 +5,10 @@ fn main() { let _ = add(u8::MAX, 1); + //~^ ERROR this arithmetic operation will overflow } #[inline(always)] fn add(x: u8, y: u8) -> u8 { x + y - //~^ ERROR this arithmetic operation will overflow } diff --git a/src/test/ui/const_prop/inline_spans.stderr b/src/test/ui/const_prop/inline_spans.stderr index c85c9d3843bb3..05596b8dd3fa4 100644 --- a/src/test/ui/const_prop/inline_spans.stderr +++ b/src/test/ui/const_prop/inline_spans.stderr @@ -1,8 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/inline_spans.rs:12:5 + --> $DIR/inline_spans.rs:7:13 | +LL | let _ = add(u8::MAX, 1); + | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow +... LL | x + y - | ^^^^^ attempt to compute `u8::MAX + 1_u8` which would overflow + | ----- in the inlined copy of this | = note: `#[deny(arithmetic_overflow)]` on by default From 888ef24c2295fc3a1e96f864376fb22b00cc5583 Mon Sep 17 00:00:00 2001 From: oli Date: Tue, 27 Oct 2020 14:16:23 +0000 Subject: [PATCH 04/39] Address review comment --- compiler/rustc_errors/src/emitter.rs | 3 ++- src/test/ui/const_prop/inline_spans.stderr | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 1922dbef64d67..dda1e4c24eda3 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -357,7 +357,8 @@ pub trait Emitter { } if matches!(trace.kind, ExpnKind::Inlined) { - new_labels.push((trace.call_site, "in the inlined copy of this".to_string())); + new_labels + .push((trace.call_site, "in the inlined copy of this code".to_string())); } else if always_backtrace { new_labels.push(( trace.def_site, diff --git a/src/test/ui/const_prop/inline_spans.stderr b/src/test/ui/const_prop/inline_spans.stderr index 05596b8dd3fa4..5a54967e0d055 100644 --- a/src/test/ui/const_prop/inline_spans.stderr +++ b/src/test/ui/const_prop/inline_spans.stderr @@ -5,7 +5,7 @@ LL | let _ = add(u8::MAX, 1); | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow ... LL | x + y - | ----- in the inlined copy of this + | ----- in the inlined copy of this code | = note: `#[deny(arithmetic_overflow)]` on by default From 4206f9fc16a0fbc8b42fe4c500864686f90e6970 Mon Sep 17 00:00:00 2001 From: Ben Striegel Date: Tue, 27 Oct 2020 16:20:58 -0400 Subject: [PATCH 05/39] Prefer numeric associated constants in example Per their documentation, the `max_value()` and `min_value()` associated functions have been superseded by the `MAX` and `MIN` associated constants since Rust 1.43 and are considered "soft deprecated", with all uses currently being replaced in the rustc repo. --- example/std_example.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 079b429904911..cb512a4aa335e 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -315,13 +315,13 @@ fn test_checked_mul() { assert_eq!(1i8.checked_mul(-128i8), Some(-128i8)); assert_eq!((-128i8).checked_mul(-128i8), None); - assert_eq!(1u64.checked_mul(u64::max_value()), Some(u64::max_value())); - assert_eq!(u64::max_value().checked_mul(u64::max_value()), None); - assert_eq!(1i64.checked_mul(i64::max_value()), Some(i64::max_value())); - assert_eq!(i64::max_value().checked_mul(i64::max_value()), None); - assert_eq!((-1i64).checked_mul(i64::min_value() + 1), Some(i64::max_value())); - assert_eq!(1i64.checked_mul(i64::min_value()), Some(i64::min_value())); - assert_eq!(i64::min_value().checked_mul(i64::min_value()), None); + assert_eq!(1u64.checked_mul(u64::MAX), Some(u64::MAX)); + assert_eq!(u64::MAX.checked_mul(u64::MAX), None); + assert_eq!(1i64.checked_mul(i64::MAX), Some(i64::MAX)); + assert_eq!(i64::MAX.checked_mul(i64::MAX), None); + assert_eq!((-1i64).checked_mul(i64::MIN + 1), Some(i64::MAX)); + assert_eq!(1i64.checked_mul(i64::MIN), Some(i64::MIN)); + assert_eq!(i64::MIN.checked_mul(i64::MIN), None); } #[derive(PartialEq)] From 5103a258aa806b4072c7081c6cb71a102979852e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 28 Oct 2020 11:06:40 +0100 Subject: [PATCH 06/39] Rustup to rustc 1.49.0-nightly (07e968b64 2020-10-27) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 87e54719fdc76..71c5ca7431dba 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-26 +nightly-2020-10-28 From 4cc6b4f9bf056e49127eee470a3585250c19a87c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 28 Oct 2020 21:46:08 +0100 Subject: [PATCH 07/39] Fix many clippy warnings --- src/abi/comments.rs | 12 ++++----- src/abi/mod.rs | 53 ++++++++++++++++++-------------------- src/allocator.rs | 4 +-- src/archive.rs | 2 +- src/atomic_shim.rs | 2 +- src/backend.rs | 5 ++-- src/base.rs | 4 +-- src/cast.rs | 8 +++--- src/codegen_i128.rs | 8 +++--- src/constant.rs | 16 +++++------- src/debuginfo/emit.rs | 4 +-- src/debuginfo/line_info.rs | 4 +-- src/driver/jit.rs | 4 +-- src/intrinsics/llvm.rs | 6 ++--- src/intrinsics/simd.rs | 4 +-- src/lib.rs | 1 + src/linkage.rs | 8 +++--- src/main_shim.rs | 2 +- src/metadata.rs | 4 +-- src/optimize/stack2reg.rs | 3 ++- src/pretty_clif.rs | 8 +++--- src/value_and_place.rs | 19 ++++++-------- src/vtable.rs | 16 +++--------- 23 files changed, 88 insertions(+), 109 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 7bb00c8d46a4c..01073d26e832a 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -11,9 +11,9 @@ use crate::abi::pass_mode::*; use crate::prelude::*; pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) { - fx.add_global_comment(format!( - "kind loc.idx param pass mode ty" - )); + fx.add_global_comment( + "kind loc.idx param pass mode ty".to_string(), + ); } pub(super) fn add_arg_comment<'tcx>( @@ -56,9 +56,9 @@ pub(super) fn add_arg_comment<'tcx>( pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) { fx.add_global_comment(String::new()); - fx.add_global_comment(format!( - "kind local ty size align (abi,pref)" - )); + fx.add_global_comment( + "kind local ty size align (abi,pref)".to_string(), + ); } pub(super) fn add_local_place_comments<'tcx>( diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 8016912284317..1fa36b944f721 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -300,7 +300,7 @@ impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> { return_ty: Ty<'tcx>, ) -> CValue<'tcx> { let (input_tys, args): (Vec<_>, Vec<_>) = args - .into_iter() + .iter() .map(|arg| { ( self.clif_type(arg.layout().ty).unwrap(), @@ -421,34 +421,31 @@ pub(crate) fn codegen_fn_prelude<'tcx>( // While this is normally an optimization to prevent an unnecessary copy when an argument is // not mutated by the current function, this is necessary to support unsized arguments. - match arg_kind { - ArgKind::Normal(Some(val)) => { - if let Some((addr, meta)) = val.try_to_ptr() { - let local_decl = &fx.mir.local_decls[local]; - // v this ! is important - let internally_mutable = !val.layout().ty.is_freeze( - fx.tcx.at(local_decl.source_info.span), - ParamEnv::reveal_all(), - ); - if local_decl.mutability == mir::Mutability::Not && !internally_mutable { - // We wont mutate this argument, so it is fine to borrow the backing storage - // of this argument, to prevent a copy. - - let place = if let Some(meta) = meta { - CPlace::for_ptr_with_extra(addr, meta, val.layout()) - } else { - CPlace::for_ptr(addr, val.layout()) - }; - - #[cfg(debug_assertions)] - self::comments::add_local_place_comments(fx, place, local); - - assert_eq!(fx.local_map.push(place), local); - continue; - } + if let ArgKind::Normal(Some(val)) = arg_kind { + if let Some((addr, meta)) = val.try_to_ptr() { + let local_decl = &fx.mir.local_decls[local]; + // v this ! is important + let internally_mutable = !val.layout().ty.is_freeze( + fx.tcx.at(local_decl.source_info.span), + ParamEnv::reveal_all(), + ); + if local_decl.mutability == mir::Mutability::Not && !internally_mutable { + // We wont mutate this argument, so it is fine to borrow the backing storage + // of this argument, to prevent a copy. + + let place = if let Some(meta) = meta { + CPlace::for_ptr_with_extra(addr, meta, val.layout()) + } else { + CPlace::for_ptr(addr, val.layout()) + }; + + #[cfg(debug_assertions)] + self::comments::add_local_place_comments(fx, place, local); + + assert_eq!(fx.local_map.push(place), local); + continue; } } - _ => {} } let place = make_local_place(fx, local, layout, is_ssa); @@ -568,7 +565,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( } args } else { - args.into_iter() + args.iter() .map(|arg| trans_operand(fx, arg)) .collect::>() }; diff --git a/src/allocator.rs b/src/allocator.rs index 0735ad6f83299..6c5916550ff63 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -123,7 +123,7 @@ fn codegen_inner( .unwrap(); let mut ctx = Context::new(); - ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone()); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig); { let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); @@ -131,7 +131,7 @@ fn codegen_inner( let block = bcx.create_block(); bcx.switch_to_block(block); let args = (&[usize_ty, usize_ty]) - .into_iter() + .iter() .map(|&ty| bcx.append_block_param(block, ty)) .collect::>(); diff --git a/src/archive.rs b/src/archive.rs index 6382f8df3446b..9a970efbcfd0b 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -132,7 +132,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } // ok, don't skip this - return false; + false }) } diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 92281fdacc941..2f0157c257b98 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -7,7 +7,7 @@ use crate::prelude::*; #[cfg(all(feature = "jit", unix))] #[no_mangle] -pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = +static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; pub(crate) fn init_global_lock( diff --git a/src/backend.rs b/src/backend.rs index 8b900fd0dd0c8..aac37b376dc35 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -73,7 +73,7 @@ impl WriteDebugInfo for ObjectProduct { // FIXME use SHT_X86_64_UNWIND for .eh_frame let section_id = self.object.add_section( segment, - name.clone(), + name, if id == SectionId::EhFrame { SectionKind::ReadOnlyData } else { @@ -201,6 +201,5 @@ pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule { if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() { builder.per_function_section(true); } - let module = ObjectModule::new(builder); - module + ObjectModule::new(builder) } diff --git a/src/base.rs b/src/base.rs index fa9b8853d39e9..3e455dbc0e201 100644 --- a/src/base.rs +++ b/src/base.rs @@ -753,7 +753,7 @@ fn trans_stmt<'tcx>( } Rvalue::Aggregate(kind, operands) => match **kind { AggregateKind::Array(_ty) => { - for (i, operand) in operands.into_iter().enumerate() { + for (i, operand) in operands.iter().enumerate() { let operand = trans_operand(fx, operand); let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); let to = lval.place_index(fx, index); @@ -938,7 +938,7 @@ pub(crate) fn trans_place<'tcx>( let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)), - fx.layout_of(fx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), + fx.layout_of(fx.tcx.mk_array(elem_ty, to - from)), ); } ty::Slice(elem_ty) => { diff --git a/src/cast.rs b/src/cast.rs index 122a36b5bf741..57204de1135be 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -181,12 +181,10 @@ pub(crate) fn clif_int_or_float_cast( fx.bcx.ins().select(has_overflow, max_val, val) }; fx.bcx.ins().ireduce(to_ty, val) + } else if to_signed { + fx.bcx.ins().fcvt_to_sint_sat(to_ty, from) } else { - if to_signed { - fx.bcx.ins().fcvt_to_sint_sat(to_ty, from) - } else { - fx.bcx.ins().fcvt_to_uint_sat(to_ty, from) - } + fx.bcx.ins().fcvt_to_uint_sat(to_ty, from) } } else if from_ty.is_float() && to_ty.is_float() { // float -> float diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index e998403dea6bb..d6a38bdafc9ba 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -21,9 +21,9 @@ pub(crate) fn maybe_codegen<'tcx>( match bin_op { BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => { assert!(!checked); - return None; + None } - BinOp::Add | BinOp::Sub if !checked => return None, + BinOp::Add | BinOp::Sub if !checked => None, BinOp::Add => { let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); return Some(if is_signed { @@ -57,7 +57,7 @@ pub(crate) fn maybe_codegen<'tcx>( }; fx.easy_call("__multi3", &[lhs, rhs], val_ty) }; - return Some(res); + Some(res) } BinOp::Div => { assert!(!checked); @@ -77,7 +77,7 @@ pub(crate) fn maybe_codegen<'tcx>( } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { assert!(!checked); - return None; + None } BinOp::Shl | BinOp::Shr => { let is_overflow = if checked { diff --git a/src/constant.rs b/src/constant.rs index 1b514958a4809..bdf9ccba62afb 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -188,7 +188,7 @@ pub(crate) fn trans_const_value<'tcx>( match x { Scalar::Raw { data, size } => { assert_eq!(u64::from(size), layout.size.bytes()); - return CValue::const_val(fx, layout, data); + CValue::const_val(fx, layout, data) } Scalar::Ptr(ptr) => { let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id); @@ -232,7 +232,7 @@ pub(crate) fn trans_const_value<'tcx>( } else { base_addr }; - return CValue::by_val(val, layout); + CValue::by_val(val, layout) } } } @@ -293,14 +293,12 @@ fn data_id_for_static( let rlinkage = tcx.codegen_fn_attrs(def_id).linkage; let linkage = if definition { crate::linkage::get_static_linkage(tcx, def_id) + } else if rlinkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak) + || rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny) + { + Linkage::Preemptible } else { - if rlinkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak) - || rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny) - { - Linkage::Preemptible - } else { - Linkage::Import - } + Linkage::Import }; let instance = Instance::mono(tcx, def_id).polymorphize(tcx); diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index cf8fee2b1d17c..f6f795e45615c 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -195,9 +195,7 @@ impl Writer for WriterRelocate { }); self.write_udata(0, size) } - _ => { - return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)); - } + _ => Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)), }, } } diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 4de8485532896..d226755d85de0 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -49,7 +49,7 @@ fn osstr_as_utf8_bytes(path: &OsStr) -> &[u8] { pub(crate) const MD5_LEN: usize = 16; -pub fn make_file_info(hash: SourceFileHash) -> Option { +pub(crate) fn make_file_info(hash: SourceFileHash) -> Option { if hash.kind == SourceFileHashAlgorithm::Md5 { let mut buf = [0u8; MD5_LEN]; buf.copy_from_slice(hash.hash_bytes()); @@ -190,7 +190,7 @@ impl<'tcx> DebugContext<'tcx> { if current_file_changed { let file_id = line_program_add_file(line_program, line_strings, &file); line_program.row().file = file_id; - last_file = Some(file.clone()); + last_file = Some(file); } line_program.row().line = line; diff --git a/src/driver/jit.rs b/src/driver/jit.rs index b5bab3d9e1ed1..3f47df7d844b3 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -94,7 +94,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { let args = ::std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new()); let args = std::iter::once(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string()) - .chain(args.split(" ")) + .chain(args.split(' ')) .map(|arg| CString::new(arg).unwrap()) .collect::>(); let mut argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); @@ -151,7 +151,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { } let dlsym_name = if cfg!(target_os = "macos") { // On macOS `dlsym` expects the name without leading `_`. - assert!(name.starts_with("_"), "{:?}", name); + assert!(name.starts_with('_'), "{:?}", name); &name[1..] } else { &name diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index 18d86f0c5f959..171445f2d71b6 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -53,7 +53,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( }; llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) { let kind_const = crate::constant::mir_operand_get_const_val(fx, kind).expect("llvm.x86.sse2.cmp.* kind not const"); - let flt_cc = match kind_const.val.try_to_bits(Size::from_bytes(1)).expect(&format!("kind not scalar: {:?}", kind_const)) { + let flt_cc = match kind_const.val.try_to_bits(Size::from_bytes(1)).unwrap_or_else(|| panic!("kind not scalar: {:?}", kind_const)) { 0 => FloatCC::Equal, 1 => FloatCC::LessThan, 2 => FloatCC::LessThanOrEqual, @@ -84,7 +84,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( llvm.x86.sse2.psrli.d, (c a, o imm8) { let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const"); simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| { - let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).expect(&format!("imm8 not scalar: {:?}", imm8)) { + let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8)) { imm8 if imm8 < 32 => fx.bcx.ins().ushr_imm(lane, i64::from(imm8 as u8)), _ => fx.bcx.ins().iconst(types::I32, 0), }; @@ -94,7 +94,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( llvm.x86.sse2.pslli.d, (c a, o imm8) { let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const"); simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| { - let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).expect(&format!("imm8 not scalar: {:?}", imm8)) { + let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8)) { imm8 if imm8 < 32 => fx.bcx.ins().ishl_imm(lane, i64::from(imm8 as u8)), _ => fx.bcx.ins().iconst(types::I32, 0), }; diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index b4269f4fafa0b..2e31c4669e25b 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -127,7 +127,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( ); }; - let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); + let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const)); let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, base.layout()); if idx >= lane_count.into() { fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); @@ -149,7 +149,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( ); }; - let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); + let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const)); let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, v.layout()); if idx >= lane_count.into() { fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); diff --git a/src/lib.rs b/src/lib.rs index fd00a2e00a6a4..7daff2a24b959 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ )] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] +#![warn(unreachable_pub)] #[cfg(feature = "jit")] extern crate libc; diff --git a/src/linkage.rs b/src/linkage.rs index fe5d1d6444363..dc1e2107ce712 100644 --- a/src/linkage.rs +++ b/src/linkage.rs @@ -25,11 +25,9 @@ pub(crate) fn get_static_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage { RLinkage::ExternalWeak | RLinkage::WeakAny => Linkage::Preemptible, _ => panic!("{:?}", linkage), } + } else if tcx.is_reachable_non_generic(def_id) { + Linkage::Export } else { - if tcx.is_reachable_non_generic(def_id) { - Linkage::Export - } else { - Linkage::Hidden - } + Linkage::Hidden } } diff --git a/src/main_shim.rs b/src/main_shim.rs index db34d89fe2be7..10f515e38ead2 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -76,7 +76,7 @@ pub(crate) fn maybe_create_entry_wrapper( .unwrap(); let mut ctx = Context::new(); - ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone()); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig); { let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); diff --git a/src/metadata.rs b/src/metadata.rs index 04369bf89fd2d..cda2a187ff9b7 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -29,7 +29,7 @@ impl MetadataLoader for CraneliftMetadataLoader { .expect("Rlib metadata file too big to load into memory."), ); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; - let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); + let buf: OwningRef, [u8]> = OwningRef::new(buf); return Ok(rustc_erase_owner!(buf.map_owner_box())); } } @@ -47,7 +47,7 @@ impl MetadataLoader for CraneliftMetadataLoader { .data() .map_err(|e| format!("failed to read .rustc section: {:?}", e))? .to_owned(); - let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); + let buf: OwningRef, [u8]> = OwningRef::new(buf); Ok(rustc_erase_owner!(buf.map_owner_box())) } } diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index f368d65f7f8d8..3c939d5a58639 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -228,7 +228,8 @@ pub(super) fn optimize_function( match *potential_stores { [] => { #[cfg(debug_assertions)] - clif_comments.add_comment(load, format!("[BUG?] Reading uninitialized memory")); + clif_comments + .add_comment(load, "[BUG?] Reading uninitialized memory".to_string()); } [store] if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 7f8ab953d7199..ff878af7f5eef 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -131,11 +131,11 @@ impl FuncWriter for &'_ CommentWriter { if !comment.is_empty() { writeln!(w, "; {}", comment)?; } else { - writeln!(w, "")?; + writeln!(w)?; } } if !self.global_comments.is_empty() { - writeln!(w, "")?; + writeln!(w)?; } self.super_preamble(w, func, reg_info) @@ -153,7 +153,7 @@ impl FuncWriter for &'_ CommentWriter { if let Some(comment) = self.entity_comments.get(&entity) { writeln!(w, " ; {}", comment.replace('\n', "\n; ")) } else { - writeln!(w, "") + writeln!(w) } } @@ -261,7 +261,7 @@ pub(crate) fn write_clif_file<'tcx>( writeln!(file, "set is_pic")?; writeln!(file, "set enable_simd")?; writeln!(file, "target {} haswell", target_triple)?; - writeln!(file, "")?; + writeln!(file)?; file.write_all(clif.as_bytes())?; }; if let Err(err) = res { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 5d513cb3ea022..9a2470ba40d34 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -27,10 +27,10 @@ fn codegen_field<'tcx>( return simple(fx); } match field_layout.ty.kind() { - ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(fx), + ty::Slice(..) | ty::Str | ty::Foreign(..) => simple(fx), ty::Adt(def, _) if def.repr.packed() => { assert_eq!(layout.align.abi.bytes(), 1); - return simple(fx); + simple(fx) } _ => { // We have to align the offset for DST's @@ -237,15 +237,12 @@ impl<'tcx> CValue<'tcx> { let clif_ty = fx.clif_type(layout.ty).unwrap(); - match layout.ty.kind() { - ty::Bool => { - assert!( - const_val == 0 || const_val == 1, - "Invalid bool 0x{:032X}", - const_val - ); - } - _ => {} + if let ty::Bool = layout.ty.kind() { + assert!( + const_val == 0 || const_val == 1, + "Invalid bool 0x{:032X}", + const_val + ); } let val = match layout.ty.kind() { diff --git a/src/vtable.rs b/src/vtable.rs index bb3cf8b3f3a3a..238abc0d8bdfa 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -108,14 +108,14 @@ fn build_vtable<'tcx>( (&[]).iter() }; let methods = methods.cloned().map(|opt_mth| { - opt_mth.map_or(None, |(def_id, substs)| { - Some(import_function( + opt_mth.map(|(def_id, substs)| { + import_function( tcx, &mut fx.cx.module, Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs) .unwrap() .polymorphize(fx.tcx), - )) + ) }) }); components.extend(methods); @@ -137,15 +137,7 @@ fn build_vtable<'tcx>( } } - data_ctx.set_align( - fx.tcx - .data_layout - .pointer_align - .pref - .bytes() - .try_into() - .unwrap(), - ); + data_ctx.set_align(fx.tcx.data_layout.pointer_align.pref.bytes()); let data_id = fx .cx From 114be422efbabf6632491cda8a7b3a74249374a9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 31 Oct 2020 10:12:51 +0100 Subject: [PATCH 08/39] Rustup to rustc 1.49.0-nightly (ffe52882e 2020-10-30) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 71c5ca7431dba..0ca96be9ae731 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-28 +nightly-2020-10-31 From c067be07c12d107bf85cc6045f50c19dc79f2e3c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 31 Oct 2020 10:13:35 +0100 Subject: [PATCH 09/39] Implement -Zfunction-sections --- docs/env_vars.md | 3 --- src/backend.rs | 7 ++++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/env_vars.md b/docs/env_vars.md index 07b75622a58ef..f0a0a6ad42ef5 100644 --- a/docs/env_vars.md +++ b/docs/env_vars.md @@ -9,7 +9,4 @@ object files when their content should have been changed by a change to cg_clif.
CG_CLIF_DISPLAY_CG_TIME
If "1", display the time it took to perform codegen for a crate
-
CG_CLIF_FUNCTION_SECTIONS
-
Use a single section for each function. This will often reduce the executable size at the - cost of making linking significantly slower.
diff --git a/src/backend.rs b/src/backend.rs index aac37b376dc35..9e32259716f51 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -198,8 +198,9 @@ pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule { cranelift_module::default_libcall_names(), ) .unwrap(); - if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() { - builder.per_function_section(true); - } + // Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size + // is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections + // can easily double the amount of time necessary to perform linking. + builder.per_function_section(sess.opts.debugging_opts.function_sections.unwrap_or(false)); ObjectModule::new(builder) } From 34be539ca44c198cfc02048e7decebbe37e810f7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 31 Oct 2020 18:31:29 +0100 Subject: [PATCH 10/39] Use Pointer::dangling for ZST's in trans_const_value --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index bdf9ccba62afb..5c3477a4ddb8e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -164,7 +164,7 @@ pub(crate) fn trans_const_value<'tcx>( if layout.is_zst() { return CValue::by_ref( - crate::Pointer::const_addr(fx, i64::try_from(layout.align.pref.bytes()).unwrap()), + crate::Pointer::dangling(layout.align.pref), layout, ); } From 6b1902a0fa7e68c097157d6bb4c64c672fbb596b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 31 Oct 2020 19:38:35 +0100 Subject: [PATCH 11/39] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- src/debuginfo/unwind.rs | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6cfbed0a5e430..a88ea5827329f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" [[package]] name = "cranelift-entity" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" [[package]] name = "cranelift-frontend" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" dependencies = [ "cranelift-codegen", "cranelift-entity", diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 61ebd931d2f14..68138404c2436 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -55,6 +55,7 @@ impl<'tcx> UnwindContext<'tcx> { UnwindInfo::WindowsX64(_) => { // FIXME implement this } + unwind_info => unimplemented!("{:?}", unwind_info), } } From f4e8af268be3042643f581ded2e4c92bf95f66f3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Nov 2020 09:50:33 +0100 Subject: [PATCH 12/39] Update Cranelift Fixes bootstrapping of rustc using cg_clif Fixes #1097 --- Cargo.lock | 20 ++++++++++---------- example/mini_core.rs | 10 ++++++++++ example/mini_core_hello_world.rs | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a88ea5827329f..2889fac77f6a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" [[package]] name = "cranelift-entity" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" [[package]] name = "cranelift-frontend" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#53f044715b99cd97ccd24e54b25c72a8646b9a72" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdecea03c360ea82e6482f0cf6c614effef21" dependencies = [ "cranelift-codegen", "cranelift-entity", diff --git a/example/mini_core.rs b/example/mini_core.rs index a972beedaa387..ce07fe83df18f 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -48,6 +48,7 @@ unsafe impl Copy for u8 {} unsafe impl Copy for u16 {} unsafe impl Copy for u32 {} unsafe impl Copy for u64 {} +unsafe impl Copy for u128 {} unsafe impl Copy for usize {} unsafe impl Copy for i8 {} unsafe impl Copy for i16 {} @@ -283,6 +284,15 @@ impl PartialEq for u64 { } } +impl PartialEq for u128 { + fn eq(&self, other: &u128) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u128) -> bool { + (*self) != (*other) + } +} + impl PartialEq for usize { fn eq(&self, other: &usize) -> bool { (*self) == (*other) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 376056e19383f..4a8375afac3ce 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -287,6 +287,8 @@ fn main() { assert_eq!(repeat[0], Some(42)); assert_eq!(repeat[1], Some(42)); + from_decimal_string(); + #[cfg(not(jit))] test_tls(); @@ -446,3 +448,23 @@ fn check_niche_behavior () { intrinsics::abort(); } } + +fn from_decimal_string() { + loop { + let multiplier = 1; + + take_multiplier_ref(&multiplier); + + if multiplier == 1 { + break; + } + + unreachable(); + } +} + +fn take_multiplier_ref(_multiplier: &u128) {} + +fn unreachable() -> ! { + panic("unreachable") +} From d27f2f093258c145f2db6ee6c3ee636a767e6e01 Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Sun, 1 Nov 2020 19:24:30 +0600 Subject: [PATCH 13/39] Rename trans to codegen --- src/abi/mod.rs | 10 +++--- src/base.rs | 80 +++++++++++++++++++++---------------------- src/common.rs | 2 +- src/constant.rs | 6 ++-- src/driver/mod.rs | 6 ++-- src/inline_asm.rs | 8 ++--- src/intrinsics/mod.rs | 22 ++++++------ src/lib.rs | 2 +- src/num.rs | 18 +++++----- 9 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 1fa36b944f721..81091728692f3 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -497,7 +497,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); - let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); + let destination = destination.map(|(place, bb)| (codegen_place(fx, place), bb)); // Handle special calls like instrinsics and empty drop glue. let instance = if let ty::FnDef(def_id, substs) = *fn_ty.kind() { @@ -550,8 +550,8 @@ pub(crate) fn codegen_terminator_call<'tcx>( // Unpack arguments tuple for closures let args = if fn_sig.abi == Abi::RustCall { assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); - let self_arg = trans_operand(fx, &args[0]); - let pack_arg = trans_operand(fx, &args[1]); + let self_arg = codegen_operand(fx, &args[0]); + let pack_arg = codegen_operand(fx, &args[1]); let tupled_arguments = match pack_arg.layout().ty.kind() { ty::Tuple(ref tupled_arguments) => tupled_arguments, @@ -566,7 +566,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( args } else { args.iter() - .map(|arg| trans_operand(fx, arg)) + .map(|arg| codegen_operand(fx, arg)) .collect::>() }; @@ -610,7 +610,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let nop_inst = fx.bcx.ins().nop(); fx.add_comment(nop_inst, "indirect call"); } - let func = trans_operand(fx, func).load_scalar(fx); + let func = codegen_operand(fx, func).load_scalar(fx); ( Some(func), args.get(0) diff --git a/src/base.rs b/src/base.rs index 3e455dbc0e201..5474e5960f100 100644 --- a/src/base.rs +++ b/src/base.rs @@ -5,7 +5,7 @@ use rustc_middle::ty::adjustment::PointerCast; use crate::prelude::*; -pub(crate) fn trans_fn<'tcx>( +pub(crate) fn codegen_fn<'tcx>( cx: &mut crate::CodegenCx<'tcx, impl Module>, instance: Instance<'tcx>, linkage: Linkage, @@ -202,7 +202,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { fx.bcx.ins().nop(); for stmt in &bb_data.statements { fx.set_debug_loc(stmt.source_info); - trans_stmt(fx, block, stmt); + codegen_stmt(fx, block, stmt); } #[cfg(debug_assertions)] @@ -258,7 +258,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { continue; } } - let cond = trans_operand(fx, cond).load_scalar(fx); + let cond = codegen_operand(fx, cond).load_scalar(fx); let target = fx.get_block(*target); let failure = fx.bcx.create_block(); @@ -276,8 +276,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { match msg { AssertKind::BoundsCheck { ref len, ref index } => { - let len = trans_operand(fx, len).load_scalar(fx); - let index = trans_operand(fx, index).load_scalar(fx); + let len = codegen_operand(fx, len).load_scalar(fx); + let index = codegen_operand(fx, index).load_scalar(fx); let location = fx .get_caller_location(bb_data.terminator().source_info.span) .load_scalar(fx); @@ -301,7 +301,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { switch_ty, targets, } => { - let discr = trans_operand(fx, discr).load_scalar(fx); + let discr = codegen_operand(fx, discr).load_scalar(fx); if switch_ty.kind() == fx.tcx.types.bool.kind() { assert_eq!(targets.iter().count(), 1); @@ -396,14 +396,14 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { | TerminatorKind::FalseUnwind { .. } | TerminatorKind::DropAndReplace { .. } | TerminatorKind::GeneratorDrop => { - bug!("shouldn't exist at trans {:?}", bb_data.terminator()); + bug!("shouldn't exist at codegen {:?}", bb_data.terminator()); } TerminatorKind::Drop { place, target, unwind: _, } => { - let drop_place = trans_place(fx, *place); + let drop_place = codegen_place(fx, *place); crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); let target_block = fx.get_block(*target); @@ -416,7 +416,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { fx.bcx.finalize(); } -fn trans_stmt<'tcx>( +fn codegen_stmt<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, #[allow(unused_variables)] cur_block: Block, stmt: &Statement<'tcx>, @@ -439,19 +439,19 @@ fn trans_stmt<'tcx>( place, variant_index, } => { - let place = trans_place(fx, **place); + let place = codegen_place(fx, **place); crate::discriminant::codegen_set_discriminant(fx, place, *variant_index); } StatementKind::Assign(to_place_and_rval) => { - let lval = trans_place(fx, to_place_and_rval.0); + let lval = codegen_place(fx, to_place_and_rval.0); let dest_layout = lval.layout(); match &to_place_and_rval.1 { Rvalue::Use(operand) => { - let val = trans_operand(fx, operand); + let val = codegen_operand(fx, operand); lval.write_cvalue(fx, val); } Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { - let place = trans_place(fx, *place); + let place = codegen_place(fx, *place); let ref_ = place.place_ref(fx, lval.layout()); lval.write_cvalue(fx, ref_); } @@ -460,29 +460,29 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, val); } Rvalue::BinaryOp(bin_op, lhs, rhs) => { - let lhs = trans_operand(fx, lhs); - let rhs = trans_operand(fx, rhs); + let lhs = codegen_operand(fx, lhs); + let rhs = codegen_operand(fx, rhs); let res = crate::num::codegen_binop(fx, *bin_op, lhs, rhs); lval.write_cvalue(fx, res); } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { - let lhs = trans_operand(fx, lhs); - let rhs = trans_operand(fx, rhs); + let lhs = codegen_operand(fx, lhs); + let rhs = codegen_operand(fx, rhs); let res = if !fx.tcx.sess.overflow_checks() { let val = - crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); + crate::num::codegen_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); CValue::by_val_pair(val, is_overflow, lval.layout()) } else { - crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs) + crate::num::codegen_checked_int_binop(fx, *bin_op, lhs, rhs) }; lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, operand) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); let layout = operand.layout(); let val = operand.load_scalar(fx); let res = match un_op { @@ -500,7 +500,7 @@ fn trans_stmt<'tcx>( ty::Int(IntTy::I128) => { // FIXME remove this case once ineg.i128 works let zero = CValue::const_val(fx, layout, 0); - crate::num::trans_int_binop(fx, BinOp::Sub, zero, operand) + crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand) } ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout), ty::Float(_) => CValue::by_val(fx.bcx.ins().fneg(val), layout), @@ -534,11 +534,11 @@ fn trans_stmt<'tcx>( | Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, to_ty) | Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, to_ty) => { let to_layout = fx.layout_of(fx.monomorphize(to_ty)); - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); lval.write_cvalue(fx, operand.cast_pointer_to(to_layout)); } Rvalue::Cast(CastKind::Misc, operand, to_ty) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); let from_ty = operand.layout().ty; let to_ty = fx.monomorphize(to_ty); @@ -639,7 +639,7 @@ fn trans_stmt<'tcx>( operand, _to_ty, ) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); match *operand.layout().ty.kind() { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( @@ -657,18 +657,18 @@ fn trans_stmt<'tcx>( } } Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _to_ty) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); operand.unsize_value(fx, lval); } Rvalue::Discriminant(place) => { - let place = trans_place(fx, *place); + let place = codegen_place(fx, *place); let value = place.to_cvalue(fx); let discr = crate::discriminant::codegen_get_discriminant(fx, value, dest_layout); lval.write_cvalue(fx, discr); } Rvalue::Repeat(operand, times) => { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); let times = fx .monomorphize(times) .eval(fx.tcx, ParamEnv::reveal_all()) @@ -706,7 +706,7 @@ fn trans_stmt<'tcx>( } } Rvalue::Len(place) => { - let place = trans_place(fx, *place); + let place = codegen_place(fx, *place); let usize_layout = fx.layout_of(fx.tcx.types.usize); let len = codegen_array_len(fx, place); lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); @@ -754,13 +754,13 @@ fn trans_stmt<'tcx>( Rvalue::Aggregate(kind, operands) => match **kind { AggregateKind::Array(_ty) => { for (i, operand) in operands.iter().enumerate() { - let operand = trans_operand(fx, operand); + let operand = codegen_operand(fx, operand); let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); } } - _ => unreachable!("shouldn't exist at trans {:?}", to_place_and_rval.1), + _ => unreachable!("shouldn't exist at codegen {:?}", to_place_and_rval.1), }, } } @@ -813,20 +813,20 @@ fn trans_stmt<'tcx>( assert!(!alignstack); assert_eq!(inputs.len(), 2); - let leaf = trans_operand(fx, &inputs[0].1).load_scalar(fx); // %eax - let subleaf = trans_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx + let leaf = codegen_operand(fx, &inputs[0].1).load_scalar(fx); // %eax + let subleaf = codegen_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx let (eax, ebx, ecx, edx) = crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); assert_eq!(outputs.len(), 4); - trans_place(fx, outputs[0]) + codegen_place(fx, outputs[0]) .write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[1]) + codegen_place(fx, outputs[1]) .write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[2]) + codegen_place(fx, outputs[2]) .write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[3]) + codegen_place(fx, outputs[3]) .write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32))); } "xgetbv" => { @@ -892,7 +892,7 @@ fn codegen_array_len<'tcx>( } } -pub(crate) fn trans_place<'tcx>( +pub(crate) fn codegen_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, place: Place<'tcx>, ) -> CPlace<'tcx> { @@ -964,16 +964,16 @@ pub(crate) fn trans_place<'tcx>( cplace } -pub(crate) fn trans_operand<'tcx>( +pub(crate) fn codegen_operand<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, operand: &Operand<'tcx>, ) -> CValue<'tcx> { match operand { Operand::Move(place) | Operand::Copy(place) => { - let cplace = trans_place(fx, *place); + let cplace = codegen_place(fx, *place); cplace.to_cvalue(fx) } - Operand::Constant(const_) => crate::constant::trans_constant(fx, const_), + Operand::Constant(const_) => crate::constant::codegen_constant(fx, const_), } } diff --git a/src/common.rs b/src/common.rs index 13c62add41a3b..eda77bf19d354 100644 --- a/src/common.rs +++ b/src/common.rs @@ -406,7 +406,7 @@ impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> { caller.line as u32, caller.col_display as u32 + 1, )); - crate::constant::trans_const_value(self, const_loc, self.tcx.caller_location_ty()) + crate::constant::codegen_const_value(self, const_loc, self.tcx.caller_location_ty()) } pub(crate) fn triple(&self) -> &target_lexicon::Triple { diff --git a/src/constant.rs b/src/constant.rs index 5c3477a4ddb8e..dbe2bb73a4f73 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -106,7 +106,7 @@ fn codegen_static_ref<'tcx>( CPlace::for_ptr(crate::pointer::Pointer::new(global_ptr), layout) } -pub(crate) fn trans_constant<'tcx>( +pub(crate) fn codegen_constant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { @@ -151,10 +151,10 @@ pub(crate) fn trans_constant<'tcx>( | ConstKind::Error(_) => unreachable!("{:?}", const_), }; - trans_const_value(fx, const_val, const_.ty) + codegen_const_value(fx, const_val, const_.ty) } -pub(crate) fn trans_const_value<'tcx>( +pub(crate) fn codegen_const_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, const_val: ConstValue<'tcx>, ty: Ty<'tcx>, diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 2fb353ca1628a..a11dc57ee6453 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -64,11 +64,11 @@ fn codegen_mono_items<'tcx>( for (mono_item, (linkage, visibility)) in mono_items { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - trans_mono_item(cx, mono_item, linkage); + codegen_mono_item(cx, mono_item, linkage); } } -fn trans_mono_item<'tcx, M: Module>( +fn codegen_mono_item<'tcx, M: Module>( cx: &mut crate::CodegenCx<'tcx, M>, mono_item: MonoItem<'tcx>, linkage: Linkage, @@ -80,7 +80,7 @@ fn trans_mono_item<'tcx, M: Module>( crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name)); debug_assert!(!inst.substs.needs_infer()); tcx.sess - .time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); + .time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.constants_cx, def_id); diff --git a/src/inline_asm.rs b/src/inline_asm.rs index aa2edb2dfd4f7..04aac780125d9 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -50,7 +50,7 @@ pub(crate) fn codegen_inline_asm<'tcx>( inputs.push(( reg, new_slot(reg.reg_class()), - crate::base::trans_operand(fx, value).load_scalar(fx), + crate::base::codegen_operand(fx, value).load_scalar(fx), )); } InlineAsmOperand::Out { @@ -64,7 +64,7 @@ pub(crate) fn codegen_inline_asm<'tcx>( outputs.push(( reg, new_slot(reg.reg_class()), - crate::base::trans_place(fx, place), + crate::base::codegen_place(fx, place), )); } } @@ -79,13 +79,13 @@ pub(crate) fn codegen_inline_asm<'tcx>( inputs.push(( reg, new_slot(reg.reg_class()), - crate::base::trans_operand(fx, in_value).load_scalar(fx), + crate::base::codegen_operand(fx, in_value).load_scalar(fx), )); if let Some(out_place) = out_place { outputs.push(( reg, new_slot(reg.reg_class()), - crate::base::trans_place(fx, out_place), + crate::base::codegen_place(fx, out_place), )); } } diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 074fba6b5c33a..a5f45b7abf4c8 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -31,10 +31,10 @@ macro intrinsic_arg { $arg }, (c $fx:expr, $arg:ident) => { - trans_operand($fx, $arg) + codegen_operand($fx, $arg) }, (v $fx:expr, $arg:ident) => { - trans_operand($fx, $arg).load_scalar($fx) + codegen_operand($fx, $arg).load_scalar($fx) } } @@ -90,7 +90,7 @@ macro call_intrinsic_match { assert!($substs.is_noop()); if let [$(ref $arg),*] = *$args { let ($($arg,)*) = ( - $(trans_operand($fx, $arg),)* + $(codegen_operand($fx, $arg),)* ); let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.tcx.types.$ty); $ret.write_cvalue($fx, res); @@ -577,7 +577,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( "unchecked_shr" => BinOp::Shr, _ => unreachable!("intrinsic {}", intrinsic), }; - let res = crate::num::trans_int_binop(fx, bin_op, x, y); + let res = crate::num::codegen_int_binop(fx, bin_op, x, y); ret.write_cvalue(fx, res); }; _ if intrinsic.ends_with("_with_overflow"), (c x, c y) { @@ -589,7 +589,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( _ => unreachable!("intrinsic {}", intrinsic), }; - let res = crate::num::trans_checked_int_binop( + let res = crate::num::codegen_checked_int_binop( fx, bin_op, x, @@ -605,7 +605,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( "wrapping_mul" => BinOp::Mul, _ => unreachable!("intrinsic {}", intrinsic), }; - let res = crate::num::trans_int_binop( + let res = crate::num::codegen_int_binop( fx, bin_op, x, @@ -623,7 +623,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let signed = type_sign(T); - let checked_res = crate::num::trans_checked_int_binop( + let checked_res = crate::num::codegen_checked_int_binop( fx, bin_op, lhs, @@ -867,7 +867,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () { let const_val = fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); - let val = crate::constant::trans_const_value( + let val = crate::constant::codegen_const_value( fx, const_val, ret.layout().ty, @@ -886,12 +886,12 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; ptr_guaranteed_eq, (c a, c b) { - let val = crate::num::trans_ptr_binop(fx, BinOp::Eq, a, b); + let val = crate::num::codegen_ptr_binop(fx, BinOp::Eq, a, b); ret.write_cvalue(fx, val); }; ptr_guaranteed_ne, (c a, c b) { - let val = crate::num::trans_ptr_binop(fx, BinOp::Ne, a, b); + let val = crate::num::codegen_ptr_binop(fx, BinOp::Ne, a, b); ret.write_cvalue(fx, val); }; @@ -1069,7 +1069,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; fadd_fast | fsub_fast | fmul_fast | fdiv_fast | frem_fast, (c x, c y) { - let res = crate::num::trans_float_binop(fx, match intrinsic { + let res = crate::num::codegen_float_binop(fx, match intrinsic { "fadd_fast" => BinOp::Add, "fsub_fast" => BinOp::Sub, "fmul_fast" => BinOp::Mul, diff --git a/src/lib.rs b/src/lib.rs index 7daff2a24b959..ba9ee0d450ee6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,7 +111,7 @@ mod prelude { pub(crate) use cranelift_module::{self, DataContext, DataId, FuncId, Linkage, Module}; pub(crate) use crate::abi::*; - pub(crate) use crate::base::{trans_operand, trans_place}; + pub(crate) use crate::base::{codegen_operand, codegen_place}; pub(crate) use crate::cast::*; pub(crate) use crate::common::*; pub(crate) use crate::debuginfo::{DebugContext, UnwindContext}; diff --git a/src/num.rs b/src/num.rs index b37826d71f4e0..41f4a9b9662bc 100644 --- a/src/num.rs +++ b/src/num.rs @@ -89,10 +89,10 @@ pub(crate) fn codegen_binop<'tcx>( } match in_lhs.layout().ty.kind() { - ty::Bool => crate::num::trans_bool_binop(fx, bin_op, in_lhs, in_rhs), - ty::Uint(_) | ty::Int(_) => crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs), - ty::Float(_) => crate::num::trans_float_binop(fx, bin_op, in_lhs, in_rhs), - ty::RawPtr(..) | ty::FnPtr(..) => crate::num::trans_ptr_binop(fx, bin_op, in_lhs, in_rhs), + ty::Bool => crate::num::codegen_bool_binop(fx, bin_op, in_lhs, in_rhs), + ty::Uint(_) | ty::Int(_) => crate::num::codegen_int_binop(fx, bin_op, in_lhs, in_rhs), + ty::Float(_) => crate::num::codegen_float_binop(fx, bin_op, in_lhs, in_rhs), + ty::RawPtr(..) | ty::FnPtr(..) => crate::num::codegen_ptr_binop(fx, bin_op, in_lhs, in_rhs), _ => unreachable!( "{:?}({:?}, {:?})", bin_op, @@ -102,7 +102,7 @@ pub(crate) fn codegen_binop<'tcx>( } } -pub(crate) fn trans_bool_binop<'tcx>( +pub(crate) fn codegen_bool_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -123,7 +123,7 @@ pub(crate) fn trans_bool_binop<'tcx>( CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)) } -pub(crate) fn trans_int_binop<'tcx>( +pub(crate) fn codegen_int_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -196,7 +196,7 @@ pub(crate) fn trans_int_binop<'tcx>( CValue::by_val(val, in_lhs.layout()) } -pub(crate) fn trans_checked_int_binop<'tcx>( +pub(crate) fn codegen_checked_int_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -357,7 +357,7 @@ pub(crate) fn trans_checked_int_binop<'tcx>( out_place.to_cvalue(fx) } -pub(crate) fn trans_float_binop<'tcx>( +pub(crate) fn codegen_float_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -402,7 +402,7 @@ pub(crate) fn trans_float_binop<'tcx>( CValue::by_val(res, in_lhs.layout()) } -pub(crate) fn trans_ptr_binop<'tcx>( +pub(crate) fn codegen_ptr_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, From c674c2c46c140e0e260dfe140ac941d3088e7139 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Nov 2020 14:45:41 +0100 Subject: [PATCH 14/39] Hide anonymous allocations from linked artifact --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index dbe2bb73a4f73..ce1d5ed2e6178 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -276,7 +276,7 @@ fn data_id_for_alloc_id( ) -> DataId { module .declare_data( - &format!("__alloc_{:x}", alloc_id.0), + &format!(".L__alloc_{:x}", alloc_id.0), Linkage::Local, mutability == rustc_hir::Mutability::Mut, false, From 8b9c2135d06ee0255d24b18efba8ef9cf92fb67f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Nov 2020 18:35:19 +0100 Subject: [PATCH 15/39] Fix transmutes between vectors and integers Fixes #1102 --- src/value_and_place.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 9a2470ba40d34..2b9ea5273b608 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -332,7 +332,7 @@ impl<'tcx> CPlace<'tcx> { let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, + size: u32::try_from(layout.size.bytes()).unwrap(), offset: None, }); CPlace { @@ -530,6 +530,13 @@ impl<'tcx> CPlace<'tcx> { dst_ty: Type, ) { let src_ty = fx.bcx.func.dfg.value_type(data); + assert_eq!( + src_ty.bytes(), + dst_ty.bytes(), + "write_cvalue_transmute: {:?} -> {:?}", + src_ty, + dst_ty, + ); let data = match (src_ty, dst_ty) { (_, _) if src_ty == dst_ty => data, @@ -541,6 +548,17 @@ impl<'tcx> CPlace<'tcx> { _ if src_ty.is_vector() && dst_ty.is_vector() => { fx.bcx.ins().raw_bitcast(dst_ty, data) } + _ if src_ty.is_vector() || dst_ty.is_vector() => { + // FIXME do something more efficient for transmutes between vectors and integers. + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: src_ty.bytes(), + offset: None, + }); + let ptr = Pointer::stack_slot(stack_slot); + ptr.store(fx, data, MemFlags::trusted()); + ptr.load(fx, dst_ty, MemFlags::trusted()) + } _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty), }; fx.bcx From c93d25b6af6849f726bc52332fb993e8d6898a00 Mon Sep 17 00:00:00 2001 From: Vishnunarayan K I Date: Mon, 2 Nov 2020 00:05:55 +0530 Subject: [PATCH 16/39] reverse binding order in matches ... ... to allow the subbinding of copyable fields in bindings after `@` Fixes #69971 --- .../src/build/matches/simplify.rs | 15 +- ...her-can-live-while-the-other-survives-1.rs | 4 +- ...can-live-while-the-other-survives-1.stderr | 36 +- .../bind-by-move-no-subbindings-fun-param.rs | 2 +- ...nd-by-move-no-subbindings-fun-param.stderr | 13 +- .../borrowck-move-and-move.rs | 12 +- .../borrowck-move-and-move.stderr | 110 +++--- .../borrowck-pat-at-and-box.rs | 16 +- .../borrowck-pat-at-and-box.stderr | 120 +++---- .../borrowck-pat-by-move-and-ref-inverse.rs | 28 +- ...orrowck-pat-by-move-and-ref-inverse.stderr | 313 ++++-------------- .../borrowck-pat-by-move-and-ref.rs | 14 + .../borrowck-pat-by-move-and-ref.stderr | 222 +++++++++++-- .../borrowck-pat-ref-mut-and-ref.rs | 23 +- .../borrowck-pat-ref-mut-and-ref.stderr | 208 +++++++----- .../borrowck-pat-ref-mut-twice.rs | 15 +- .../borrowck-pat-ref-mut-twice.stderr | 144 +++----- .../bindings-after-at/copy-and-move-mixed.rs | 6 +- .../copy-and-move-mixed.stderr | 32 +- ...lt-binding-modes-both-sides-independent.rs | 2 +- ...inding-modes-both-sides-independent.stderr | 15 +- 21 files changed, 641 insertions(+), 709 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index e46274770be17..296051b173e5a 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -131,7 +131,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } PatKind::Binding { name, mutability, mode, var, ty, ref subpattern, is_primary: _ } => { - candidate.bindings.push(Binding { + // issue #69971: the binding order should be right to left if there are more + // bindings after `@` to please the borrow checker + // Ex + // struct NonCopyStruct { + // copy_field: u32, + // } + // + // fn foo1(x: NonCopyStruct) { + // let y @ NonCopyStruct { copy_field: z } = x; + // // the above should turn into + // let z = x.copy_field; + // let y = x; + // } + candidate.bindings.insert(0, Binding { name, mutability, span: match_pair.pattern.span, diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs index ba9543bf73869..71503ecf2622b 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs @@ -12,6 +12,7 @@ fn main() { let x = Some(X { x: () }); match x { Some(ref _y @ _z) => {} //~ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value None => panic!(), } @@ -19,13 +20,13 @@ fn main() { match x { Some(_z @ ref _y) => {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value None => panic!(), } let mut x = Some(X { x: () }); match x { Some(ref mut _y @ _z) => {} //~ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value None => panic!(), } @@ -33,7 +34,6 @@ fn main() { match x { Some(_z @ ref mut _y) => {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value None => panic!(), } } diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr index 44dbcb9a75466..e50ae3e7eebd3 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr @@ -8,7 +8,7 @@ LL | Some(ref _y @ _z) => {} | value borrowed, by `_y`, here error: borrow of moved value - --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:20:14 + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:21:14 | LL | Some(_z @ ref _y) => {} | --^^^------ @@ -27,7 +27,7 @@ LL | Some(ref mut _y @ _z) => {} | value borrowed, by `_y`, here error: borrow of moved value - --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:34:14 + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:35:14 | LL | Some(_z @ ref mut _y) => {} | --^^^---------- @@ -37,34 +37,34 @@ LL | Some(_z @ ref mut _y) => {} | move occurs because `_z` has type `X` which does not implement the `Copy` trait error[E0382]: borrow of moved value - --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:20:19 + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:14:14 | -LL | Some(_z @ ref _y) => {} - | -----^^^^^^ - | | | - | | value borrowed here after move - | value moved here +LL | Some(ref _y @ _z) => {} + | ^^^^^^^^^-- + | | | + | | value moved here + | value borrowed here after move | = note: move occurs because value has type `X`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving `x.0` | -LL | Some(ref _z @ ref _y) => {} - | ^^^ +LL | Some(ref _y @ ref _z) => {} + | ^^^ error[E0382]: borrow of moved value - --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:34:19 + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:28:14 | -LL | Some(_z @ ref mut _y) => {} - | -----^^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here +LL | Some(ref mut _y @ _z) => {} + | ^^^^^^^^^^^^^-- + | | | + | | value moved here + | value borrowed here after move | = note: move occurs because value has type `X`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving `x.0` | -LL | Some(ref _z @ ref mut _y) => {} - | ^^^ +LL | Some(ref mut _y @ ref _z) => {} + | ^^^ error: aborting due to 6 previous errors diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.rs b/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.rs index 3ab6f40725cfb..08240db4472ed 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.rs +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.rs @@ -7,7 +7,7 @@ fn main() {} struct A(Box); fn f(a @ A(u): A) -> Box { - //~^ ERROR use of moved value + //~^ ERROR use of partially moved value drop(a); u } diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr b/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr index f25d5a2d9b82d..a77b866d8373d 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-no-subbindings-fun-param.stderr @@ -1,12 +1,13 @@ -error[E0382]: use of moved value - --> $DIR/bind-by-move-no-subbindings-fun-param.rs:9:12 +error[E0382]: use of partially moved value + --> $DIR/bind-by-move-no-subbindings-fun-param.rs:9:6 | LL | fn f(a @ A(u): A) -> Box { - | ------^- + | ^^^^^^-^ | | | - | | value used here after move - | value moved here - | move occurs because value has type `A`, which does not implement the `Copy` trait + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `Box`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs index d014c9828da2a..83f9b82b242a6 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs @@ -12,22 +12,22 @@ fn main() { let a @ b = U; //~ ERROR use of moved value - let a @ (b, c) = (U, U); //~ ERROR use of moved value + let a @ (b, c) = (U, U); //~ ERROR use of partially moved value - let a @ (b, c) = (u(), u()); //~ ERROR use of moved value + let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value match Ok(U) { - a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of moved value - //~^ ERROR use of moved value + a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of partially moved value + //~^ ERROR use of partially moved value } fn fun(a @ b: U) {} //~ ERROR use of moved value match [u(), u(), u(), u()] { - xs @ [a, .., b] => {} //~ ERROR use of moved value + xs @ [a, .., b] => {} //~ ERROR use of partially moved value } match [u(), u(), u(), u()] { - xs @ [_, ys @ .., _] => {} //~ ERROR use of moved value + xs @ [_, ys @ .., _] => {} //~ ERROR use of partially moved value } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr index 5039f580ff6ea..b9be896882360 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr @@ -1,82 +1,94 @@ error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:13:13 + --> $DIR/borrowck-move-and-move.rs:13:9 | LL | let a @ b = U; - | ----^ - move occurs because value has type `U`, which does not implement the `Copy` trait + | ^^^^- - move occurs because value has type `U`, which does not implement the `Copy` trait | | | - | | value used here after move - | value moved here + | | value moved here + | value used here after move -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:15:17 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:15:9 | LL | let a @ (b, c) = (U, U); - | --------^- ------ move occurs because value has type `(U, U)`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here + | ^^^^^-^^^^ + | | | + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:17:17 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:17:9 | LL | let a @ (b, c) = (u(), u()); - | --------^- ---------- move occurs because value has type `(U, U)`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here + | ^^^^^-^^^^ + | | | + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:20:16 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:20:9 | -LL | match Ok(U) { - | ----- move occurs because value has type `std::result::Result`, which does not implement the `Copy` trait LL | a @ Ok(b) | a @ Err(b) => {} - | -------^- + | ^^^^^^^-^ | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | a @ Ok(ref b) | a @ Err(b) => {} + | ^^^ -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:20:29 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:20:21 | -LL | match Ok(U) { - | ----- move occurs because value has type `std::result::Result`, which does not implement the `Copy` trait LL | a @ Ok(b) | a @ Err(b) => {} - | --------^- + | ^^^^^^^^-^ | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | a @ Ok(b) | a @ Err(ref b) => {} + | ^^^ -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:27:22 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:27:9 | -LL | match [u(), u(), u(), u()] { - | -------------------- move occurs because value has type `[U; 4]`, which does not implement the `Copy` trait LL | xs @ [a, .., b] => {} - | -------------^- - | | | - | | value used here after move - | value moved here + | ^^^^^^-^^^^^^^^ + | | | + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:31:18 +error[E0382]: use of partially moved value + --> $DIR/borrowck-move-and-move.rs:31:9 | -LL | match [u(), u(), u(), u()] { - | -------------------- move occurs because value has type `[U; 4]`, which does not implement the `Copy` trait LL | xs @ [_, ys @ .., _] => {} - | ---------^^^^^^^---- + | ^^^^^^^^^-------^^^^ | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait error[E0382]: use of moved value - --> $DIR/borrowck-move-and-move.rs:24:16 + --> $DIR/borrowck-move-and-move.rs:24:12 | LL | fn fun(a @ b: U) {} - | ----^ + | ^^^^- | | | - | | value used here after move - | value moved here + | | value moved here + | value used here after move | move occurs because value has type `U`, which does not implement the `Copy` trait error: aborting due to 8 previous errors diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.rs index 236710ed85493..07fac1d363133 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.rs @@ -18,22 +18,19 @@ fn nc() -> NC { fn main() { let a @ box &b = Box::new(&C); - //~^ ERROR use of moved value let a @ box b = Box::new(C); - //~^ ERROR use of moved value fn f1(a @ box &b: Box<&C>) {} - //~^ ERROR use of moved value fn f2(a @ box b: Box) {} - //~^ ERROR use of moved value match Box::new(C) { - a @ box b => {} //~ ERROR use of moved value + a @ box b => {} } let ref a @ box b = Box::new(NC); //~ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value let ref a @ box ref mut b = Box::new(nc()); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable @@ -41,22 +38,23 @@ fn main() { //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable let ref a @ box ref mut b = Box::new(NC); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = NC; let ref a @ box ref mut b = Box::new(NC); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = NC; drop(a); let ref mut a @ box ref b = Box::new(NC); //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *a = Box::new(NC); drop(b); fn f5(ref mut a @ box ref b: Box) { //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *a = Box::new(NC); drop(b); } @@ -64,7 +62,7 @@ fn main() { match Box::new(nc()) { ref mut a @ box ref b => { //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *a = Box::new(NC); drop(b); } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr index d9a8bbfb6b103..83da16a72a7ba 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr @@ -1,5 +1,5 @@ error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-at-and-box.rs:36:9 + --> $DIR/borrowck-pat-at-and-box.rs:32:9 | LL | let ref a @ box b = Box::new(NC); | -----^^^^^^^- @@ -8,7 +8,7 @@ LL | let ref a @ box b = Box::new(NC); | value borrowed, by `a`, here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:38:9 + --> $DIR/borrowck-pat-at-and-box.rs:35:9 | LL | let ref a @ box ref mut b = Box::new(nc()); | -----^^^^^^^--------- @@ -17,7 +17,7 @@ LL | let ref a @ box ref mut b = Box::new(nc()); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:40:9 + --> $DIR/borrowck-pat-at-and-box.rs:37:9 | LL | let ref a @ box ref mut b = Box::new(NC); | -----^^^^^^^--------- @@ -26,7 +26,7 @@ LL | let ref a @ box ref mut b = Box::new(NC); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:42:9 + --> $DIR/borrowck-pat-at-and-box.rs:39:9 | LL | let ref a @ box ref mut b = Box::new(NC); | -----^^^^^^^--------- @@ -35,7 +35,7 @@ LL | let ref a @ box ref mut b = Box::new(NC); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:45:9 + --> $DIR/borrowck-pat-at-and-box.rs:43:9 | LL | let ref a @ box ref mut b = Box::new(NC); | -----^^^^^^^--------- @@ -44,7 +44,7 @@ LL | let ref a @ box ref mut b = Box::new(NC); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:51:9 + --> $DIR/borrowck-pat-at-and-box.rs:49:9 | LL | let ref mut a @ box ref b = Box::new(NC); | ---------^^^^^^^----- @@ -53,7 +53,7 @@ LL | let ref mut a @ box ref b = Box::new(NC); | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:65:9 + --> $DIR/borrowck-pat-at-and-box.rs:63:9 | LL | ref mut a @ box ref b => { | ---------^^^^^^^----- @@ -62,7 +62,7 @@ LL | ref mut a @ box ref b => { | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:57:11 + --> $DIR/borrowck-pat-at-and-box.rs:55:11 | LL | fn f5(ref mut a @ box ref b: Box) { | ---------^^^^^^^----- @@ -70,104 +70,78 @@ LL | fn f5(ref mut a @ box ref b: Box) { | | immutable borrow, by `b`, occurs here | mutable borrow, by `a`, occurs here -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:20:18 +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-at-and-box.rs:32:9 | -LL | let a @ box &b = Box::new(&C); - | ---------^ ------------ move occurs because value has type `Box<&C>`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:23:17 +LL | let ref a @ box b = Box::new(NC); + | ^^^^^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move | -LL | let a @ box b = Box::new(C); - | --------^ ----------- move occurs because value has type `Box`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here + = note: move occurs because value has type `NC`, which does not implement the `Copy` trait -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:33:17 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-at-and-box.rs:39:9 | -LL | match Box::new(C) { - | ----------- move occurs because value has type `Box`, which does not implement the `Copy` trait -LL | a @ box b => {} - | --------^ - | | | - | | value used here after move - | value moved here +LL | let ref a @ box ref mut b = Box::new(NC); + | ^^^^^^^^^^^^--------- + | | | + | | mutable borrow occurs here + | immutable borrow occurs here +... +LL | *b = NC; + | ------- mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-at-and-box.rs:45:21 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-at-and-box.rs:43:9 | LL | let ref a @ box ref mut b = Box::new(NC); - | ------------^^^^^^^^^ + | ^^^^^^^^^^^^--------- | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = NC; + | ------- mutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:51:25 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-at-and-box.rs:49:9 | LL | let ref mut a @ box ref b = Box::new(NC); - | ----------------^^^^^ + | ^^^^^^^^^^^^^^^^----- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | *a = Box::new(NC); - | -- mutable borrow later used here +LL | drop(b); + | - immutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:65:25 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-at-and-box.rs:63:9 | LL | ref mut a @ box ref b => { - | ----------------^^^^^ + | ^^^^^^^^^^^^^^^^----- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | *a = Box::new(NC); - | -- mutable borrow later used here +LL | drop(b); + | - immutable borrow later used here -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:26:20 - | -LL | fn f1(a @ box &b: Box<&C>) {} - | ---------^ - | | | - | | value used here after move - | value moved here - | move occurs because value has type `Box<&C>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-at-and-box.rs:29:19 - | -LL | fn f2(a @ box b: Box) {} - | --------^ - | | | - | | value used here after move - | value moved here - | move occurs because value has type `Box`, which does not implement the `Copy` trait - -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:57:27 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-at-and-box.rs:55:11 | LL | fn f5(ref mut a @ box ref b: Box) { - | ----------------^^^^^ + | ^^^^^^^^^^^^^^^^----- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | *a = Box::new(NC); - | -- mutable borrow later used here +LL | drop(b); + | - immutable borrow later used here -error: aborting due to 17 previous errors +error: aborting due to 14 previous errors Some errors have detailed explanations: E0382, E0502. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs index 3e5a543c4c36a..e75ff78abd7cc 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs @@ -12,18 +12,14 @@ fn main() { fn f1(a @ ref b: U) {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR use of moved value + //~| ERROR use of partially moved value fn f3(a @ [ref mut b, ref c]: [U; 2]) {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ ref b = U; //~^ ERROR borrow of moved value @@ -31,25 +27,18 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR use of moved value + //~| ERROR use of partially moved value let a @ [ref mut b, ref c] = [U, U]; //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ ref b = u(); //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR use of moved value + //~| ERROR use of partially moved value let a @ [ref mut b, ref c] = [u(), u()]; //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value match Some(U) { a @ Some(ref b) => {} @@ -61,21 +50,17 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR use of moved value + //~| ERROR use of partially moved value None => {} } match Some([U, U]) { mut a @ Some([ref b, ref mut c]) => {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value None => {} } match Some(u()) { a @ Some(ref b) => {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value None => {} } match Some((u(), u())) { @@ -83,15 +68,12 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR borrow of moved value - //~| ERROR use of moved value + //~| ERROR use of partially moved value None => {} } match Some([u(), u()]) { mut a @ Some([ref b, ref mut c]) => {} //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value None => {} } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index 282031aeb0754..4a126a2219246 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -1,5 +1,5 @@ error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:28:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9 | LL | let a @ ref b = U; | -^^^----- @@ -9,7 +9,7 @@ LL | let a @ ref b = U; | move occurs because `a` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | -^^^^^^^^^^^^---------^^^^^^-----^ @@ -20,7 +20,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:14 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:14 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | -----^^^--------- @@ -30,7 +30,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:33 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:33 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | -^^^----- @@ -40,7 +40,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:37:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9 | LL | let a @ [ref mut b, ref c] = [U, U]; | -^^^^---------^^-----^ @@ -51,7 +51,7 @@ LL | let a @ [ref mut b, ref c] = [U, U]; | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:40:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9 | LL | let a @ ref b = u(); | -^^^----- @@ -61,7 +61,7 @@ LL | let a @ ref b = u(); | move occurs because `a` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | -^^^^^^^^^^^^---------^^^^^^-----^ @@ -72,7 +72,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:14 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:14 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | -----^^^--------- @@ -82,7 +82,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:33 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:33 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | -^^^----- @@ -92,7 +92,7 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:50:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:40:9 | LL | let a @ [ref mut b, ref c] = [u(), u()]; | -^^^^---------^^-----^ @@ -103,7 +103,7 @@ LL | let a @ [ref mut b, ref c] = [u(), u()]; | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:44:9 | LL | a @ Some(ref b) => {} | -^^^^^^^^-----^ @@ -113,7 +113,7 @@ LL | a @ Some(ref b) => {} | move occurs because `a` has type `Option` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^ @@ -124,7 +124,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:19 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:19 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -----^^^--------- @@ -134,7 +134,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:38 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:38 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^----- @@ -144,7 +144,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:70:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:57:9 | LL | mut a @ Some([ref b, ref mut c]) => {} | -----^^^^^^^^^-----^^---------^^ @@ -155,7 +155,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:76:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:62:9 | LL | a @ Some(ref b) => {} | -^^^^^^^^-----^ @@ -165,7 +165,7 @@ LL | a @ Some(ref b) => {} | move occurs because `a` has type `Option` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^ @@ -176,7 +176,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:19 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -----^^^--------- @@ -186,7 +186,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:38 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^----- @@ -196,7 +196,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:92:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:9 | LL | mut a @ Some([ref b, ref mut c]) => {} | -----^^^^^^^^^-----^^---------^^ @@ -217,7 +217,7 @@ LL | fn f1(a @ ref b: U) {} | move occurs because `a` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:11 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:11 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | -----^^^^^^^^-----^^^^^^^^^^-----^ @@ -228,7 +228,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:20 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:20 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | -^^^----- @@ -238,7 +238,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:31 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:31 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | -----^^^----- @@ -248,7 +248,7 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:11 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:21:11 | LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} | -^^^^---------^^-----^ @@ -258,262 +258,69 @@ LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:22 - | -LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | --------^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:33 - | -LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | ------------------------^^^^^^^^^- ------ move occurs because value has type `(U, U)`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:30:37 +error[E0382]: use of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:37:25 - | -LL | let a @ [ref mut b, ref c] = [U, U]; - | ----------------^^^^^- ------ move occurs because value has type `[U; 2]`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:40:13 - | -LL | let a @ ref b = u(); - | ----^^^^^ --- move occurs because value has type `U`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:22 + | ^^^^^-----------------^^^^^^^^^^^^ + | | | + | | value partially moved here + | value used here after partial move | -LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | --------^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:33 - | -LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | ------------------------^^^^^^^^^- ---------- move occurs because value has type `(U, U)`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:43:37 +error[E0382]: use of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here + | ^^^^^-----------------^^^^^^^^^^^^ + | | | + | | value partially moved here + | value used here after partial move | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:50:25 - | -LL | let a @ [ref mut b, ref c] = [u(), u()]; - | ----------------^^^^^- ---------- move occurs because value has type `[U; 2]`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:27 +error[E0382]: use of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | --------^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here + | ^^^^^^^^^^-----------------^^^^^^^^^^^^^ + | | | + | | value partially moved here + | value used here after partial move | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving the value | LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} | ^^^ -error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:38 +error[E0382]: use of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 | -LL | match Some((U, U)) { - | ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | -----------------------------^^^^^^^^^-- - | | | - | | value used here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:60:42 + | ^^^^^^^^^^-----------------^^^^^^^^^^^^^ + | | | + | | value partially moved here + | value used here after partial move | -LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} - | ^^^ - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:70:30 - | -LL | match Some([U, U]) { - | ------------ move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait -LL | mut a @ Some([ref b, ref mut c]) => {} - | ---------------------^^^^^^^^^-- - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:76:18 - | -LL | match Some(u()) { - | --------- move occurs because value has type `Option`, which does not implement the `Copy` trait -LL | a @ Some(ref b) => {} - | ---------^^^^^- - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:27 - | -LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | --------^^^^^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving the value | LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} | ^^^ -error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:38 - | -LL | match Some((u(), u())) { - | ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait -LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | -----------------------------^^^^^^^^^-- - | | | - | | value used here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:82:42 - | -LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} - | ^^^ - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:92:30 - | -LL | match Some([u(), u()]) { - | ---------------- move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait -LL | mut a @ Some([ref b, ref mut c]) => {} - | ---------------------^^^^^^^^^-- - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:13:15 - | -LL | fn f1(a @ ref b: U) {} - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:24 - | -LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | ----^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: use of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:31 +error[E0382]: use of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:11 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | --------------------^^^^^^^^^^^^^- - | | | - | | value used here after move - | value moved here - | move occurs because value has type `(U, U)`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:17:39 + | ^^^^^^^^^---------^^^^^^^^^^^^^^^^ + | | | + | | value partially moved here + | value used here after partial move | -LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | --------^^^^^ - | | | - | | value borrowed here after move - | value moved here - | - = note: move occurs because value has type `U`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:27 - | -LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} - | ----------------^^^^^- - | | | - | | value borrowed here after move - | value moved here - | move occurs because value has type `[U; 2]`, which does not implement the `Copy` trait + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 48 previous errors +error: aborting due to 30 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs index 42c3290ddfbb2..691d0a32fa88f 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs @@ -12,12 +12,16 @@ fn main() { fn f1(ref a @ b: U) {} //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} //~^ ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value + //~| ERROR borrow of moved value fn f3(ref mut a @ [b, mut c]: [U; 2]) {} //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value let ref a @ b = U; //~^ ERROR cannot move out of value because it is borrowed @@ -27,14 +31,19 @@ fn main() { //~| ERROR cannot move out of value because it is borrowed let ref mut a @ [b, mut c] = [U, U]; //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value let ref a @ b = u(); //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); //~^ ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value + //~| ERROR borrow of moved value let ref mut a @ [b, mut c] = [u(), u()]; //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value match Some(U) { ref a @ Some(b) => {} @@ -51,11 +60,13 @@ fn main() { match Some([U, U]) { ref mut a @ Some([b, mut c]) => {} //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value None => {} } match Some(u()) { ref a @ Some(b) => {} //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value None => {} } match Some((u(), u())) { @@ -63,11 +74,14 @@ fn main() { //~^ ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value + //~| ERROR borrow of moved value None => {} } match Some([u(), u()]) { ref mut a @ Some([b, mut c]) => {} //~^ ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of partially moved value None => {} } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index a275705b19332..9113821d746ef 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -1,5 +1,5 @@ error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:22:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:26:9 | LL | let ref a @ b = U; | -----^^^- @@ -8,7 +8,7 @@ LL | let ref a @ b = U; | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:24:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:28:9 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ @@ -18,7 +18,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:24:18 + --> $DIR/borrowck-pat-by-move-and-ref.rs:28:18 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | -----^^^----- @@ -27,7 +27,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:24:33 + --> $DIR/borrowck-pat-by-move-and-ref.rs:28:33 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | -----^^^- @@ -36,7 +36,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:28:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:32:9 | LL | let ref mut a @ [b, mut c] = [U, U]; | ---------^^^^-^^-----^ @@ -46,7 +46,7 @@ LL | let ref mut a @ [b, mut c] = [U, U]; | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:30:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:35:9 | LL | let ref a @ b = u(); | -----^^^- @@ -55,7 +55,7 @@ LL | let ref a @ b = u(); | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:32:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:9 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ @@ -65,7 +65,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:32:18 + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:18 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | -----^^^----- @@ -74,7 +74,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:32:33 + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:33 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | -----^^^- @@ -83,7 +83,7 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:36:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:44:9 | LL | let ref mut a @ [b, mut c] = [u(), u()]; | ---------^^^^-^^-----^ @@ -93,7 +93,7 @@ LL | let ref mut a @ [b, mut c] = [u(), u()]; | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:40:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:49:9 | LL | ref a @ Some(b) => {} | -----^^^^^^^^-^ @@ -102,7 +102,7 @@ LL | ref a @ Some(b) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:45:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:54:9 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^ @@ -112,7 +112,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:45:23 + --> $DIR/borrowck-pat-by-move-and-ref.rs:54:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^----- @@ -121,7 +121,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:45:38 + --> $DIR/borrowck-pat-by-move-and-ref.rs:54:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^- @@ -130,7 +130,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:52:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:61:9 | LL | ref mut a @ Some([b, mut c]) => {} | ---------^^^^^^^^^-^^-----^^ @@ -140,7 +140,7 @@ LL | ref mut a @ Some([b, mut c]) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:57:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9 | LL | ref a @ Some(b) => {} | -----^^^^^^^^-^ @@ -149,7 +149,7 @@ LL | ref a @ Some(b) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:62:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:73:9 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^ @@ -159,7 +159,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:62:23 + --> $DIR/borrowck-pat-by-move-and-ref.rs:73:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^----- @@ -168,7 +168,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:62:38 + --> $DIR/borrowck-pat-by-move-and-ref.rs:73:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^- @@ -177,7 +177,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:69:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9 | LL | ref mut a @ Some([b, mut c]) => {} | ---------^^^^^^^^^-^^-----^^ @@ -196,7 +196,7 @@ LL | fn f1(ref a @ b: U) {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:15:11 + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:11 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ @@ -206,7 +206,7 @@ LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:15:20 + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:20 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | -----^^^----- @@ -215,7 +215,7 @@ LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:15:35 + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:35 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | -----^^^- @@ -224,7 +224,7 @@ LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:19:11 + --> $DIR/borrowck-pat-by-move-and-ref.rs:22:11 | LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} | ---------^^^^-^^-----^ @@ -233,5 +233,177 @@ LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} | | value moved into `b` here | value borrowed, by `a`, here -error: aborting due to 25 previous errors +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:32:9 + | +LL | let ref mut a @ [b, mut c] = [U, U]; + | ^^^^^^^^^^^^^-^^^^^^^^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:35:9 + | +LL | let ref a @ b = u(); + | ^^^^^^^^- --- move occurs because value has type `U`, which does not implement the `Copy` trait + | | | + | | value moved here + | value borrowed here after move + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:18 + | +LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); + | ^^^^^^^^----- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:38:33 + | +LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); + | ^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:44:9 + | +LL | let ref mut a @ [b, mut c] = [u(), u()]; + | ^^^^^^^^^^^^^-^^^^^^^^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:61:9 + | +LL | ref mut a @ Some([b, mut c]) => {} + | ^^^^^^^^^^^^^^^^^^-^^^^^^^^^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | ref mut a @ Some([ref b, mut c]) => {} + | ^^^ + +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9 + | +LL | ref a @ Some(b) => {} + | ^^^^^^^^^^^^^-^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | ref a @ Some(ref b) => {} + | ^^^ + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:73:23 + | +LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} + | ^^^^^^^^----- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | ref a @ Some((ref b @ ref mut c, ref d @ e)) => {} + | ^^^ + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:73:38 + | +LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} + | ^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {} + | ^^^ + +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9 + | +LL | ref mut a @ Some([b, mut c]) => {} + | ^^^^^^^^^^^^^^^^^^-^^^^^^^^^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this field in the pattern to avoid moving the value + | +LL | ref mut a @ Some([ref b, mut c]) => {} + | ^^^ + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:13:11 + | +LL | fn f1(ref a @ b: U) {} + | ^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move + | move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:20 + | +LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} + | ^^^^^^^^----- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:16:35 + | +LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} + | ^^^^^^^^- + | | | + | | value moved here + | value borrowed here after move + | + = note: move occurs because value has type `U`, which does not implement the `Copy` trait + +error[E0382]: borrow of partially moved value + --> $DIR/borrowck-pat-by-move-and-ref.rs:22:11 + | +LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} + | ^^^^^^^^^^^^^-^^^^^^^^ + | | | + | | value partially moved here + | value borrowed here after partial move + | + = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait + +error: aborting due to 39 previous errors +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs index f67cd45ca95ab..f543eaece8020 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs @@ -9,7 +9,7 @@ fn main() { match &mut Some(1) { ref mut z @ &mut Some(ref a) => { //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable **z = None; println!("{}", *a); } @@ -30,6 +30,7 @@ fn main() { fn f4_also_moved(ref a @ ref mut b @ c: U) {} //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub //~^ ERROR cannot borrow value as mutable more than once at a time @@ -46,12 +47,12 @@ fn main() { let ref mut a @ ref b = u(); //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *a = u(); drop(b); let ref a @ ref mut b = u(); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = u(); drop(a); @@ -77,8 +78,8 @@ fn main() { ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = U; drop(a); } @@ -89,6 +90,8 @@ fn main() { //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot assign to `*b`, as it is immutable for the pattern guard + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable _ => {} } match Ok(U) { @@ -102,6 +105,8 @@ fn main() { ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable //~| ERROR cannot move out of `b` in pattern guard //~| ERROR cannot move out of `b` in pattern guard _ => {} @@ -117,20 +122,20 @@ fn main() { let ref a @ (ref mut b, ref mut c) = (U, U); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = U; *c = U; let ref a @ (ref mut b, ref mut c) = (U, U); //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = U; drop(a); let ref a @ (ref mut b, ref mut c) = (U, U); - //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable *b = U; //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable - *c = U; //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + *c = U; drop(a); let ref mut a @ (ref b, ref c) = (U, U); //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index e6231dd49bade..d9b59504419ac 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -8,7 +8,7 @@ LL | ref mut z @ &mut Some(ref a) => { | mutable borrow, by `z`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:34:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:35:9 | LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub | ---------^^^^-----------------^ @@ -18,7 +18,7 @@ LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:34:22 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:35:22 | LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub | -----^^^--------- @@ -27,7 +27,7 @@ LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub | immutable borrow, by `b`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:38:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:39:9 | LL | let ref a @ ref mut b = U; | -----^^^--------- @@ -36,7 +36,7 @@ LL | let ref a @ ref mut b = U; | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:40:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:41:9 | LL | let ref mut a @ ref b = U; | ---------^^^----- @@ -45,7 +45,7 @@ LL | let ref mut a @ ref b = U; | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:42:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:43:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -55,7 +55,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:44:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:45:9 | LL | let ref mut a @ (ref b, ref c) = (U, U); | ---------^^^^-----^^-----^ @@ -65,7 +65,7 @@ LL | let ref mut a @ (ref b, ref c) = (U, U); | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:47:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:48:9 | LL | let ref mut a @ ref b = u(); | ---------^^^----- @@ -74,7 +74,7 @@ LL | let ref mut a @ ref b = u(); | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:52:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:53:9 | LL | let ref a @ ref mut b = u(); | -----^^^--------- @@ -83,7 +83,7 @@ LL | let ref a @ ref mut b = u(); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:58:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:59:9 | LL | let ref mut a @ ref b = U; | ---------^^^----- @@ -92,7 +92,7 @@ LL | let ref mut a @ ref b = U; | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:62:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:63:9 | LL | let ref a @ ref mut b = U; | -----^^^--------- @@ -101,7 +101,7 @@ LL | let ref a @ ref mut b = U; | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:68:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:69:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { | ---------^^^^^^-----^ @@ -110,7 +110,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:68:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:69:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { | ---------^^^^^^^-----^ @@ -119,7 +119,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:77:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | -----^^^^^^---------^ @@ -128,7 +128,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:77:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | -----^^^^^^^---------^ @@ -137,7 +137,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:88:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} | -----^^^^^^---------^ @@ -146,7 +146,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:88:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} | -----^^^^^^^---------^ @@ -155,7 +155,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:95:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ---------^^^^^^-----^ @@ -164,7 +164,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:95:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ---------^^^^^^^-----^ @@ -173,7 +173,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:102:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | -----^^^^^^---------^ @@ -182,7 +182,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:102:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | -----^^^^^^^---------^ @@ -191,7 +191,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:110:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ---------^^^^^^-----^ @@ -200,7 +200,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:110:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ---------^^^^^^^-----^ @@ -209,7 +209,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:118:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -219,7 +219,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -229,7 +229,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:130:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -239,7 +239,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:140:9 | LL | let ref mut a @ (ref b, ref c) = (U, U); | ---------^^^^-----^^-----^ @@ -294,68 +294,86 @@ LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} | | value moved into `c` here | value borrowed, by `b`, here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:31 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:9 | LL | ref mut z @ &mut Some(ref a) => { - | ----------------------^^^^^- + | ^^^^^^^^^^^^^^^^^^^^^^-----^ | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | **z = None; - | ---------- mutable borrow later used here +LL | println!("{}", *a); + | -- immutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:47:21 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:48:9 | LL | let ref mut a @ ref b = u(); - | ------------^^^^^ + | ^^^^^^^^^^^^----- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | *a = u(); - | -------- mutable borrow later used here +LL | drop(b); + | - immutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:52:17 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:53:9 | LL | let ref a @ ref mut b = u(); - | --------^^^^^^^^^ + | ^^^^^^^^--------- | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = u(); + | -------- mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:77:20 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { - | -----------^^^^^^^^^- + | ^^^^^^^^^^^---------^ | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = U; + | ------ mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:77:45 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { - | ------------^^^^^^^^^- + | ^^^^^^^^^^^^---------^ | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = U; + | ------ mutable borrow later used here + +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:9 + | +LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} + | ^^^^^^^^^^^---------^ ------ mutable borrow later used here + | | | + | | mutable borrow occurs here + | immutable borrow occurs here + +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:33 + | +LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} + | ^^^^^^^^^^^^---------^ ------ mutable borrow later used here + | | | + | | mutable borrow occurs here + | immutable borrow occurs here error[E0594]: cannot assign to `*b`, as it is immutable for the pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:88:61 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:61 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} | ^^^^^^ cannot assign @@ -363,15 +381,33 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } = note: variables bound in patterns are immutable until the end of the pattern guard error[E0594]: cannot assign to `*a`, as it is immutable for the pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:95:61 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:61 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ^^^^^^^^^^^ cannot assign | = note: variables bound in patterns are immutable until the end of the pattern guard +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:9 + | +LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} + | ^^^^^^^^^^^---------^ - mutable borrow later used here + | | | + | | mutable borrow occurs here + | immutable borrow occurs here + +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:33 + | +LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} + | ^^^^^^^^^^^^---------^ - mutable borrow later used here + | | | + | | mutable borrow occurs here + | immutable borrow occurs here + error[E0507]: cannot move out of `b` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:102:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:66 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait @@ -379,7 +415,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `b` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:102:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:66 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait @@ -387,7 +423,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `a` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:110:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ^ move occurs because `a` has type `&mut std::result::Result`, which does not implement the `Copy` trait @@ -395,62 +431,60 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `a` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:110:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ^ move occurs because `a` has type `&mut std::result::Result`, which does not implement the `Copy` trait | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:18 - | -LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | ---------^^^^^^^^^------------ - | | | - | | mutable borrow occurs here - | immutable borrow occurs here -... -LL | drop(a); - | - immutable borrow later used here - -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:29 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | --------------------^^^^^^^^^- + | ^^^^^^^^^^^^^^^^^^^^---------^ | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *c = U; + | ------ mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:130:18 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | ---------^^^^^^^^^------------ + | ^^^^^^^^^---------^^^^^^^^^^^^ | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *b = U; + | ------ mutable borrow later used here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:130:29 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | --------------------^^^^^^^^^- + | ^^^^^^^^^^^^^^^^^^^^---------^ | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | drop(a); - | - immutable borrow later used here +LL | *c = U; + | ------ mutable borrow later used here + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:30:30 + | +LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} + | --------^^^^^^^^^^^^- + | | | | + | | | value moved here + | | value borrowed here after move + | move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 47 previous errors +error: aborting due to 51 previous errors -Some errors have detailed explanations: E0502, E0507, E0594. -For more information about an error, try `rustc --explain E0502`. +Some errors have detailed explanations: E0382, E0502, E0507, E0594. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs index 8faaa1c881fbf..c58f041349931 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs @@ -23,23 +23,24 @@ fn main() { fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} //~^ ERROR cannot borrow value as mutable more than once at a time //~| ERROR cannot move out of value because it is borrowed + //~| ERROR borrow of moved value let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time drop(a); let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time drop(b); let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time *a = U; let ref mut a @ ref mut b = U; //~^ ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time *b = U; let ref mut a @ ( @@ -64,18 +65,14 @@ fn main() { let a @ (ref mut b, ref mut c) = (U, U); //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let mut val = (U, [U, U]); let a @ (b, [c, d]) = &mut val; // Same as ^-- //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ &mut ref mut b = &mut U; //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value let a @ &mut (ref mut b, ref mut c) = &mut (U, U); //~^ ERROR borrow of moved value - //~| ERROR borrow of moved value match Ok(U) { ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { @@ -87,6 +84,8 @@ fn main() { ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { //~^ ERROR cannot borrow value as mutable more than once at a time //~| ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time *b = U; } } @@ -94,8 +93,6 @@ fn main() { ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { //~^ ERROR cannot borrow value as mutable more than once at a time //~| ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time *a = Err(U); // FIXME: The binding name value used above makes for problematic diagnostics. @@ -106,8 +103,6 @@ fn main() { ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { //~^ ERROR cannot borrow value as mutable more than once at a time //~| ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time drop(a); } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr index 2e0f5fcabddf3..5ae71c2a9fd31 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr @@ -1,5 +1,5 @@ error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:27:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:28:9 | LL | let ref mut a @ ref mut b = U; | ---------^^^--------- @@ -17,7 +17,7 @@ LL | let ref mut a @ ref mut b = U; | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:34:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:35:9 | LL | let ref mut a @ ref mut b = U; | ---------^^^--------- @@ -26,7 +26,7 @@ LL | let ref mut a @ ref mut b = U; | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:37:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:38:9 | LL | let ref mut a @ ref mut b = U; | ---------^^^--------- @@ -44,7 +44,7 @@ LL | let ref mut a @ ref mut b = U; | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:45:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:46:9 | LL | let ref mut a @ ( | ^-------- @@ -66,7 +66,7 @@ LL | | ) = (U, [U, U, U]); | |_____^ error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:55:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:56:9 | LL | let ref mut a @ ( | ^-------- @@ -88,7 +88,7 @@ LL | | ) = (u(), [u(), u(), u()]); | |_________^ error: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:65:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:66:9 | LL | let a @ (ref mut b, ref mut c) = (U, U); | -^^^^---------^^---------^ @@ -111,7 +111,7 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^-- | move occurs because `a` has type `&mut (U, [U; 2])` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:73:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:72:9 | LL | let a @ &mut ref mut b = &mut U; | -^^^^^^^^--------- @@ -121,7 +121,7 @@ LL | let a @ &mut ref mut b = &mut U; | move occurs because `a` has type `&mut U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:76:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:74:9 | LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); | -^^^^^^^^^---------^^---------^ @@ -132,7 +132,7 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); | move occurs because `a` has type `&mut (U, U)` which does not implement the `Copy` trait error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:81:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:78:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -141,7 +141,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:81:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:78:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -150,7 +150,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:87:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:84:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -159,7 +159,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:87:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:84:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -168,7 +168,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:94:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:93:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -177,7 +177,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:94:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:93:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -186,7 +186,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:106:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -195,7 +195,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:106:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -259,114 +259,64 @@ LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} | value borrowed, by `b`, here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:27:21 + --> $DIR/borrowck-pat-ref-mut-twice.rs:31:9 | LL | let ref mut a @ ref mut b = U; - | ------------^^^^^^^^^ + | ^^^^^^^^^^^^--------- | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here + | | first mutable borrow occurs here + | second mutable borrow occurs here ... -LL | drop(a); +LL | drop(b); | - first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:37:21 + --> $DIR/borrowck-pat-ref-mut-twice.rs:41:9 | LL | let ref mut a @ ref mut b = U; - | ------------^^^^^^^^^ + | ^^^^^^^^^^^^--------- | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here + | | first mutable borrow occurs here + | second mutable borrow occurs here ... -LL | *a = U; +LL | *b = U; | ------ first borrow later used here -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:65:25 - | -LL | let a @ (ref mut b, ref mut c) = (U, U); - | ----------------^^^^^^^^^- ------ move occurs because value has type `(U, U)`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:69:21 - | -LL | let a @ (b, [c, d]) = &mut val; // Same as ^-- - | ------------^-- -------- move occurs because value has type `&mut (U, [U; 2])`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:73:18 - | -LL | let a @ &mut ref mut b = &mut U; - | ---------^^^^^^^^^ ------ move occurs because value has type `&mut U`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - -error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-ref-mut-twice.rs:76:30 - | -LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); - | ---------------------^^^^^^^^^- ----------- move occurs because value has type `&mut (U, U)`, which does not implement the `Copy` trait - | | | - | | value borrowed here after move - | value moved here - error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:94:24 + --> $DIR/borrowck-pat-ref-mut-twice.rs:84:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------------^^^^^^^^^- + | ^^^^^^^^^^^^^^^---------^ | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here + | | first mutable borrow occurs here + | second mutable borrow occurs here ... -LL | *a = Err(U); - | ----------- first borrow later used here +LL | *b = U; + | ------ first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:94:53 + --> $DIR/borrowck-pat-ref-mut-twice.rs:84:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ----------------^^^^^^^^^- + | ^^^^^^^^^^^^^^^^---------^ | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here -... -LL | *a = Err(U); - | ----------- first borrow later used here - -error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:106:24 - | -LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------------^^^^^^^^^- - | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here + | | first mutable borrow occurs here + | second mutable borrow occurs here ... -LL | drop(a); - | - first borrow later used here +LL | *b = U; + | ------ first borrow later used here -error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:106:53 +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-ref-mut-twice.rs:23:34 | -LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ----------------^^^^^^^^^- - | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here -... -LL | drop(a); - | - first borrow later used here +LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} + | ------------^^^^^^^^^^^^- + | | | | + | | | value moved here + | | value borrowed here after move + | move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 34 previous errors +error: aborting due to 29 previous errors Some errors have detailed explanations: E0382, E0499. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs index 3954d17e1c2bc..1dc9716f54bef 100644 --- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs +++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs @@ -8,10 +8,6 @@ struct C; struct NC(A, B); fn main() { - let a @ NC(b, c) = NC(C, C); - //~^ ERROR use of moved value - let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); - //~^ ERROR use of moved value - //~| ERROR use of moved value + //~^ ERROR use of partially moved value } diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr index cc2786a13f4e8..9ffbadf36a61c 100644 --- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr +++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr @@ -1,32 +1,14 @@ -error[E0382]: use of moved value - --> $DIR/copy-and-move-mixed.rs:11:19 - | -LL | let a @ NC(b, c) = NC(C, C); - | ----------^- -------- move occurs because value has type `NC`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - -error[E0382]: use of moved value - --> $DIR/copy-and-move-mixed.rs:14:19 +error[E0382]: use of partially moved value + --> $DIR/copy-and-move-mixed.rs:11:9 | LL | let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); - | ----------^^^^^^^^^^^^- --------------- move occurs because value has type `NC>`, which does not implement the `Copy` trait + | ^^^^^^^^^^------------^ | | | - | | value used here after move - | value moved here - -error[E0382]: use of moved value - --> $DIR/copy-and-move-mixed.rs:14:29 - | -LL | let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); - | ----------^- - | | | - | | value used here after move - | value moved here + | | value partially moved here + | value used here after partial move | - = note: move occurs because value has type `NC`, which does not implement the `Copy` trait + = note: partial move occurs because value has type `NC`, which does not implement the `Copy` trait -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.rs b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.rs index 276088b9a9ee9..c15167e717592 100644 --- a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.rs +++ b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.rs @@ -28,7 +28,7 @@ fn main() { let _a: &NotCopy = a; let _b: NotCopy = b; let ref mut a @ b = NotCopy; //~ ERROR cannot move out of value because it is borrowed - //~^ ERROR cannot move out of value because it is borrowed + //~^ ERROR borrow of moved value let _a: &NotCopy = a; let _b: NotCopy = b; match Ok(NotCopy) { diff --git a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr index 11d5e24f34e13..a41fec7a3f86d 100644 --- a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr +++ b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr @@ -44,18 +44,15 @@ LL | ref a @ b => { | | value moved into `b` here | value borrowed, by `a`, here -error[E0505]: cannot move out of value because it is borrowed - --> $DIR/default-binding-modes-both-sides-independent.rs:30:21 +error[E0382]: borrow of moved value + --> $DIR/default-binding-modes-both-sides-independent.rs:30:9 | LL | let ref mut a @ b = NotCopy; - | ------------^ + | ^^^^^^^^^^^^- ------- move occurs because value has type `NotCopy`, which does not implement the `Copy` trait | | | - | | move out of value occurs here - | borrow of value occurs here -LL | -LL | let _a: &NotCopy = a; - | - borrow later used here + | | value moved here + | value borrowed here after move error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0505`. +For more information about this error, try `rustc --explain E0382`. From 324e63de289e249481445a399fcbcad62b7ab71d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Nov 2020 19:38:21 +0100 Subject: [PATCH 17/39] Ensure that sysroot build works with CARGO_TARGET_DIR set --- build_sysroot/build_sysroot.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 04c82ca2a5128..2b2208fc8e59d 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -9,6 +9,9 @@ pushd ../ >/dev/null source ./scripts/config.sh popd >/dev/null +# We expect the target dir in the default location. Guard against the user changing it. +export CARGO_TARGET_DIR=target + # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true From cb367602ff7878b02e91bac72178e70b305dda85 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Nov 2020 19:39:44 +0100 Subject: [PATCH 18/39] Split the actual tests out into scripts/tests.sh --- scripts/tests.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++++ test.sh | 98 ++------------------------------------------- 2 files changed, 106 insertions(+), 94 deletions(-) create mode 100644 scripts/tests.sh diff --git a/scripts/tests.sh b/scripts/tests.sh new file mode 100644 index 0000000000000..7d1e488ac3a06 --- /dev/null +++ b/scripts/tests.sh @@ -0,0 +1,102 @@ +function no_sysroot_tests() { + RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2" + + echo "[BUILD] mini_core" + $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE + + echo "[BUILD] example" + $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE + + if [[ "$JIT_SUPPORTED" = "1" ]]; then + echo "[JIT] mini_core_hello_world" + CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE + else + echo "[JIT] mini_core_hello_world (skipped)" + fi + + echo "[AOT] mini_core_hello_world" + $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE + $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd + # (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd + + echo "[AOT] arbitrary_self_types_pointers_and_wrappers" + $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE + $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers +} + +function base_sysroot_tests() { + echo "[AOT] alloc_example" + $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE + $RUN_WRAPPER ./target/out/alloc_example + + if [[ "$JIT_SUPPORTED" = "1" ]]; then + echo "[JIT] std_example" + $RUSTC --jit example/std_example.rs --target $HOST_TRIPLE + else + echo "[JIT] std_example (skipped)" + fi + + echo "[AOT] dst_field_align" + # FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. + $RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE + $RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false) + + echo "[AOT] std_example" + $RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE + $RUN_WRAPPER ./target/out/std_example arg + + echo "[AOT] subslice-patterns-const-eval" + $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE + $RUN_WRAPPER ./target/out/subslice-patterns-const-eval + + echo "[AOT] track-caller-attribute" + $RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE + $RUN_WRAPPER ./target/out/track-caller-attribute + + echo "[AOT] mod_bench" + $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE + $RUN_WRAPPER ./target/out/mod_bench + + pushd rand + rm -r ./target || true + ../cargo.sh test --workspace + popd +} + +function extended_sysroot_tests() { + pushd simple-raytracer + if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then + echo "[BENCH COMPILE] ebobby/simple-raytracer" + hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \ + "RUSTC=rustc RUSTFLAGS='' cargo build" \ + "../cargo.sh build" + + echo "[BENCH RUN] ebobby/simple-raytracer" + cp ./target/debug/main ./raytracer_cg_clif + hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif + else + echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)" + echo "[COMPILE] ebobby/simple-raytracer" + ../cargo.sh build + echo "[BENCH RUN] ebobby/simple-raytracer (skipped)" + fi + popd + + pushd build_sysroot/sysroot_src/library/core/tests + echo "[TEST] libcore" + rm -r ./target || true + ../../../../../cargo.sh test + popd + + pushd regex + echo "[TEST] rust-lang/regex example shootout-regex-dna" + ../cargo.sh clean + # Make sure `[codegen mono items] start` doesn't poison the diff + ../cargo.sh build --example shootout-regex-dna + cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt + diff -u res.txt examples/regexdna-output.txt + + echo "[TEST] rust-lang/regex tests" + ../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options + popd +} diff --git a/test.sh b/test.sh index a1c4d9f287283..c62ee8716bc20 100755 --- a/test.sh +++ b/test.sh @@ -13,107 +13,17 @@ fi # Config source scripts/config.sh +source scripts/tests.sh export CG_CLIF_INCR_CACHE_DISABLED=1 -RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2" # Cleanup rm -r target/out || true -# Perform all tests -echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE - -echo "[BUILD] example" -$RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE - -if [[ "$JIT_SUPPORTED" = "1" ]]; then - echo "[JIT] mini_core_hello_world" - CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE -else - echo "[JIT] mini_core_hello_world (skipped)" -fi - -echo "[AOT] mini_core_hello_world" -$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd -# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd - -echo "[AOT] arbitrary_self_types_pointers_and_wrappers" -$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers +no_sysroot_tests echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh --release -echo "[AOT] alloc_example" -$RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/alloc_example - -if [[ "$JIT_SUPPORTED" = "1" ]]; then - echo "[JIT] std_example" - $RUSTC --jit example/std_example.rs --target $HOST_TRIPLE -else - echo "[JIT] std_example (skipped)" -fi - -echo "[AOT] dst_field_align" -# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. -$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false) - -echo "[AOT] std_example" -$RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/std_example arg - -echo "[AOT] subslice-patterns-const-eval" -$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/subslice-patterns-const-eval - -echo "[AOT] track-caller-attribute" -$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/track-caller-attribute - -echo "[AOT] mod_bench" -$RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/mod_bench - -pushd rand -rm -r ./target || true -../cargo.sh test --workspace -popd - -pushd simple-raytracer -if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then - echo "[BENCH COMPILE] ebobby/simple-raytracer" - hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \ - "RUSTC=rustc RUSTFLAGS='' cargo build" \ - "../cargo.sh build" - - echo "[BENCH RUN] ebobby/simple-raytracer" - cp ./target/debug/main ./raytracer_cg_clif - hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif -else - echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)" - echo "[COMPILE] ebobby/simple-raytracer" - ../cargo.sh build - echo "[BENCH RUN] ebobby/simple-raytracer (skipped)" -fi -popd - -pushd build_sysroot/sysroot_src/library/core/tests -echo "[TEST] libcore" -rm -r ./target || true -../../../../../cargo.sh test -popd - -pushd regex -echo "[TEST] rust-lang/regex example shootout-regex-dna" -../cargo.sh clean -# Make sure `[codegen mono items] start` doesn't poison the diff -../cargo.sh build --example shootout-regex-dna -cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt -diff -u res.txt examples/regexdna-output.txt +base_sysroot_tests -echo "[TEST] rust-lang/regex tests" -../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -popd +extended_sysroot_tests From 1ea618a7b68bc434d4ff8514fbb6edf483efe9e9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Nov 2020 19:47:14 +0100 Subject: [PATCH 19/39] Make it easier to use build_sysroot.sh --- build_sysroot/build_sysroot.sh | 6 +++++- test.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 2b2208fc8e59d..7557f74b28607 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -5,6 +5,10 @@ set -e cd $(dirname "$0") +if [ -z $CHANNEL ]; then +export CHANNEL='release' +fi + pushd ../ >/dev/null source ./scripts/config.sh popd >/dev/null @@ -24,7 +28,7 @@ export RUSTFLAGS=$RUSTFLAGS" --clif" # Build libs export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort" -if [[ "$1" == "--release" ]]; then +if [[ "$1" != "--debug" ]]; then sysroot_channel='release' # FIXME Enable incremental again once rust-lang/rust#74946 is fixed # FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore diff --git a/test.sh b/test.sh index c62ee8716bc20..e7a0d6ab4e1f6 100755 --- a/test.sh +++ b/test.sh @@ -22,7 +22,7 @@ rm -r target/out || true no_sysroot_tests echo "[BUILD] sysroot" -time ./build_sysroot/build_sysroot.sh --release +time ./build_sysroot/build_sysroot.sh base_sysroot_tests From 9410b5820a6a54dc0d13138173bf6a67387146b2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Nov 2020 19:51:35 +0100 Subject: [PATCH 20/39] Update build instructions --- Readme.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 680ff877656b0..ca380703a7f24 100644 --- a/Readme.md +++ b/Readme.md @@ -4,7 +4,7 @@ The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). This has the potential to improve compilation times in debug mode. If your project doesn't use any of the things listed under "Not yet supported", it should work fine. If not please open an issue. -## Building +## Building and testing ```bash $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git @@ -13,6 +13,13 @@ $ ./prepare.sh # download and patch sysroot src and install hyperfine for benchm $ ./test.sh --release ``` +If you want to only build but not test you should replace the last command with: + +```bash +$ cargo build --release +$ ./build_sysroot/build_sysroot.sh +``` + ## Usage rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects. From 0e2337a5d683c04004226502d2243ceb89cf4c22 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 31 Oct 2020 15:34:10 +0100 Subject: [PATCH 21/39] Deny #[deprecated] on trait impl blocks. They have no effect there, but were silently accepted. --- compiler/rustc_passes/src/stability.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index c9497f2a5b2b0..18d9e9f78d6b9 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -31,6 +31,8 @@ enum AnnotationKind { Required, // Annotation is useless, reject it Prohibited, + // Deprecation annotation is useless, reject it. (Stability attribute is still required.) + DeprecationProhibited, // Annotation itself is useless, but it can be propagated to children Container, } @@ -89,7 +91,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { if let Some(depr) = &depr { is_deprecated = true; - if kind == AnnotationKind::Prohibited { + if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited { self.tcx.sess.span_err(item_sp, "This deprecation annotation is useless"); } @@ -322,6 +324,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { } hir::ItemKind::Impl { of_trait: Some(_), .. } => { self.in_trait_impl = true; + kind = AnnotationKind::DeprecationProhibited; } hir::ItemKind::Struct(ref sd, _) => { if let Some(ctor_hir_id) = sd.ctor_hir_id() { From 706bc336515581c7559a5ccdfae0a7d93b0508fa Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 1 Nov 2020 12:29:57 +0100 Subject: [PATCH 22/39] Use the right span for errors about #[deprecated] attributes. --- compiler/rustc_attr/src/builtin.rs | 20 +++++++------- compiler/rustc_expand/src/base.rs | 2 +- compiler/rustc_passes/src/stability.rs | 26 ++++++++++++------- src/test/ui/deprecation/deprecation-sanity.rs | 4 +-- .../ui/deprecation/deprecation-sanity.stderr | 12 ++++++--- .../stability-attribute-sanity.rs | 6 ++--- .../stability-attribute-sanity.stderr | 18 ++++++++----- 7 files changed, 53 insertions(+), 35 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 48238c8bbf571..49ac97d833f9a 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -637,19 +637,15 @@ pub struct Deprecation { } /// Finds the deprecation attribute. `None` if none exists. -pub fn find_deprecation(sess: &Session, attrs: &[Attribute], item_sp: Span) -> Option { - find_deprecation_generic(sess, attrs.iter(), item_sp) +pub fn find_deprecation(sess: &Session, attrs: &[Attribute]) -> Option<(Deprecation, Span)> { + find_deprecation_generic(sess, attrs.iter()) } -fn find_deprecation_generic<'a, I>( - sess: &Session, - attrs_iter: I, - item_sp: Span, -) -> Option +fn find_deprecation_generic<'a, I>(sess: &Session, attrs_iter: I) -> Option<(Deprecation, Span)> where I: Iterator, { - let mut depr: Option = None; + let mut depr: Option<(Deprecation, Span)> = None; let diagnostic = &sess.parse_sess.span_diagnostic; 'outer: for attr in attrs_iter { @@ -658,8 +654,10 @@ where continue; } - if depr.is_some() { - struct_span_err!(diagnostic, item_sp, E0550, "multiple deprecated attributes").emit(); + if let Some((_, span)) = &depr { + struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes") + .span_note(*span, "first deprecation attribute here") + .emit(); break; } @@ -780,7 +778,7 @@ where sess.mark_attr_used(&attr); let is_since_rustc_version = sess.check_name(attr, sym::rustc_deprecated); - depr = Some(Deprecation { since, note, suggestion, is_since_rustc_version }); + depr = Some((Deprecation { since, note, suggestion, is_since_rustc_version }, attr.span)); } depr diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index b0e43a260e91d..b435def87ac84 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -793,7 +793,7 @@ impl SyntaxExtension { allow_internal_unsafe: sess.contains_name(attrs, sym::allow_internal_unsafe), local_inner_macros, stability, - deprecation: attr::find_deprecation(&sess, attrs, span), + deprecation: attr::find_deprecation(&sess, attrs).map(|(d, _)| d), helper_attrs, edition, is_builtin, diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 18d9e9f78d6b9..bacbab1a4f492 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -85,14 +85,22 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { did_error = self.forbid_staged_api_attrs(hir_id, attrs, inherit_deprecation.clone()); } - let depr = - if did_error { None } else { attr::find_deprecation(&self.tcx.sess, attrs, item_sp) }; + let depr = if did_error { None } else { attr::find_deprecation(&self.tcx.sess, attrs) }; let mut is_deprecated = false; - if let Some(depr) = &depr { + if let Some((depr, span)) = &depr { is_deprecated = true; if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited { - self.tcx.sess.span_err(item_sp, "This deprecation annotation is useless"); + self.tcx + .sess + .struct_span_err(*span, "this deprecation annotation is useless") + .span_suggestion( + *span, + "try removing the deprecation attribute", + String::new(), + rustc_errors::Applicability::MachineApplicable, + ) + .emit(); } // `Deprecation` is just two pointers, no need to intern it @@ -116,7 +124,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } } else { self.recurse_with_stability_attrs( - depr.map(|d| DeprecationEntry::local(d, hir_id)), + depr.map(|(d, _)| DeprecationEntry::local(d, hir_id)), None, None, visit_children, @@ -141,11 +149,11 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } } - if depr.as_ref().map_or(false, |d| d.is_since_rustc_version) { + if let Some((rustc_attr::Deprecation { is_since_rustc_version: true, .. }, span)) = &depr { if stab.is_none() { struct_span_err!( self.tcx.sess, - item_sp, + *span, E0549, "rustc_deprecated attribute must be paired with \ either stable or unstable attribute" @@ -168,7 +176,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { // Check if deprecated_since < stable_since. If it is, // this is *almost surely* an accident. if let (&Some(dep_since), &attr::Stable { since: stab_since }) = - (&depr.as_ref().and_then(|d| d.since), &stab.level) + (&depr.as_ref().and_then(|(d, _)| d.since), &stab.level) { // Explicit version of iter::order::lt to handle parse errors properly for (dep_v, stab_v) in @@ -214,7 +222,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } self.recurse_with_stability_attrs( - depr.map(|d| DeprecationEntry::local(d, hir_id)), + depr.map(|(d, _)| DeprecationEntry::local(d, hir_id)), stab, const_stab, visit_children, diff --git a/src/test/ui/deprecation/deprecation-sanity.rs b/src/test/ui/deprecation/deprecation-sanity.rs index a559908b792bb..4cbcec9b1d880 100644 --- a/src/test/ui/deprecation/deprecation-sanity.rs +++ b/src/test/ui/deprecation/deprecation-sanity.rs @@ -24,8 +24,8 @@ mod bogus_attribute_types_1 { } #[deprecated(since = "a", note = "b")] -#[deprecated(since = "a", note = "b")] -fn multiple1() { } //~ ERROR multiple deprecated attributes +#[deprecated(since = "a", note = "b")] //~ ERROR multiple deprecated attributes +fn multiple1() { } #[deprecated(since = "a", since = "b", note = "c")] //~ ERROR multiple 'since' items fn f1() { } diff --git a/src/test/ui/deprecation/deprecation-sanity.stderr b/src/test/ui/deprecation/deprecation-sanity.stderr index 57143d6810554..4f70c55a95755 100644 --- a/src/test/ui/deprecation/deprecation-sanity.stderr +++ b/src/test/ui/deprecation/deprecation-sanity.stderr @@ -41,10 +41,16 @@ LL | #[deprecated("test")] | ^^^^^^ error[E0550]: multiple deprecated attributes - --> $DIR/deprecation-sanity.rs:28:1 + --> $DIR/deprecation-sanity.rs:27:1 | -LL | fn multiple1() { } - | ^^^^^^^^^^^^^^^^^^ +LL | #[deprecated(since = "a", note = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: first deprecation attribute here + --> $DIR/deprecation-sanity.rs:26:1 + | +LL | #[deprecated(since = "a", note = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0538]: multiple 'since' items --> $DIR/deprecation-sanity.rs:30:27 diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.rs b/src/test/ui/stability-attribute/stability-attribute-sanity.rs index 80d7ae6dc637d..abd603b356ee6 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.rs +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.rs @@ -59,14 +59,14 @@ fn multiple3() { } #[stable(feature = "a", since = "b")] #[rustc_deprecated(since = "b", reason = "text")] -#[rustc_deprecated(since = "b", reason = "text")] +#[rustc_deprecated(since = "b", reason = "text")] //~ ERROR multiple deprecated attributes #[rustc_const_unstable(feature = "c", issue = "none")] #[rustc_const_unstable(feature = "d", issue = "none")] //~ ERROR multiple stability levels -pub const fn multiple4() { } //~ ERROR multiple deprecated attributes +pub const fn multiple4() { } //~^ ERROR Invalid stability or deprecation version found #[rustc_deprecated(since = "a", reason = "text")] fn deprecated_without_unstable_or_stable() { } -//~^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute +//~^^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute fn main() { } diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr index 134c657c62015..f3edd5773cbb8 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr @@ -83,10 +83,16 @@ LL | #[stable(feature = "a", since = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0550]: multiple deprecated attributes - --> $DIR/stability-attribute-sanity.rs:65:1 + --> $DIR/stability-attribute-sanity.rs:62:1 | -LL | pub const fn multiple4() { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_deprecated(since = "b", reason = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: first deprecation attribute here + --> $DIR/stability-attribute-sanity.rs:61:1 + | +LL | #[rustc_deprecated(since = "b", reason = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0544]: multiple stability levels --> $DIR/stability-attribute-sanity.rs:64:1 @@ -101,10 +107,10 @@ LL | pub const fn multiple4() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0549]: rustc_deprecated attribute must be paired with either stable or unstable attribute - --> $DIR/stability-attribute-sanity.rs:69:1 + --> $DIR/stability-attribute-sanity.rs:68:1 | -LL | fn deprecated_without_unstable_or_stable() { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_deprecated(since = "a", reason = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 18 previous errors From 6f1992a7d60152cd962feb907bfdc03290d9f8a4 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 1 Nov 2020 12:58:47 +0100 Subject: [PATCH 23/39] Turn 'useless #[deprecated]' error into a lint. --- compiler/rustc_lint_defs/src/builtin.rs | 27 +++++++++++++++++++++++++ compiler/rustc_passes/src/stability.rs | 22 ++++++++++---------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 048f096aabe13..a1b7c13e4c0f0 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2705,6 +2705,32 @@ declare_lint! { }; } +declare_lint! { + /// The `useless_deprecated` lint detects deprecation attributes with no effect. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// struct X; + /// + /// #[deprecated = "message"] + /// impl Default for X { + /// fn default() -> Self { + /// X + /// } + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Deprecation attributes have no effect on trait implementations. + pub USELESS_DEPRECATED, + Deny, + "detects deprecation attributes with no effect", +} + declare_tool_lint! { pub rustc::INEFFECTIVE_UNSTABLE_TRAIT_IMPL, Deny, @@ -2792,6 +2818,7 @@ declare_lint_pass! { INEFFECTIVE_UNSTABLE_TRAIT_IMPL, UNINHABITED_STATIC, FUNCTION_ITEM_REFERENCES, + USELESS_DEPRECATED, ] } diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index bacbab1a4f492..f6923b0dd9c3c 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -15,7 +15,7 @@ use rustc_middle::middle::privacy::AccessLevels; use rustc_middle::middle::stability::{DeprecationEntry, Index}; use rustc_middle::ty::{self, query::Providers, TyCtxt}; use rustc_session::lint; -use rustc_session::lint::builtin::INEFFECTIVE_UNSTABLE_TRAIT_IMPL; +use rustc_session::lint::builtin::{INEFFECTIVE_UNSTABLE_TRAIT_IMPL, USELESS_DEPRECATED}; use rustc_session::parse::feature_err; use rustc_session::Session; use rustc_span::symbol::{sym, Symbol}; @@ -91,16 +91,16 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { is_deprecated = true; if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited { - self.tcx - .sess - .struct_span_err(*span, "this deprecation annotation is useless") - .span_suggestion( - *span, - "try removing the deprecation attribute", - String::new(), - rustc_errors::Applicability::MachineApplicable, - ) - .emit(); + self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| { + lint.build("this `#[deprecated]' annotation has no effect") + .span_suggestion( + *span, + "try removing the deprecation attribute", + String::new(), + rustc_errors::Applicability::MachineApplicable, + ) + .emit() + }); } // `Deprecation` is just two pointers, no need to intern it From 9fc991a0ea1df0a5ef96c50fb8dce115c096d8f5 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 1 Nov 2020 13:09:03 +0100 Subject: [PATCH 24/39] Add test for #[deprecated] attribute on trait impl block. --- src/test/ui/deprecation/deprecation-sanity.rs | 9 +++++++++ src/test/ui/deprecation/deprecation-sanity.stderr | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/test/ui/deprecation/deprecation-sanity.rs b/src/test/ui/deprecation/deprecation-sanity.rs index 4cbcec9b1d880..5fb3f81958965 100644 --- a/src/test/ui/deprecation/deprecation-sanity.rs +++ b/src/test/ui/deprecation/deprecation-sanity.rs @@ -30,4 +30,13 @@ fn multiple1() { } #[deprecated(since = "a", since = "b", note = "c")] //~ ERROR multiple 'since' items fn f1() { } +struct X; + +#[deprecated = "hello"] //~ ERROR this `#[deprecated]' annotation has no effect +impl Default for X { + fn default() -> Self { + X + } +} + fn main() { } diff --git a/src/test/ui/deprecation/deprecation-sanity.stderr b/src/test/ui/deprecation/deprecation-sanity.stderr index 4f70c55a95755..b926a6dc09da7 100644 --- a/src/test/ui/deprecation/deprecation-sanity.stderr +++ b/src/test/ui/deprecation/deprecation-sanity.stderr @@ -58,7 +58,15 @@ error[E0538]: multiple 'since' items LL | #[deprecated(since = "a", since = "b", note = "c")] | ^^^^^^^^^^^ -error: aborting due to 9 previous errors +error: this `#[deprecated]' annotation has no effect + --> $DIR/deprecation-sanity.rs:35:1 + | +LL | #[deprecated = "hello"] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute + | + = note: `#[deny(useless_deprecated)]` on by default + +error: aborting due to 10 previous errors Some errors have detailed explanations: E0538, E0541, E0550, E0551, E0565. For more information about an error, try `rustc --explain E0538`. From ace02c40f0d5970c46aaee74f7ee2fb27480c783 Mon Sep 17 00:00:00 2001 From: Ayrton Date: Sun, 1 Nov 2020 23:14:21 -0400 Subject: [PATCH 25/39] Corrected suggestion for generic parameters in `function_item_references` lint This lint was incorrectly suggesting casting a function to a pointer without specifying generic type parameters or const generics. This would cause a compiler error since the missing parameters couldn't be inferred. This commit fixed the suggestion and added a few tests with generics. --- .../src/transform/function_item_references.rs | 54 +++++++---- src/test/ui/lint/function-item-references.rs | 16 +++- .../ui/lint/function-item-references.stderr | 90 ++++++++++++------- 3 files changed, 111 insertions(+), 49 deletions(-) diff --git a/compiler/rustc_mir/src/transform/function_item_references.rs b/compiler/rustc_mir/src/transform/function_item_references.rs index 61427422e4b59..d592580af9cec 100644 --- a/compiler/rustc_mir/src/transform/function_item_references.rs +++ b/compiler/rustc_mir/src/transform/function_item_references.rs @@ -51,10 +51,11 @@ impl<'a, 'tcx> Visitor<'tcx> for FunctionItemRefChecker<'a, 'tcx> { let arg_ty = args[0].ty(self.body, self.tcx); for generic_inner_ty in arg_ty.walk() { if let GenericArgKind::Type(inner_ty) = generic_inner_ty.unpack() { - if let Some(fn_id) = FunctionItemRefChecker::is_fn_ref(inner_ty) { - let ident = self.tcx.item_name(fn_id).to_ident_string(); + if let Some((fn_id, fn_substs)) = + FunctionItemRefChecker::is_fn_ref(inner_ty) + { let span = self.nth_arg_span(&args, 0); - self.emit_lint(ident, fn_id, source_info, span); + self.emit_lint(fn_id, fn_substs, source_info, span); } } } @@ -66,6 +67,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FunctionItemRefChecker<'a, 'tcx> { } self.super_terminator(terminator, location); } + /// Emits a lint for function references formatted with `fmt::Pointer::fmt` by macros. These /// cases are handled as operands instead of call terminators to avoid any dependence on /// unstable, internal formatting details like whether `fmt` is called directly or not. @@ -76,13 +78,12 @@ impl<'a, 'tcx> Visitor<'tcx> for FunctionItemRefChecker<'a, 'tcx> { if let ty::FnDef(def_id, substs_ref) = *op_ty.kind() { if self.tcx.is_diagnostic_item(sym::pointer_trait_fmt, def_id) { let param_ty = substs_ref.type_at(0); - if let Some(fn_id) = FunctionItemRefChecker::is_fn_ref(param_ty) { + if let Some((fn_id, fn_substs)) = FunctionItemRefChecker::is_fn_ref(param_ty) { // The operand's ctxt wouldn't display the lint since it's inside a macro so // we have to use the callsite's ctxt. let callsite_ctxt = source_info.span.source_callsite().ctxt(); let span = source_info.span.with_ctxt(callsite_ctxt); - let ident = self.tcx.item_name(fn_id).to_ident_string(); - self.emit_lint(ident, fn_id, source_info, span); + self.emit_lint(fn_id, fn_substs, source_info, span); } } } @@ -115,10 +116,11 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { if TyS::same_type(inner_ty, bound_ty) { // Do a substitution using the parameters from the callsite let subst_ty = inner_ty.subst(self.tcx, substs_ref); - if let Some(fn_id) = FunctionItemRefChecker::is_fn_ref(subst_ty) { - let ident = self.tcx.item_name(fn_id).to_ident_string(); + if let Some((fn_id, fn_substs)) = + FunctionItemRefChecker::is_fn_ref(subst_ty) + { let span = self.nth_arg_span(args, arg_num); - self.emit_lint(ident, fn_id, source_info, span); + self.emit_lint(fn_id, fn_substs, source_info, span); } } } @@ -127,6 +129,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { } } } + /// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type. fn is_pointer_trait(&self, bound: &PredicateAtom<'tcx>) -> Option> { if let ty::PredicateAtom::Trait(predicate, _) = bound { @@ -139,22 +142,26 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { None } } + /// If a type is a reference or raw pointer to the anonymous type of a function definition, - /// returns that function's `DefId`. - fn is_fn_ref(ty: Ty<'tcx>) -> Option { + /// returns that function's `DefId` and `SubstsRef`. + fn is_fn_ref(ty: Ty<'tcx>) -> Option<(DefId, SubstsRef<'tcx>)> { let referent_ty = match ty.kind() { ty::Ref(_, referent_ty, _) => Some(referent_ty), ty::RawPtr(ty_and_mut) => Some(&ty_and_mut.ty), _ => None, }; referent_ty - .map( - |ref_ty| { - if let ty::FnDef(def_id, _) = *ref_ty.kind() { Some(def_id) } else { None } - }, - ) + .map(|ref_ty| { + if let ty::FnDef(def_id, substs_ref) = *ref_ty.kind() { + Some((def_id, substs_ref)) + } else { + None + } + }) .unwrap_or(None) } + fn nth_arg_span(&self, args: &Vec>, n: usize) -> Span { match &args[n] { Operand::Copy(place) | Operand::Move(place) => { @@ -163,7 +170,14 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { Operand::Constant(constant) => constant.span, } } - fn emit_lint(&self, ident: String, fn_id: DefId, source_info: SourceInfo, span: Span) { + + fn emit_lint( + &self, + fn_id: DefId, + fn_substs: SubstsRef<'tcx>, + source_info: SourceInfo, + span: Span, + ) { let lint_root = self.body.source_scopes[source_info.scope] .local_data .as_ref() @@ -180,6 +194,10 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { s } }; + let ident = self.tcx.item_name(fn_id).to_ident_string(); + let ty_params = fn_substs.types().map(|ty| format!("{}", ty)); + let const_params = fn_substs.consts().map(|c| format!("{}", c)); + let params = ty_params.chain(const_params).collect::>().join(", "); let num_args = fn_sig.inputs().map_bound(|inputs| inputs.len()).skip_binder(); let variadic = if fn_sig.c_variadic() { ", ..." } else { "" }; let ret = if fn_sig.output().skip_binder().is_unit() { "" } else { " -> _" }; @@ -190,7 +208,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> { &format!("cast `{}` to obtain a function pointer", ident), format!( "{} as {}{}fn({}{}){}", - ident, + if params.is_empty() { ident } else { format!("{}::<{}>", ident, params) }, unsafety, abi, vec!["_"; num_args].join(", "), diff --git a/src/test/ui/lint/function-item-references.rs b/src/test/ui/lint/function-item-references.rs index 439b56967d072..5f7f5e66eaa9f 100644 --- a/src/test/ui/lint/function-item-references.rs +++ b/src/test/ui/lint/function-item-references.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(c_variadic)] +#![feature(c_variadic, min_const_generics)] #![warn(function_item_references)] use std::fmt::Pointer; use std::fmt::Formatter; @@ -12,6 +12,10 @@ unsafe fn unsafe_fn() { } extern "C" fn c_fn() { } unsafe extern "C" fn unsafe_c_fn() { } unsafe extern fn variadic(_x: u32, _args: ...) { } +fn take_generic_ref<'a, T>(_x: &'a T) { } +fn take_generic_array(_x: [T; N]) { } +fn multiple_generic(_x: T, _y: U) { } +fn multiple_generic_arrays(_x: [T; N], _y: [U; M]) { } //function references passed to these functions should never lint fn call_fn(f: &dyn Fn(u32) -> u32, x: u32) { f(x); } @@ -109,6 +113,14 @@ fn main() { //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &variadic); //~^ WARNING taking a reference to a function item does not give a function pointer + println!("{:p}", &take_generic_ref::); + //~^ WARNING taking a reference to a function item does not give a function pointer + println!("{:p}", &take_generic_array::); + //~^ WARNING taking a reference to a function item does not give a function pointer + println!("{:p}", &multiple_generic::); + //~^ WARNING taking a reference to a function item does not give a function pointer + println!("{:p}", &multiple_generic_arrays::); + //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &std::env::var::); //~^ WARNING taking a reference to a function item does not give a function pointer @@ -132,6 +144,8 @@ fn main() { std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); //~^ WARNING taking a reference to a function item does not give a function pointer //~^^ WARNING taking a reference to a function item does not give a function pointer + std::mem::transmute::<_, usize>(&take_generic_ref::); + //~^ WARNING taking a reference to a function item does not give a function pointer //the correct way to transmute function pointers std::mem::transmute::<_, usize>(foo as fn() -> u32); diff --git a/src/test/ui/lint/function-item-references.stderr b/src/test/ui/lint/function-item-references.stderr index 610dff04e6edf..33db687df31d2 100644 --- a/src/test/ui/lint/function-item-references.stderr +++ b/src/test/ui/lint/function-item-references.stderr @@ -1,5 +1,5 @@ warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:40:18 + --> $DIR/function-item-references.rs:44:18 | LL | Pointer::fmt(&zst_ref, f) | ^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` @@ -11,166 +11,196 @@ LL | #![warn(function_item_references)] | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:77:22 + --> $DIR/function-item-references.rs:81:22 | LL | println!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:79:20 + --> $DIR/function-item-references.rs:83:20 | LL | print!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:81:21 + --> $DIR/function-item-references.rs:85:21 | LL | format!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:84:22 + --> $DIR/function-item-references.rs:88:22 | LL | println!("{:p}", &foo as *const _); | ^^^^^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:86:22 + --> $DIR/function-item-references.rs:90:22 | LL | println!("{:p}", zst_ref); | ^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:88:22 + --> $DIR/function-item-references.rs:92:22 | LL | println!("{:p}", cast_zst_ptr); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:90:22 + --> $DIR/function-item-references.rs:94:22 | LL | println!("{:p}", coerced_zst_ptr); | ^^^^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:93:22 + --> $DIR/function-item-references.rs:97:22 | LL | println!("{:p}", &fn_item); | ^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:95:22 + --> $DIR/function-item-references.rs:99:22 | LL | println!("{:p}", indirect_ref); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:98:22 + --> $DIR/function-item-references.rs:102:22 | LL | println!("{:p}", &nop); | ^^^^ help: cast `nop` to obtain a function pointer: `nop as fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:100:22 + --> $DIR/function-item-references.rs:104:22 | LL | println!("{:p}", &bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:102:22 + --> $DIR/function-item-references.rs:106:22 | LL | println!("{:p}", &baz); | ^^^^ help: cast `baz` to obtain a function pointer: `baz as fn(_, _) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:104:22 + --> $DIR/function-item-references.rs:108:22 | LL | println!("{:p}", &unsafe_fn); | ^^^^^^^^^^ help: cast `unsafe_fn` to obtain a function pointer: `unsafe_fn as unsafe fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:106:22 + --> $DIR/function-item-references.rs:110:22 | LL | println!("{:p}", &c_fn); | ^^^^^ help: cast `c_fn` to obtain a function pointer: `c_fn as extern "C" fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:108:22 + --> $DIR/function-item-references.rs:112:22 | LL | println!("{:p}", &unsafe_c_fn); | ^^^^^^^^^^^^ help: cast `unsafe_c_fn` to obtain a function pointer: `unsafe_c_fn as unsafe extern "C" fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:110:22 + --> $DIR/function-item-references.rs:114:22 | LL | println!("{:p}", &variadic); | ^^^^^^^^^ help: cast `variadic` to obtain a function pointer: `variadic as unsafe extern "C" fn(_, ...)` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:112:22 + --> $DIR/function-item-references.rs:116:22 + | +LL | println!("{:p}", &take_generic_ref::); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_ref` to obtain a function pointer: `take_generic_ref:: as fn(_)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:118:22 + | +LL | println!("{:p}", &take_generic_array::); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_array` to obtain a function pointer: `take_generic_array:: as fn(_)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:120:22 + | +LL | println!("{:p}", &multiple_generic::); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `multiple_generic` to obtain a function pointer: `multiple_generic:: as fn(_, _)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:122:22 + | +LL | println!("{:p}", &multiple_generic_arrays::); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `multiple_generic_arrays` to obtain a function pointer: `multiple_generic_arrays:: as fn(_, _)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:124:22 | LL | println!("{:p}", &std::env::var::); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `var` to obtain a function pointer: `var as fn(_) -> _` + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `var` to obtain a function pointer: `var:: as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:115:32 + --> $DIR/function-item-references.rs:127:32 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `nop` to obtain a function pointer: `nop as fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:115:38 + --> $DIR/function-item-references.rs:127:38 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:115:44 + --> $DIR/function-item-references.rs:127:44 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:130:41 + --> $DIR/function-item-references.rs:142:41 | LL | std::mem::transmute::<_, usize>(&foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:132:50 + --> $DIR/function-item-references.rs:144:50 | LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:132:50 + --> $DIR/function-item-references.rs:144:50 | LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:142:15 + --> $DIR/function-item-references.rs:147:41 + | +LL | std::mem::transmute::<_, usize>(&take_generic_ref::); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_ref` to obtain a function pointer: `take_generic_ref:: as fn(_)` + +warning: taking a reference to a function item does not give a function pointer + --> $DIR/function-item-references.rs:156:15 | LL | print_ptr(&bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:144:24 + --> $DIR/function-item-references.rs:158:24 | LL | bound_by_ptr_trait(&bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:146:30 + --> $DIR/function-item-references.rs:160:30 | LL | bound_by_ptr_trait_tuple((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:146:30 + --> $DIR/function-item-references.rs:160:30 | LL | bound_by_ptr_trait_tuple((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` -warning: 28 warnings emitted +warning: 33 warnings emitted From 5dee38d8bbadc00f60a263431292d685a324e422 Mon Sep 17 00:00:00 2001 From: Vishnunarayan K I Date: Mon, 2 Nov 2020 12:30:38 +0530 Subject: [PATCH 26/39] update some ui tests and update move ref drop semantics output --- .../borrowck-move-error-with-note.stderr | 2 +- ...ck-slice-pattern-element-loan-slice.stderr | 12 +++++----- src/test/ui/issues/issue-12567.stderr | 4 ++-- src/test/ui/nll/move-errors.stderr | 24 +++++++++---------- .../move-ref-patterns-dynamic-semantics.rs | 2 +- .../span/dropck_direct_cycle_with_drop.stderr | 8 +++---- .../span/send-is-not-static-std-sync-2.stderr | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.stderr b/src/test/ui/borrowck/borrowck-move-error-with-note.stderr index ead02414a622b..de410a8b3120c 100644 --- a/src/test/ui/borrowck/borrowck-move-error-with-note.stderr +++ b/src/test/ui/borrowck/borrowck-move-error-with-note.stderr @@ -1,4 +1,4 @@ -error[E0507]: cannot move out of `f.0` which is behind a shared reference +error[E0507]: cannot move out of `f.1` which is behind a shared reference --> $DIR/borrowck-move-error-with-note.rs:11:11 | LL | match *f { diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr index d3388e071aa53..f7fa467c4682c 100644 --- a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr +++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr @@ -32,23 +32,23 @@ error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as im --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:25:23 | LL | if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s { - | ------------- immutable borrow occurs here + | ------------- immutable borrow occurs here ... LL | if let [_, _, ref mut from_begin2, ..] = *s { | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin2, from_end1, from_end3, from_end4]); - | --------- immutable borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:28:26 | LL | if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s { - | ------------- immutable borrow occurs here + | ------------- immutable borrow occurs here ... LL | if let [_, _, _, ref mut from_begin3, ..] = *s { | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin3, from_end1, from_end3, from_end4]); - | --------- immutable borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:33:21 @@ -75,12 +75,12 @@ error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as im --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:39:21 | LL | if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s { - | --------------- immutable borrow occurs here + | --------------- immutable borrow occurs here ... LL | if let [.., ref mut from_end4, _, _, _] = *s { | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin0, from_begin1, from_begin3, from_end4]); - | ----------- immutable borrow later used here + | ----------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:47:20 diff --git a/src/test/ui/issues/issue-12567.stderr b/src/test/ui/issues/issue-12567.stderr index 3ce659ccd14da..2a88d8f0524ac 100644 --- a/src/test/ui/issues/issue-12567.stderr +++ b/src/test/ui/issues/issue-12567.stderr @@ -8,7 +8,7 @@ LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) | -- data moved here LL | => println!("one empty"), LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here + | --- ...and here | = note: move occurs because these variables have types that don't implement the `Copy` trait @@ -22,7 +22,7 @@ LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) | -- data moved here LL | => println!("one empty"), LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here + | --- ...and here | = note: move occurs because these variables have types that don't implement the `Copy` trait diff --git a/src/test/ui/nll/move-errors.stderr b/src/test/ui/nll/move-errors.stderr index 0df326425ad9c..b69ed0bb875a2 100644 --- a/src/test/ui/nll/move-errors.stderr +++ b/src/test/ui/nll/move-errors.stderr @@ -97,18 +97,6 @@ LL | B::U(D(s)) => (), | data moved here | move occurs because `s` has type `String`, which does not implement the `Copy` trait -error[E0509]: cannot move out of type `D`, which implements the `Drop` trait - --> $DIR/move-errors.rs:92:11 - | -LL | match x { - | ^ cannot move out of here -... -LL | (D(s), &t) => (), - | - - | | - | data moved here - | move occurs because `s` has type `String`, which does not implement the `Copy` trait - error[E0507]: cannot move out of `*x.1` which is behind a shared reference --> $DIR/move-errors.rs:92:11 | @@ -121,6 +109,18 @@ LL | (D(s), &t) => (), | data moved here | move occurs because `t` has type `String`, which does not implement the `Copy` trait +error[E0509]: cannot move out of type `D`, which implements the `Drop` trait + --> $DIR/move-errors.rs:92:11 + | +LL | match x { + | ^ cannot move out of here +... +LL | (D(s), &t) => (), + | - + | | + | data moved here + | move occurs because `s` has type `String`, which does not implement the `Copy` trait + error[E0509]: cannot move out of type `F`, which implements the `Drop` trait --> $DIR/move-errors.rs:102:11 | diff --git a/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs b/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs index 1d6d9acead1d4..fdf92b6694513 100644 --- a/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs +++ b/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs @@ -74,6 +74,6 @@ fn main() { }; lam((mk(19), mk(20), mk(21), mk(22))); } - let expected = [2, 3, 6, 5, 7, 8, 12, 11, 9, 10, 18, 13, 14, 15, 16, 17, 21, 19, 20, 22, 4, 1]; + let expected = [2, 3, 6, 5, 7, 8, 12, 11, 9, 10, 13, 18, 14, 15, 16, 17, 19, 21, 20, 22, 4, 1]; assert_eq!(&*d.borrow(), &expected); } diff --git a/src/test/ui/span/dropck_direct_cycle_with_drop.stderr b/src/test/ui/span/dropck_direct_cycle_with_drop.stderr index 07ae138ac71ea..e01c1f87428f0 100644 --- a/src/test/ui/span/dropck_direct_cycle_with_drop.stderr +++ b/src/test/ui/span/dropck_direct_cycle_with_drop.stderr @@ -8,9 +8,7 @@ LL | } | - | | | `d2` dropped here while still borrowed - | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` - | - = note: values in a scope are dropped in the opposite order they are defined + | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` error[E0597]: `d1` does not live long enough --> $DIR/dropck_direct_cycle_with_drop.rs:38:19 @@ -22,7 +20,9 @@ LL | } | - | | | `d1` dropped here while still borrowed - | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` + | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` + | + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/span/send-is-not-static-std-sync-2.stderr b/src/test/ui/span/send-is-not-static-std-sync-2.stderr index bcd07e1164777..e4aa2aed24e42 100644 --- a/src/test/ui/span/send-is-not-static-std-sync-2.stderr +++ b/src/test/ui/span/send-is-not-static-std-sync-2.stderr @@ -24,7 +24,7 @@ error[E0597]: `x` does not live long enough --> $DIR/send-is-not-static-std-sync-2.rs:31:25 | LL | let (_tx, rx) = { - | --- borrow later used here + | -- borrow later used here ... LL | let _ = tx.send(&x); | ^^ borrowed value does not live long enough From 9088807dd31f205b443fd2f6cef32f5ea295ecae Mon Sep 17 00:00:00 2001 From: Vishnunarayan K I Date: Mon, 2 Nov 2020 13:48:53 +0530 Subject: [PATCH 27/39] update mir tests --- ...wise_branch.opt1.EarlyOtherwiseBranch.diff | 6 +-- ...wise_branch.opt2.EarlyOtherwiseBranch.diff | 6 +-- ...ement_tuple.opt1.EarlyOtherwiseBranch.diff | 12 +++--- ...h.before-SimplifyBranches-final.after.diff | 40 +++++++++---------- ...ch_68867.try_sum.EarlyOtherwiseBranch.diff | 24 +++++------ ...nch_noopt.noopt1.EarlyOtherwiseBranch.diff | 6 +-- ...nch_noopt.noopt2.EarlyOtherwiseBranch.diff | 6 +-- ....match_tuple.SimplifyCfg-initial.after.mir | 6 +-- .../issue_73223.main.PreCodegen.64bit.diff | 8 ++-- ..._73223.main.SimplifyArmIdentity.64bit.diff | 12 +++--- ...76432.test.SimplifyComparisonIntegral.diff | 12 +++--- ...fg-initial.after-ElaborateDrops.after.diff | 40 +++++++++---------- 12 files changed, 89 insertions(+), 89 deletions(-) diff --git a/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff index 386726bfddc74..c897aff936c49 100644 --- a/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff @@ -52,13 +52,13 @@ - } - - bb3: { - StorageLive(_8); // scope 0 at $DIR/early_otherwise_branch.rs:5:15: 5:16 - _8 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:15: 5:16 StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25 _9 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25 + StorageLive(_8); // scope 0 at $DIR/early_otherwise_branch.rs:5:15: 5:16 + _8 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:15: 5:16 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch.rs:5:31: 5:32 - StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32 StorageDead(_8); // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32 + StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32 - goto -> bb4; // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 7:6 + goto -> bb3; // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 7:6 } diff --git a/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff index bc5934dec84e4..4ab7b8aed1636 100644 --- a/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff @@ -59,13 +59,13 @@ - - bb4: { + bb2: { - StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch.rs:13:15: 13:16 - _9 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:15: 13:16 StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25 _10 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25 + StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch.rs:13:15: 13:16 + _9 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:15: 13:16 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch.rs:13:31: 13:32 - StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32 StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32 + StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32 - goto -> bb6; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 16:6 + goto -> bb4; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 16:6 } diff --git a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff index b0357f1aecd61..58a7c4a841abf 100644 --- a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff @@ -71,16 +71,16 @@ - bb4: { + bb3: { - StorageLive(_11); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:15: 6:16 - _11 = (((_4.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:15: 6:16 - StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25 - _12 = (((_4.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25 StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34 _13 = (((_4.2: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34 + StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25 + _12 = (((_4.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25 + StorageLive(_11); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:15: 6:16 + _11 = (((_4.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:15: 6:16 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 - StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 - StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 + StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 + StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 - goto -> bb5; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 8:6 + goto -> bb4; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 8:6 } diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff index f51a08ed73068..963f7ffc92025 100644 --- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff +++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff @@ -109,10 +109,10 @@ } + bb2: { -+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 -+ _15 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 + _16 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 ++ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 ++ _15 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 + nop; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49 + nop; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 + nop; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 @@ -132,10 +132,10 @@ bb3: { - _8 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:21: 24:30 - switchInt(move _8) -> [1_isize: bb7, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:21: 24:30 -+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 -+ _20 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 + _21 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 ++ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 ++ _20 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 + nop; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49 + nop; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 + nop; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 @@ -155,10 +155,10 @@ bb4: { - _9 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:23: 25:34 - switchInt(move _9) -> [2_isize: bb8, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:23: 25:34 -+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 -+ _25 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 + _26 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 ++ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 ++ _25 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 + nop; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55 + nop; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 + nop; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 @@ -178,10 +178,10 @@ bb5: { - _10 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:23: 26:34 - switchInt(move _10) -> [3_isize: bb9, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:23: 26:34 -+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 -+ _30 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 + _31 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 ++ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 ++ _30 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 + nop; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55 + nop; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 + nop; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 @@ -199,10 +199,10 @@ } bb6: { -- StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 -- _12 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 - StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 - _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 +- StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 +- _12 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 - StorageLive(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49 - StorageLive(_15); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 - _15 = _12; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 @@ -214,8 +214,8 @@ - ((_3 as Vw).0: f32) = move _14; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50 - discriminant(_3) = 0; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50 - StorageDead(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 -- StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 - StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 +- StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7 + discriminant(_0) = 0; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7 @@ -225,10 +225,10 @@ } bb7: { -- StorageLive(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 -- _17 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 - StorageLive(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 - _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 +- StorageLive(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 +- _17 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 - StorageLive(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49 - StorageLive(_20); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 - _20 = _17; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 @@ -240,16 +240,16 @@ - ((_3 as Vh).0: f32) = move _19; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50 - discriminant(_3) = 1; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50 - StorageDead(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 -- StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 - StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 +- StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 - } - - bb8: { -- StorageLive(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 -- _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 - StorageLive(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 - _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 +- StorageLive(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 +- _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 - StorageLive(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55 - StorageLive(_25); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 - _25 = _22; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 @@ -261,16 +261,16 @@ - ((_3 as Vmin).0: f32) = move _24; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56 - discriminant(_3) = 2; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56 - StorageDead(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 -- StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 - StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 +- StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 - } - - bb9: { -- StorageLive(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 -- _27 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 - StorageLive(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 - _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 +- StorageLive(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 +- _27 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 - StorageLive(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55 - StorageLive(_30); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 - _30 = _27; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 @@ -282,8 +282,8 @@ - ((_3 as Vmax).0: f32) = move _29; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56 - discriminant(_3) = 3; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56 - StorageDead(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 -- StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 - StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 +- StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 - } - diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff index 05ef6721e6535..fcfa8fcb25735 100644 --- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff @@ -109,10 +109,10 @@ - - bb6: { + bb2: { - StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 - _12 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 + StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 + _12 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 StorageLive(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49 StorageLive(_15); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 _15 = _12; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 @@ -124,18 +124,18 @@ ((_3 as Vw).0: f32) = move _14; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50 discriminant(_3) = 0; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50 StorageDead(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 - StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 + StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 } - bb7: { + bb3: { - StorageLive(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 - _17 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 StorageLive(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 + StorageLive(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 + _17 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 StorageLive(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49 StorageLive(_20); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 _20 = _17; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 @@ -147,18 +147,18 @@ ((_3 as Vh).0: f32) = move _19; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50 discriminant(_3) = 1; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50 StorageDead(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 - StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 + StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 } - bb8: { + bb4: { - StorageLive(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 - _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 StorageLive(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 + StorageLive(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 + _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 StorageLive(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55 StorageLive(_25); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 _25 = _22; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 @@ -170,18 +170,18 @@ ((_3 as Vmin).0: f32) = move _24; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56 discriminant(_3) = 2; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56 StorageDead(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 - StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 + StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 } - bb9: { + bb5: { - StorageLive(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 - _27 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 StorageLive(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 + StorageLive(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 + _27 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 StorageLive(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55 StorageLive(_30); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 _30 = _27; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 @@ -193,8 +193,8 @@ ((_3 as Vmax).0: f32) = move _29; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56 discriminant(_3) = 3; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56 StorageDead(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 - StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 + StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 } diff --git a/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff index 9a6094f12dfb1..6703bc58c32df 100644 --- a/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff @@ -56,13 +56,13 @@ } bb4: { - StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16 - _9 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16 StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25 _10 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25 + StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16 + _9 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 - StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 + StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 13:6 } diff --git a/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff index c3aecb4529351..9efb2239e4069 100644 --- a/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff @@ -42,13 +42,13 @@ } bb3: { - StorageLive(_8); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:15: 20:16 - _8 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:15: 20:16 StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25 _9 = (((_3.1: std::option::Option) as Some).0: bool); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25 + StorageLive(_8); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:15: 20:16 + _8 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:15: 20:16 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32 - StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32 StorageDead(_8); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32 + StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32 goto -> bb4; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:19:5: 22:6 } diff --git a/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir b/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir index 0db0f8349bb73..f83acf723f588 100644 --- a/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir @@ -61,10 +61,10 @@ fn match_tuple(_1: (u32, bool, Option, u32)) -> u32 { } bb9: { - StorageLive(_7); // scope 0 at $DIR/exponential-or.rs:8:10: 8:21 - _7 = (_1.0: u32); // scope 0 at $DIR/exponential-or.rs:8:10: 8:21 StorageLive(_8); // scope 0 at $DIR/exponential-or.rs:8:57: 8:78 _8 = (_1.3: u32); // scope 0 at $DIR/exponential-or.rs:8:57: 8:78 + StorageLive(_7); // scope 0 at $DIR/exponential-or.rs:8:10: 8:21 + _7 = (_1.0: u32); // scope 0 at $DIR/exponential-or.rs:8:10: 8:21 StorageLive(_9); // scope 1 at $DIR/exponential-or.rs:8:83: 8:84 _9 = _7; // scope 1 at $DIR/exponential-or.rs:8:83: 8:84 StorageLive(_10); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88 @@ -72,8 +72,8 @@ fn match_tuple(_1: (u32, bool, Option, u32)) -> u32 { _0 = BitXor(move _9, move _10); // scope 1 at $DIR/exponential-or.rs:8:83: 8:88 StorageDead(_10); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88 StorageDead(_9); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88 - StorageDead(_8); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88 StorageDead(_7); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88 + StorageDead(_8); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88 goto -> bb10; // scope 0 at $DIR/exponential-or.rs:7:5: 10:6 } diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index 23aefe07892fd..08ad18fd0a72f 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -89,10 +89,10 @@ // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[1])) } (_5.1: &i32) = move _6; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _7 = (_5.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _8 = (_5.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _7 = (_5.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -106,8 +106,8 @@ bb1: { StorageDead(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 @@ -133,8 +133,8 @@ _19 = &_20; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_17.1: &&i32) = move _19; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _25 = (_17.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _28 = (_17.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _25 = (_17.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _24 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index b9cb58e14c45d..9a825abd261c8 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -138,10 +138,10 @@ (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -159,8 +159,8 @@ bb3: { _8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 @@ -205,10 +205,10 @@ (_31.1: &&i32) = move _34; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_34); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_32); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_36); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _36 = (_31.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _37 = (_31.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_36); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _36 = (_31.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_38); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_39); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _39 = _36; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -284,8 +284,8 @@ _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_38); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_37); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_36); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_37); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _29 = &_30; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _28 = _29; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index 499134b69919f..c4582cc6b52b3 100644 --- a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -78,12 +78,12 @@ } bb2: { - StorageLive(_13); // scope 1 at $DIR/issue_76432.rs:9:10: 9:16 - _13 = &(*_2)[0 of 3]; // scope 1 at $DIR/issue_76432.rs:9:10: 9:16 - StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:9:18: 9:24 - _14 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:9:18: 9:24 StorageLive(_15); // scope 1 at $DIR/issue_76432.rs:9:26: 9:32 _15 = &(*_2)[2 of 3]; // scope 1 at $DIR/issue_76432.rs:9:26: 9:32 + StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:9:18: 9:24 + _14 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:9:18: 9:24 + StorageLive(_13); // scope 1 at $DIR/issue_76432.rs:9:10: 9:16 + _13 = &(*_2)[0 of 3]; // scope 1 at $DIR/issue_76432.rs:9:10: 9:16 StorageLive(_16); // scope 2 at $DIR/issue_76432.rs:9:38: 9:52 StorageLive(_17); // scope 2 at $DIR/issue_76432.rs:9:38: 9:52 _17 = &raw const (*_13); // scope 2 at $DIR/issue_76432.rs:9:38: 9:40 @@ -103,9 +103,9 @@ StorageDead(_18); // scope 2 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_17); // scope 2 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_16); // scope 2 at $DIR/issue_76432.rs:9:84: 9:85 - StorageDead(_15); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 - StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_13); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 + StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 + StorageDead(_15); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_9); // scope 1 at $DIR/issue_76432.rs:11:6: 11:7 _0 = const (); // scope 0 at $DIR/issue_76432.rs:6:44: 12:2 StorageDead(_5); // scope 0 at $DIR/issue_76432.rs:12:1: 12:2 diff --git a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 4e7cd77035eec..4d13cd54b21d5 100644 --- a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -59,10 +59,10 @@ - } - - bb6: { - StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 - _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 + StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 + _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 - goto -> bb21; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb16; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -70,16 +70,17 @@ - bb7: { + bb4: { _0 = const 1_i32; // scope 1 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - drop(_7) -> [return: bb20, unwind: bb27]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + drop(_7) -> [return: bb15, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 } - bb8: { + bb5: { - StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 - _6 = &(_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 + StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + _6 = &(_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 - _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 - _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 StorageLive(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 @@ -116,12 +117,12 @@ StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 -- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 - _5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 +- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 + StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + _5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 - goto -> bb7; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb4; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -129,18 +130,18 @@ - bb13: { + bb9: { StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - falseEdge -> [real: bb2, imaginary: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } - bb14: { + bb10: { - StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 - _6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 + StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 + _6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 - _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 - _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 StorageLive(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 @@ -177,12 +178,12 @@ StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 -- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 - _5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 +- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 + StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 + _5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 - goto -> bb7; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb4; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -190,8 +191,8 @@ - bb19: { + bb14: { StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - falseEdge -> [real: bb4, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + goto -> bb2; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } @@ -199,9 +200,8 @@ - bb20: { + bb15: { StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -209,16 +209,17 @@ - bb21: { + bb16: { _0 = const 2_i32; // scope 2 at $DIR/match-arm-scopes.rs:16:41: 16:42 + StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 - drop(_16) -> [return: bb23, unwind: bb27]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 + drop(_16) -> [return: bb18, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 } - bb22: { + bb17: { - StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 - _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 + StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 + _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 - goto -> bb21; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb16; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -226,7 +227,6 @@ - bb23: { + bb18: { StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 - StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 - goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -239,8 +239,8 @@ - bb25: { + bb20: { - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - drop(_2) -> [return: bb26, unwind: bb28]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 + drop(_2) -> [return: bb21, unwind: bb23]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 } From 9c647d102168f0344bf895aedf96dd52c193aa25 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 2 Nov 2020 13:17:14 +0100 Subject: [PATCH 28/39] Improve deprecation attribute diagnostic messages. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (From the PR feedback.) Co-authored-by: Esteban Küber --- compiler/rustc_attr/src/builtin.rs | 3 ++- compiler/rustc_passes/src/stability.rs | 6 +++--- src/test/ui/deprecation/deprecation-sanity.rs | 2 +- src/test/ui/deprecation/deprecation-sanity.stderr | 12 ++++-------- .../stability-attribute-sanity.stderr | 8 ++------ 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 49ac97d833f9a..2fd625c2a6c26 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -656,7 +656,8 @@ where if let Some((_, span)) = &depr { struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes") - .span_note(*span, "first deprecation attribute here") + .span_label(attr.span, "repeated deprecation attribute") + .span_label(*span, "first deprecation attribute") .emit(); break; } diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index f6923b0dd9c3c..04b5c65e464fb 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -92,10 +92,10 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited { self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| { - lint.build("this `#[deprecated]' annotation has no effect") - .span_suggestion( + lint.build("this `#[deprecated]` annotation has no effect") + .span_suggestion_short( *span, - "try removing the deprecation attribute", + "remove the unnecessary deprecation attribute", String::new(), rustc_errors::Applicability::MachineApplicable, ) diff --git a/src/test/ui/deprecation/deprecation-sanity.rs b/src/test/ui/deprecation/deprecation-sanity.rs index 5fb3f81958965..4fc3fddadb99e 100644 --- a/src/test/ui/deprecation/deprecation-sanity.rs +++ b/src/test/ui/deprecation/deprecation-sanity.rs @@ -32,7 +32,7 @@ fn f1() { } struct X; -#[deprecated = "hello"] //~ ERROR this `#[deprecated]' annotation has no effect +#[deprecated = "hello"] //~ ERROR this `#[deprecated]` annotation has no effect impl Default for X { fn default() -> Self { X diff --git a/src/test/ui/deprecation/deprecation-sanity.stderr b/src/test/ui/deprecation/deprecation-sanity.stderr index b926a6dc09da7..7e70c35eeabdf 100644 --- a/src/test/ui/deprecation/deprecation-sanity.stderr +++ b/src/test/ui/deprecation/deprecation-sanity.stderr @@ -44,13 +44,9 @@ error[E0550]: multiple deprecated attributes --> $DIR/deprecation-sanity.rs:27:1 | LL | #[deprecated(since = "a", note = "b")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: first deprecation attribute here - --> $DIR/deprecation-sanity.rs:26:1 - | + | -------------------------------------- first deprecation attribute LL | #[deprecated(since = "a", note = "b")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute error[E0538]: multiple 'since' items --> $DIR/deprecation-sanity.rs:30:27 @@ -58,11 +54,11 @@ error[E0538]: multiple 'since' items LL | #[deprecated(since = "a", since = "b", note = "c")] | ^^^^^^^^^^^ -error: this `#[deprecated]' annotation has no effect +error: this `#[deprecated]` annotation has no effect --> $DIR/deprecation-sanity.rs:35:1 | LL | #[deprecated = "hello"] - | ^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute | = note: `#[deny(useless_deprecated)]` on by default diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr index f3edd5773cbb8..bf2436a535fd4 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr @@ -86,13 +86,9 @@ error[E0550]: multiple deprecated attributes --> $DIR/stability-attribute-sanity.rs:62:1 | LL | #[rustc_deprecated(since = "b", reason = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: first deprecation attribute here - --> $DIR/stability-attribute-sanity.rs:61:1 - | + | ------------------------------------------------- first deprecation attribute LL | #[rustc_deprecated(since = "b", reason = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute error[E0544]: multiple stability levels --> $DIR/stability-attribute-sanity.rs:64:1 From 6bdce7bedd765438ce4f138cb0ce9335659e32d6 Mon Sep 17 00:00:00 2001 From: Vishnunarayan K I Date: Mon, 2 Nov 2020 22:29:20 +0530 Subject: [PATCH 29/39] new fix method and update tests --- .../src/build/matches/simplify.rs | 38 +++++++++++------- ....match_tuple.SimplifyCfg-initial.after.mir | 6 +-- .../issue_73223.main.PreCodegen.64bit.diff | 8 ++-- ..._73223.main.SimplifyArmIdentity.64bit.diff | 12 +++--- ...76432.test.SimplifyComparisonIntegral.diff | 12 +++--- ...fg-initial.after-ElaborateDrops.after.diff | 40 +++++++++---------- .../borrowck-move-error-with-note.stderr | 2 +- ...ck-slice-pattern-element-loan-slice.stderr | 12 +++--- src/test/ui/nll/move-errors.stderr | 24 +++++------ .../borrowck-move-and-move.stderr | 18 ++++----- ...orrowck-pat-by-move-and-ref-inverse.stderr | 38 +++++++++--------- .../borrowck-pat-by-move-and-ref.stderr | 38 +++++++++--------- .../borrowck-pat-ref-mut-and-ref.stderr | 18 ++++----- .../move-ref-patterns-dynamic-semantics.rs | 2 +- .../span/dropck_direct_cycle_with_drop.stderr | 8 ++-- .../span/send-is-not-static-std-sync-2.stderr | 2 +- 16 files changed, 143 insertions(+), 135 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index 296051b173e5a..278d7a6374d4c 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -44,6 +44,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { candidate: &mut Candidate<'pat, 'tcx>, ) -> bool { // repeatedly simplify match pairs until fixed point is reached + debug!("simplify_candidate(candidate={:?})", candidate); + let mut new_bindings = Vec::new(); loop { let match_pairs = mem::take(&mut candidate.match_pairs); @@ -56,7 +58,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let mut changed = false; for match_pair in match_pairs { - match self.simplify_match_pair(match_pair, candidate) { + match self.simplify_match_pair(match_pair, candidate, &mut new_bindings) { Ok(()) => { changed = true; } @@ -65,6 +67,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } } + // issue #69971: the binding order should be right to left if there are more + // bindings after `@` to please the borrow checker + // Ex + // struct NonCopyStruct { + // copy_field: u32, + // } + // + // fn foo1(x: NonCopyStruct) { + // let y @ NonCopyStruct { copy_field: z } = x; + // // the above should turn into + // let z = x.copy_field; + // let y = x; + // } + new_bindings.extend_from_slice(&candidate.bindings); + mem::swap(&mut candidate.bindings, &mut new_bindings); + new_bindings.clear(); + if !changed { // Move or-patterns to the end, because they can result in us // creating additional candidates, so we want to test them as @@ -72,6 +91,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { candidate .match_pairs .sort_by_key(|pair| matches!(*pair.pattern.kind, PatKind::Or { .. })); + debug!("simplify_candidate: simplifed {:?}", candidate); return false; // if we were not able to simplify any, done. } } @@ -104,6 +124,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, match_pair: MatchPair<'pat, 'tcx>, candidate: &mut Candidate<'pat, 'tcx>, + bindings: &mut Vec>, ) -> Result<(), MatchPair<'pat, 'tcx>> { let tcx = self.hir.tcx(); match *match_pair.pattern.kind { @@ -131,20 +152,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } PatKind::Binding { name, mutability, mode, var, ty, ref subpattern, is_primary: _ } => { - // issue #69971: the binding order should be right to left if there are more - // bindings after `@` to please the borrow checker - // Ex - // struct NonCopyStruct { - // copy_field: u32, - // } - // - // fn foo1(x: NonCopyStruct) { - // let y @ NonCopyStruct { copy_field: z } = x; - // // the above should turn into - // let z = x.copy_field; - // let y = x; - // } - candidate.bindings.insert(0, Binding { + bindings.push(Binding { name, mutability, span: match_pair.pattern.span, diff --git a/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir b/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir index f83acf723f588..0db0f8349bb73 100644 --- a/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir @@ -61,10 +61,10 @@ fn match_tuple(_1: (u32, bool, Option, u32)) -> u32 { } bb9: { - StorageLive(_8); // scope 0 at $DIR/exponential-or.rs:8:57: 8:78 - _8 = (_1.3: u32); // scope 0 at $DIR/exponential-or.rs:8:57: 8:78 StorageLive(_7); // scope 0 at $DIR/exponential-or.rs:8:10: 8:21 _7 = (_1.0: u32); // scope 0 at $DIR/exponential-or.rs:8:10: 8:21 + StorageLive(_8); // scope 0 at $DIR/exponential-or.rs:8:57: 8:78 + _8 = (_1.3: u32); // scope 0 at $DIR/exponential-or.rs:8:57: 8:78 StorageLive(_9); // scope 1 at $DIR/exponential-or.rs:8:83: 8:84 _9 = _7; // scope 1 at $DIR/exponential-or.rs:8:83: 8:84 StorageLive(_10); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88 @@ -72,8 +72,8 @@ fn match_tuple(_1: (u32, bool, Option, u32)) -> u32 { _0 = BitXor(move _9, move _10); // scope 1 at $DIR/exponential-or.rs:8:83: 8:88 StorageDead(_10); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88 StorageDead(_9); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88 - StorageDead(_7); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88 StorageDead(_8); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88 + StorageDead(_7); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88 goto -> bb10; // scope 0 at $DIR/exponential-or.rs:7:5: 10:6 } diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index 08ad18fd0a72f..23aefe07892fd 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -89,10 +89,10 @@ // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[1])) } (_5.1: &i32) = move _6; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _8 = (_5.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _7 = (_5.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _8 = (_5.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -106,8 +106,8 @@ bb1: { StorageDead(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 @@ -133,8 +133,8 @@ _19 = &_20; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_17.1: &&i32) = move _19; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _28 = (_17.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _25 = (_17.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _28 = (_17.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _24 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index 9a825abd261c8..b9cb58e14c45d 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -138,10 +138,10 @@ (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -159,8 +159,8 @@ bb3: { _8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 @@ -205,10 +205,10 @@ (_31.1: &&i32) = move _34; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_34); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_32); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _37 = (_31.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_36); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _36 = (_31.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _37 = (_31.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_38); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_39); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _39 = _36; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -284,8 +284,8 @@ _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_38); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_36); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_37); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_36); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _29 = &_30; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _28 = _29; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index c4582cc6b52b3..499134b69919f 100644 --- a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -78,12 +78,12 @@ } bb2: { - StorageLive(_15); // scope 1 at $DIR/issue_76432.rs:9:26: 9:32 - _15 = &(*_2)[2 of 3]; // scope 1 at $DIR/issue_76432.rs:9:26: 9:32 - StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:9:18: 9:24 - _14 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:9:18: 9:24 StorageLive(_13); // scope 1 at $DIR/issue_76432.rs:9:10: 9:16 _13 = &(*_2)[0 of 3]; // scope 1 at $DIR/issue_76432.rs:9:10: 9:16 + StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:9:18: 9:24 + _14 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:9:18: 9:24 + StorageLive(_15); // scope 1 at $DIR/issue_76432.rs:9:26: 9:32 + _15 = &(*_2)[2 of 3]; // scope 1 at $DIR/issue_76432.rs:9:26: 9:32 StorageLive(_16); // scope 2 at $DIR/issue_76432.rs:9:38: 9:52 StorageLive(_17); // scope 2 at $DIR/issue_76432.rs:9:38: 9:52 _17 = &raw const (*_13); // scope 2 at $DIR/issue_76432.rs:9:38: 9:40 @@ -103,9 +103,9 @@ StorageDead(_18); // scope 2 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_17); // scope 2 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_16); // scope 2 at $DIR/issue_76432.rs:9:84: 9:85 - StorageDead(_13); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 - StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_15); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 + StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 + StorageDead(_13); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_9); // scope 1 at $DIR/issue_76432.rs:11:6: 11:7 _0 = const (); // scope 0 at $DIR/issue_76432.rs:6:44: 12:2 StorageDead(_5); // scope 0 at $DIR/issue_76432.rs:12:1: 12:2 diff --git a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 4d13cd54b21d5..4e7cd77035eec 100644 --- a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -59,10 +59,10 @@ - } - - bb6: { - StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 - _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 + StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 + _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 - goto -> bb21; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb16; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -70,17 +70,16 @@ - bb7: { + bb4: { _0 = const 1_i32; // scope 1 at $DIR/match-arm-scopes.rs:15:77: 15:78 - StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - drop(_7) -> [return: bb20, unwind: bb27]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + drop(_7) -> [return: bb15, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 } - bb8: { + bb5: { - StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 - _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 _6 = &(_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 + _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 - _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 - _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 StorageLive(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 @@ -117,12 +116,12 @@ StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 -- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 - _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 +- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 _5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 + _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 - goto -> bb7; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb4; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -130,18 +129,18 @@ - bb13: { + bb9: { StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - falseEdge -> [real: bb2, imaginary: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } - bb14: { + bb10: { - StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 - _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 _6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 + StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 + _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 - _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 - _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 StorageLive(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 @@ -178,12 +177,12 @@ StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 -- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 - _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 +- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 _5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 + StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 + _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 - goto -> bb7; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb4; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -191,8 +190,8 @@ - bb19: { + bb14: { StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - falseEdge -> [real: bb4, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + goto -> bb2; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } @@ -200,8 +199,9 @@ - bb20: { + bb15: { StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -209,17 +209,16 @@ - bb21: { + bb16: { _0 = const 2_i32; // scope 2 at $DIR/match-arm-scopes.rs:16:41: 16:42 - StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 - drop(_16) -> [return: bb23, unwind: bb27]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 + drop(_16) -> [return: bb18, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 } - bb22: { + bb17: { - StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 - _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 + StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 + _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 - goto -> bb21; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb16; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -227,6 +226,7 @@ - bb23: { + bb18: { StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 + StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 - goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } @@ -239,8 +239,8 @@ - bb25: { + bb20: { - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - drop(_2) -> [return: bb26, unwind: bb28]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 + drop(_2) -> [return: bb21, unwind: bb23]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 } diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.stderr b/src/test/ui/borrowck/borrowck-move-error-with-note.stderr index de410a8b3120c..ead02414a622b 100644 --- a/src/test/ui/borrowck/borrowck-move-error-with-note.stderr +++ b/src/test/ui/borrowck/borrowck-move-error-with-note.stderr @@ -1,4 +1,4 @@ -error[E0507]: cannot move out of `f.1` which is behind a shared reference +error[E0507]: cannot move out of `f.0` which is behind a shared reference --> $DIR/borrowck-move-error-with-note.rs:11:11 | LL | match *f { diff --git a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr index f7fa467c4682c..d3388e071aa53 100644 --- a/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr +++ b/src/test/ui/borrowck/borrowck-slice-pattern-element-loan-slice.stderr @@ -32,23 +32,23 @@ error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as im --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:25:23 | LL | if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s { - | ------------- immutable borrow occurs here + | ------------- immutable borrow occurs here ... LL | if let [_, _, ref mut from_begin2, ..] = *s { | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin2, from_end1, from_end3, from_end4]); - | --------- immutable borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:28:26 | LL | if let [.., _, ref from_end4, ref from_end3, _, ref from_end1] = *s { - | ------------- immutable borrow occurs here + | ------------- immutable borrow occurs here ... LL | if let [_, _, _, ref mut from_begin3, ..] = *s { | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin3, from_end1, from_end3, from_end4]); - | --------- immutable borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:33:21 @@ -75,12 +75,12 @@ error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as im --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:39:21 | LL | if let [ref from_begin0, ref from_begin1, _, ref from_begin3, _, ..] = *s { - | --------------- immutable borrow occurs here + | --------------- immutable borrow occurs here ... LL | if let [.., ref mut from_end4, _, _, _] = *s { | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin0, from_begin1, from_begin3, from_end4]); - | ----------- immutable borrow later used here + | ----------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan-slice.rs:47:20 diff --git a/src/test/ui/nll/move-errors.stderr b/src/test/ui/nll/move-errors.stderr index b69ed0bb875a2..0df326425ad9c 100644 --- a/src/test/ui/nll/move-errors.stderr +++ b/src/test/ui/nll/move-errors.stderr @@ -97,18 +97,6 @@ LL | B::U(D(s)) => (), | data moved here | move occurs because `s` has type `String`, which does not implement the `Copy` trait -error[E0507]: cannot move out of `*x.1` which is behind a shared reference - --> $DIR/move-errors.rs:92:11 - | -LL | match x { - | ^ -... -LL | (D(s), &t) => (), - | - - | | - | data moved here - | move occurs because `t` has type `String`, which does not implement the `Copy` trait - error[E0509]: cannot move out of type `D`, which implements the `Drop` trait --> $DIR/move-errors.rs:92:11 | @@ -121,6 +109,18 @@ LL | (D(s), &t) => (), | data moved here | move occurs because `s` has type `String`, which does not implement the `Copy` trait +error[E0507]: cannot move out of `*x.1` which is behind a shared reference + --> $DIR/move-errors.rs:92:11 + | +LL | match x { + | ^ +... +LL | (D(s), &t) => (), + | - + | | + | data moved here + | move occurs because `t` has type `String`, which does not implement the `Copy` trait + error[E0509]: cannot move out of type `F`, which implements the `Drop` trait --> $DIR/move-errors.rs:102:11 | diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr index b9be896882360..482ebd9b423fb 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr @@ -11,9 +11,9 @@ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:15:9 | LL | let a @ (b, c) = (U, U); - | ^^^^^-^^^^ - | | | - | | value partially moved here + | ^^^^^^^^-^ + | | | + | | value partially moved here | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait @@ -22,9 +22,9 @@ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:17:9 | LL | let a @ (b, c) = (u(), u()); - | ^^^^^-^^^^ - | | | - | | value partially moved here + | ^^^^^^^^-^ + | | | + | | value partially moved here | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait @@ -63,9 +63,9 @@ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:27:9 | LL | xs @ [a, .., b] => {} - | ^^^^^^-^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^-^ + | | | + | | value partially moved here | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index 4a126a2219246..c1ea5d8ec6dda 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -262,9 +262,9 @@ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:26:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | ^^^^^-----------------^^^^^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^^^^^^^^^---------^ + | | | + | | value partially moved here | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait @@ -273,9 +273,9 @@ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:35:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | ^^^^^-----------------^^^^^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^^^^^^^^^---------^ + | | | + | | value partially moved here | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait @@ -284,39 +284,39 @@ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ^^^^^^^^^^-----------------^^^^^^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^ + | | | + | | value partially moved here | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving the value | -LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} - | ^^^ +LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} + | ^^^ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ^^^^^^^^^^-----------------^^^^^^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^ + | | | + | | value partially moved here | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving the value | -LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} - | ^^^ +LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} + | ^^^ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:11 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | ^^^^^^^^^---------^^^^^^^^^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^^^^^-------------^ + | | | + | | value partially moved here | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index 9113821d746ef..a39ff8774f79e 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -237,9 +237,9 @@ error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:32:9 | LL | let ref mut a @ [b, mut c] = [U, U]; - | ^^^^^^^^^^^^^-^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^-----^ + | | | + | | value partially moved here | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait @@ -279,9 +279,9 @@ error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:44:9 | LL | let ref mut a @ [b, mut c] = [u(), u()]; - | ^^^^^^^^^^^^^-^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^-----^ + | | | + | | value partially moved here | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait @@ -290,16 +290,16 @@ error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:61:9 | LL | ref mut a @ Some([b, mut c]) => {} - | ^^^^^^^^^^^^^^^^^^-^^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^^^^^^-----^^ + | | | + | | value partially moved here | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving the value | -LL | ref mut a @ Some([ref b, mut c]) => {} - | ^^^ +LL | ref mut a @ Some([b, ref mut c]) => {} + | ^^^ error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9 @@ -350,16 +350,16 @@ error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9 | LL | ref mut a @ Some([b, mut c]) => {} - | ^^^^^^^^^^^^^^^^^^-^^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^^^^^^-----^^ + | | | + | | value partially moved here | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait help: borrow this field in the pattern to avoid moving the value | -LL | ref mut a @ Some([ref b, mut c]) => {} - | ^^^ +LL | ref mut a @ Some([b, ref mut c]) => {} + | ^^^ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:13:11 @@ -397,9 +397,9 @@ error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:22:11 | LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} - | ^^^^^^^^^^^^^-^^^^^^^^ - | | | - | | value partially moved here + | ^^^^^^^^^^^^^^^^-----^ + | | | + | | value partially moved here | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index d9b59504419ac..26182a1bc7419 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -442,12 +442,12 @@ error[E0502]: cannot borrow value as immutable because it is also borrowed as mu --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | ^^^^^^^^^^^^^^^^^^^^---------^ - | | | - | | mutable borrow occurs here + | ^^^^^^^^^---------^^^^^^^^^^^^ + | | | + | | mutable borrow occurs here | immutable borrow occurs here ... -LL | *c = U; +LL | *b = U; | ------ mutable borrow later used here error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable @@ -466,12 +466,12 @@ error[E0502]: cannot borrow value as immutable because it is also borrowed as mu --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | ^^^^^^^^^^^^^^^^^^^^---------^ - | | | - | | mutable borrow occurs here + | ^^^^^^^^^---------^^^^^^^^^^^^ + | | | + | | mutable borrow occurs here | immutable borrow occurs here -... -LL | *c = U; +LL | +LL | *b = U; | ------ mutable borrow later used here error[E0382]: borrow of moved value diff --git a/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs b/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs index fdf92b6694513..1d6d9acead1d4 100644 --- a/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs +++ b/src/test/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs @@ -74,6 +74,6 @@ fn main() { }; lam((mk(19), mk(20), mk(21), mk(22))); } - let expected = [2, 3, 6, 5, 7, 8, 12, 11, 9, 10, 13, 18, 14, 15, 16, 17, 19, 21, 20, 22, 4, 1]; + let expected = [2, 3, 6, 5, 7, 8, 12, 11, 9, 10, 18, 13, 14, 15, 16, 17, 21, 19, 20, 22, 4, 1]; assert_eq!(&*d.borrow(), &expected); } diff --git a/src/test/ui/span/dropck_direct_cycle_with_drop.stderr b/src/test/ui/span/dropck_direct_cycle_with_drop.stderr index e01c1f87428f0..07ae138ac71ea 100644 --- a/src/test/ui/span/dropck_direct_cycle_with_drop.stderr +++ b/src/test/ui/span/dropck_direct_cycle_with_drop.stderr @@ -8,7 +8,9 @@ LL | } | - | | | `d2` dropped here while still borrowed - | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` + | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` + | + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `d1` does not live long enough --> $DIR/dropck_direct_cycle_with_drop.rs:38:19 @@ -20,9 +22,7 @@ LL | } | - | | | `d1` dropped here while still borrowed - | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` - | - = note: values in a scope are dropped in the opposite order they are defined + | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` error: aborting due to 2 previous errors diff --git a/src/test/ui/span/send-is-not-static-std-sync-2.stderr b/src/test/ui/span/send-is-not-static-std-sync-2.stderr index e4aa2aed24e42..bcd07e1164777 100644 --- a/src/test/ui/span/send-is-not-static-std-sync-2.stderr +++ b/src/test/ui/span/send-is-not-static-std-sync-2.stderr @@ -24,7 +24,7 @@ error[E0597]: `x` does not live long enough --> $DIR/send-is-not-static-std-sync-2.rs:31:25 | LL | let (_tx, rx) = { - | -- borrow later used here + | --- borrow later used here ... LL | let _ = tx.send(&x); | ^^ borrowed value does not live long enough From 0c34f5aba8544e2319c1587ac067c188a2d97877 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 2 Nov 2020 18:16:57 +0100 Subject: [PATCH 30/39] Refactor the build system --- .gitignore | 2 +- Readme.md | 29 +++++++------ build.sh | 47 +++++++++++++++++++++ build_sysroot/build_sysroot.sh | 30 ++++++------- build_sysroot/prepare_sysroot_src.sh | 2 +- clean_all.sh | 2 +- cargo.sh => scripts/cargo.sh | 14 ++----- scripts/config.sh | 9 ++-- scripts/filter_profile.rs | 3 +- scripts/rustup.sh | 9 ++++ scripts/tests.sh | 63 ++++++++++++++++++---------- src/bin/cg_clif.rs | 5 --- test.sh | 24 +++-------- 13 files changed, 145 insertions(+), 94 deletions(-) create mode 100755 build.sh rename cargo.sh => scripts/cargo.sh (51%) mode change 100644 => 100755 scripts/tests.sh diff --git a/.gitignore b/.gitignore index 0da9927b479b4..18196bce00945 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ perf.data perf.data.old *.events *.string* -/build_sysroot/sysroot +/build /build_sysroot/sysroot_src /rust /rand diff --git a/Readme.md b/Readme.md index ca380703a7f24..151334877a0b1 100644 --- a/Readme.md +++ b/Readme.md @@ -2,7 +2,10 @@ > ⚠⚠⚠ Certain kinds of FFI don't work yet. ⚠⚠⚠ -The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). This has the potential to improve compilation times in debug mode. If your project doesn't use any of the things listed under "Not yet supported", it should work fine. If not please open an issue. +The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). +This has the potential to improve compilation times in debug mode. +If your project doesn't use any of the things listed under "Not yet supported", it should work fine. +If not please open an issue. ## Building and testing @@ -10,40 +13,40 @@ The goal of this project is to create an alternative codegen backend for the rus $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift $ ./prepare.sh # download and patch sysroot src and install hyperfine for benchmarking -$ ./test.sh --release +$ ./build.sh ``` -If you want to only build but not test you should replace the last command with: +To run the test suite replace the last command with: ```bash -$ cargo build --release -$ ./build_sysroot/build_sysroot.sh +$ ./test.sh ``` +This will implicitly build cg_clif too. Both `build.sh` and `test.sh` accept a `--debug` argument to +build in debug mode. + ## Usage rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects. -Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`prepare.sh` and `test.sh`). +Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`prepare.sh` and `build.sh` or `test.sh`). ### Cargo In the directory with your project (where you can do the usual `cargo build`), run: ```bash -$ $cg_clif_dir/cargo.sh run +$ $cg_clif_dir/build/cargo.sh run ``` This should build and run your project with rustc_codegen_cranelift instead of the usual LLVM backend. -If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./test.sh`) you should set `CHANNEL="debug"`. - ### Rustc > You should prefer using the Cargo method. ```bash -$ $cg_clif_dir/target/release/cg_clif my_crate.rs +$ $cg_clif_dir/build/cg_clif my_crate.rs ``` ### Jit mode @@ -54,13 +57,13 @@ In jit mode cg_clif will immediately execute your code without creating an execu > The jit mode will probably need cargo integration to make this possible. ```bash -$ $cg_clif_dir/cargo.sh jit +$ $cg_clif_dir/build/cargo.sh jit ``` or ```bash -$ $cg_clif_dir/target/release/cg_clif --jit my_crate.rs +$ $cg_clif_dir/build/cg_clif --jit my_crate.rs ``` ### Shell @@ -69,7 +72,7 @@ These are a few functions that allow you to easily run rust code from the shell ```bash function jit_naked() { - echo "$@" | $cg_clif_dir/target/release/cg_clif - --jit + echo "$@" | $cg_clif_dir/build/cg_clif - --jit } function jit() { diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000000..f9a87e68a046a --- /dev/null +++ b/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +# Settings +export CHANNEL="release" +build_sysroot=1 +target_dir='build' +while [[ $# != 0 ]]; do + case $1 in + "--debug") + export CHANNEL="debug" + ;; + "--without-sysroot") + build_sysroot=0 + ;; + "--target-dir") + target_dir=$2 + shift + ;; + *) + echo "Unknown flag '$1'" + echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR]" + ;; + esac + shift +done + +# Build cg_clif +export RUSTFLAGS="-Zrun_dsymutil=no" +if [[ "$CHANNEL" == "release" ]]; then + cargo build --release +else + cargo build +fi + +rm -rf $target_dir +mkdir $target_dir +cp -a target/$CHANNEL/cg_clif{,_build_sysroot} target/$CHANNEL/*rustc_codegen_cranelift* $target_dir/ +cp -a rust-toolchain scripts/config.sh scripts/cargo.sh $target_dir + +if [[ "$build_sysroot" == "1" ]]; then + echo "[BUILD] sysroot" + export CG_CLIF_INCR_CACHE_DISABLED=1 + dir=$(pwd) + cd $target_dir + time $dir/build_sysroot/build_sysroot.sh +fi diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 7557f74b28607..1d87562a6a419 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -3,28 +3,24 @@ # Requires the CHANNEL env var to be set to `debug` or `release.` set -e -cd $(dirname "$0") -if [ -z $CHANNEL ]; then -export CHANNEL='release' -fi +source ./config.sh -pushd ../ >/dev/null -source ./scripts/config.sh -popd >/dev/null +dir=$(pwd) -# We expect the target dir in the default location. Guard against the user changing it. -export CARGO_TARGET_DIR=target +# Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that +# build scripts are still compiled using cg_llvm. +export RUSTC=$dir"/cg_clif_build_sysroot" +export RUSTFLAGS=$RUSTFLAGS" --clif" + +cd $(dirname "$0") # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache -rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true -rm -r sysroot/ 2>/dev/null || true +#rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true -# Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that -# build scripts are still compiled using cg_llvm. -export RUSTC=$(pwd)/../"target/"$CHANNEL"/cg_clif_build_sysroot" -export RUSTFLAGS=$RUSTFLAGS" --clif" +# We expect the target dir in the default location. Guard against the user changing it. +export CARGO_TARGET_DIR=target # Build libs export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort" @@ -39,5 +35,5 @@ else fi # Copy files to sysroot -mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ -cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +mkdir -p $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +cp -a target/$TARGET_TRIPLE/$sysroot_channel/deps/* $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/build_sysroot/prepare_sysroot_src.sh b/build_sysroot/prepare_sysroot_src.sh index 14aa77478f54d..d0fb09ce745d4 100755 --- a/build_sysroot/prepare_sysroot_src.sh +++ b/build_sysroot/prepare_sysroot_src.sh @@ -12,7 +12,7 @@ fi rm -rf $DST_DIR mkdir -p $DST_DIR/library -cp -r $SRC_DIR/library $DST_DIR/ +cp -a $SRC_DIR/library $DST_DIR/ pushd $DST_DIR echo "[GIT] init" diff --git a/clean_all.sh b/clean_all.sh index 3003a0ea2d102..5a69c862d016d 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -1,5 +1,5 @@ #!/bin/bash --verbose set -e -rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/} perf.data{,.old} +rm -rf target/ build/ build_sysroot/{sysroot_src/,target/} perf.data{,.old} rm -rf rand/ regex/ simple-raytracer/ diff --git a/cargo.sh b/scripts/cargo.sh similarity index 51% rename from cargo.sh rename to scripts/cargo.sh index cebc3e67363a8..e63daa40f3540 100755 --- a/cargo.sh +++ b/scripts/cargo.sh @@ -1,19 +1,13 @@ #!/bin/bash -if [ -z $CHANNEL ]; then -export CHANNEL='release' -fi - -pushd $(dirname "$0") >/dev/null -source scripts/config.sh +dir=$(dirname "$0") +source $dir/config.sh # read nightly compiler from rust-toolchain file -TOOLCHAIN=$(cat rust-toolchain) - -popd >/dev/null +TOOLCHAIN=$(cat $dir/rust-toolchain) cmd=$1 -shift +shift || true if [[ "$cmd" = "jit" ]]; then cargo +${TOOLCHAIN} rustc $@ -- --jit diff --git a/scripts/config.sh b/scripts/config.sh index 530b7f242a098..af181f4f72439 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -39,18 +39,19 @@ echo export RUSTC_WRAPPER= fi -export RUSTC=$(pwd)/"target/"$CHANNEL"/cg_clif" +dir=$(cd $(dirname "$BASH_SOURCE"); pwd) + +export RUSTC=$dir"/cg_clif" export RUSTFLAGS=$linker export RUSTDOCFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Zpanic-abort-tests '\ -'-Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +'-Zcodegen-backend='$dir'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir'/sysroot' # FIXME remove once the atomic shim is gone if [[ `uname` == 'Darwin' ]]; then export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup" fi -export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib:\ -$(pwd)/target/"$CHANNEL":$(rustc --print sysroot)/lib" +export LD_LIBRARY_PATH="$dir:$(rustc --print sysroot)/lib:$dir/target/out:$dir/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib" export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH export CG_CLIF_DISPLAY_CG_TIME=1 diff --git a/scripts/filter_profile.rs b/scripts/filter_profile.rs index c70c3ec47f31f..3327c10089d9b 100755 --- a/scripts/filter_profile.rs +++ b/scripts/filter_profile.rs @@ -1,9 +1,8 @@ #!/bin/bash #![forbid(unsafe_code)]/* This line is ignored by bash # This block is ignored by rustc -CHANNEL="release" pushd $(dirname "$0")/../ -source scripts/config.sh +source build/config.sh popd PROFILE=$1 OUTPUT=$2 exec $RUSTC $RUSTFLAGS --jit $0 #*/ diff --git a/scripts/rustup.sh b/scripts/rustup.sh index 38991d6d47dd0..541b3c6563bab 100755 --- a/scripts/rustup.sh +++ b/scripts/rustup.sh @@ -26,6 +26,15 @@ case $1 in git add rust-toolchain build_sysroot/Cargo.lock git commit -m "Rustup to $(rustc -V)" ;; + "push") + cg_clif=$(pwd) + pushd ../rust + branch=update_cg_clif-$(date +%Y-%m-%d) + git checkout -b $branch + git subtree pull --prefix=compiler/rustc_codegen_cranelift/ https://github.com/bjorn3/rustc_codegen_cranelift.git master + git push -u my $branch + popd + ;; *) echo "Unknown command '$1'" echo "Usage: ./rustup.sh prepare|commit" diff --git a/scripts/tests.sh b/scripts/tests.sh old mode 100644 new mode 100755 index 7d1e488ac3a06..d941b73c81bcc --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -1,65 +1,71 @@ -function no_sysroot_tests() { - RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2" +#!/bin/bash + +set -e + +source build/config.sh +export CG_CLIF_INCR_CACHE_DISABLED=1 +MY_RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2" +function no_sysroot_tests() { echo "[BUILD] mini_core" - $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE + $MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE echo "[BUILD] example" - $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE + $MY_RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE if [[ "$JIT_SUPPORTED" = "1" ]]; then echo "[JIT] mini_core_hello_world" - CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE + CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE else echo "[JIT] mini_core_hello_world (skipped)" fi echo "[AOT] mini_core_hello_world" - $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE + $MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd # (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd echo "[AOT] arbitrary_self_types_pointers_and_wrappers" - $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE + $MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers } function base_sysroot_tests() { echo "[AOT] alloc_example" - $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE + $MY_RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/alloc_example if [[ "$JIT_SUPPORTED" = "1" ]]; then echo "[JIT] std_example" - $RUSTC --jit example/std_example.rs --target $HOST_TRIPLE + $MY_RUSTC --jit example/std_example.rs --target $HOST_TRIPLE else echo "[JIT] std_example (skipped)" fi echo "[AOT] dst_field_align" # FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. - $RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE + $MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false) echo "[AOT] std_example" - $RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE + $MY_RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/std_example arg echo "[AOT] subslice-patterns-const-eval" - $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE + $MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/subslice-patterns-const-eval echo "[AOT] track-caller-attribute" - $RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE + $MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/track-caller-attribute echo "[AOT] mod_bench" - $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE + $MY_RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/mod_bench pushd rand rm -r ./target || true - ../cargo.sh test --workspace + ../build/cargo.sh test --workspace popd } @@ -69,7 +75,7 @@ function extended_sysroot_tests() { echo "[BENCH COMPILE] ebobby/simple-raytracer" hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \ "RUSTC=rustc RUSTFLAGS='' cargo build" \ - "../cargo.sh build" + "../build/cargo.sh build" echo "[BENCH RUN] ebobby/simple-raytracer" cp ./target/debug/main ./raytracer_cg_clif @@ -85,18 +91,33 @@ function extended_sysroot_tests() { pushd build_sysroot/sysroot_src/library/core/tests echo "[TEST] libcore" rm -r ./target || true - ../../../../../cargo.sh test + ../../../../../build/cargo.sh test popd pushd regex echo "[TEST] rust-lang/regex example shootout-regex-dna" - ../cargo.sh clean + ../build/cargo.sh clean # Make sure `[codegen mono items] start` doesn't poison the diff - ../cargo.sh build --example shootout-regex-dna - cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt + ../build/cargo.sh build --example shootout-regex-dna + cat examples/regexdna-input.txt | ../build/cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt diff -u res.txt examples/regexdna-output.txt echo "[TEST] rust-lang/regex tests" - ../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options + ../build/cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q popd } + +case "$1" in + "no_sysroot") + no_sysroot_tests + ;; + "base_sysroot") + base_sysroot_tests + ;; + "extended_sysroot") + extended_sysroot_tests + ;; + *) + echo "unknown test suite" + ;; +esac diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs index 9a661dcbcc5d6..6253022ade227 100644 --- a/src/bin/cg_clif.rs +++ b/src/bin/cg_clif.rs @@ -31,11 +31,6 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks { .unwrap() .parent() .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .join("build_sysroot") .join("sysroot"), ); } diff --git a/test.sh b/test.sh index e7a0d6ab4e1f6..3cdd4119d794c 100755 --- a/test.sh +++ b/test.sh @@ -1,29 +1,15 @@ #!/bin/bash set -e -# Build cg_clif export RUSTFLAGS="-Zrun_dsymutil=no" -if [[ "$1" == "--release" ]]; then - export CHANNEL='release' - cargo build --release -else - export CHANNEL='debug' - cargo build --bin cg_clif -fi -# Config -source scripts/config.sh -source scripts/tests.sh -export CG_CLIF_INCR_CACHE_DISABLED=1 +./build.sh --without-sysroot $@ -# Cleanup rm -r target/out || true -no_sysroot_tests +scripts/tests.sh no_sysroot -echo "[BUILD] sysroot" -time ./build_sysroot/build_sysroot.sh +./build.sh $@ -base_sysroot_tests - -extended_sysroot_tests +scripts/tests.sh base_sysroot +scripts/tests.sh extended_sysroot From 831573089555f8f7b6f7fbf021a92c95ad4a98a9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 2 Nov 2020 18:24:21 +0100 Subject: [PATCH 31/39] Upload prebuilt cg_clif --- .github/workflows/main.yml | 11 ++++++++++- Readme.md | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 841e1a0870ed3..e6d3375fb1bab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,4 +51,13 @@ jobs: export COMPILE_RUNS=2 export RUN_RUNS=2 - ./test.sh --release + ./test.sh + + - name: Package prebuilt cg_clif + run: tar cvfJ cg_clif.tar.xz build + + - name: Upload prebuilt cg_clif + uses: actions/upload-artifact@v2 + with: + name: cg_clif-${{ runner.os }} + path: cg_clif.tar.xz diff --git a/Readme.md b/Readme.md index 151334877a0b1..f8a5e13ed54c1 100644 --- a/Readme.md +++ b/Readme.md @@ -25,6 +25,11 @@ $ ./test.sh This will implicitly build cg_clif too. Both `build.sh` and `test.sh` accept a `--debug` argument to build in debug mode. +Alternatively you can download a pre built version from [GHA]. It is listed in the artifacts section +of workflow runs. Unfortunately due to GHA restrictions you need to be logged in to access it. + +[GHA]: https://github.com/bjorn3/rustc_codegen_cranelift/actions?query=branch%3Amaster+event%3Apush+is%3Asuccess + ## Usage rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects. From 646b00ff7710fb9f8a1a6de744f38bdcb1c932d7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 2 Nov 2020 18:54:10 +0100 Subject: [PATCH 32/39] Revert unintentional change --- build_sysroot/build_sysroot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 1d87562a6a419..eba15c0dd4308 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -17,7 +17,7 @@ cd $(dirname "$0") # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache -#rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true +rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true # We expect the target dir in the default location. Guard against the user changing it. export CARGO_TARGET_DIR=target From 54b1d101efec3da791aee1f98fb26230e88b9a05 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Nov 2020 16:57:14 +0100 Subject: [PATCH 33/39] Test bootstrapping of rustc using cg_clif --- .github/workflows/bootstrap_rustc.yml | 44 ++++++++++++++++++ scripts/test_bootstrap.sh | 65 +++++++++++++++++++++++++++ src/bin/cg_clif.rs | 12 ++--- 3 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/bootstrap_rustc.yml create mode 100755 scripts/test_bootstrap.sh diff --git a/.github/workflows/bootstrap_rustc.yml b/.github/workflows/bootstrap_rustc.yml new file mode 100644 index 0000000000000..8c94a0aa5e6eb --- /dev/null +++ b/.github/workflows/bootstrap_rustc.yml @@ -0,0 +1,44 @@ +name: Bootstrap rustc using cg_clif + +on: + - push + +jobs: + bootstrap_rustc: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Cache cargo installed crates + uses: actions/cache@v2 + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-cargo-installed-crates + + - name: Cache cargo registry and index + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo target dir + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + + - name: Prepare dependencies + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + ./prepare.sh + + - name: Test + run: | + # Enable backtraces for easier debugging + export RUST_BACKTRACE=1 + + ./scripts/test_bootstrap.sh diff --git a/scripts/test_bootstrap.sh b/scripts/test_bootstrap.sh new file mode 100755 index 0000000000000..7f43f81a6cdcd --- /dev/null +++ b/scripts/test_bootstrap.sh @@ -0,0 +1,65 @@ +#!/bin/bash +set -e + +cd $(dirname "$0")/../ + +./build.sh +source build/config.sh + +echo "[TEST] Bootstrap of rustc" +git clone https://github.com/rust-lang/rust.git || true +pushd rust +git fetch +git checkout -- . +git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(') + +git apply - < config.toml < Date: Mon, 2 Nov 2020 13:22:03 -0500 Subject: [PATCH 34/39] Use reparsed `TokenStream` if we captured any inner attributes Fixes #78675 We now bail out of `prepend_attrs` if we ended up capturing any inner attributes (which can happen in several places, due to token capturing for `macro_rules!` arguments. --- compiler/rustc_parse/src/lib.rs | 10 +-- compiler/rustc_parse/src/parser/item.rs | 33 ++----- .../issue-78675-captured-inner-attrs.rs | 32 +++++++ .../issue-78675-captured-inner-attrs.stdout | 86 +++++++++++++++++++ 4 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 src/test/ui/proc-macro/issue-78675-captured-inner-attrs.rs create mode 100644 src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index e851451269e32..bad43cd5350f2 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -611,11 +611,11 @@ fn prepend_attrs( } let mut builder = tokenstream::TokenStreamBuilder::new(); for attr in attrs { - assert_eq!( - attr.style, - ast::AttrStyle::Outer, - "inner attributes should prevent cached tokens from existing" - ); + // FIXME: Correctly handle tokens for inner attributes. + // For now, we fall back to reparsing the original AST node + if attr.style == ast::AttrStyle::Inner { + return None; + } builder.push( attr.tokens .as_ref() diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 48a635844fe70..5954b370e6d98 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -7,7 +7,7 @@ use crate::maybe_whole; use rustc_ast::ptr::P; use rustc_ast::token::{self, TokenKind}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; -use rustc_ast::{self as ast, AttrStyle, AttrVec, Attribute, DUMMY_NODE_ID}; +use rustc_ast::{self as ast, AttrVec, Attribute, DUMMY_NODE_ID}; use rustc_ast::{AssocItem, AssocItemKind, ForeignItemKind, Item, ItemKind, Mod}; use rustc_ast::{Async, Const, Defaultness, IsAuto, Mutability, Unsafe, UseTree, UseTreeKind}; use rustc_ast::{BindingMode, Block, FnDecl, FnSig, Param, SelfKind}; @@ -127,34 +127,19 @@ impl<'a> Parser<'a> { let (mut item, tokens) = if needs_tokens { let (item, tokens) = self.collect_tokens(parse_item)?; - (item, Some(tokens)) + (item, tokens) } else { (parse_item(self)?, None) }; - - self.unclosed_delims.append(&mut unclosed_delims); - - // Once we've parsed an item and recorded the tokens we got while - // parsing we may want to store `tokens` into the item we're about to - // return. Note, though, that we specifically didn't capture tokens - // related to outer attributes. The `tokens` field here may later be - // used with procedural macros to convert this item back into a token - // stream, but during expansion we may be removing attributes as we go - // along. - // - // If we've got inner attributes then the `tokens` we've got above holds - // these inner attributes. If an inner attribute is expanded we won't - // actually remove it from the token stream, so we'll just keep yielding - // it (bad!). To work around this case for now we just avoid recording - // `tokens` if we detect any inner attributes. This should help keep - // expansion correct, but we should fix this bug one day! - if let Some(tokens) = tokens { - if let Some(item) = &mut item { - if !item.attrs.iter().any(|attr| attr.style == AttrStyle::Inner) { - item.tokens = tokens; - } + if let Some(item) = &mut item { + // If we captured tokens during parsing (due to encountering an `NtItem`), + // use those instead + if item.tokens.is_none() { + item.tokens = tokens; } } + + self.unclosed_delims.append(&mut unclosed_delims); Ok(item) } diff --git a/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.rs b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.rs new file mode 100644 index 0000000000000..478809324ee6d --- /dev/null +++ b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.rs @@ -0,0 +1,32 @@ +// check-pass +// edition:2018 +// compile-flags: -Z span-debug +// aux-build:test-macros.rs + +#![no_std] // Don't load unnecessary hygiene information from std +extern crate std; + +#[macro_use] extern crate test_macros; + +macro_rules! foo {( + #[fake_attr] + $item:item +) => ( + $item +)} + +macro_rules! outer {($item:item) => ( + print_bang! { // Identity proc-macro + foo! { + #[fake_attr] + $item + } + } +)} +outer! { + mod bar { + //! Foo + } +} + +fn main() {} diff --git a/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout new file mode 100644 index 0000000000000..c4ee44f654149 --- /dev/null +++ b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout @@ -0,0 +1,86 @@ +PRINT-BANG INPUT (DISPLAY): foo ! { #[fake_attr] mod bar { + #![doc = r" Foo"] +} } +PRINT-BANG INPUT (DEBUG): TokenStream [ + Ident { + ident: "foo", + span: $DIR/issue-78675-captured-inner-attrs.rs:20:9: 20:12 (#4), + }, + Punct { + ch: '!', + spacing: Alone, + span: $DIR/issue-78675-captured-inner-attrs.rs:20:12: 20:13 (#4), + }, + Group { + delimiter: Brace, + stream: TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/issue-78675-captured-inner-attrs.rs:21:13: 21:14 (#4), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "fake_attr", + span: $DIR/issue-78675-captured-inner-attrs.rs:21:15: 21:24 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:21:14: 21:25 (#4), + }, + Group { + delimiter: None, + stream: TokenStream [ + Ident { + ident: "mod", + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Ident { + ident: "bar", + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Group { + delimiter: Brace, + stream: TokenStream [ + Punct { + ch: '#', + spacing: Joint, + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Punct { + ch: '!', + spacing: Alone, + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "doc", + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Punct { + ch: '=', + spacing: Alone, + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + Literal { + kind: StrRaw(0), + symbol: " Foo", + suffix: None, + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + }, + ], + span: $DIR/issue-78675-captured-inner-attrs.rs:20:14: 23:10 (#4), + }, +] From 1aedcd33f5aa288309718814e01f8598ac3b0b00 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 2 Nov 2020 17:34:28 -0500 Subject: [PATCH 35/39] Suggest library/std when running all stage 0 tests --- src/bootstrap/test.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 6c2c05ac7197e..5a73f58304501 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -970,7 +970,8 @@ impl Step for Compiletest { if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() { eprintln!("\ error: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail -help: use `--stage 1` instead +help: to test the compiler, use `--stage 1` instead +help: to test the standard library, use `--stage 0 library/std` instead note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`." ); std::process::exit(1); From f422e811e4932907e11e8da92f24d2834f7612f2 Mon Sep 17 00:00:00 2001 From: Vishnunarayan K I Date: Tue, 3 Nov 2020 12:15:41 +0530 Subject: [PATCH 36/39] preserve bindings order for Some --- .../src/build/matches/simplify.rs | 33 +++++- ...wise_branch.opt1.EarlyOtherwiseBranch.diff | 6 +- ...wise_branch.opt2.EarlyOtherwiseBranch.diff | 6 +- ...ement_tuple.opt1.EarlyOtherwiseBranch.diff | 12 +- ...h.before-SimplifyBranches-final.after.diff | 40 +++---- ...ch_68867.try_sum.EarlyOtherwiseBranch.diff | 24 ++-- ...nch_noopt.noopt1.EarlyOtherwiseBranch.diff | 6 +- ...nch_noopt.noopt2.EarlyOtherwiseBranch.diff | 6 +- src/test/ui/issues/issue-12567.stderr | 4 +- .../borrowck-move-and-move.rs | 4 +- .../borrowck-move-and-move.stderr | 36 +++--- .../borrowck-pat-by-move-and-ref-inverse.rs | 7 +- ...orrowck-pat-by-move-and-ref-inverse.stderr | 75 ++++++++----- .../borrowck-pat-by-move-and-ref.rs | 3 - .../borrowck-pat-by-move-and-ref.stderr | 61 ++-------- .../borrowck-pat-ref-mut-and-ref.rs | 10 +- .../borrowck-pat-ref-mut-and-ref.stderr | 104 ++++++------------ .../borrowck-pat-ref-mut-twice.rs | 6 +- .../borrowck-pat-ref-mut-twice.stderr | 54 ++++++--- 19 files changed, 239 insertions(+), 258 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index 278d7a6374d4c..e5fee5df06ab0 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -45,6 +45,26 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) -> bool { // repeatedly simplify match pairs until fixed point is reached debug!("simplify_candidate(candidate={:?})", candidate); + + // exisiting_bindings and new_bindings exists to keep the semantics in order + // reversing the binding order for bindings after `@` change binding order in places + // it shouldn't be changed, for example `let (Some(a), Some(b)) = (x, y)` + // + // To avoid this, the binding occurs in the following manner: + // * the bindings for one iteration of the following loop occurs in order (i.e. left to + // right) + // * the bindings from the previous iteration of the loop is prepended to the bindings from + // the current iteration (in the implementation this is done by mem::swap and extend) + // * after all iterations, these new bindings are then appended to the bindings that were + // prexisting (i.e. `candidate.binding` when the function was called). + // + // example: + // candidate.bindings = [1, 2, 3] + // binding in iter 1: [4, 5] + // binding in iter 2: [6, 7] + // + // final binding: [1, 2, 3, 6, 7, 4, 5] + let mut exisiting_bindings = mem::take(&mut candidate.bindings); let mut new_bindings = Vec::new(); loop { let match_pairs = mem::take(&mut candidate.match_pairs); @@ -52,13 +72,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let [MatchPair { pattern: Pat { kind: box PatKind::Or { pats }, .. }, place }] = *match_pairs { + exisiting_bindings.extend_from_slice(&new_bindings); + mem::swap(&mut candidate.bindings, &mut exisiting_bindings); candidate.subcandidates = self.create_or_subcandidates(candidate, place, pats); return true; } let mut changed = false; for match_pair in match_pairs { - match self.simplify_match_pair(match_pair, candidate, &mut new_bindings) { + match self.simplify_match_pair(match_pair, candidate) { Ok(()) => { changed = true; } @@ -80,11 +102,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // let z = x.copy_field; // let y = x; // } - new_bindings.extend_from_slice(&candidate.bindings); + candidate.bindings.extend_from_slice(&new_bindings); mem::swap(&mut candidate.bindings, &mut new_bindings); - new_bindings.clear(); + candidate.bindings.clear(); if !changed { + exisiting_bindings.extend_from_slice(&new_bindings); + mem::swap(&mut candidate.bindings, &mut exisiting_bindings); // Move or-patterns to the end, because they can result in us // creating additional candidates, so we want to test them as // late as possible. @@ -124,7 +148,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, match_pair: MatchPair<'pat, 'tcx>, candidate: &mut Candidate<'pat, 'tcx>, - bindings: &mut Vec>, ) -> Result<(), MatchPair<'pat, 'tcx>> { let tcx = self.hir.tcx(); match *match_pair.pattern.kind { @@ -152,7 +175,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } PatKind::Binding { name, mutability, mode, var, ty, ref subpattern, is_primary: _ } => { - bindings.push(Binding { + candidate.bindings.push(Binding { name, mutability, span: match_pair.pattern.span, diff --git a/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff index c897aff936c49..386726bfddc74 100644 --- a/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff @@ -52,13 +52,13 @@ - } - - bb3: { - StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25 - _9 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25 StorageLive(_8); // scope 0 at $DIR/early_otherwise_branch.rs:5:15: 5:16 _8 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:15: 5:16 + StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25 + _9 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch.rs:5:31: 5:32 - StorageDead(_8); // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32 StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32 + StorageDead(_8); // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32 - goto -> bb4; // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 7:6 + goto -> bb3; // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 7:6 } diff --git a/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff index 4ab7b8aed1636..bc5934dec84e4 100644 --- a/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff @@ -59,13 +59,13 @@ - - bb4: { + bb2: { - StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25 - _10 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25 StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch.rs:13:15: 13:16 _9 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:15: 13:16 + StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25 + _10 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch.rs:13:31: 13:32 - StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32 StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32 + StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32 - goto -> bb6; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 16:6 + goto -> bb4; // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 16:6 } diff --git a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff index 58a7c4a841abf..b0357f1aecd61 100644 --- a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff @@ -71,16 +71,16 @@ - bb4: { + bb3: { - StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34 - _13 = (((_4.2: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34 - StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25 - _12 = (((_4.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25 StorageLive(_11); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:15: 6:16 _11 = (((_4.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:15: 6:16 + StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25 + _12 = (((_4.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25 + StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34 + _13 = (((_4.2: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 - StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 - StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 + StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 + StorageDead(_11); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41 - goto -> bb5; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 8:6 + goto -> bb4; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 8:6 } diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff index 963f7ffc92025..f51a08ed73068 100644 --- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff +++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff @@ -109,10 +109,10 @@ } + bb2: { -+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 -+ _16 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 + _15 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 ++ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 ++ _16 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 + nop; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49 + nop; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 + nop; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 @@ -132,10 +132,10 @@ bb3: { - _8 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:21: 24:30 - switchInt(move _8) -> [1_isize: bb7, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:21: 24:30 -+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 -+ _21 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 + _20 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 ++ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 ++ _21 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 + nop; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49 + nop; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 + nop; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 @@ -155,10 +155,10 @@ bb4: { - _9 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:23: 25:34 - switchInt(move _9) -> [2_isize: bb8, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:23: 25:34 -+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 -+ _26 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 + _25 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 ++ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 ++ _26 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 + nop; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55 + nop; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 + nop; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 @@ -178,10 +178,10 @@ bb5: { - _10 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:23: 26:34 - switchInt(move _10) -> [3_isize: bb9, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:23: 26:34 -+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 -+ _31 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 + _30 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 ++ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 ++ _31 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 + nop; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55 + nop; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 + nop; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 @@ -199,10 +199,10 @@ } bb6: { -- StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 -- _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 - StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 - _12 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 +- StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 +- _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 - StorageLive(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49 - StorageLive(_15); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 - _15 = _12; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 @@ -214,8 +214,8 @@ - ((_3 as Vw).0: f32) = move _14; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50 - discriminant(_3) = 0; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50 - StorageDead(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 -- StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 - StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 +- StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7 + discriminant(_0) = 0; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7 @@ -225,10 +225,10 @@ } bb7: { -- StorageLive(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 -- _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 - StorageLive(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 - _17 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 +- StorageLive(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 +- _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 - StorageLive(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49 - StorageLive(_20); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 - _20 = _17; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 @@ -240,16 +240,16 @@ - ((_3 as Vh).0: f32) = move _19; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50 - discriminant(_3) = 1; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50 - StorageDead(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 -- StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 - StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 +- StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 - } - - bb8: { -- StorageLive(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 -- _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 - StorageLive(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 - _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 +- StorageLive(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 +- _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 - StorageLive(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55 - StorageLive(_25); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 - _25 = _22; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 @@ -261,16 +261,16 @@ - ((_3 as Vmin).0: f32) = move _24; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56 - discriminant(_3) = 2; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56 - StorageDead(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 -- StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 - StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 +- StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 - } - - bb9: { -- StorageLive(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 -- _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 - StorageLive(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 - _27 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 +- StorageLive(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 +- _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 - StorageLive(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55 - StorageLive(_30); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 - _30 = _27; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 @@ -282,8 +282,8 @@ - ((_3 as Vmax).0: f32) = move _29; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56 - discriminant(_3) = 3; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56 - StorageDead(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 -- StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 - StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 +- StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 - } - diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff index fcfa8fcb25735..05ef6721e6535 100644 --- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff @@ -109,10 +109,10 @@ - - bb6: { + bb2: { - StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 - _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 StorageLive(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 _12 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17 + StorageLive(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 + _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29 StorageLive(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49 StorageLive(_15); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 _15 = _12; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41 @@ -124,18 +124,18 @@ ((_3 as Vw).0: f32) = move _14; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50 discriminant(_3) = 0; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50 StorageDead(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 - StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 + StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 } - bb7: { + bb3: { - StorageLive(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 - _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 StorageLive(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 _17 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17 + StorageLive(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 + _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29 StorageLive(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49 StorageLive(_20); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 _20 = _17; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41 @@ -147,18 +147,18 @@ ((_3 as Vh).0: f32) = move _19; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50 discriminant(_3) = 1; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50 StorageDead(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 - StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 + StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 } - bb8: { + bb4: { - StorageLive(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 - _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 StorageLive(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19 + StorageLive(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 + _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33 StorageLive(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55 StorageLive(_25); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 _25 = _22; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47 @@ -170,18 +170,18 @@ ((_3 as Vmin).0: f32) = move _24; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56 discriminant(_3) = 2; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56 StorageDead(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 - StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 + StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 } - bb9: { + bb5: { - StorageLive(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 - _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 StorageLive(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 _27 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19 + StorageLive(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 + _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33 StorageLive(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55 StorageLive(_30); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 _30 = _27; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47 @@ -193,8 +193,8 @@ ((_3 as Vmax).0: f32) = move _29; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56 discriminant(_3) = 3; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56 StorageDead(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 - StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 + StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56 - goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 + goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6 } diff --git a/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff index 6703bc58c32df..9a6094f12dfb1 100644 --- a/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff @@ -56,13 +56,13 @@ } bb4: { - StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25 - _10 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25 StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16 _9 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16 + StorageLive(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25 + _10 = (((_3.1: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 - StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 StorageDead(_10); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 + StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32 goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 13:6 } diff --git a/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff index 9efb2239e4069..c3aecb4529351 100644 --- a/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff @@ -42,13 +42,13 @@ } bb3: { - StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25 - _9 = (((_3.1: std::option::Option) as Some).0: bool); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25 StorageLive(_8); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:15: 20:16 _8 = (((_3.0: std::option::Option) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:15: 20:16 + StorageLive(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25 + _9 = (((_3.1: std::option::Option) as Some).0: bool); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25 _0 = const 0_u32; // scope 1 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32 - StorageDead(_8); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32 StorageDead(_9); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32 + StorageDead(_8); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32 goto -> bb4; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:19:5: 22:6 } diff --git a/src/test/ui/issues/issue-12567.stderr b/src/test/ui/issues/issue-12567.stderr index 2a88d8f0524ac..3ce659ccd14da 100644 --- a/src/test/ui/issues/issue-12567.stderr +++ b/src/test/ui/issues/issue-12567.stderr @@ -8,7 +8,7 @@ LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) | -- data moved here LL | => println!("one empty"), LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here + | --- ...and here | = note: move occurs because these variables have types that don't implement the `Copy` trait @@ -22,7 +22,7 @@ LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) | -- data moved here LL | => println!("one empty"), LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here + | --- ...and here | = note: move occurs because these variables have types that don't implement the `Copy` trait diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs index 83f9b82b242a6..bce43f9df85c8 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs @@ -17,8 +17,8 @@ fn main() { let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value match Ok(U) { - a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of partially moved value - //~^ ERROR use of partially moved value + a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of moved value + //~^ ERROR use of moved value } fn fun(a @ b: U) {} //~ ERROR use of moved value diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr index 482ebd9b423fb..bfb7b479731a6 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr @@ -29,35 +29,27 @@ LL | let a @ (b, c) = (u(), u()); | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of partially moved value - --> $DIR/borrowck-move-and-move.rs:20:9 +error[E0382]: use of moved value + --> $DIR/borrowck-move-and-move.rs:20:16 | +LL | match Ok(U) { + | ----- move occurs because value has type `std::result::Result`, which does not implement the `Copy` trait LL | a @ Ok(b) | a @ Err(b) => {} - | ^^^^^^^-^ + | -------^- | | | - | | value partially moved here - | value used here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Ok(ref b) | a @ Err(b) => {} - | ^^^ + | | value used here after move + | value moved here -error[E0382]: use of partially moved value - --> $DIR/borrowck-move-and-move.rs:20:21 +error[E0382]: use of moved value + --> $DIR/borrowck-move-and-move.rs:20:29 | +LL | match Ok(U) { + | ----- move occurs because value has type `std::result::Result`, which does not implement the `Copy` trait LL | a @ Ok(b) | a @ Err(b) => {} - | ^^^^^^^^-^ + | --------^- | | | - | | value partially moved here - | value used here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | a @ Ok(b) | a @ Err(ref b) => {} - | ^^^ + | | value used here after move + | value moved here error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:27:9 diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs index e75ff78abd7cc..8a574f880ed8d 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs @@ -50,17 +50,19 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR use of partially moved value + //~| ERROR use of moved value None => {} } match Some([U, U]) { mut a @ Some([ref b, ref mut c]) => {} //~^ ERROR borrow of moved value + //~| ERROR borrow of moved value None => {} } match Some(u()) { a @ Some(ref b) => {} //~^ ERROR borrow of moved value + //~| ERROR borrow of moved value None => {} } match Some((u(), u())) { @@ -68,12 +70,13 @@ fn main() { //~^ ERROR borrow of moved value //~| ERROR borrow of moved value //~| ERROR borrow of moved value - //~| ERROR use of partially moved value + //~| ERROR use of moved value None => {} } match Some([u(), u()]) { mut a @ Some([ref b, ref mut c]) => {} //~^ ERROR borrow of moved value + //~| ERROR borrow of moved value None => {} } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index c1ea5d8ec6dda..79addf9d574b6 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -155,7 +155,7 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:62:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:63:9 | LL | a @ Some(ref b) => {} | -^^^^^^^^-----^ @@ -165,7 +165,7 @@ LL | a @ Some(ref b) => {} | move occurs because `a` has type `Option` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^ @@ -176,7 +176,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:19 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -----^^^--------- @@ -186,7 +186,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `b` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:38 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | -^^^----- @@ -196,7 +196,7 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | move occurs because `d` has type `U` which does not implement the `Copy` trait error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:9 + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:9 | LL | mut a @ Some([ref b, ref mut c]) => {} | -----^^^^^^^^^-----^^---------^^ @@ -280,35 +280,60 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: use of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:9 +error[E0382]: use of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:38 | +LL | match Some((U, U)) { + | ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^ + | -----------------------------^^^^^^^^^-- | | | - | | value partially moved here - | value used here after partial move + | | value used here after move + | value moved here + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:57:30 | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value +LL | match Some([U, U]) { + | ------------ move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait +LL | mut a @ Some([ref b, ref mut c]) => {} + | ---------------------^^^^^^^^^-- + | | | + | | value borrowed here after move + | value moved here + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:63:18 | -LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} - | ^^^ +LL | match Some(u()) { + | --------- move occurs because value has type `Option`, which does not implement the `Copy` trait +LL | a @ Some(ref b) => {} + | ---------^^^^^- + | | | + | | value borrowed here after move + | value moved here -error[E0382]: use of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 +error[E0382]: use of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:38 | +LL | match Some((u(), u())) { + | ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^ + | -----------------------------^^^^^^^^^-- | | | - | | value partially moved here - | value used here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value + | | value used here after move + | value moved here + +error[E0382]: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:30 | -LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} - | ^^^ +LL | match Some([u(), u()]) { + | ---------------- move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait +LL | mut a @ Some([ref b, ref mut c]) => {} + | ---------------------^^^^^^^^^-- + | | | + | | value borrowed here after move + | value moved here error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:11 @@ -321,6 +346,6 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 30 previous errors +error: aborting due to 33 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs index 691d0a32fa88f..b9235eabd88f4 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs @@ -60,13 +60,11 @@ fn main() { match Some([U, U]) { ref mut a @ Some([b, mut c]) => {} //~^ ERROR cannot move out of value because it is borrowed - //~| ERROR borrow of partially moved value None => {} } match Some(u()) { ref a @ Some(b) => {} //~^ ERROR cannot move out of value because it is borrowed - //~| ERROR borrow of partially moved value None => {} } match Some((u(), u())) { @@ -81,7 +79,6 @@ fn main() { match Some([u(), u()]) { ref mut a @ Some([b, mut c]) => {} //~^ ERROR cannot move out of value because it is borrowed - //~| ERROR borrow of partially moved value None => {} } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index a39ff8774f79e..50b2f8929f225 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -140,7 +140,7 @@ LL | ref mut a @ Some([b, mut c]) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:66:9 | LL | ref a @ Some(b) => {} | -----^^^^^^^^-^ @@ -149,7 +149,7 @@ LL | ref a @ Some(b) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:9 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^ @@ -159,7 +159,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `a`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:23 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^----- @@ -168,7 +168,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `b`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:38 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | -----^^^- @@ -177,7 +177,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed, by `d`, here error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9 + --> $DIR/borrowck-pat-by-move-and-ref.rs:80:9 | LL | ref mut a @ Some([b, mut c]) => {} | ---------^^^^^^^^^-^^-----^^ @@ -286,38 +286,8 @@ LL | let ref mut a @ [b, mut c] = [u(), u()]; | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error[E0382]: borrow of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:61:9 - | -LL | ref mut a @ Some([b, mut c]) => {} - | ^^^^^^^^^^^^^^^^^^^^^-----^^ - | | | - | | value partially moved here - | value borrowed here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | ref mut a @ Some([b, ref mut c]) => {} - | ^^^ - -error[E0382]: borrow of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9 - | -LL | ref a @ Some(b) => {} - | ^^^^^^^^^^^^^-^ - | | | - | | value partially moved here - | value borrowed here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | ref a @ Some(ref b) => {} - | ^^^ - error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:23 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | ^^^^^^^^----- @@ -332,7 +302,7 @@ LL | ref a @ Some((ref b @ ref mut c, ref d @ e)) => {} | ^^^ error[E0382]: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:73:38 + --> $DIR/borrowck-pat-by-move-and-ref.rs:71:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | ^^^^^^^^- @@ -346,21 +316,6 @@ help: borrow this field in the pattern to avoid moving the value LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {} | ^^^ -error[E0382]: borrow of partially moved value - --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9 - | -LL | ref mut a @ Some([b, mut c]) => {} - | ^^^^^^^^^^^^^^^^^^^^^-----^^ - | | | - | | value partially moved here - | value borrowed here after partial move - | - = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value - | -LL | ref mut a @ Some([b, ref mut c]) => {} - | ^^^ - error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:13:11 | @@ -404,6 +359,6 @@ LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 39 previous errors +error: aborting due to 36 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs index f543eaece8020..2d391cd7d0722 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs @@ -9,7 +9,7 @@ fn main() { match &mut Some(1) { ref mut z @ &mut Some(ref a) => { //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable **z = None; println!("{}", *a); } @@ -78,8 +78,8 @@ fn main() { ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable + //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable *b = U; drop(a); } @@ -90,8 +90,6 @@ fn main() { //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot assign to `*b`, as it is immutable for the pattern guard - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable _ => {} } match Ok(U) { @@ -105,8 +103,6 @@ fn main() { ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable - //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable //~| ERROR cannot move out of `b` in pattern guard //~| ERROR cannot move out of `b` in pattern guard _ => {} diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index 26182a1bc7419..00136c2576423 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -155,7 +155,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ---------^^^^^^-----^ @@ -164,7 +164,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ---------^^^^^^^-----^ @@ -173,7 +173,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | -----^^^^^^---------^ @@ -182,7 +182,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | -----^^^^^^^---------^ @@ -191,7 +191,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ---------^^^^^^-----^ @@ -200,7 +200,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false | mutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:33 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ---------^^^^^^^-----^ @@ -209,7 +209,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false | mutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:119:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -219,7 +219,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:125:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -229,7 +229,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | -----^^^^---------^^---------^ @@ -239,7 +239,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U); | immutable borrow, by `a`, occurs here error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:140:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:136:9 | LL | let ref mut a @ (ref b, ref c) = (U, U); | ---------^^^^-----^^-----^ @@ -294,17 +294,17 @@ LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} | | value moved into `c` here | value borrowed, by `b`, here -error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:9 +error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:31 | LL | ref mut z @ &mut Some(ref a) => { - | ^^^^^^^^^^^^^^^^^^^^^^-----^ + | ----------------------^^^^^- | | | | | immutable borrow occurs here | mutable borrow occurs here ... -LL | println!("{}", *a); - | -- immutable borrow later used here +LL | **z = None; + | ---------- mutable borrow later used here error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:48:9 @@ -330,47 +330,29 @@ LL | let ref a @ ref mut b = u(); LL | *b = u(); | -------- mutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:9 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:20 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { - | ^^^^^^^^^^^---------^ + | -----------^^^^^^^^^- | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | *b = U; - | ------ mutable borrow later used here +LL | drop(a); + | - immutable borrow later used here -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:33 +error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:45 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { - | ^^^^^^^^^^^^---------^ + | ------------^^^^^^^^^- | | | | | mutable borrow occurs here | immutable borrow occurs here ... -LL | *b = U; - | ------ mutable borrow later used here - -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:9 - | -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} - | ^^^^^^^^^^^---------^ ------ mutable borrow later used here - | | | - | | mutable borrow occurs here - | immutable borrow occurs here - -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:33 - | -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} - | ^^^^^^^^^^^^---------^ ------ mutable borrow later used here - | | | - | | mutable borrow occurs here - | immutable borrow occurs here +LL | drop(a); + | - immutable borrow later used here error[E0594]: cannot assign to `*b`, as it is immutable for the pattern guard --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:61 @@ -381,33 +363,15 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } = note: variables bound in patterns are immutable until the end of the pattern guard error[E0594]: cannot assign to `*a`, as it is immutable for the pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:61 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:61 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} | ^^^^^^^^^^^ cannot assign | = note: variables bound in patterns are immutable until the end of the pattern guard -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:9 - | -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} - | ^^^^^^^^^^^---------^ - mutable borrow later used here - | | | - | | mutable borrow occurs here - | immutable borrow occurs here - -error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:33 - | -LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} - | ^^^^^^^^^^^^---------^ - mutable borrow later used here - | | | - | | mutable borrow occurs here - | immutable borrow occurs here - error[E0507]: cannot move out of `b` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait @@ -415,7 +379,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `b` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} | ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait @@ -423,7 +387,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `a` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ^ move occurs because `a` has type `&mut std::result::Result`, which does not implement the `Copy` trait @@ -431,7 +395,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `a` in pattern guard - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:66 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} | ^ move occurs because `a` has type `&mut std::result::Result`, which does not implement the `Copy` trait @@ -439,7 +403,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:119:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | ^^^^^^^^^---------^^^^^^^^^^^^ @@ -451,7 +415,7 @@ LL | *b = U; | ------ mutable borrow later used here error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:125:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | ^^^^^^^^^---------^^^^^^^^^^^^ @@ -463,7 +427,7 @@ LL | *b = U; | ------ mutable borrow later used here error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9 + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); | ^^^^^^^^^---------^^^^^^^^^^^^ @@ -484,7 +448,7 @@ LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} | | value borrowed here after move | move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 51 previous errors +error: aborting due to 47 previous errors Some errors have detailed explanations: E0382, E0502, E0507, E0594. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs index c58f041349931..339814e1e3167 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs @@ -84,8 +84,6 @@ fn main() { ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { //~^ ERROR cannot borrow value as mutable more than once at a time //~| ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time - //~| ERROR cannot borrow value as mutable more than once at a time *b = U; } } @@ -93,6 +91,8 @@ fn main() { ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { //~^ ERROR cannot borrow value as mutable more than once at a time //~| ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time *a = Err(U); // FIXME: The binding name value used above makes for problematic diagnostics. @@ -103,6 +103,8 @@ fn main() { ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { //~^ ERROR cannot borrow value as mutable more than once at a time //~| ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time + //~| ERROR cannot borrow value as mutable more than once at a time drop(a); } } diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr index 5ae71c2a9fd31..0370037f24210 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr @@ -168,7 +168,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:93:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^---------^ @@ -177,7 +177,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | first mutable borrow, by `a`, occurs here error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:93:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | ---------^^^^^^^---------^ @@ -283,28 +283,52 @@ LL | *b = U; | ------ first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:84:9 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:24 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ^^^^^^^^^^^^^^^---------^ + | ---------------^^^^^^^^^- | | | - | | first mutable borrow occurs here - | second mutable borrow occurs here + | | second mutable borrow occurs here + | first mutable borrow occurs here ... -LL | *b = U; - | ------ first borrow later used here +LL | *a = Err(U); + | ----------- first borrow later used here error[E0499]: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:84:37 + --> $DIR/borrowck-pat-ref-mut-twice.rs:91:53 + | +LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { + | ----------------^^^^^^^^^- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here +... +LL | *a = Err(U); + | ----------- first borrow later used here + +error[E0499]: cannot borrow value as mutable more than once at a time + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:24 + | +LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { + | ---------------^^^^^^^^^- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here +... +LL | drop(a); + | - first borrow later used here + +error[E0499]: cannot borrow value as mutable more than once at a time + --> $DIR/borrowck-pat-ref-mut-twice.rs:103:53 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ^^^^^^^^^^^^^^^^---------^ + | ----------------^^^^^^^^^- | | | - | | first mutable borrow occurs here - | second mutable borrow occurs here + | | second mutable borrow occurs here + | first mutable borrow occurs here ... -LL | *b = U; - | ------ first borrow later used here +LL | drop(a); + | - first borrow later used here error[E0382]: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:23:34 @@ -316,7 +340,7 @@ LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} | | value borrowed here after move | move occurs because value has type `U`, which does not implement the `Copy` trait -error: aborting due to 29 previous errors +error: aborting due to 31 previous errors Some errors have detailed explanations: E0382, E0499. For more information about an error, try `rustc --explain E0382`. From f44f96d61c11e439e9d4092258e3322e126418bf Mon Sep 17 00:00:00 2001 From: Vishnunarayan K I Date: Tue, 3 Nov 2020 14:40:42 +0530 Subject: [PATCH 37/39] add tests --- .../pattern/bindings-after-at/bind-by-copy.rs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/test/ui/pattern/bindings-after-at/bind-by-copy.rs diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-copy.rs b/src/test/ui/pattern/bindings-after-at/bind-by-copy.rs new file mode 100644 index 0000000000000..508e486afec72 --- /dev/null +++ b/src/test/ui/pattern/bindings-after-at/bind-by-copy.rs @@ -0,0 +1,49 @@ +// run-pass + +// Test copy + +#![feature(bindings_after_at)] + +struct A { a: i32, b: i32 } +struct B { a: i32, b: C } +struct D { a: i32, d: C } +#[derive(Copy,Clone)] +struct C { c: i32 } + +pub fn main() { + match (A {a: 10, b: 20}) { + x@A {a, b: 20} => { assert!(x.a == 10); assert!(a == 10); } + A {b: _b, ..} => { panic!(); } + } + + let mut x@B {b, ..} = B {a: 10, b: C {c: 20}}; + assert_eq!(x.a, 10); + x.b.c = 30; + assert_eq!(b.c, 20); + let mut y@D {d, ..} = D {a: 10, d: C {c: 20}}; + assert_eq!(y.a, 10); + y.d.c = 30; + assert_eq!(d.c, 20); + + let some_b = Some(B { a: 10, b: C { c: 20 } }); + + // in irrefutable pattern + if let Some(x @ B { b, .. }) = some_b { + assert_eq!(x.b.c, 20); + assert_eq!(b.c, 20); + } else { + unreachable!(); + } + + let some_b = Some(B { a: 10, b: C { c: 20 } }); + + if let Some(x @ B { b: mut b @ C { c }, .. }) = some_b { + assert_eq!(x.b.c, 20); + assert_eq!(b.c, 20); + b.c = 30; + assert_eq!(b.c, 30); + assert_eq!(c, 20); + } else { + unreachable!(); + } +} From c32de757cdc3355a48bbe372cf31c9d60b59a204 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 3 Nov 2020 12:01:46 +0100 Subject: [PATCH 38/39] lldb_batchmode: show more error information Even more information to try and debug #78665. --- src/etc/lldb_batchmode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/etc/lldb_batchmode.py b/src/etc/lldb_batchmode.py index 629c8e04ec533..fc355c87b52a2 100644 --- a/src/etc/lldb_batchmode.py +++ b/src/etc/lldb_batchmode.py @@ -28,7 +28,7 @@ import _thread as thread # Set this to True for additional output -DEBUG_OUTPUT = False +DEBUG_OUTPUT = True def print_debug(s): @@ -102,7 +102,7 @@ def execute_command(command_interpreter, command): registered_breakpoints.add(breakpoint_id) else: print("Error while trying to register breakpoint callback, id = " + - str(breakpoint_id)) + str(breakpoint_id) + ", message = " + str(res.GetError())) else: print(res.GetError()) From 5827fbadf6feaa3da42d7223ac9f10148c827a89 Mon Sep 17 00:00:00 2001 From: Vishnunarayan K I Date: Tue, 3 Nov 2020 17:14:51 +0530 Subject: [PATCH 39/39] review comments --- .../src/build/matches/simplify.rs | 20 +++++++++---------- .../bindings-after-at/copy-and-move-mixed.rs | 3 +++ .../copy-and-move-mixed.stderr | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index e5fee5df06ab0..29fc23c324f44 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -44,10 +44,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { candidate: &mut Candidate<'pat, 'tcx>, ) -> bool { // repeatedly simplify match pairs until fixed point is reached - debug!("simplify_candidate(candidate={:?})", candidate); + debug!(?candidate, "simplify_candidate"); - // exisiting_bindings and new_bindings exists to keep the semantics in order - // reversing the binding order for bindings after `@` change binding order in places + // existing_bindings and new_bindings exists to keep the semantics in order. + // Reversing the binding order for bindings after `@` changes the binding order in places // it shouldn't be changed, for example `let (Some(a), Some(b)) = (x, y)` // // To avoid this, the binding occurs in the following manner: @@ -64,7 +64,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // binding in iter 2: [6, 7] // // final binding: [1, 2, 3, 6, 7, 4, 5] - let mut exisiting_bindings = mem::take(&mut candidate.bindings); + let mut existing_bindings = mem::take(&mut candidate.bindings); let mut new_bindings = Vec::new(); loop { let match_pairs = mem::take(&mut candidate.match_pairs); @@ -72,8 +72,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let [MatchPair { pattern: Pat { kind: box PatKind::Or { pats }, .. }, place }] = *match_pairs { - exisiting_bindings.extend_from_slice(&new_bindings); - mem::swap(&mut candidate.bindings, &mut exisiting_bindings); + existing_bindings.extend_from_slice(&new_bindings); + mem::swap(&mut candidate.bindings, &mut existing_bindings); candidate.subcandidates = self.create_or_subcandidates(candidate, place, pats); return true; } @@ -89,7 +89,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } } - // issue #69971: the binding order should be right to left if there are more + // Avoid issue #69971: the binding order should be right to left if there are more // bindings after `@` to please the borrow checker // Ex // struct NonCopyStruct { @@ -107,15 +107,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { candidate.bindings.clear(); if !changed { - exisiting_bindings.extend_from_slice(&new_bindings); - mem::swap(&mut candidate.bindings, &mut exisiting_bindings); + existing_bindings.extend_from_slice(&new_bindings); + mem::swap(&mut candidate.bindings, &mut existing_bindings); // Move or-patterns to the end, because they can result in us // creating additional candidates, so we want to test them as // late as possible. candidate .match_pairs .sort_by_key(|pair| matches!(*pair.pattern.kind, PatKind::Or { .. })); - debug!("simplify_candidate: simplifed {:?}", candidate); + debug!(simplified = ?candidate, "simplify_candidate"); return false; // if we were not able to simplify any, done. } } diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs index 1dc9716f54bef..f731aa2e96327 100644 --- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs +++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs @@ -8,6 +8,9 @@ struct C; struct NC(A, B); fn main() { + // this compiles + let a @ NC(b, c) = NC(C, C); + let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); //~^ ERROR use of partially moved value } diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr index 9ffbadf36a61c..183a37176ec6c 100644 --- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr +++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr @@ -1,5 +1,5 @@ error[E0382]: use of partially moved value - --> $DIR/copy-and-move-mixed.rs:11:9 + --> $DIR/copy-and-move-mixed.rs:14:9 | LL | let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); | ^^^^^^^^^^------------^