diff --git a/compiler/rustc_mir_build/src/build/block.rs b/compiler/rustc_mir_build/src/build/block.rs index d5f72e6f22dfa..82f38ac0e7620 100644 --- a/compiler/rustc_mir_build/src/build/block.rs +++ b/compiler/rustc_mir_build/src/build/block.rs @@ -3,6 +3,7 @@ use crate::build::ForGuard::OutsideGuard; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use crate::thir::*; use rustc_hir as hir; +use rustc_middle::middle::region; use rustc_middle::mir::*; use rustc_session::lint::builtin::UNSAFE_OP_IN_UNSAFE_FN; use rustc_session::lint::Level; @@ -12,6 +13,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { crate fn ast_block( &mut self, destination: Place<'tcx>, + scope: Option, block: BasicBlock, ast_block: &'tcx hir::Block<'tcx>, source_info: SourceInfo, @@ -28,9 +30,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.in_opt_scope(opt_destruction_scope.map(|de| (de, source_info)), move |this| { this.in_scope((region_scope, source_info), LintLevel::Inherited, move |this| { if targeted_by_break { - this.in_breakable_scope(None, destination, span, |this| { + this.in_breakable_scope(None, destination, scope, span, |this| { Some(this.ast_block_stmts( destination, + scope, block, span, stmts, @@ -39,7 +42,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { )) }) } else { - this.ast_block_stmts(destination, block, span, stmts, expr, safety_mode) + this.ast_block_stmts(destination, scope, block, span, stmts, expr, safety_mode) } }) }) @@ -48,6 +51,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fn ast_block_stmts( &mut self, destination: Place<'tcx>, + scope: Option, mut block: BasicBlock, span: Span, stmts: Vec>, @@ -182,7 +186,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }; this.block_context.push(BlockFrame::TailExpr { tail_result_is_ignored, span }); - unpack!(block = this.into(destination, block, expr)); + unpack!(block = this.into(destination, scope, block, expr)); let popped = this.block_context.pop(); assert!(popped.map_or(false, |bf| bf.is_tail_expr())); diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 7c34b996055d3..c0e4141a558d9 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -11,6 +11,8 @@ use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, UpvarSubsts}; use rustc_span::Span; +use std::slice; + impl<'a, 'tcx> Builder<'a, 'tcx> { /// Returns an rvalue suitable for use until the end of the current /// scope expression. @@ -112,12 +114,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let box_ = Rvalue::NullaryOp(NullOp::Box, value.ty); this.cfg.push_assign(block, source_info, Place::from(result), box_); - // initialize the box contents: + // Initialize the box contents. No scope is needed since the + // `Box` is already scheduled to be dropped. unpack!( - block = - this.into(this.hir.tcx().mk_place_deref(Place::from(result)), block, value) + block = this.into( + this.hir.tcx().mk_place_deref(Place::from(result)), + None, + block, + value, + ) ); - block.and(Rvalue::Use(Operand::Move(Place::from(result)))) + let result_operand = Operand::Move(Place::from(result)); + this.record_operands_moved(slice::from_ref(&result_operand)); + block.and(Rvalue::Use(result_operand)) } ExprKind::Cast { source } => { let source = unpack!(block = this.as_operand(block, scope, source)); @@ -161,6 +170,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .map(|f| unpack!(block = this.as_operand(block, scope, f))) .collect(); + this.record_operands_moved(&fields); block.and(Rvalue::Aggregate(box AggregateKind::Array(el_ty), fields)) } ExprKind::Tuple { fields } => { @@ -171,6 +181,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .map(|f| unpack!(block = this.as_operand(block, scope, f))) .collect(); + this.record_operands_moved(&fields); block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields)) } ExprKind::Closure { closure_id, substs, upvars, movability } => { @@ -222,6 +233,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } UpvarSubsts::Closure(substs) => box AggregateKind::Closure(closure_id, substs), }; + this.record_operands_moved(&operands); block.and(Rvalue::Aggregate(result, operands)) } ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => { diff --git a/compiler/rustc_mir_build/src/build/expr/as_temp.rs b/compiler/rustc_mir_build/src/build/expr/as_temp.rs index 9984b527ffdb4..241330d96e7bd 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_temp.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_temp.rs @@ -114,11 +114,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - unpack!(block = this.into(temp_place, block, expr)); - - if let Some(temp_lifetime) = temp_lifetime { - this.schedule_drop(expr_span, temp_lifetime, temp, DropKind::Value); - } + unpack!(block = this.into(temp_place, temp_lifetime, block, expr)); block.and(temp) } diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 50001c38dc737..5f9743b7f598a 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -1,28 +1,37 @@ //! See docs in build/expr/mod.rs use crate::build::expr::category::{Category, RvalueFunc}; +use crate::build::scope::DropKind; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use crate::thir::*; use rustc_ast::InlineAsmOptions; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_hir as hir; +use rustc_middle::middle::region; use rustc_middle::mir::*; use rustc_middle::ty::{self, CanonicalUserTypeAnnotation}; use rustc_span::symbol::sym; - use rustc_target::spec::abi::Abi; +use std::slice; + impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr`, storing the result into `destination`, which /// is assumed to be uninitialized. + /// If a `drop_scope` is provided, `destination` is scheduled to be dropped + /// in `scope` once it has been initialized. crate fn into_expr( &mut self, destination: Place<'tcx>, + scope: Option, mut block: BasicBlock, expr: Expr<'tcx>, ) -> BlockAnd<()> { - debug!("into_expr(destination={:?}, block={:?}, expr={:?})", destination, block, expr); + debug!( + "into_expr(destination={:?}, scope={:?}, block={:?}, expr={:?})", + destination, scope, block, expr + ); // since we frequently have to reference `self` from within a // closure, where `self` would be shadowed, it's easier to @@ -37,6 +46,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { _ => false, }; + let schedule_drop = move |this: &mut Self| { + if let Some(drop_scope) = scope { + let local = + destination.as_local().expect("cannot schedule drop of non-Local place"); + this.schedule_drop(expr_span, drop_scope, local, DropKind::Value); + } + }; + if !expr_is_block_or_scope { this.block_context.push(BlockFrame::SubExpr); } @@ -46,15 +63,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let region_scope = (region_scope, source_info); ensure_sufficient_stack(|| { this.in_scope(region_scope, lint_level, |this| { - this.into(destination, block, value) + this.into(destination, scope, block, value) }) }) } ExprKind::Block { body: ast_block } => { - this.ast_block(destination, block, ast_block, source_info) + this.ast_block(destination, scope, block, ast_block, source_info) } ExprKind::Match { scrutinee, arms } => { - this.match_expr(destination, expr_span, block, scrutinee, arms) + this.match_expr(destination, scope, expr_span, block, scrutinee, arms) } ExprKind::NeverToAny { source } => { let source = this.hir.mirror(source); @@ -66,6 +83,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // This is an optimization. If the expression was a call then we already have an // unreachable block. Don't bother to terminate it and create a new one. + schedule_drop(this); if is_call { block.unit() } else { @@ -141,26 +159,35 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Start the loop. this.cfg.goto(block, source_info, loop_block); - this.in_breakable_scope(Some(loop_block), destination, expr_span, move |this| { - // conduct the test, if necessary - let body_block = this.cfg.start_new_block(); - this.cfg.terminate( - loop_block, - source_info, - TerminatorKind::FalseUnwind { real_target: body_block, unwind: None }, - ); - this.diverge_from(loop_block); - - // The “return” value of the loop body must always be an unit. We therefore - // introduce a unit temporary as the destination for the loop body. - let tmp = this.get_unit_temp(); - // Execute the body, branching back to the test. - let body_block_end = unpack!(this.into(tmp, body_block, body)); - this.cfg.goto(body_block_end, source_info, loop_block); - - // Loops are only exited by `break` expressions. - None - }) + this.in_breakable_scope( + Some(loop_block), + destination, + scope, + expr_span, + move |this| { + // conduct the test, if necessary + let body_block = this.cfg.start_new_block(); + this.cfg.terminate( + loop_block, + source_info, + TerminatorKind::FalseUnwind { real_target: body_block, unwind: None }, + ); + this.diverge_from(loop_block); + + // The “return” value of the loop body must always be an unit. We therefore + // introduce a unit temporary as the destination for the loop body. + let tmp = this.get_unit_temp(); + // Execute the body, branching back to the test. + // We don't need to provide a drop scope because `tmp` + // has type `()`. + let body_block_end = unpack!(this.into(tmp, None, body_block, body)); + this.cfg.goto(body_block_end, source_info, loop_block); + schedule_drop(this); + + // Loops are only exited by `break` expressions. + None + }, + ) } ExprKind::Call { ty, fun, args, from_hir_call, fn_span } => { let intrinsic = match *ty.kind() { @@ -192,8 +219,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .local_decls .push(LocalDecl::with_source_info(ptr_ty, source_info).internal()); let ptr_temp = Place::from(ptr_temp); - let block = unpack!(this.into(ptr_temp, block, ptr)); - this.into(this.hir.tcx().mk_place_deref(ptr_temp), block, val) + // No need for a scope, ptr_temp doesn't need drop + let block = unpack!(this.into(ptr_temp, None, block, ptr)); + // Maybe we should provide a scope here so that + // `move_val_init` wouldn't leak on panic even with an + // arbitrary `val` expression, but `schedule_drop`, + // borrowck and drop elaboration all prevent us from + // dropping `ptr_temp.deref()`. + this.into(this.hir.tcx().mk_place_deref(ptr_temp), None, block, val) } else { let args: Vec<_> = args .into_iter() @@ -226,10 +259,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }, ); this.diverge_from(block); + schedule_drop(this); success.unit() } } - ExprKind::Use { source } => this.into(destination, block, source), + ExprKind::Use { source } => this.into(destination, scope, block, source), ExprKind::Borrow { arg, borrow_kind } => { // We don't do this in `as_rvalue` because we use `as_place` // for borrow expressions, so we cannot create an `RValue` that @@ -271,7 +305,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let field_names = this.hir.all_fields(adt_def, variant_index); - let fields = if let Some(FruInfo { base, field_types }) = base { + let fields: Vec<_> = if let Some(FruInfo { base, field_types }) = base { let base = unpack!(block = this.as_place(block, base)); // MIR does not natively support FRU, so for each @@ -306,12 +340,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { user_ty, active_field_index, ); + this.record_operands_moved(&fields); this.cfg.push_assign( block, source_info, destination, Rvalue::Aggregate(adt, fields), ); + schedule_drop(this); block.unit() } ExprKind::InlineAsm { template, operands, options, line_spans } => { @@ -408,6 +444,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let place = unpack!(block = this.as_place(block, expr)); let rvalue = Rvalue::Use(this.consume_by_copy_or_move(place)); this.cfg.push_assign(block, source_info, destination, rvalue); + schedule_drop(this); block.unit() } ExprKind::Index { .. } | ExprKind::Deref { .. } | ExprKind::Field { .. } => { @@ -425,6 +462,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let place = unpack!(block = this.as_place(block, expr)); let rvalue = Rvalue::Use(this.consume_by_copy_or_move(place)); this.cfg.push_assign(block, source_info, destination, rvalue); + schedule_drop(this); block.unit() } @@ -432,12 +470,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let scope = this.local_scope(); let value = unpack!(block = this.as_operand(block, scope, value)); let resume = this.cfg.start_new_block(); + this.record_operands_moved(slice::from_ref(&value)); this.cfg.terminate( block, source_info, TerminatorKind::Yield { value, resume, resume_arg: destination, drop: None }, ); this.generator_drop_cleanup(block); + schedule_drop(this); resume.unit() } @@ -469,6 +509,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let rvalue = unpack!(block = this.as_local_rvalue(block, expr)); this.cfg.push_assign(block, source_info, destination, rvalue); + schedule_drop(this); block.unit() } }; diff --git a/compiler/rustc_mir_build/src/build/expr/stmt.rs b/compiler/rustc_mir_build/src/build/expr/stmt.rs index f117689d940fd..a974ea0db5f3c 100644 --- a/compiler/rustc_mir_build/src/build/expr/stmt.rs +++ b/compiler/rustc_mir_build/src/build/expr/stmt.rs @@ -3,6 +3,7 @@ use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use crate::thir::*; use rustc_middle::middle::region; use rustc_middle::mir::*; +use std::slice; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Builds a block of MIR statements to evaluate the THIR `expr`. @@ -46,6 +47,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if this.hir.needs_drop(lhs.ty) { let rhs = unpack!(block = this.as_local_operand(block, rhs)); let lhs = unpack!(block = this.as_place(block, lhs)); + this.record_operands_moved(slice::from_ref(&rhs)); unpack!(block = this.build_drop_and_replace(block, lhs_span, lhs, rhs)); } else { let rhs = unpack!(block = this.as_local_rvalue(block, rhs)); diff --git a/compiler/rustc_mir_build/src/build/into.rs b/compiler/rustc_mir_build/src/build/into.rs index 7264e495b84fd..ee1838ddea66c 100644 --- a/compiler/rustc_mir_build/src/build/into.rs +++ b/compiler/rustc_mir_build/src/build/into.rs @@ -6,6 +6,7 @@ use crate::build::{BlockAnd, Builder}; use crate::thir::*; +use rustc_middle::middle::region; use rustc_middle::mir::*; pub(in crate::build) trait EvalInto<'tcx> { @@ -13,6 +14,7 @@ pub(in crate::build) trait EvalInto<'tcx> { self, builder: &mut Builder<'_, 'tcx>, destination: Place<'tcx>, + scope: Option, block: BasicBlock, ) -> BlockAnd<()>; } @@ -21,13 +23,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { crate fn into( &mut self, destination: Place<'tcx>, + scope: Option, block: BasicBlock, expr: E, ) -> BlockAnd<()> where E: EvalInto<'tcx>, { - expr.eval_into(self, destination, block) + expr.eval_into(self, destination, scope, block) } } @@ -36,10 +39,11 @@ impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> { self, builder: &mut Builder<'_, 'tcx>, destination: Place<'tcx>, + scope: Option, block: BasicBlock, ) -> BlockAnd<()> { let expr = builder.hir.mirror(self); - builder.into_expr(destination, block, expr) + builder.into_expr(destination, scope, block, expr) } } @@ -48,8 +52,9 @@ impl<'tcx> EvalInto<'tcx> for Expr<'tcx> { self, builder: &mut Builder<'_, 'tcx>, destination: Place<'tcx>, + scope: Option, block: BasicBlock, ) -> BlockAnd<()> { - builder.into_expr(destination, block, self) + builder.into_expr(destination, scope, block, self) } } diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 3ee15248ae28e..7ffdb7e33fb1e 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -87,6 +87,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { crate fn match_expr( &mut self, destination: Place<'tcx>, + destination_scope: Option, span: Span, mut block: BasicBlock, scrutinee: ExprRef<'tcx>, @@ -107,6 +108,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.lower_match_arms( destination, + destination_scope, scrutinee_place, scrutinee_span, arm_candidates, @@ -213,75 +215,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - /// Lower the bindings, guards and arm bodies of a `match` expression. - /// - /// The decision tree should have already been created - /// (by [Builder::lower_match_tree]). - /// - /// `outer_source_info` is the SourceInfo for the whole match. - fn lower_match_arms( - &mut self, - destination: Place<'tcx>, - scrutinee_place: Place<'tcx>, - scrutinee_span: Span, - arm_candidates: Vec<(&'_ Arm<'tcx>, Candidate<'_, 'tcx>)>, - outer_source_info: SourceInfo, - fake_borrow_temps: Vec<(Place<'tcx>, Local)>, - ) -> BlockAnd<()> { - let arm_end_blocks: Vec<_> = arm_candidates - .into_iter() - .map(|(arm, candidate)| { - debug!("lowering arm {:?}\ncandidate = {:?}", arm, candidate); - - let arm_source_info = self.source_info(arm.span); - let arm_scope = (arm.scope, arm_source_info); - self.in_scope(arm_scope, arm.lint_level, |this| { - let body = this.hir.mirror(arm.body.clone()); - let scope = this.declare_bindings( - None, - arm.span, - &arm.pattern, - ArmHasGuard(arm.guard.is_some()), - Some((Some(&scrutinee_place), scrutinee_span)), - ); - - let arm_block = this.bind_pattern( - outer_source_info, - candidate, - arm.guard.as_ref(), - &fake_borrow_temps, - scrutinee_span, - Some(arm.scope), - ); - - if let Some(source_scope) = scope { - this.source_scope = source_scope; - } - - this.into(destination, arm_block, body) - }) - }) - .collect(); - - // all the arm blocks will rejoin here - let end_block = self.cfg.start_new_block(); - - for arm_block in arm_end_blocks { - self.cfg.goto(unpack!(arm_block), outer_source_info, end_block); - } - - self.source_scope = outer_source_info.scope; - - end_block.unit() - } - /// Binds the variables and ascribes types for a given `match` arm or /// `let` binding. /// /// Also check if the guard matches, if it's provided. /// `arm_scope` should be `Some` if and only if this is called for a /// `match` arm. - fn bind_pattern( + crate fn bind_pattern( &mut self, outer_source_info: SourceInfo, candidate: Candidate<'_, 'tcx>, @@ -365,13 +305,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { PatKind::Binding { mode: BindingMode::ByValue, var, subpattern: None, .. } => { let place = self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard, true); - unpack!(block = self.into(place, block, initializer)); + let region_scope = self.hir.region_scope_tree.var_scope(var.local_id); + + unpack!(block = self.into(place, Some(region_scope), block, initializer)); // Inject a fake read, see comments on `FakeReadCause::ForLet`. let source_info = self.source_info(irrefutable_pat.span); self.cfg.push_fake_read(block, source_info, FakeReadCause::ForLet, place); - self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard); block.unit() } @@ -398,9 +339,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ascription: thir::pattern::Ascription { user_ty: pat_ascription_ty, variance: _, user_ty_span }, } => { + let region_scope = self.hir.region_scope_tree.var_scope(var.local_id); let place = self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard, true); - unpack!(block = self.into(place, block, initializer)); + unpack!(block = self.into(place, Some(region_scope), block, initializer)); // Inject a fake read, see comments on `FakeReadCause::ForLet`. let pattern_source_info = self.source_info(irrefutable_pat.span); @@ -438,7 +380,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }, ); - self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard); block.unit() } @@ -684,7 +625,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[derive(Debug)] -struct Candidate<'pat, 'tcx> { +pub(super) struct Candidate<'pat, 'tcx> { /// `Span` of the original pattern that gave rise to this candidate span: Span, @@ -1394,12 +1335,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { match test.kind { TestKind::SwitchInt { switch_ty, ref mut options } => { for candidate in candidates.iter() { - if !self.add_cases_to_switch( - &match_place, - candidate, - switch_ty, - options, - ) { + if !self.add_cases_to_switch(&match_place, candidate, switch_ty, options) { break; } } @@ -1780,14 +1716,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // ``` // // and that is clearly not correct. - let by_value_bindings = - parent_bindings - .iter() - .flat_map(|(bindings, _)| bindings) - .chain(&candidate.bindings) - .filter(|binding| { - matches!(binding.binding_mode, BindingMode::ByValue ) - }); + let by_value_bindings = parent_bindings + .iter() + .flat_map(|(bindings, _)| bindings) + .chain(&candidate.bindings) + .filter(|binding| matches!(binding.binding_mode, BindingMode::ByValue)); // Read all of the by reference bindings to ensure that the // place they refer to can't be modified by the guard. for binding in by_value_bindings.clone() { diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index c50389a850ec6..34ef4ed78fd01 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -75,7 +75,9 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ kind: hir::TraitItemKind::Const(ty, Some(body_id)), .. }) => (*body_id, ty.span, None), - Node::AnonConst(hir::AnonConst { body, hir_id, .. }) => (*body, tcx.hir().span(*hir_id), None), + Node::AnonConst(hir::AnonConst { body, hir_id, .. }) => { + (*body, tcx.hir().span(*hir_id), None) + } _ => span_bug!(tcx.hir().span(id), "can't build MIR for {:?}", def.did), }; @@ -183,7 +185,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ return_ty, return_ty_span, body, - span_with_body + span_with_body, ); mir.yield_ty = yield_ty; mir @@ -581,7 +583,7 @@ fn construct_fn<'a, 'tcx, A>( return_ty: Ty<'tcx>, return_ty_span: Span, body: &'tcx hir::Body<'tcx>, - span_with_body: Span + span_with_body: Span, ) -> Body<'tcx> where A: Iterator>, @@ -615,8 +617,12 @@ where let arg_scope_s = (arg_scope, source_info); // Attribute epilogue to function's closing brace let fn_end = span_with_body.shrink_to_hi(); - let return_block = - unpack!(builder.in_breakable_scope(None, Place::return_place(), fn_end, |builder| { + let return_block = unpack!(builder.in_breakable_scope( + None, + Place::return_place(), + Some(call_site_scope), + fn_end, + |builder| { Some(builder.in_scope(arg_scope_s, LintLevel::Inherited, |builder| { builder.args_and_body( START_BLOCK, @@ -626,11 +632,13 @@ where &body.value, ) })) - })); + }, + )); let source_info = builder.source_info(fn_end); builder.cfg.terminate(return_block, source_info, TerminatorKind::Return); let should_abort = should_abort_on_panic(tcx, fn_def_id, abi); builder.build_drop_trees(should_abort); + builder.unschedule_return_place_drop(); return_block.unit() })); @@ -657,12 +665,15 @@ fn construct_const<'a, 'tcx>( let owner_id = tcx.hir().body_owner(body_id); let def_id = tcx.hir().local_def_id(owner_id); let span = tcx.hir().span(owner_id); - let mut builder = Builder::new(hir, def_id.to_def_id(), span, 0, Safety::Safe, const_ty, const_ty_span, None); + let mut builder = + Builder::new(hir, def_id.to_def_id(), span, 0, Safety::Safe, const_ty, const_ty_span, None); let mut block = START_BLOCK; let ast_expr = &tcx.hir().body(body_id).value; let expr = builder.hir.mirror(ast_expr); - unpack!(block = builder.into_expr(Place::return_place(), block, expr)); + // We don't provide a scope because we can't unwind in constants, so won't + // need to drop the return place. + unpack!(block = builder.into_expr(Place::return_place(), None, block, expr)); let source_info = builder.source_info(span); builder.cfg.terminate(block, source_info, TerminatorKind::Return); @@ -697,7 +708,8 @@ fn construct_error<'a, 'tcx>(hir: Cx<'a, 'tcx>, body_id: hir::BodyId) -> Body<'t hir::BodyOwnerKind::Const => 0, hir::BodyOwnerKind::Static(_) => 0, }; - let mut builder = Builder::new(hir, def_id.to_def_id(), span, num_params, Safety::Safe, ty, span, None); + let mut builder = + Builder::new(hir, def_id.to_def_id(), span, num_params, Safety::Safe, ty, span, None); let source_info = builder.source_info(span); // Some MIR passes will expect the number of parameters to match the // function declaration. @@ -941,7 +953,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } let body = self.hir.mirror(ast_body); - self.into(Place::return_place(), block, body) + let call_site = + region::Scope { id: ast_body.hir_id.local_id, data: region::ScopeData::CallSite }; + self.into(Place::return_place(), Some(call_site), block, body) } fn set_correct_source_scope_for_arg( diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index e91227d8357de..468b3484ca5ea 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -81,9 +81,10 @@ that contains only loops and breakable blocks. It tracks where a `break`, */ +use crate::build::matches::{ArmHasGuard, Candidate}; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG}; -use crate::thir::{Expr, ExprRef, LintLevel}; -use rustc_data_structures::fx::FxHashMap; +use crate::thir::{Arm, Expr, ExprRef, LintLevel}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_index::vec::IndexVec; use rustc_middle::middle::region; @@ -121,8 +122,6 @@ struct Scope { /// end of the vector (top of the stack) first. drops: Vec, - moved_locals: Vec, - /// The drop index that will drop everything in and below this scope on an /// unwind path. cached_unwind_block: Option, @@ -158,6 +157,8 @@ struct BreakableScope<'tcx> { /// The destination of the loop/block expression itself (i.e., where to put /// the result of a `break` or `return` expression) break_destination: Place<'tcx>, + /// The scope that the destination should have its drop scheduled in. + destination_scope: Option, /// Drops that happen on the `break`/`return` path. break_drops: DropTree, /// Drops that happen on the `continue` path. @@ -406,7 +407,6 @@ impl<'tcx> Scopes<'tcx> { region_scope: region_scope.0, region_scope_span: region_scope.1.span, drops: vec![], - moved_locals: vec![], cached_unwind_block: None, cached_generator_drop_block: None, }); @@ -441,6 +441,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, loop_block: Option, break_destination: Place<'tcx>, + destination_scope: Option, span: Span, f: F, ) -> BlockAnd<()> @@ -451,15 +452,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let scope = BreakableScope { region_scope, break_destination, + destination_scope, break_drops: DropTree::new(), continue_drops: loop_block.map(|_| DropTree::new()), }; + let continue_block = loop_block.map(|block| (block, self.diverge_cleanup())); self.scopes.breakable_scopes.push(scope); let normal_exit_block = f(self); let breakable_scope = self.scopes.breakable_scopes.pop().unwrap(); assert!(breakable_scope.region_scope == region_scope); + if let Some(drops) = breakable_scope.continue_drops { + self.build_exit_tree(drops, continue_block); + } let break_block = self.build_exit_tree(breakable_scope.break_drops, None); - if let Some(drops) = breakable_scope.continue_drops { self.build_exit_tree(drops, loop_block); } match (normal_exit_block, break_block) { (Some(block), None) | (None, Some(block)) => block, (None, None) => self.cfg.start_new_block().unit(), @@ -588,22 +593,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .rposition(|breakable_scope| breakable_scope.region_scope == scope) .unwrap_or_else(|| span_bug!(span, "no enclosing breakable scope found")) }; - let (break_index, destination) = match target { + let (break_index, destination, dest_scope) = match target { BreakableTarget::Return => { let scope = &self.scopes.breakable_scopes[0]; if scope.break_destination != Place::return_place() { span_bug!(span, "`return` in item with no return scope"); } - (0, Some(scope.break_destination)) + (0, Some(scope.break_destination), scope.destination_scope) } BreakableTarget::Break(scope) => { let break_index = get_scope_index(scope); let scope = &self.scopes.breakable_scopes[break_index]; - (break_index, Some(scope.break_destination)) + (break_index, Some(scope.break_destination), scope.destination_scope) } BreakableTarget::Continue(scope) => { let break_index = get_scope_index(scope); - (break_index, None) + (break_index, None, None) } }; @@ -611,7 +616,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let Some(value) = value { debug!("stmt_expr Break val block_context.push(SubExpr)"); self.block_context.push(BlockFrame::SubExpr); - unpack!(block = self.into(destination, block, value)); + unpack!(block = self.into(destination, dest_scope, block, value)); + dest_scope + .map(|scope| self.unschedule_drop(scope, destination.as_local().unwrap())); self.block_context.pop(); } else { self.cfg.push_assign_unit(block, source_info, destination, self.hir.tcx()) @@ -861,14 +868,47 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { span_bug!(span, "region scope {:?} not in scope to drop {:?}", region_scope, local); } - /// Indicates that the "local operand" stored in `local` is + /// Unschedule a drop. Used for `break`, `return` and `match` expressions, + /// where `record_operands_moved` is not powerful enough. + /// + /// The given local is expected to have a value drop scheduled in the given + /// scope and for that drop to be the most recent thing scheduled in that + /// scope. + fn unschedule_drop(&mut self, region_scope: region::Scope, local: Local) { + if !self.hir.needs_drop(self.local_decls[local].ty) { + return; + } + for scope in self.scopes.scopes.iter_mut().rev() { + scope.invalidate_cache(); + + if scope.region_scope == region_scope { + let drop = scope.drops.pop(); + + match drop { + Some(DropData { local: removed_local, kind: DropKind::Value, .. }) + if removed_local == local => + { + return; + } + _ => bug!( + "found wrong drop, expected value drop of {:?}, found {:?}", + local, + drop, + ), + } + } + } + + bug!("region scope {:?} not in scope to unschedule drop of {:?}", region_scope, local); + } + + /// Indicates that the "local operands" stored in `local` is /// *moved* at some point during execution (see `local_scope` for /// more information about what a "local operand" is -- in short, /// it's an intermediate operand created as part of preparing some /// MIR instruction). We use this information to suppress - /// redundant drops on the non-unwind paths. This results in less - /// MIR, but also avoids spurious borrow check errors - /// (c.f. #64391). + /// redundant drops. This results in less MIR, but also avoids spurious + /// borrow check errors (c.f. #64391). /// /// Example: when compiling the call to `foo` here: /// @@ -904,29 +944,32 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { return; } - Some(local_scope) => self - .scopes - .scopes - .iter_mut() - .rfind(|scope| scope.region_scope == local_scope) - .unwrap_or_else(|| bug!("scope {:?} not found in scope list!", local_scope)), + Some(local_scope) => { + let top_scope = self.scopes.scopes.last_mut().unwrap(); + assert!( + top_scope.region_scope == local_scope, + "local scope ({:?}) is not the topmost scope!", + local_scope + ); + + top_scope + } }; // look for moves of a local variable, like `MOVE(_X)` - let locals_moved = operands.iter().flat_map(|operand| match operand { - Operand::Copy(_) | Operand::Constant(_) => None, - Operand::Move(place) => place.as_local(), - }); + let locals_moved = operands + .iter() + .filter_map(|operand| match operand { + Operand::Copy(_) | Operand::Constant(_) => None, + Operand::Move(place) => place.as_local(), + }) + .collect::>(); - for local in locals_moved { - // check if we have a Drop for this operand and -- if so - // -- add it to the list of moved operands. Note that this - // local might not have been an operand created for this - // call, it could come from other places too. - if scope.drops.iter().any(|drop| drop.local == local && drop.kind == DropKind::Value) { - scope.moved_locals.push(local); - } - } + // Remove the drops for the moved operands. + scope + .drops + .retain(|drop| drop.kind == DropKind::Storage || !locals_moved.contains(&drop.local)); + scope.invalidate_cache(); } // Other @@ -1116,11 +1159,96 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { success_block } + /// Lower the arms and guards of a match. + /// + /// The decision tree should have already been created (by + /// [Builder::lower_match_tree]). + /// + /// This is this module, and not in `build::matches` because we have to do + /// some careful scope manipulation to have the drop of the destination be + /// scheduled at the end of each arm and then cleared for the next arm. + crate fn lower_match_arms( + &mut self, + destination: Place<'tcx>, + destination_scope: Option, + scrutinee_place: Place<'tcx>, + scrutinee_span: Span, + arm_candidates: Vec<(&'_ Arm<'tcx>, Candidate<'_, 'tcx>)>, + outer_source_info: SourceInfo, + fake_borrow_temps: Vec<(Place<'tcx>, Local)>, + ) -> BlockAnd<()> { + if arm_candidates.is_empty() { + // If there are no arms to schedule drops, then we have to do it + // manually. + if let Some(scope) = destination_scope { + self.schedule_drop( + outer_source_info.span, + scope, + destination.as_local().unwrap(), + DropKind::Value, + ); + } + return self.cfg.start_new_block().unit(); + } + let mut first_arm = true; + let arm_end_blocks: Vec<_> = arm_candidates + .into_iter() + .map(|(arm, candidate)| { + debug!("lowering arm {:?}\ncandidate = {:?}", arm, candidate); + + if first_arm { + first_arm = false; + } else if let Some(scope) = destination_scope { + self.unschedule_drop(scope, destination.as_local().unwrap()); + } + + let arm_source_info = self.source_info(arm.span); + let arm_scope = (arm.scope, arm_source_info); + self.in_scope(arm_scope, arm.lint_level, |this| { + let body = this.hir.mirror(arm.body.clone()); + let scope = this.declare_bindings( + None, + arm.span, + &arm.pattern, + ArmHasGuard(arm.guard.is_some()), + Some((Some(&scrutinee_place), scrutinee_span)), + ); + + let arm_block = this.bind_pattern( + outer_source_info, + candidate, + arm.guard.as_ref(), + &fake_borrow_temps, + scrutinee_span, + Some(arm.scope), + ); + + if let Some(source_scope) = scope { + this.source_scope = source_scope; + } + + this.into(destination, destination_scope, arm_block, body) + }) + }) + .collect(); + + // all the arm blocks will rejoin here + let end_block = self.cfg.start_new_block(); + + for arm_block in arm_end_blocks { + self.cfg.goto(unpack!(arm_block), outer_source_info, end_block); + } + + self.source_scope = outer_source_info.scope; + + end_block.unit() + } + /// Unschedules any drops in the top scope. /// /// This is only needed for `match` arm scopes, because they have one /// entrance per pattern, but only one exit. - crate fn clear_top_scope(&mut self, region_scope: region::Scope) { + pub(super) fn clear_top_scope(&mut self, region_scope: region::Scope) { let top_scope = self.scopes.scopes.last_mut().unwrap(); assert_eq!(top_scope.region_scope, region_scope); @@ -1128,6 +1256,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { top_scope.drops.clear(); top_scope.invalidate_cache(); } + + /// Unschedules the drop of the return place. + /// + /// If the return type of a function requires drop, then we schedule it + /// in the outermost scope so that it's dropped if there's a panic while + /// we drop any local variables. But we don't want to drop it if we + /// return normally. + crate fn unschedule_return_place_drop(&mut self) { + assert_eq!(self.scopes.scopes.len(), 1); + assert!(self.scopes.scopes[0].drops.len() <= 1); + self.scopes.scopes[0].drops.clear(); + } } /// Builds drops for `pop_scope` and `leave_top_scope`. @@ -1174,14 +1314,6 @@ fn build_scope_drops<'tcx>( debug_assert_eq!(unwind_drops.drops[unwind_to].0.kind, drop_data.kind); unwind_to = unwind_drops.drops[unwind_to].1; - // If the operand has been moved, and we are not on an unwind - // path, then don't generate the drop. (We only take this into - // account for non-unwind paths so as not to disturb the - // caching mechanism.) - if scope.moved_locals.iter().any(|&o| o == local) { - continue; - } - unwind_drops.add_entry(block, unwind_to); let next = cfg.start_new_block(); @@ -1211,20 +1343,24 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> { /// Build a drop tree for a breakable scope. /// /// If `continue_block` is `Some`, then the tree is for `continue` inside a - /// loop. Otherwise this is for `break` or `return`. + /// loop. Otherwise this is for `break` or `return`. The `DropIdx` is the + /// next drop in the case that the drop tree unwinds. This is needed + /// because the drop of the break destination has already been scheduled + /// but it hasn't been initialized on the `continue` paths. fn build_exit_tree( &mut self, mut drops: DropTree, - continue_block: Option, + continue_block: Option<(BasicBlock, DropIdx)>, ) -> Option> { let mut blocks = IndexVec::from_elem(None, &drops.drops); - blocks[ROOT_NODE] = continue_block; + blocks[ROOT_NODE] = continue_block.map(|(block, _)| block); drops.build_mir::(&mut self.cfg, &mut blocks); // Link the exit drop tree to unwind drop tree. if drops.drops.iter().any(|(drop, _)| drop.kind == DropKind::Value) { - let unwind_target = self.diverge_cleanup(); + let unwind_target = continue_block + .map_or_else(|| self.diverge_cleanup(), |(_, unwind_target)| unwind_target); let mut unwind_indices = IndexVec::from_elem_n(unwind_target, 1); for (drop_idx, drop_data) in drops.drops.iter_enumerated().skip(1) { match drop_data.0.kind { @@ -1387,7 +1523,7 @@ impl<'tcx> DropTreeBuilder<'tcx> for Unwind { | TerminatorKind::Yield { .. } | TerminatorKind::GeneratorDrop | TerminatorKind::FalseEdge { .. } - | TerminatorKind::InlineAsm {.. } => { + | TerminatorKind::InlineAsm { .. } => { span_bug!(term.source_info.span, "cannot unwind from {:?}", term.kind) } } diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs index 23cd4f3d83d62..97df8ea07d23e 100644 --- a/library/alloc/src/collections/btree/map/tests.rs +++ b/library/alloc/src/collections/btree/map/tests.rs @@ -1772,7 +1772,7 @@ fn test_append_drop_leak() { catch_unwind(move || left.append(&mut right)).unwrap_err(); - assert_eq!(DROPS.load(SeqCst), 4); // Rust issue #47949 ate one little piggy + assert_eq!(DROPS.load(SeqCst), 5); } #[test] diff --git a/src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir index 7e0ca3dea4b71..0c7b64cb97f8f 100644 --- a/src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir @@ -41,44 +41,36 @@ fn main() -> () { StorageLive(_5); // scope 3 at $DIR/basic_assignment.rs:19:9: 19:15 StorageLive(_6); // scope 4 at $DIR/basic_assignment.rs:23:14: 23:20 _6 = move _4; // scope 4 at $DIR/basic_assignment.rs:23:14: 23:20 - replace(_5 <- move _6) -> [return: bb1, unwind: bb5]; // scope 4 at $DIR/basic_assignment.rs:23:5: 23:11 + replace(_5 <- move _6) -> [return: bb1, unwind: bb4]; // scope 4 at $DIR/basic_assignment.rs:23:5: 23:11 } bb1: { - drop(_6) -> [return: bb2, unwind: bb6]; // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20 - } - - bb2: { StorageDead(_6); // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20 _0 = const (); // scope 0 at $DIR/basic_assignment.rs:10:11: 24:2 - drop(_5) -> [return: bb3, unwind: bb7]; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 + drop(_5) -> [return: bb2, unwind: bb5]; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 } - bb3: { + bb2: { StorageDead(_5); // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 - drop(_4) -> [return: bb4, unwind: bb8]; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 + drop(_4) -> [return: bb3, unwind: bb6]; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 } - bb4: { + bb3: { StorageDead(_4); // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 StorageDead(_2); // scope 1 at $DIR/basic_assignment.rs:24:1: 24:2 StorageDead(_1); // scope 0 at $DIR/basic_assignment.rs:24:1: 24:2 return; // scope 0 at $DIR/basic_assignment.rs:24:2: 24:2 } - bb5 (cleanup): { - drop(_6) -> bb6; // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20 - } - - bb6 (cleanup): { - drop(_5) -> bb7; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 + bb4 (cleanup): { + drop(_5) -> bb5; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 } - bb7 (cleanup): { - drop(_4) -> bb8; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 + bb5 (cleanup): { + drop(_4) -> bb6; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 } - bb8 (cleanup): { + bb6 (cleanup): { resume; // scope 0 at $DIR/basic_assignment.rs:10:1: 24:2 } } diff --git a/src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir b/src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir index cfbd3a58637c0..20ea7b026bc6e 100644 --- a/src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir +++ b/src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir @@ -14,7 +14,7 @@ fn main() -> () { StorageLive(_1); // scope 0 at $DIR/box_expr.rs:7:9: 7:10 StorageLive(_2); // scope 0 at $DIR/box_expr.rs:7:13: 7:25 _2 = Box(S); // scope 0 at $DIR/box_expr.rs:7:13: 7:25 - (*_2) = S::new() -> [return: bb1, unwind: bb7]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25 + (*_2) = S::new() -> [return: bb1, unwind: bb5]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25 // mir::Constant // + span: $DIR/box_expr.rs:7:17: 7:23 // + literal: Const { ty: fn() -> S {S::new}, val: Value(Scalar()) } @@ -22,45 +22,37 @@ fn main() -> () { bb1: { _1 = move _2; // scope 0 at $DIR/box_expr.rs:7:13: 7:25 - drop(_2) -> bb2; // scope 0 at $DIR/box_expr.rs:7:24: 7:25 - } - - bb2: { StorageDead(_2); // scope 0 at $DIR/box_expr.rs:7:24: 7:25 StorageLive(_3); // scope 1 at $DIR/box_expr.rs:8:5: 8:12 StorageLive(_4); // scope 1 at $DIR/box_expr.rs:8:10: 8:11 _4 = move _1; // scope 1 at $DIR/box_expr.rs:8:10: 8:11 - _3 = std::mem::drop::>(move _4) -> [return: bb3, unwind: bb5]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12 + _3 = std::mem::drop::>(move _4) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12 // mir::Constant // + span: $DIR/box_expr.rs:8:5: 8:9 // + literal: Const { ty: fn(std::boxed::Box) {std::mem::drop::>}, val: Value(Scalar()) } } - bb3: { + bb2: { StorageDead(_4); // scope 1 at $DIR/box_expr.rs:8:11: 8:12 StorageDead(_3); // scope 1 at $DIR/box_expr.rs:8:12: 8:13 _0 = const (); // scope 0 at $DIR/box_expr.rs:6:11: 9:2 - drop(_1) -> bb4; // scope 0 at $DIR/box_expr.rs:9:1: 9:2 + drop(_1) -> bb3; // scope 0 at $DIR/box_expr.rs:9:1: 9:2 } - bb4: { + bb3: { StorageDead(_1); // scope 0 at $DIR/box_expr.rs:9:1: 9:2 return; // scope 0 at $DIR/box_expr.rs:9:2: 9:2 } - bb5 (cleanup): { - drop(_4) -> bb6; // scope 1 at $DIR/box_expr.rs:8:11: 8:12 - } - - bb6 (cleanup): { - drop(_1) -> bb8; // scope 0 at $DIR/box_expr.rs:9:1: 9:2 + bb4 (cleanup): { + drop(_1) -> bb6; // scope 0 at $DIR/box_expr.rs:9:1: 9:2 } - bb7 (cleanup): { - drop(_2) -> bb8; // scope 0 at $DIR/box_expr.rs:7:24: 7:25 + bb5 (cleanup): { + drop(_2) -> bb6; // scope 0 at $DIR/box_expr.rs:7:24: 7:25 } - bb8 (cleanup): { + bb6 (cleanup): { resume; // scope 0 at $DIR/box_expr.rs:6:1: 9:2 } } diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff index 07994eb3c1661..22737381c71ae 100644 --- a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff @@ -5,18 +5,19 @@ let mut _0: (); // return place in scope 0 at $DIR/inline-diverging.rs:21:12: 21:12 let _1: (!, !); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 -+ let mut _7: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _8: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _9: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 1 (inlined call_twice:: ! {sleep}>) { // at $DIR/inline-diverging.rs:22:5: 22:22 + debug f => _2; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let _3: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _5: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _6: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _7: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 2 { + debug a => _3; // in scope 2 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 3 { -+ debug b => _6; // in scope 3 at $DIR/inline-diverging.rs:22:5: 22:22 ++ debug b => _7; // in scope 3 at $DIR/inline-diverging.rs:22:5: 22:22 + } + scope 6 (inlined ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline-diverging.rs:22:5: 22:22 + scope 7 (inlined sleep) { // at $DIR/inline-diverging.rs:22:5: 22:22 @@ -40,12 +41,12 @@ - // mir::Constant // + span: $DIR/inline-diverging.rs:22:16: 22:21 // + literal: Const { ty: fn() -> ! {sleep}, val: Value(Scalar()) } -+ StorageLive(_6); // scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 ++ StorageLive(_7); // scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_3); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_4); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + _4 = &_2; // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ StorageLive(_7); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ _7 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ StorageLive(_8); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ _8 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + goto -> bb1; // scope 5 at $DIR/inline-diverging.rs:22:5: 22:22 } diff --git a/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir index 7113c42b9c77f..bbbd2bcf128b1 100644 --- a/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir @@ -6,21 +6,18 @@ fn main() -> () { let mut _2: S; // in scope 0 at $DIR/issue-41110.rs:8:13: 8:14 let mut _3: S; // in scope 0 at $DIR/issue-41110.rs:8:21: 8:27 let mut _4: S; // in scope 0 at $DIR/issue-41110.rs:8:21: 8:22 - let mut _5: bool; // in scope 0 at $DIR/issue-41110.rs:8:27: 8:28 scope 1 { debug x => _1; // in scope 1 at $DIR/issue-41110.rs:8:9: 8:10 } bb0: { - _5 = const false; // scope 0 at $DIR/issue-41110.rs:8:9: 8:10 StorageLive(_1); // scope 0 at $DIR/issue-41110.rs:8:9: 8:10 StorageLive(_2); // scope 0 at $DIR/issue-41110.rs:8:13: 8:14 - _5 = const true; // scope 0 at $DIR/issue-41110.rs:8:13: 8:14 _2 = S; // scope 0 at $DIR/issue-41110.rs:8:13: 8:14 StorageLive(_3); // scope 0 at $DIR/issue-41110.rs:8:21: 8:27 StorageLive(_4); // scope 0 at $DIR/issue-41110.rs:8:21: 8:22 _4 = S; // scope 0 at $DIR/issue-41110.rs:8:21: 8:22 - _3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue-41110.rs:8:21: 8:27 + _3 = S::id(move _4) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-41110.rs:8:21: 8:27 // mir::Constant // + span: $DIR/issue-41110.rs:8:23: 8:25 // + literal: Const { ty: fn(S) -> S {S::id}, val: Value(Scalar()) } @@ -28,8 +25,7 @@ fn main() -> () { bb1: { StorageDead(_4); // scope 0 at $DIR/issue-41110.rs:8:26: 8:27 - _5 = const false; // scope 0 at $DIR/issue-41110.rs:8:13: 8:28 - _1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue-41110.rs:8:13: 8:28 + _1 = S::other(move _2, move _3) -> bb2; // scope 0 at $DIR/issue-41110.rs:8:13: 8:28 // mir::Constant // + span: $DIR/issue-41110.rs:8:15: 8:20 // + literal: Const { ty: fn(S, S) {S::other}, val: Value(Scalar()) } @@ -37,7 +33,6 @@ fn main() -> () { bb2: { StorageDead(_3); // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 - _5 = const false; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 StorageDead(_2); // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 _0 = const (); // scope 0 at $DIR/issue-41110.rs:7:11: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-41110.rs:9:1: 9:2 @@ -45,26 +40,10 @@ fn main() -> () { } bb3 (cleanup): { - goto -> bb5; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + drop(_2) -> bb4; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 } bb4 (cleanup): { - goto -> bb5; // scope 0 at $DIR/issue-41110.rs:8:26: 8:27 - } - - bb5 (cleanup): { - goto -> bb8; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 - } - - bb6 (cleanup): { resume; // scope 0 at $DIR/issue-41110.rs:7:1: 9:2 } - - bb7 (cleanup): { - drop(_2) -> bb6; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 - } - - bb8 (cleanup): { - switchInt(_5) -> [false: bb6, otherwise: bb7]; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 - } } diff --git a/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir index c4e852ca3212a..b0c7260f0f4dc 100644 --- a/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir @@ -25,7 +25,7 @@ fn test() -> () { StorageLive(_3); // scope 2 at $DIR/issue-41110.rs:17:5: 17:12 StorageLive(_4); // scope 2 at $DIR/issue-41110.rs:17:10: 17:11 _4 = move _2; // scope 2 at $DIR/issue-41110.rs:17:10: 17:11 - _3 = std::mem::drop::(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue-41110.rs:17:5: 17:12 + _3 = std::mem::drop::(move _4) -> [return: bb1, unwind: bb5]; // scope 2 at $DIR/issue-41110.rs:17:5: 17:12 // mir::Constant // + span: $DIR/issue-41110.rs:17:5: 17:9 // + literal: Const { ty: fn(S) {std::mem::drop::}, val: Value(Scalar()) } @@ -37,65 +37,53 @@ fn test() -> () { StorageLive(_5); // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 _6 = const false; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 _5 = move _1; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 - goto -> bb12; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + goto -> bb9; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 } bb2: { - goto -> bb3; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 - } - - bb3: { StorageDead(_5); // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 _0 = const (); // scope 0 at $DIR/issue-41110.rs:14:15: 19:2 - drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 + drop(_2) -> [return: bb3, unwind: bb6]; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 } - bb4: { + bb3: { StorageDead(_2); // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 - goto -> bb5; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + goto -> bb4; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 } - bb5: { + bb4: { _6 = const false; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 StorageDead(_1); // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 return; // scope 0 at $DIR/issue-41110.rs:19:2: 19:2 } - bb6 (cleanup): { - goto -> bb8; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 - } - - bb7 (cleanup): { - goto -> bb8; // scope 2 at $DIR/issue-41110.rs:17:11: 17:12 - } - - bb8 (cleanup): { - goto -> bb9; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 + bb5 (cleanup): { + goto -> bb6; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 } - bb9 (cleanup): { - goto -> bb14; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + bb6 (cleanup): { + goto -> bb11; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 } - bb10 (cleanup): { + bb7 (cleanup): { resume; // scope 0 at $DIR/issue-41110.rs:14:1: 19:2 } - bb11 (cleanup): { + bb8 (cleanup): { _2 = move _5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 - goto -> bb6; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + goto -> bb5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 } - bb12: { + bb9: { _2 = move _5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 goto -> bb2; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 } - bb13 (cleanup): { - drop(_1) -> bb10; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + bb10 (cleanup): { + drop(_1) -> bb7; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 } - bb14 (cleanup): { - switchInt(_6) -> [false: bb10, otherwise: bb13]; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + bb11 (cleanup): { + switchInt(_6) -> [false: bb7, otherwise: bb10]; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 } } diff --git a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir index 453886f3effdf..5011c2adfa581 100644 --- a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir @@ -26,7 +26,7 @@ fn main() -> () { _8 = const false; // scope 0 at $DIR/issue-41888.rs:7:9: 7:10 StorageLive(_1); // scope 0 at $DIR/issue-41888.rs:7:9: 7:10 StorageLive(_2); // scope 1 at $DIR/issue-41888.rs:8:8: 8:14 - _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue-41888.rs:8:8: 8:14 + _2 = cond() -> [return: bb1, unwind: bb9]; // scope 1 at $DIR/issue-41888.rs:8:8: 8:14 // mir::Constant // + span: $DIR/issue-41888.rs:8:8: 8:12 // + literal: Const { ty: fn() -> bool {cond}, val: Value(Scalar()) } @@ -38,7 +38,7 @@ fn main() -> () { bb2: { _0 = const (); // scope 1 at $DIR/issue-41888.rs:14:6: 14:6 - goto -> bb8; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6 + goto -> bb7; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6 } bb3: { @@ -47,38 +47,34 @@ fn main() -> () { _4 = K; // scope 1 at $DIR/issue-41888.rs:9:18: 9:19 _3 = E::F(move _4); // scope 1 at $DIR/issue-41888.rs:9:13: 9:20 StorageDead(_4); // scope 1 at $DIR/issue-41888.rs:9:19: 9:20 - goto -> bb14; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + goto -> bb12; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 } bb4: { - goto -> bb5; // scope 1 at $DIR/issue-41888.rs:9:19: 9:20 - } - - bb5: { StorageDead(_3); // scope 1 at $DIR/issue-41888.rs:9:19: 9:20 _5 = discriminant(_1); // scope 1 at $DIR/issue-41888.rs:10:16: 10:24 - switchInt(move _5) -> [0_isize: bb7, otherwise: bb6]; // scope 1 at $DIR/issue-41888.rs:10:16: 10:24 + switchInt(move _5) -> [0_isize: bb6, otherwise: bb5]; // scope 1 at $DIR/issue-41888.rs:10:16: 10:24 } - bb6: { + bb5: { _0 = const (); // scope 1 at $DIR/issue-41888.rs:13:10: 13:10 - goto -> bb8; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10 + goto -> bb7; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10 } - bb7: { + bb6: { StorageLive(_6); // scope 1 at $DIR/issue-41888.rs:10:21: 10:23 _9 = const false; // scope 1 at $DIR/issue-41888.rs:10:21: 10:23 _6 = move ((_1 as F).0: K); // scope 1 at $DIR/issue-41888.rs:10:21: 10:23 _0 = const (); // scope 2 at $DIR/issue-41888.rs:10:29: 13:10 StorageDead(_6); // scope 1 at $DIR/issue-41888.rs:13:9: 13:10 - goto -> bb8; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10 + goto -> bb7; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10 } - bb8: { - goto -> bb20; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb7: { + goto -> bb18; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb9: { + bb8: { _7 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 _8 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 _9 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 @@ -87,27 +83,23 @@ fn main() -> () { return; // scope 0 at $DIR/issue-41888.rs:15:2: 15:2 } - bb10 (cleanup): { - goto -> bb11; // scope 1 at $DIR/issue-41888.rs:9:19: 9:20 - } - - bb11 (cleanup): { - goto -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb9 (cleanup): { + goto -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb12 (cleanup): { + bb10 (cleanup): { resume; // scope 0 at $DIR/issue-41888.rs:6:1: 15:2 } - bb13 (cleanup): { + bb11 (cleanup): { _7 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _8 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _9 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _1 = move _3; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 - goto -> bb10; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + goto -> bb9; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 } - bb14: { + bb12: { _7 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _8 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _9 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 @@ -115,38 +107,38 @@ fn main() -> () { goto -> bb4; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 } - bb15: { + bb13: { _7 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 - goto -> bb9; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + goto -> bb8; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb16 (cleanup): { - goto -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb14 (cleanup): { + goto -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb17: { - drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb15: { + drop(_1) -> [return: bb13, unwind: bb10]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb18 (cleanup): { - drop(_1) -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb16 (cleanup): { + drop(_1) -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb19: { + bb17: { _10 = discriminant(_1); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 - switchInt(move _10) -> [0_isize: bb15, otherwise: bb17]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + switchInt(move _10) -> [0_isize: bb13, otherwise: bb15]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb20: { - switchInt(_7) -> [false: bb15, otherwise: bb19]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb18: { + switchInt(_7) -> [false: bb13, otherwise: bb17]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb21 (cleanup): { + bb19 (cleanup): { _11 = discriminant(_1); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 - switchInt(move _11) -> [0_isize: bb16, otherwise: bb18]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + switchInt(move _11) -> [0_isize: bb14, otherwise: bb16]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb22 (cleanup): { - switchInt(_7) -> [false: bb12, otherwise: bb21]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb20 (cleanup): { + switchInt(_7) -> [false: bb10, otherwise: bb19]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } } diff --git a/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir b/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir index c1421f20a0ba2..f74cdd7191927 100644 --- a/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir +++ b/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir @@ -30,7 +30,7 @@ fn test() -> Option> { StorageLive(_3); // scope 0 at $DIR/issue-62289.rs:9:15: 9:20 StorageLive(_4); // scope 0 at $DIR/issue-62289.rs:9:15: 9:19 _4 = Option::::None; // scope 0 at $DIR/issue-62289.rs:9:15: 9:19 - _3 = as Try>::into_result(move _4) -> [return: bb1, unwind: bb12]; // scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + _3 = as Try>::into_result(move _4) -> [return: bb1, unwind: bb10]; // scope 0 at $DIR/issue-62289.rs:9:15: 9:20 // mir::Constant // + span: $DIR/issue-62289.rs:9:15: 9:20 // + literal: Const { ty: fn(std::option::Option) -> std::result::Result< as std::ops::Try>::Ok, as std::ops::Try>::Error> { as std::ops::Try>::into_result}, val: Value(Scalar()) } @@ -48,7 +48,11 @@ fn test() -> Option> { (*_2) = _10; // scope 4 at $DIR/issue-62289.rs:9:15: 9:20 StorageDead(_10); // scope 0 at $DIR/issue-62289.rs:9:19: 9:20 _1 = move _2; // scope 0 at $DIR/issue-62289.rs:9:10: 9:21 - drop(_2) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + _0 = Option::>::Some(move _1); // scope 0 at $DIR/issue-62289.rs:9:5: 9:22 + StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 + StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2 + goto -> bb8; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 } bb3: { @@ -61,7 +65,7 @@ fn test() -> Option> { StorageLive(_8); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 StorageLive(_9); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 _9 = _6; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 - _8 = >::from(move _9) -> [return: bb5, unwind: bb12]; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + _8 = >::from(move _9) -> [return: bb5, unwind: bb10]; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 // mir::Constant // + span: $DIR/issue-62289.rs:9:19: 9:20 // + literal: Const { ty: fn(std::option::NoneError) -> std::option::NoneError {>::from}, val: Value(Scalar()) } @@ -69,7 +73,7 @@ fn test() -> Option> { bb5: { StorageDead(_9); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 - _0 = > as Try>::from_error(move _8) -> [return: bb6, unwind: bb12]; // scope 2 at $DIR/issue-62289.rs:9:15: 9:20 + _0 = > as Try>::from_error(move _8) -> [return: bb6, unwind: bb10]; // scope 2 at $DIR/issue-62289.rs:9:15: 9:20 // mir::Constant // + span: $DIR/issue-62289.rs:9:15: 9:20 // + literal: Const { ty: fn(> as std::ops::Try>::Error) -> std::option::Option> {> as std::ops::Try>::from_error}, val: Value(Scalar()) } @@ -78,41 +82,29 @@ fn test() -> Option> { bb6: { StorageDead(_8); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 StorageDead(_6); // scope 0 at $DIR/issue-62289.rs:9:19: 9:20 - drop(_2) -> bb9; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + drop(_2) -> [return: bb7, unwind: bb9]; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 } bb7: { - StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 - _0 = Option::>::Some(move _1); // scope 0 at $DIR/issue-62289.rs:9:5: 9:22 - drop(_1) -> bb8; // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 - } - - bb8: { - StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 - StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2 - goto -> bb10; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 - } - - bb9: { StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2 - goto -> bb10; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 + goto -> bb8; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 } - bb10: { + bb8: { return; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 } - bb11 (cleanup): { - drop(_1) -> bb13; // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 + bb9 (cleanup): { + drop(_0) -> bb11; // scope 0 at $DIR/issue-62289.rs:10:1: 10:2 } - bb12 (cleanup): { - drop(_2) -> bb13; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + bb10 (cleanup): { + drop(_2) -> bb11; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 } - bb13 (cleanup): { + bb11 (cleanup): { resume; // scope 0 at $DIR/issue-62289.rs:8:1: 10:2 } } diff --git a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir index bbb433dbe25c7..2f95931d2b2a1 100644 --- a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir +++ b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir @@ -28,7 +28,7 @@ fn main() -> () { bb1: { StorageDead(_3); // scope 0 at $DIR/no-spurious-drop-after-call.rs:9:33: 9:34 - _1 = std::mem::drop::(move _2) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35 + _1 = std::mem::drop::(move _2) -> bb2; // scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35 // mir::Constant // + span: $DIR/no-spurious-drop-after-call.rs:9:5: 9:19 // + literal: Const { ty: fn(std::string::String) {std::mem::drop::}, val: Value(Scalar()) } @@ -41,12 +41,4 @@ fn main() -> () { _0 = const (); // scope 0 at $DIR/no-spurious-drop-after-call.rs:8:11: 10:2 return; // scope 0 at $DIR/no-spurious-drop-after-call.rs:10:2: 10:2 } - - bb3 (cleanup): { - drop(_2) -> bb4; // scope 0 at $DIR/no-spurious-drop-after-call.rs:9:34: 9:35 - } - - bb4 (cleanup): { - resume; // scope 0 at $DIR/no-spurious-drop-after-call.rs:8:1: 10:2 - } } diff --git a/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir index d18f6308ded84..9bca5d24605fb 100644 --- a/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir +++ b/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir @@ -22,62 +22,38 @@ fn move_out_by_subslice() -> () { _3 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 (*_3) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 _2 = move _3; // scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 - drop(_3) -> [return: bb1, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 - } - - bb1: { StorageDead(_3); // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 StorageLive(_4); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 StorageLive(_5); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 _5 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 (*_5) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 _4 = move _5; // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 - drop(_5) -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 - } - - bb2: { StorageDead(_5); // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 _1 = [move _2, move _4]; // scope 0 at $DIR/uniform_array_move_out.rs:11:13: 11:27 - drop(_4) -> [return: bb3, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 - } - - bb3: { StorageDead(_4); // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 - drop(_2) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 - } - - bb4: { StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 FakeRead(ForLet, _1); // scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10 StorageLive(_6); // scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17 _6 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17 _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:10:27: 13:2 - drop(_6) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + drop(_6) -> [return: bb1, unwind: bb3]; // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 } - bb5: { + bb1: { StorageDead(_6); // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 - drop(_1) -> [return: bb6, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 } - bb6: { + bb2: { StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 return; // scope 0 at $DIR/uniform_array_move_out.rs:13:2: 13:2 } - bb7 (cleanup): { - drop(_1) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 - } - - bb8 (cleanup): { - drop(_4) -> bb9; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 - } - - bb9 (cleanup): { - drop(_2) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 + bb3 (cleanup): { + drop(_1) -> bb4; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 } - bb10 (cleanup): { + bb4 (cleanup): { resume; // scope 0 at $DIR/uniform_array_move_out.rs:10:1: 13:2 } } diff --git a/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir index eda8e5fd3afe7..c9004416f2ec1 100644 --- a/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir +++ b/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir @@ -22,62 +22,38 @@ fn move_out_from_end() -> () { _3 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 (*_3) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 _2 = move _3; // scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 - drop(_3) -> [return: bb1, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 - } - - bb1: { StorageDead(_3); // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 StorageLive(_4); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 StorageLive(_5); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 _5 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 (*_5) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 _4 = move _5; // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 - drop(_5) -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 - } - - bb2: { StorageDead(_5); // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 _1 = [move _2, move _4]; // scope 0 at $DIR/uniform_array_move_out.rs:5:13: 5:27 - drop(_4) -> [return: bb3, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 - } - - bb3: { StorageDead(_4); // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 - drop(_2) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 - } - - bb4: { StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 FakeRead(ForLet, _1); // scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10 StorageLive(_6); // scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16 _6 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16 _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:4:24: 7:2 - drop(_6) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + drop(_6) -> [return: bb1, unwind: bb3]; // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 } - bb5: { + bb1: { StorageDead(_6); // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 - drop(_1) -> [return: bb6, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 } - bb6: { + bb2: { StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 return; // scope 0 at $DIR/uniform_array_move_out.rs:7:2: 7:2 } - bb7 (cleanup): { - drop(_1) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 - } - - bb8 (cleanup): { - drop(_4) -> bb9; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 - } - - bb9 (cleanup): { - drop(_2) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 + bb3 (cleanup): { + drop(_1) -> bb4; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 } - bb10 (cleanup): { + bb4 (cleanup): { resume; // scope 0 at $DIR/uniform_array_move_out.rs:4:1: 7:2 } } diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt index e14e733fff6d4..4c03e950af029 100644 --- a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt @@ -19,12 +19,12 @@ 18| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); 19| 2|} ------------------ - | used_crate::used_only_from_bin_crate_generic_function::<&str>: + | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec>: | 17| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 19| 1|} ------------------ - | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec>: + | used_crate::used_only_from_bin_crate_generic_function::<&str>: | 17| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 19| 1|} diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.async.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.async.txt index 82a4457b6ef1e..abc2d32a89795 100644 --- a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.async.txt +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.async.txt @@ -28,18 +28,16 @@ Counter in file 0 79:14 -> 79:16, 0 Counter in file 0 81:1 -> 81:2, 0 Counter in file 0 91:25 -> 91:34, 0 Counter in file 0 5:1 -> 5:25, #1 +Counter in file 0 5:25 -> 6:14, #1 +Counter in file 0 7:9 -> 7:10, #2 +Counter in file 0 9:9 -> 9:10, (#1 - #2) +Counter in file 0 11:1 -> 11:2, (#2 + (#1 - #2)) Counter in file 0 21:1 -> 21:23, #1 -Counter in file 0 17:20 -> 17:21, #1 Counter in file 0 67:5 -> 67:23, #1 Counter in file 0 38:1 -> 38:19, #1 -Counter in file 0 13:20 -> 13:21, #1 Counter in file 0 29:1 -> 29:22, #1 Counter in file 0 93:1 -> 101:2, #1 Counter in file 0 91:1 -> 91:25, #1 -Counter in file 0 5:25 -> 6:14, #1 -Counter in file 0 7:9 -> 7:10, #2 -Counter in file 0 9:9 -> 9:10, (#1 - #2) -Counter in file 0 11:1 -> 11:2, (#2 + (#1 - #2)) Counter in file 0 38:19 -> 42:12, #1 Counter in file 0 43:9 -> 43:10, #3 Counter in file 0 43:14 -> 43:18, (#1 + 0) @@ -55,6 +53,7 @@ Counter in file 0 51:5 -> 52:18, #1 Counter in file 0 53:13 -> 53:14, #2 Counter in file 0 63:13 -> 63:14, (#1 - #2) Counter in file 0 65:5 -> 65:6, (#2 + (#1 - #2)) +Counter in file 0 13:20 -> 13:21, #1 Counter in file 0 49:1 -> 68:12, #1 Counter in file 0 69:9 -> 69:10, #2 Counter in file 0 69:14 -> 69:27, (#1 + 0) @@ -70,6 +69,7 @@ Counter in file 0 86:14 -> 86:16, #2 Counter in file 0 87:14 -> 87:16, #3 Counter in file 0 89:1 -> 89:2, (#3 + (#2 + (#1 - (#3 + #2)))) Counter in file 0 17:1 -> 17:20, #1 +Counter in file 0 17:20 -> 17:21, #1 Counter in file 0 66:5 -> 66:23, #1 Counter in file 0 17:9 -> 17:10, #1 Counter in file 0 17:9 -> 17:10, #1 diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.generics.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.generics.txt index e2cbf6f709e6e..b41f482173b3d 100644 --- a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.generics.txt +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.generics.txt @@ -32,12 +32,12 @@ Combined regions: 10:5 -> 12:6 (count=1) Segment at 10:5 (count = 1), RegionEntry Segment at 12:6 (count = 0), Skipped -Emitting segments for function: _RNvXs_Cs4fqI2P2rA04_8genericsINtB4_8FireworklENtNtNtCs3rFBWs28XFJ_4core3ops4drop4Drop4dropB4_ +Emitting segments for function: _RNvXs_Cs4fqI2P2rA04_8genericsINtB4_8FireworklENtNtNtCs6HRHKMTmAen_4core3ops4drop4Drop4dropB4_ Combined regions: 17:5 -> 19:6 (count=1) Segment at 17:5 (count = 1), RegionEntry Segment at 19:6 (count = 0), Skipped -Emitting segments for function: _RNvXs_Cs4fqI2P2rA04_8genericsINtB4_8FireworkdENtNtNtCs3rFBWs28XFJ_4core3ops4drop4Drop4dropB4_ +Emitting segments for function: _RNvXs_Cs4fqI2P2rA04_8genericsINtB4_8FireworkdENtNtNtCs6HRHKMTmAen_4core3ops4drop4Drop4dropB4_ Combined regions: 17:5 -> 19:6 (count=1) Segment at 17:5 (count = 1), RegionEntry diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.uses_crate.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.uses_crate.txt index b0319cd9e1896..42cc4904e5f66 100644 --- a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.uses_crate.txt +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage_counters.uses_crate.txt @@ -1,6 +1,6 @@ -Counter in file 0 17:1 -> 19:2, #1 Counter in file 0 25:1 -> 27:2, #1 Counter in file 0 17:1 -> 19:2, #1 +Counter in file 0 17:1 -> 19:2, #1 Counter in file 0 5:1 -> 12:2, #1 Counter in file 0 17:1 -> 19:2, 0 Counter in file 0 33:1 -> 35:2, 0 @@ -78,17 +78,17 @@ Segment at 51:1 (count = 0), RegionEntry Segment at 51:2 (count = 0), Skipped Segment at 53:1 (count = 1), RegionEntry Segment at 61:2 (count = 0), Skipped -Emitting segments for function: _RINvCsbDqzXfLQacH_10used_crate41used_only_from_bin_crate_generic_functionReECs4fqI2P2rA04_10uses_crate +Emitting segments for function: _RINvCsbDqzXfLQacH_10used_crate41used_only_from_bin_crate_generic_functionRINtNtCsFAjihUSTht_5alloc3vec3VeclEECs4fqI2P2rA04_10uses_crate Combined regions: 17:1 -> 19:2 (count=1) Segment at 17:1 (count = 1), RegionEntry Segment at 19:2 (count = 0), Skipped -Emitting segments for function: _RINvCsbDqzXfLQacH_10used_crate41used_only_from_bin_crate_generic_functionRINtNtCs3QflaznQylx_5alloc3vec3VeclEECs4fqI2P2rA04_10uses_crate +Emitting segments for function: _RINvCsbDqzXfLQacH_10used_crate41used_only_from_bin_crate_generic_functionReECs4fqI2P2rA04_10uses_crate Combined regions: 17:1 -> 19:2 (count=1) Segment at 17:1 (count = 1), RegionEntry Segment at 19:2 (count = 0), Skipped -Emitting segments for function: _RINvCsbDqzXfLQacH_10used_crate46used_only_from_this_lib_crate_generic_functionINtNtCs3QflaznQylx_5alloc3vec3VeclEEB2_ +Emitting segments for function: _RINvCsbDqzXfLQacH_10used_crate46used_only_from_this_lib_crate_generic_functionINtNtCsFAjihUSTht_5alloc3vec3VeclEEB2_ Combined regions: 21:1 -> 23:2 (count=1) Segment at 21:1 (count = 1), RegionEntry @@ -98,7 +98,7 @@ Combined regions: 21:1 -> 23:2 (count=1) Segment at 21:1 (count = 1), RegionEntry Segment at 23:2 (count = 0), Skipped -Emitting segments for function: _RINvCsbDqzXfLQacH_10used_crate50used_from_bin_crate_and_lib_crate_generic_functionINtNtCs3QflaznQylx_5alloc3vec3VeclEECs4fqI2P2rA04_10uses_crate +Emitting segments for function: _RINvCsbDqzXfLQacH_10used_crate50used_from_bin_crate_and_lib_crate_generic_functionINtNtCsFAjihUSTht_5alloc3vec3VeclEECs4fqI2P2rA04_10uses_crate Combined regions: 25:1 -> 27:2 (count=1) Segment at 25:1 (count = 1), RegionEntry diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on.-------.InstrumentCoverage.0.html index 81310c8cb25aa..19707255d07c7 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on.-------.InstrumentCoverage.0.html @@ -70,166 +70,166 @@
@0,1,2,3,4,5⦊pub fn block_on<F: Future>(mut future: F) -> F::Output { let mut future = unsafe { Pin::new_unchecked(&mut future) }; static VTABLE: RawWakerVTable = RawWakerVTable::new( |_| unimplemented!("clone"), |_| unimplemented!("wake"), |_| unimplemented!("wake_by_ref"), |_| (), ); let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; let mut context = Context::from_waker(&waker)⦉@0,1,2,3,4,5; loop { if let Poll::Ready(@10,12,14,15,16,17⦊val⦉@10,12,14,15,16,17) = @6,7,8,9⦊future.as_mut().poll(&mut context)⦉@6,7,8,9 { break @10,12,14,15,16,17⦊val⦉@10,12,14,15,16,17; }@11,13⦊⦉@11,13 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.main.-------.InstrumentCoverage.0.html index 313a36ed6c2f2..611799161d398 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.main.-------.InstrumentCoverage.0.html @@ -69,9 +69,9 @@ -
@0,1,2,3,4,5,6,7,8,9,10,11,12,13⦊fn main() { - let _ = g(10); - let _ = h(9); - let mut future = Box::pin(i(8)); - j(7); - l(6); - let _ = m(5); - executor::block_on(future.as_mut()); -@4,5,6,7,8⦊format!("'{}'", val) @@ -117,13 +117,13 @@ 103:9-103:29: @4[23]: _18 = (_16.0: &&str) 103:9-103:29: @4[26]: _20 = &(*_18) 103:9-103:29: @4[28]: _21 = <&str as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r &str, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -103:9-103:29: @4.Call: _19 = ArgumentV1::new::<&str>(move _20, move _21) -> [return: bb5, unwind: bb9] +103:9-103:29: @4.Call: _19 = ArgumentV1::new::<&str>(move _20, move _21) -> [return: bb5, unwind: bb10] 103:9-103:29: @5[2]: _15 = [move _19] 103:9-103:29: @5[5]: _14 = &_15 103:9-103:29: @5[6]: _13 = &(*_14) 103:9-103:29: @5[7]: _12 = move _13 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -103:9-103:29: @5.Call: _7 = Arguments::new_v1(move _8, move _12) -> [return: bb6, unwind: bb9] -103:9-103:29: @6.Call: _6 = format(move _7) -> [return: bb7, unwind: bb9] +103:9-103:29: @5.Call: _7 = Arguments::new_v1(move _8, move _12) -> [return: bb6, unwind: bb10] +103:9-103:29: @6.Call: _6 = format(move _7) -> [return: bb7, unwind: bb10] 103:9-103:29: @7[1]: FakeRead(ForLet, _6) 103:9-103:29: @7[6]: _0 = move _6 104:6-104:6: @8.Return: return"> }⦉@4,5,6,7,8
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main.-------.InstrumentCoverage.0.html index 702c7937064b7..3bd446b0e049d 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main.-------.InstrumentCoverage.0.html @@ -69,7079 +69,7079 @@ -
@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊fn main() { -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure - // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. - // dependent conditions. + let is_true = std::env::args().len() == 1; - let is_true = std::env::args().len() == 1; + let is_false = ! is_true; - let is_false = ! is_true; + - + let mut some_string = Some(String::from("the string content")); - let mut some_string = Some(String::from("the string content")); + println!( - println!( + "The string or alt: {}" - "The string or alt: {}" + , - , + some_string - some_string + . - . + unwrap_or_else - unwrap_or_else + ( - ( + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|| +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|| { let mut countdown = 0; if is_false { countdown = 10; } "alt string 1".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊ -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊ + ) - ) + ); - ); + - + some_string = Some(String::from("the string content")); - some_string = Some(String::from("the string content")); + let - let + a - a + = - = + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|| +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|| { let mut countdown = 0; if is_false { countdown = 10; } "alt string 2".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + println!( - println!( + "The string or alt: {}" - "The string or alt: {}" + , - , + some_string - some_string + . - . + unwrap_or_else - unwrap_or_else + ( - ( + a - a + ) - ) + ); - ); + - + some_string = None; - some_string = None; + println!( - println!( + "The string or alt: {}" - "The string or alt: {}" + , - , + some_string - some_string + . - . + unwrap_or_else - unwrap_or_else + ( - ( + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|| +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|| { let mut countdown = 0; if is_false { countdown = 10; } "alt string 3".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊ -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊ + ) - ) + ); - ); + - + some_string = None; - some_string = None; + let - let + a - a + = - = + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|| +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|| { let mut countdown = 0; if is_false { countdown = 10; } "alt string 4".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + println!( - println!( + "The string or alt: {}" - "The string or alt: {}" + , - , + some_string - some_string + . - . + unwrap_or_else - unwrap_or_else + ( - ( + a - a + ) - ) + ); - ); + - + let - let + quote_closure - quote_closure + = - = + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|val| +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|val| { let mut countdown = 0; if is_false { countdown = 10; } format!("'{}'", val) - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + println!( - println!( + "Repeated, quoted string: {:?}" - "Repeated, quoted string: {:?}" + , - , + std::iter::repeat("repeat me") - std::iter::repeat("repeat me") + .take(5) - .take(5) + .map - .map + ( - ( + quote_closure - quote_closure + ) - ) + .collect::<Vec<_>>() - .collect::<Vec<_>>() + ); - ); + - + let - let + _unused_closure - _unused_closure + = - = + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| mut countdown | { @@ -7149,3773 +7149,3773 @@ countdown = 10; } "closure should be unused".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + let mut countdown = 10; - let mut countdown = 10; + let _short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| _unused_arg: u8 | countdown += 1 let _short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 | countdown += 1@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + // Macros can sometimes confuse the coverage results. Compare this next assignment, with an - // Macros can sometimes confuse the coverage results. Compare this next assignment, with an + // unused closure that invokes the `println!()` macro, with the closure assignment above, that - // unused closure that invokes the `println!()` macro, with the closure assignment above, that + // does not use a macro. The closure above correctly shows `0` executions. - // does not use a macro. The closure above correctly shows `0` executions. + let _short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| _unused_arg: u8 | println!("not called") let _short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 | println!("not called")@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + // The closure assignment above is executed, with a line count of `1`, but the `println!()` - // The closure assignment above is executed, with a line count of `1`, but the `println!()` + // could not have been called, and yet, there is no indication that it wasn't... - // could not have been called, and yet, there is no indication that it wasn't... + - + // ...but adding block braces gives the expected result, showing the block was not executed. - // ...but adding block braces gives the expected result, showing the block was not executed. + let _short_unused_closure_block = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| _unused_arg: u8 | { println!("not called") } let _short_unused_closure_block = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 | { println!("not called") }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + let _shortish_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| _unused_arg: u8 | { +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +130:25-130:27: @36[15]: _125 = const 10_i32 +130:9-130:22: @36[16]: FakeRead(ForLet, _125) +131:33-131:67: @36[19]: _127 = &mut _125 +131:9-131:30: @36[22]: FakeRead(ForLet, _126) +136:9-136:30: @36[25]: FakeRead(ForLet, _128) +141:9-141:36: @36[28]: FakeRead(ForLet, _129) +143:9-143:33: @36[31]: FakeRead(ForLet, _130) +3:11-155:2: @36[38]: _0 = const ()"> let _shortish_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 | { println!("not called") - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + let _as_short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +130:25-130:27: @36[15]: _125 = const 10_i32 +130:9-130:22: @36[16]: FakeRead(ForLet, _125) +131:33-131:67: @36[19]: _127 = &mut _125 +131:9-131:30: @36[22]: FakeRead(ForLet, _126) +136:9-136:30: @36[25]: FakeRead(ForLet, _128) +141:9-141:36: @36[28]: FakeRead(ForLet, _129) +143:9-143:33: @36[31]: FakeRead(ForLet, _130) +147:9-147:33: @36[34]: FakeRead(ForLet, _131) +3:11-155:2: @36[38]: _0 = const ()"> let _as_short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 - | { println!("not called") } | { println!("not called") }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + let _almost_as_short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +130:25-130:27: @36[15]: _125 = const 10_i32 +130:9-130:22: @36[16]: FakeRead(ForLet, _125) +131:33-131:67: @36[19]: _127 = &mut _125 +131:9-131:30: @36[22]: FakeRead(ForLet, _126) +136:9-136:30: @36[25]: FakeRead(ForLet, _128) +141:9-141:36: @36[28]: FakeRead(ForLet, _129) +143:9-143:33: @36[31]: FakeRead(ForLet, _130) +147:9-147:33: @36[34]: FakeRead(ForLet, _131) +151:9-151:40: @36[37]: FakeRead(ForLet, _132) +3:11-155:2: @36[38]: _0 = const ()"> let _almost_as_short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 - | { println!("not called") } | { println!("not called") }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊ -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊ + ; - ; +}⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42
+10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +130:25-130:27: @36[15]: _125 = const 10_i32 +130:9-130:22: @36[16]: FakeRead(ForLet, _125) +131:33-131:67: @36[19]: _127 = &mut _125 +131:9-131:30: @36[22]: FakeRead(ForLet, _126) +136:9-136:30: @36[25]: FakeRead(ForLet, _128) +141:9-141:36: @36[28]: FakeRead(ForLet, _129) +143:9-143:33: @36[31]: FakeRead(ForLet, _130) +147:9-147:33: @36[34]: FakeRead(ForLet, _131) +151:9-151:40: @36[37]: FakeRead(ForLet, _132) +3:11-155:2: @36[38]: _0 = const () +155:2-155:2: @37.Return: return">}⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.use_this_lib_crate.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.use_this_lib_crate.-------.InstrumentCoverage.0.html index bed5e7bb7ce88..7c44c536379d2 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.use_this_lib_crate.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.use_this_lib_crate.-------.InstrumentCoverage.0.html @@ -69,122 +69,122 @@ -
@0,1,2,3,4,5,6,7,8⦊fn use_this_lib_crate() { -@0,1,2,3,4,5,6,7⦊fn use_this_lib_crate() { + used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); - used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); + used_with_same_type_from_bin_crate_and_lib_crate_generic_function( - used_with_same_type_from_bin_crate_and_lib_crate_generic_function( + "used from library used_crate.rs", - "used from library used_crate.rs", + ); - ); + let some_vec = vec![5, 6, 7, 8]; - let some_vec = vec![5, 6, 7, 8]; + used_only_from_this_lib_crate_generic_function(some_vec); - used_only_from_this_lib_crate_generic_function(some_vec); + used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); - used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); +}⦉@0,1,2,3,4,5,6,7,8
+58:20-58:36: @3.Call: _3 = slice::<impl [i32]>::into_vec::<std::alloc::Global>(move _4) -> [return: bb4, unwind: bb10] +58:9-58:17: @4[1]: FakeRead(ForLet, _3) +59:52-59:60: @4[4]: _8 = move _3 +59:5-59:61: @4.Call: _7 = used_only_from_this_lib_crate_generic_function::<Vec<i32>>(move _8) -> [return: bb5, unwind: bb8] +60:5-60:91: @5.Call: _9 = used_only_from_this_lib_crate_generic_function::<&str>(const "used ONLY from library used_crate.rs") -> [return: bb6, unwind: bb8] +53:25-61:2: @6[1]: _0 = const () +61:2-61:2: @7.Return: return">}⦉@0,1,2,3,4,5,6,7 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.uses_crate/uses_crate.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.uses_crate/uses_crate.main.-------.InstrumentCoverage.0.html index acb2c7d63f51b..ba6af60fa5cc9 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.uses_crate/uses_crate.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.uses_crate/uses_crate.main.-------.InstrumentCoverage.0.html @@ -69,125 +69,125 @@ -
@0,1,2,3,4,5,6,7,8,9⦊fn main() { -@0,1,2,3,4,5,6,7,8⦊fn main() { + used_crate::used_function(); - used_crate::used_function(); + let some_vec = vec![1, 2, 3, 4]; - let some_vec = vec![1, 2, 3, 4]; + used_crate::used_only_from_bin_crate_generic_function(&some_vec); - used_crate::used_only_from_bin_crate_generic_function(&some_vec); + used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); - used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); + used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); - used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); + used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?"); - used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?"); +}⦉@0,1,2,3,4,5,6,7,8,9
+7:20-7:36: @2.Call: _2 = slice::<impl [i32]>::into_vec::<std::alloc::Global>(move _3) -> [return: bb3, unwind: bb11] +7:9-7:17: @3[1]: FakeRead(ForLet, _2) +8:59-8:68: @3[4]: _7 = &_2 +8:5-8:69: @3.Call: _6 = used_only_from_bin_crate_generic_function::<&Vec<i32>>(move _7) -> [return: bb4, unwind: bb9] +9:5-9:89: @4.Call: _8 = used_only_from_bin_crate_generic_function::<&str>(const "used from bin uses_crate.rs") -> [return: bb5, unwind: bb9] +10:68-10:76: @5[3]: _10 = move _2 +10:5-10:77: @5.Call: _9 = used_from_bin_crate_and_lib_crate_generic_function::<Vec<i32>>(move _10) -> [return: bb6, unwind: bb9] +11:5-11:98: @6.Call: _11 = used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>(const "interesting?") -> [return: bb7, unwind: bb9] +5:11-12:2: @7[1]: _0 = const () +12:2-12:2: @8.Return: return">}⦉@0,1,2,3,4,5,6,7,8 diff --git a/src/test/ui/drop/dynamic-drop-async.rs b/src/test/ui/drop/dynamic-drop-async.rs index c4f7c3786168b..a952fe8e76e81 100644 --- a/src/test/ui/drop/dynamic-drop-async.rs +++ b/src/test/ui/drop/dynamic-drop-async.rs @@ -43,6 +43,7 @@ impl Future for Defer { /// The `failing_op`-th operation will panic. struct Allocator { data: RefCell>, + name: &'static str, failing_op: usize, cur_ops: Cell, } @@ -54,23 +55,28 @@ impl Drop for Allocator { fn drop(&mut self) { let data = self.data.borrow(); if data.iter().any(|d| *d) { - panic!("missing free: {:?}", data); + panic!("missing free in {:?}: {:?}", self.name, data); } } } impl Allocator { - fn new(failing_op: usize) -> Self { - Allocator { failing_op, cur_ops: Cell::new(0), data: RefCell::new(vec![]) } + fn new(failing_op: usize, name: &'static str) -> Self { + Allocator { + failing_op, + name, + cur_ops: Cell::new(0), + data: RefCell::new(vec![]), + } } - fn alloc(&self) -> impl Future> + '_ { + fn alloc(self: &Rc) -> impl Future + 'static { self.fallible_operation(); let mut data = self.data.borrow_mut(); let addr = data.len(); data.push(true); - Defer { ready: false, value: Some(Ptr(addr, self)) } + Defer { ready: false, value: Some(Ptr(addr, self.clone())) } } fn fallible_operation(&self) { self.cur_ops.set(self.cur_ops.get() + 1); @@ -83,11 +89,11 @@ impl Allocator { // Type that tracks whether it was dropped and can panic when it's created or // destroyed. -struct Ptr<'a>(usize, &'a Allocator); -impl<'a> Drop for Ptr<'a> { +struct Ptr(usize, Rc); +impl Drop for Ptr { fn drop(&mut self) { match self.1.data.borrow_mut()[self.0] { - false => panic!("double free at index {:?}", self.0), + false => panic!("double free in {:?} at index {:?}", self.1.name, self.0), ref mut d => *d = false, } @@ -111,7 +117,7 @@ async fn dynamic_drop(a: Rc, c: bool) { }; } -struct TwoPtrs<'a>(Ptr<'a>, Ptr<'a>); +struct TwoPtrs(Ptr, Ptr); async fn struct_dynamic_drop(a: Rc, c0: bool, c1: bool, c: bool) { for i in 0..2 { let x; @@ -232,21 +238,62 @@ async fn move_ref_pattern(a: Rc) { a.alloc().await; } -fn run_test(cx: &mut Context<'_>, ref f: F) +async fn panic_after_return(a: Rc, c: bool) -> (Ptr,) { + a.alloc().await; + let p = a.alloc().await; + if c { + a.alloc().await; + let q = a.alloc().await; + // We use a return type that isn't used anywhere else to make sure that + // the return place doesn't incorrectly end up in the generator state. + return (a.alloc().await,); + } + (a.alloc().await,) +} + + +async fn panic_after_init_by_loop(a: Rc) { + a.alloc().await; + let p = a.alloc().await; + let q = loop { + a.alloc().await; + let r = a.alloc().await; + break a.alloc().await; + }; +} + +async fn panic_after_init_by_match_with_bindings_and_guard(a: Rc, b: bool) { + a.alloc().await; + let p = a.alloc().await; + let q = match a.alloc().await { + ref _x if b => { + a.alloc().await; + let r = a.alloc().await; + a.alloc().await + } + _x => { + a.alloc().await; + let r = a.alloc().await; + a.alloc().await + }, + }; +} + +fn run_test(cx: &mut Context<'_>, ref f: F, name: &'static str) where F: Fn(Rc) -> G, - G: Future, + G: Future, { for polls in 0.. { // Run without any panics to find which operations happen after the // penultimate `poll`. - let first_alloc = Rc::new(Allocator::new(usize::MAX)); + let first_alloc = Rc::new(Allocator::new(usize::MAX, name)); let mut fut = Box::pin(f(first_alloc.clone())); let mut ops_before_last_poll = 0; let mut completed = false; for _ in 0..polls { ops_before_last_poll = first_alloc.cur_ops.get(); - if let Poll::Ready(()) = fut.as_mut().poll(cx) { + if let Poll::Ready(_) = fut.as_mut().poll(cx) { completed = true; } } @@ -255,7 +302,7 @@ where // Start at `ops_before_last_poll` so that we will always be able to // `poll` the expected number of times. for failing_op in ops_before_last_poll..first_alloc.cur_ops.get() { - let alloc = Rc::new(Allocator::new(failing_op + 1)); + let alloc = Rc::new(Allocator::new(failing_op + 1, name)); let f = &f; let cx = &mut *cx; let result = panic::catch_unwind(panic::AssertUnwindSafe(move || { @@ -285,48 +332,58 @@ fn clone_waker(data: *const ()) -> RawWaker { RawWaker::new(data, &RawWakerVTable::new(clone_waker, drop, drop, drop)) } +macro_rules! run_test { + ($ctxt:expr, $e:expr) => { run_test($ctxt, $e, stringify!($e)); }; +} + fn main() { let waker = unsafe { Waker::from_raw(clone_waker(ptr::null())) }; let context = &mut Context::from_waker(&waker); - run_test(context, |a| dynamic_init(a, false)); - run_test(context, |a| dynamic_init(a, true)); - run_test(context, |a| dynamic_drop(a, false)); - run_test(context, |a| dynamic_drop(a, true)); - - run_test(context, |a| assignment(a, false, false)); - run_test(context, |a| assignment(a, false, true)); - run_test(context, |a| assignment(a, true, false)); - run_test(context, |a| assignment(a, true, true)); - - run_test(context, |a| array_simple(a)); - run_test(context, |a| vec_simple(a)); - run_test(context, |a| vec_unreachable(a)); - - run_test(context, |a| struct_dynamic_drop(a, false, false, false)); - run_test(context, |a| struct_dynamic_drop(a, false, false, true)); - run_test(context, |a| struct_dynamic_drop(a, false, true, false)); - run_test(context, |a| struct_dynamic_drop(a, false, true, true)); - run_test(context, |a| struct_dynamic_drop(a, true, false, false)); - run_test(context, |a| struct_dynamic_drop(a, true, false, true)); - run_test(context, |a| struct_dynamic_drop(a, true, true, false)); - run_test(context, |a| struct_dynamic_drop(a, true, true, true)); - - run_test(context, |a| field_assignment(a, false)); - run_test(context, |a| field_assignment(a, true)); - - run_test(context, |a| mixed_drop_and_nondrop(a)); - - run_test(context, |a| slice_pattern_one_of(a, 0)); - run_test(context, |a| slice_pattern_one_of(a, 1)); - run_test(context, |a| slice_pattern_one_of(a, 2)); - run_test(context, |a| slice_pattern_one_of(a, 3)); - - run_test(context, |a| subslice_pattern_from_end_with_drop(a, true, true)); - run_test(context, |a| subslice_pattern_from_end_with_drop(a, true, false)); - run_test(context, |a| subslice_pattern_from_end_with_drop(a, false, true)); - run_test(context, |a| subslice_pattern_from_end_with_drop(a, false, false)); - run_test(context, |a| subslice_pattern_reassign(a)); - - run_test(context, |a| move_ref_pattern(a)); + run_test!(context, |a| dynamic_init(a, false)); + run_test!(context, |a| dynamic_init(a, true)); + run_test!(context, |a| dynamic_drop(a, false)); + run_test!(context, |a| dynamic_drop(a, true)); + + run_test!(context, |a| assignment(a, false, false)); + run_test!(context, |a| assignment(a, false, true)); + run_test!(context, |a| assignment(a, true, false)); + run_test!(context, |a| assignment(a, true, true)); + + run_test!(context, |a| array_simple(a)); + run_test!(context, |a| vec_simple(a)); + run_test!(context, |a| vec_unreachable(a)); + + run_test!(context, |a| struct_dynamic_drop(a, false, false, false)); + run_test!(context, |a| struct_dynamic_drop(a, false, false, true)); + run_test!(context, |a| struct_dynamic_drop(a, false, true, false)); + run_test!(context, |a| struct_dynamic_drop(a, false, true, true)); + run_test!(context, |a| struct_dynamic_drop(a, true, false, false)); + run_test!(context, |a| struct_dynamic_drop(a, true, false, true)); + run_test!(context, |a| struct_dynamic_drop(a, true, true, false)); + run_test!(context, |a| struct_dynamic_drop(a, true, true, true)); + + run_test!(context, |a| field_assignment(a, false)); + run_test!(context, |a| field_assignment(a, true)); + + run_test!(context, |a| mixed_drop_and_nondrop(a)); + + run_test!(context, |a| slice_pattern_one_of(a, 0)); + run_test!(context, |a| slice_pattern_one_of(a, 1)); + run_test!(context, |a| slice_pattern_one_of(a, 2)); + run_test!(context, |a| slice_pattern_one_of(a, 3)); + + run_test!(context, |a| subslice_pattern_from_end_with_drop(a, true, true)); + run_test!(context, |a| subslice_pattern_from_end_with_drop(a, true, false)); + run_test!(context, |a| subslice_pattern_from_end_with_drop(a, false, true)); + run_test!(context, |a| subslice_pattern_from_end_with_drop(a, false, false)); + run_test!(context, |a| subslice_pattern_reassign(a)); + + run_test!(context, |a| move_ref_pattern(a)); + + run_test!(context, |a| panic_after_return(a, false)); + run_test!(context, |a| panic_after_return(a, true)); + run_test!(context, |a| panic_after_init_by_loop(a)); + run_test!(context, |a| panic_after_init_by_match_with_bindings_and_guard(a, false)); + run_test!(context, |a| panic_after_init_by_match_with_bindings_and_guard(a, true)); } diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs index 88f557055f371..ddccee20e12a6 100644 --- a/src/test/ui/drop/dynamic-drop.rs +++ b/src/test/ui/drop/dynamic-drop.rs @@ -3,7 +3,6 @@ #![feature(generators, generator_trait)] #![feature(bindings_after_at)] - #![allow(unused_assignments)] #![allow(unused_variables)] @@ -17,6 +16,7 @@ struct InjectedFailure; struct Allocator { data: RefCell>, + name: &'static str, failing_op: usize, cur_ops: Cell, } @@ -28,17 +28,18 @@ impl Drop for Allocator { fn drop(&mut self) { let data = self.data.borrow(); if data.iter().any(|d| *d) { - panic!("missing free: {:?}", data); + panic!("missing free in {:?}: {:?}", self.name, data); } } } impl Allocator { - fn new(failing_op: usize) -> Self { + fn new(failing_op: usize, name: &'static str) -> Self { Allocator { failing_op: failing_op, cur_ops: Cell::new(0), - data: RefCell::new(vec![]) + data: RefCell::new(vec![]), + name, } } fn alloc(&self) -> Ptr<'_> { @@ -53,33 +54,17 @@ impl Allocator { data.push(true); Ptr(addr, self) } - // FIXME(#47949) Any use of this indicates a bug in rustc: we should never - // be leaking values in the cases here. - // - // Creates a `Ptr<'_>` and checks that the allocated value is leaked if the - // `failing_op` is in the list of exception. - fn alloc_leaked(&self, exceptions: Vec) -> Ptr<'_> { - let ptr = self.alloc(); - - if exceptions.iter().any(|operation| *operation == self.failing_op) { - let mut data = self.data.borrow_mut(); - data[ptr.0] = false; - } - ptr - } } struct Ptr<'a>(usize, &'a Allocator); impl<'a> Drop for Ptr<'a> { fn drop(&mut self) { match self.1.data.borrow_mut()[self.0] { - false => { - panic!("double free at index {:?}", self.0) - } - ref mut d => *d = false + false => panic!("double free in {:?} at index {:?}", self.1.name, self.0), + ref mut d => *d = false, } - self.1.cur_ops.set(self.1.cur_ops.get()+1); + self.1.cur_ops.set(self.1.cur_ops.get() + 1); if self.1.cur_ops.get() == self.1.failing_op { panic!(InjectedFailure); @@ -177,11 +162,7 @@ fn generator(a: &Allocator, run_count: usize) { assert!(run_count < 4); let mut gen = || { - (a.alloc(), - yield a.alloc(), - a.alloc(), - yield a.alloc() - ); + (a.alloc(), yield a.alloc(), a.alloc(), yield a.alloc()); }; for _ in 0..run_count { Pin::new(&mut gen).resume(()); @@ -205,28 +186,40 @@ fn vec_unreachable(a: &Allocator) { } fn slice_pattern_first(a: &Allocator) { - let[_x, ..] = [a.alloc(), a.alloc(), a.alloc()]; + let [_x, ..] = [a.alloc(), a.alloc(), a.alloc()]; } fn slice_pattern_middle(a: &Allocator) { - let[_, _x, _] = [a.alloc(), a.alloc(), a.alloc()]; + let [_, _x, _] = [a.alloc(), a.alloc(), a.alloc()]; } fn slice_pattern_two(a: &Allocator) { - let[_x, _, _y, _] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; + let [_x, _, _y, _] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; } fn slice_pattern_last(a: &Allocator) { - let[.., _y] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; + let [.., _y] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; } fn slice_pattern_one_of(a: &Allocator, i: usize) { let array = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; let _x = match i { - 0 => { let [a, ..] = array; a } - 1 => { let [_, a, ..] = array; a } - 2 => { let [_, _, a, _] = array; a } - 3 => { let [_, _, _, a] = array; a } + 0 => { + let [a, ..] = array; + a + } + 1 => { + let [_, a, ..] = array; + a + } + 2 => { + let [_, _, a, _] = array; + a + } + 3 => { + let [_, _, _, a] = array; + a + } _ => panic!("unmatched"), }; } @@ -234,9 +227,9 @@ fn slice_pattern_one_of(a: &Allocator, i: usize) { fn subslice_pattern_from_end(a: &Allocator, arg: bool) { let a = [a.alloc(), a.alloc(), a.alloc()]; if arg { - let[.., _x, _] = a; + let [.., _x, _] = a; } else { - let[_, _y @ ..] = a; + let [_, _y @ ..] = a; } } @@ -248,45 +241,61 @@ fn subslice_pattern_from_end_with_drop(a: &Allocator, arg: bool, arg2: bool) { } if arg { - let[.., _x, _] = a; + let [.., _x, _] = a; } else { - let[_, _y @ ..] = a; + let [_, _y @ ..] = a; } } fn slice_pattern_reassign(a: &Allocator) { let mut ar = [a.alloc(), a.alloc()]; - let[_, _x] = ar; + let [_, _x] = ar; ar = [a.alloc(), a.alloc()]; - let[.., _y] = ar; + let [.., _y] = ar; } fn subslice_pattern_reassign(a: &Allocator) { let mut ar = [a.alloc(), a.alloc(), a.alloc()]; - let[_, _, _x] = ar; + let [_, _, _x] = ar; ar = [a.alloc(), a.alloc(), a.alloc()]; - let[_, _y @ ..] = ar; + let [_, _y @ ..] = ar; } fn index_field_mixed_ends(a: &Allocator) { let ar = [(a.alloc(), a.alloc()), (a.alloc(), a.alloc())]; - let[(_x, _), ..] = ar; - let[(_, _y), _] = ar; - let[_, (_, _w)] = ar; - let[.., (_z, _)] = ar; + let [(_x, _), ..] = ar; + let [(_, _y), _] = ar; + let [_, (_, _w)] = ar; + let [.., (_z, _)] = ar; } fn subslice_mixed_min_lengths(a: &Allocator, c: i32) { let ar = [(a.alloc(), a.alloc()), (a.alloc(), a.alloc())]; match c { - 0 => { let[_x, ..] = ar; } - 1 => { let[_x, _, ..] = ar; } - 2 => { let[_x, _] = ar; } - 3 => { let[(_x, _), _, ..] = ar; } - 4 => { let[.., (_x, _)] = ar; } - 5 => { let[.., (_x, _), _] = ar; } - 6 => { let [_y @ ..] = ar; } - _ => { let [_y @ .., _] = ar; } + 0 => { + let [_x, ..] = ar; + } + 1 => { + let [_x, _, ..] = ar; + } + 2 => { + let [_x, _] = ar; + } + 3 => { + let [(_x, _), _, ..] = ar; + } + 4 => { + let [.., (_x, _)] = ar; + } + 5 => { + let [.., (_x, _), _] = ar; + } + 6 => { + let [_y @ ..] = ar; + } + _ => { + let [_y @ .., _] = ar; + } } } @@ -334,87 +343,160 @@ fn move_ref_pattern(a: &Allocator) { } fn panic_after_return(a: &Allocator) -> Ptr<'_> { - // Panic in the drop of `p` or `q` can leak - let exceptions = vec![8, 9]; a.alloc(); let p = a.alloc(); { a.alloc(); let p = a.alloc(); - // FIXME (#47949) We leak values when we panic in a destructor after - // evaluating an expression with `rustc_mir::build::Builder::into`. - a.alloc_leaked(exceptions) + a.alloc() } } fn panic_after_return_expr(a: &Allocator) -> Ptr<'_> { - // Panic in the drop of `p` or `q` can leak - let exceptions = vec![8, 9]; a.alloc(); let p = a.alloc(); { a.alloc(); let q = a.alloc(); - // FIXME (#47949) - return a.alloc_leaked(exceptions); + return a.alloc(); } } fn panic_after_init(a: &Allocator) { - // Panic in the drop of `r` can leak - let exceptions = vec![8]; a.alloc(); let p = a.alloc(); let q = { a.alloc(); let r = a.alloc(); - // FIXME (#47949) - a.alloc_leaked(exceptions) + a.alloc() }; } fn panic_after_init_temp(a: &Allocator) { - // Panic in the drop of `r` can leak - let exceptions = vec![8]; a.alloc(); let p = a.alloc(); { a.alloc(); let r = a.alloc(); - // FIXME (#47949) - a.alloc_leaked(exceptions) + a.alloc() }; } fn panic_after_init_by_loop(a: &Allocator) { - // Panic in the drop of `r` can leak - let exceptions = vec![8]; a.alloc(); let p = a.alloc(); let q = loop { a.alloc(); let r = a.alloc(); - // FIXME (#47949) - break a.alloc_leaked(exceptions); + break a.alloc(); + }; +} + +fn panic_after_init_by_match(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let _ = loop { + let q = match b { + true => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + false => { + a.alloc(); + let r = a.alloc(); + break a.alloc(); + } + }; + return; + }; +} + +fn panic_after_init_by_match_with_guard(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let q = match a.alloc() { + _ if b => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + _ => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + }; +} + +fn panic_after_init_by_match_with_bindings_and_guard(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let q = match a.alloc() { + _x if b => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + _x => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + }; +} + +fn panic_after_init_by_match_with_ref_bindings_and_guard(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let q = match a.alloc() { + ref _x if b => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + ref _x => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + }; +} + +fn panic_after_init_by_break_if(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let q = loop { + let r = a.alloc(); + break if b { + let s = a.alloc(); + a.alloc() + } else { + a.alloc() + }; }; } -fn run_test(mut f: F) - where F: FnMut(&Allocator) +fn run_test(mut f: F, name: &'static str) +where + F: FnMut(&Allocator), { - let first_alloc = Allocator::new(usize::MAX); + let first_alloc = Allocator::new(usize::MAX, name); f(&first_alloc); - for failing_op in 1..first_alloc.cur_ops.get()+1 { - let alloc = Allocator::new(failing_op); + for failing_op in 1..first_alloc.cur_ops.get() + 1 { + let alloc = Allocator::new(failing_op, name); let alloc = &alloc; let f = panic::AssertUnwindSafe(&mut f); let result = panic::catch_unwind(move || { f.0(alloc); }); match result { - Ok(..) => panic!("test executed {} ops but now {}", - first_alloc.cur_ops.get(), alloc.cur_ops.get()), + Ok(..) => panic!( + "test executed {} ops but now {}", + first_alloc.cur_ops.get(), + alloc.cur_ops.get() + ), Err(e) => { if e.downcast_ref::().is_none() { panic::resume_unwind(e); @@ -424,98 +506,115 @@ fn run_test(mut f: F) } } -fn run_test_nopanic(mut f: F) - where F: FnMut(&Allocator) +fn run_test_nopanic(mut f: F, name: &'static str) +where + F: FnMut(&Allocator), { - let first_alloc = Allocator::new(usize::MAX); + let first_alloc = Allocator::new(usize::MAX, name); f(&first_alloc); } +macro_rules! run_test { + ($e:expr) => { + run_test($e, stringify!($e)); + }; +} + fn main() { - run_test(|a| dynamic_init(a, false)); - run_test(|a| dynamic_init(a, true)); - run_test(|a| dynamic_drop(a, false)); - run_test(|a| dynamic_drop(a, true)); - - run_test(|a| assignment2(a, false, false)); - run_test(|a| assignment2(a, false, true)); - run_test(|a| assignment2(a, true, false)); - run_test(|a| assignment2(a, true, true)); - - run_test(|a| assignment1(a, false)); - run_test(|a| assignment1(a, true)); - - run_test(|a| array_simple(a)); - run_test(|a| vec_simple(a)); - run_test(|a| vec_unreachable(a)); - - run_test(|a| struct_dynamic_drop(a, false, false, false)); - run_test(|a| struct_dynamic_drop(a, false, false, true)); - run_test(|a| struct_dynamic_drop(a, false, true, false)); - run_test(|a| struct_dynamic_drop(a, false, true, true)); - run_test(|a| struct_dynamic_drop(a, true, false, false)); - run_test(|a| struct_dynamic_drop(a, true, false, true)); - run_test(|a| struct_dynamic_drop(a, true, true, false)); - run_test(|a| struct_dynamic_drop(a, true, true, true)); - - run_test(|a| field_assignment(a, false)); - run_test(|a| field_assignment(a, true)); - - run_test(|a| generator(a, 0)); - run_test(|a| generator(a, 1)); - run_test(|a| generator(a, 2)); - run_test(|a| generator(a, 3)); - - run_test(|a| mixed_drop_and_nondrop(a)); - - run_test(|a| slice_pattern_first(a)); - run_test(|a| slice_pattern_middle(a)); - run_test(|a| slice_pattern_two(a)); - run_test(|a| slice_pattern_last(a)); - run_test(|a| slice_pattern_one_of(a, 0)); - run_test(|a| slice_pattern_one_of(a, 1)); - run_test(|a| slice_pattern_one_of(a, 2)); - run_test(|a| slice_pattern_one_of(a, 3)); - - run_test(|a| subslice_pattern_from_end(a, true)); - run_test(|a| subslice_pattern_from_end(a, false)); - run_test(|a| subslice_pattern_from_end_with_drop(a, true, true)); - run_test(|a| subslice_pattern_from_end_with_drop(a, true, false)); - run_test(|a| subslice_pattern_from_end_with_drop(a, false, true)); - run_test(|a| subslice_pattern_from_end_with_drop(a, false, false)); - run_test(|a| slice_pattern_reassign(a)); - run_test(|a| subslice_pattern_reassign(a)); - - run_test(|a| index_field_mixed_ends(a)); - run_test(|a| subslice_mixed_min_lengths(a, 0)); - run_test(|a| subslice_mixed_min_lengths(a, 1)); - run_test(|a| subslice_mixed_min_lengths(a, 2)); - run_test(|a| subslice_mixed_min_lengths(a, 3)); - run_test(|a| subslice_mixed_min_lengths(a, 4)); - run_test(|a| subslice_mixed_min_lengths(a, 5)); - run_test(|a| subslice_mixed_min_lengths(a, 6)); - run_test(|a| subslice_mixed_min_lengths(a, 7)); - - run_test(|a| move_ref_pattern(a)); - - run_test(|a| { + run_test!(|a| dynamic_init(a, false)); + run_test!(|a| dynamic_init(a, true)); + run_test!(|a| dynamic_drop(a, false)); + run_test!(|a| dynamic_drop(a, true)); + + run_test!(|a| assignment2(a, false, false)); + run_test!(|a| assignment2(a, false, true)); + run_test!(|a| assignment2(a, true, false)); + run_test!(|a| assignment2(a, true, true)); + + run_test!(|a| assignment1(a, false)); + run_test!(|a| assignment1(a, true)); + + run_test!(|a| array_simple(a)); + run_test!(|a| vec_simple(a)); + run_test!(|a| vec_unreachable(a)); + + run_test!(|a| struct_dynamic_drop(a, false, false, false)); + run_test!(|a| struct_dynamic_drop(a, false, false, true)); + run_test!(|a| struct_dynamic_drop(a, false, true, false)); + run_test!(|a| struct_dynamic_drop(a, false, true, true)); + run_test!(|a| struct_dynamic_drop(a, true, false, false)); + run_test!(|a| struct_dynamic_drop(a, true, false, true)); + run_test!(|a| struct_dynamic_drop(a, true, true, false)); + run_test!(|a| struct_dynamic_drop(a, true, true, true)); + + run_test!(|a| field_assignment(a, false)); + run_test!(|a| field_assignment(a, true)); + + run_test!(|a| generator(a, 0)); + run_test!(|a| generator(a, 1)); + run_test!(|a| generator(a, 2)); + run_test!(|a| generator(a, 3)); + + run_test!(|a| mixed_drop_and_nondrop(a)); + + run_test!(|a| slice_pattern_first(a)); + run_test!(|a| slice_pattern_middle(a)); + run_test!(|a| slice_pattern_two(a)); + run_test!(|a| slice_pattern_last(a)); + run_test!(|a| slice_pattern_one_of(a, 0)); + run_test!(|a| slice_pattern_one_of(a, 1)); + run_test!(|a| slice_pattern_one_of(a, 2)); + run_test!(|a| slice_pattern_one_of(a, 3)); + + run_test!(|a| subslice_pattern_from_end(a, true)); + run_test!(|a| subslice_pattern_from_end(a, false)); + run_test!(|a| subslice_pattern_from_end_with_drop(a, true, true)); + run_test!(|a| subslice_pattern_from_end_with_drop(a, true, false)); + run_test!(|a| subslice_pattern_from_end_with_drop(a, false, true)); + run_test!(|a| subslice_pattern_from_end_with_drop(a, false, false)); + run_test!(|a| slice_pattern_reassign(a)); + run_test!(|a| subslice_pattern_reassign(a)); + + run_test!(|a| index_field_mixed_ends(a)); + run_test!(|a| subslice_mixed_min_lengths(a, 0)); + run_test!(|a| subslice_mixed_min_lengths(a, 1)); + run_test!(|a| subslice_mixed_min_lengths(a, 2)); + run_test!(|a| subslice_mixed_min_lengths(a, 3)); + run_test!(|a| subslice_mixed_min_lengths(a, 4)); + run_test!(|a| subslice_mixed_min_lengths(a, 5)); + run_test!(|a| subslice_mixed_min_lengths(a, 6)); + run_test!(|a| subslice_mixed_min_lengths(a, 7)); + + run_test!(|a| move_ref_pattern(a)); + + run_test!(|a| { panic_after_return(a); }); - run_test(|a| { + run_test!(|a| { panic_after_return_expr(a); }); - run_test(|a| panic_after_init(a)); - run_test(|a| panic_after_init_temp(a)); - run_test(|a| panic_after_init_by_loop(a)); - - run_test(|a| bindings_after_at_dynamic_init_move(a, true)); - run_test(|a| bindings_after_at_dynamic_init_move(a, false)); - run_test(|a| bindings_after_at_dynamic_init_ref(a, true)); - run_test(|a| bindings_after_at_dynamic_init_ref(a, false)); - run_test(|a| bindings_after_at_dynamic_drop_move(a, true)); - run_test(|a| bindings_after_at_dynamic_drop_move(a, false)); - run_test(|a| bindings_after_at_dynamic_drop_ref(a, true)); - run_test(|a| bindings_after_at_dynamic_drop_ref(a, false)); - - run_test_nopanic(|a| union1(a)); + run_test!(|a| panic_after_init(a)); + run_test!(|a| panic_after_init_temp(a)); + run_test!(|a| panic_after_init_by_loop(a)); + run_test!(|a| panic_after_init_by_match(a, false)); + run_test!(|a| panic_after_init_by_match(a, true)); + run_test!(|a| panic_after_init_by_match_with_guard(a, false)); + run_test!(|a| panic_after_init_by_match_with_guard(a, true)); + run_test!(|a| panic_after_init_by_match_with_bindings_and_guard(a, false)); + run_test!(|a| panic_after_init_by_match_with_bindings_and_guard(a, true)); + run_test!(|a| panic_after_init_by_match_with_ref_bindings_and_guard(a, false)); + run_test!(|a| panic_after_init_by_match_with_ref_bindings_and_guard(a, true)); + run_test!(|a| panic_after_init_by_break_if(a, false)); + run_test!(|a| panic_after_init_by_break_if(a, true)); + + run_test!(|a| bindings_after_at_dynamic_init_move(a, true)); + run_test!(|a| bindings_after_at_dynamic_init_move(a, false)); + run_test!(|a| bindings_after_at_dynamic_init_ref(a, true)); + run_test!(|a| bindings_after_at_dynamic_init_ref(a, false)); + run_test!(|a| bindings_after_at_dynamic_drop_move(a, true)); + run_test!(|a| bindings_after_at_dynamic_drop_move(a, false)); + run_test!(|a| bindings_after_at_dynamic_drop_ref(a, true)); + run_test!(|a| bindings_after_at_dynamic_drop_ref(a, false)); + + run_test_nopanic(|a| union1(a), "|a| union1(a)"); }