diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 9b1642df11401..1b9ccbd850bee 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -87,9 +87,12 @@ impl<'hir> LoweringContext<'_, 'hir> { ExprKind::Let(ref pat, ref scrutinee) => { self.lower_expr_let(e.span, pat, scrutinee) } - ExprKind::If(ref cond, ref then, ref else_opt) => { - self.lower_expr_if(e.span, cond, then, else_opt.as_deref()) - } + ExprKind::If(ref cond, ref then, ref else_opt) => match cond.kind { + ExprKind::Let(ref pat, ref scrutinee) => { + self.lower_expr_if_let(e.span, pat, scrutinee, then, else_opt.as_deref()) + } + _ => self.lower_expr_if(cond, then, else_opt.as_deref()), + }, ExprKind::While(ref cond, ref body, opt_label) => self .with_loop_scope(e.id, |this| { this.lower_expr_while_in_loop_scope(e.span, cond, body, opt_label) @@ -337,10 +340,30 @@ impl<'hir> LoweringContext<'_, 'hir> { fn lower_expr_if( &mut self, - span: Span, cond: &Expr, then: &Block, else_opt: Option<&Expr>, + ) -> hir::ExprKind<'hir> { + macro_rules! make_if { + ($opt:expr) => {{ + let then_expr = self.lower_block_expr(then); + hir::ExprKind::If(self.lower_expr(cond), self.arena.alloc(then_expr), $opt) + }}; + } + if let Some(rslt) = else_opt { + make_if!(Some(self.lower_expr(rslt))) + } else { + make_if!(None) + } + } + + fn lower_expr_if_let( + &mut self, + span: Span, + pat: &Pat, + scrutinee: &Expr, + then: &Block, + else_opt: Option<&Expr>, ) -> hir::ExprKind<'hir> { // FIXME(#53667): handle lowering of && and parens. @@ -353,30 +376,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let else_arm = self.arm(else_pat, else_expr); // Handle then + scrutinee: - let (then_pat, scrutinee, desugar) = match cond.kind { - // ` => `: - ExprKind::Let(ref pat, ref scrutinee) => { - let scrutinee = self.lower_expr(scrutinee); - let pat = self.lower_pat(pat); - (pat, scrutinee, hir::MatchSource::IfLetDesugar { contains_else_clause }) - } - // `true => `: - _ => { - // Lower condition: - let cond = self.lower_expr(cond); - let span_block = - self.mark_span_with_reason(DesugaringKind::CondTemporary, cond.span, None); - // Wrap in a construct equivalent to `{ let _t = $cond; _t }` - // to preserve drop semantics since `if cond { ... }` does not - // let temporaries live outside of `cond`. - let cond = self.expr_drop_temps(span_block, cond, ThinVec::new()); - let pat = self.pat_bool(span, true); - (pat, cond, hir::MatchSource::IfDesugar { contains_else_clause }) - } - }; + let scrutinee = self.lower_expr(scrutinee); + let then_pat = self.lower_pat(pat); + let then_expr = self.lower_block_expr(then); let then_arm = self.arm(then_pat, self.arena.alloc(then_expr)); + let desugar = hir::MatchSource::IfLetDesugar { contains_else_clause }; hir::ExprKind::Match(scrutinee, arena_vec![self; then_arm, else_arm], desugar) } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 269916390ed45..af6b0a22d4b29 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1431,6 +1431,7 @@ impl Expr<'_> { ExprKind::Lit(_) => ExprPrecedence::Lit, ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast, ExprKind::DropTemps(ref expr, ..) => expr.precedence(), + ExprKind::If(..) => ExprPrecedence::If, ExprKind::Loop(..) => ExprPrecedence::Loop, ExprKind::Match(..) => ExprPrecedence::Match, ExprKind::Closure(..) => ExprPrecedence::Closure, @@ -1492,6 +1493,7 @@ impl Expr<'_> { | ExprKind::MethodCall(..) | ExprKind::Struct(..) | ExprKind::Tup(..) + | ExprKind::If(..) | ExprKind::Match(..) | ExprKind::Closure(..) | ExprKind::Block(..) @@ -1608,6 +1610,10 @@ pub enum ExprKind<'hir> { /// This construct only exists to tweak the drop order in HIR lowering. /// An example of that is the desugaring of `for` loops. DropTemps(&'hir Expr<'hir>), + /// An `if` block, with an optional else block. + /// + /// I.e., `if { } else { }`. + If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>), /// A conditionless loop (can be exited with `break`, `continue`, or `return`). /// /// I.e., `'label: loop { }`. @@ -1761,8 +1767,6 @@ pub enum LocalSource { pub enum MatchSource { /// A `match _ { .. }`. Normal, - /// An `if _ { .. }` (optionally with `else { .. }`). - IfDesugar { contains_else_clause: bool }, /// An `if let _ = _ { .. }` (optionally with `else { .. }`). IfLetDesugar { contains_else_clause: bool }, /// An `if let _ = _ => { .. }` match guard. @@ -1785,7 +1789,7 @@ impl MatchSource { use MatchSource::*; match self { Normal => "match", - IfDesugar { .. } | IfLetDesugar { .. } | IfLetGuardDesugar => "if", + IfLetDesugar { .. } | IfLetGuardDesugar => "if", WhileDesugar | WhileLetDesugar => "while", ForLoopDesugar => "for", TryDesugar => "?", diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index d01906bc17eb2..8707a84a98fcc 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -1146,6 +1146,11 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) ExprKind::DropTemps(ref subexpression) => { visitor.visit_expr(subexpression); } + ExprKind::If(ref cond, ref then, ref else_opt) => { + visitor.visit_expr(cond); + visitor.visit_expr(then); + walk_list!(visitor, visit_expr, else_opt); + } ExprKind::Loop(ref block, ref opt_label, _) => { walk_list!(visitor, visit_label, opt_label); visitor.visit_block(block); diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 06599e7893285..a3ab1d96e1dfe 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1080,6 +1080,50 @@ impl<'a> State<'a> { self.ann.post(self, AnnNode::Block(blk)) } + fn print_else(&mut self, els: Option<&hir::Expr<'_>>) { + match els { + Some(_else) => { + match _else.kind { + // "another else-if" + hir::ExprKind::If(ref i, ref then, ref e) => { + self.cbox(INDENT_UNIT - 1); + self.ibox(0); + self.s.word(" else if "); + self.print_expr_as_cond(&i); + self.s.space(); + self.print_expr(&then); + self.print_else(e.as_ref().map(|e| &**e)) + } + // "final else" + hir::ExprKind::Block(ref b, _) => { + self.cbox(INDENT_UNIT - 1); + self.ibox(0); + self.s.word(" else "); + self.print_block(&b) + } + // BLEAH, constraints would be great here + _ => { + panic!("print_if saw if with weird alternative"); + } + } + } + _ => {} + } + } + + pub fn print_if( + &mut self, + test: &hir::Expr<'_>, + blk: &hir::Expr<'_>, + elseopt: Option<&hir::Expr<'_>>, + ) { + self.head("if"); + self.print_expr_as_cond(test); + self.s.space(); + self.print_expr(blk); + self.print_else(elseopt) + } + pub fn print_anon_const(&mut self, constant: &hir::AnonConst) { self.ann.nested(self, Nested::Body(constant.body)) } @@ -1349,6 +1393,9 @@ impl<'a> State<'a> { // Print `}`: self.bclose_maybe_open(expr.span, true); } + hir::ExprKind::If(ref test, ref blk, ref elseopt) => { + self.print_if(&test, &blk, elseopt.as_ref().map(|e| &**e)); + } hir::ExprKind::Loop(ref blk, opt_label, _) => { if let Some(label) = opt_label { self.print_ident(label.ident); @@ -2429,7 +2476,13 @@ impl<'a> State<'a> { // // Duplicated from `parse::classify`, but adapted for the HIR. fn expr_requires_semi_to_be_stmt(e: &hir::Expr<'_>) -> bool { - !matches!(e.kind, hir::ExprKind::Match(..) | hir::ExprKind::Block(..) | hir::ExprKind::Loop(..)) + !matches!( + e.kind, + hir::ExprKind::If(..) + | hir::ExprKind::Match(..) + | hir::ExprKind::Block(..) + | hir::ExprKind::Loop(..) + ) } /// This statement requires a semicolon after it. diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 209d1838e3ebc..6641606f1e89e 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -658,12 +658,12 @@ impl<'hir> Map<'hir> { CRATE_HIR_ID } - /// When on a match arm tail expression or on a match arm, give back the enclosing `match` - /// expression. + /// When on an if expression, a match arm tail expression or a match arm, give back + /// the enclosing `if` or `match` expression. /// - /// Used by error reporting when there's a type error in a match arm caused by the `match` + /// Used by error reporting when there's a type error in an if or match arm caused by the /// expression needing to be unit. - pub fn get_match_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>> { + pub fn get_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>> { for (_, node) in self.parent_iter(hir_id) { match node { Node::Item(_) @@ -671,7 +671,9 @@ impl<'hir> Map<'hir> { | Node::TraitItem(_) | Node::ImplItem(_) | Node::Stmt(Stmt { kind: StmtKind::Local(_), .. }) => break, - Node::Expr(expr @ Expr { kind: ExprKind::Match(..), .. }) => return Some(expr), + Node::Expr(expr @ Expr { kind: ExprKind::If(..) | ExprKind::Match(..), .. }) => { + return Some(expr); + } _ => {} } } diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index cf2e4e8916d0a..c11b8f7459389 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -531,6 +531,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | ExprKind::Borrow { .. } | ExprKind::AddressOf { .. } | ExprKind::Match { .. } + | ExprKind::If { .. } | ExprKind::Loop { .. } | ExprKind::Block { .. } | ExprKind::Assign { .. } 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 3f381f3f15e8e..55bdbcfc5b916 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -251,6 +251,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | ExprKind::StaticRef { .. } | ExprKind::Block { .. } | ExprKind::Match { .. } + | ExprKind::If { .. } | ExprKind::NeverToAny { .. } | ExprKind::Use { .. } | ExprKind::Borrow { .. } diff --git a/compiler/rustc_mir_build/src/build/expr/category.rs b/compiler/rustc_mir_build/src/build/expr/category.rs index 8561170856fd4..9320b5810e396 100644 --- a/compiler/rustc_mir_build/src/build/expr/category.rs +++ b/compiler/rustc_mir_build/src/build/expr/category.rs @@ -45,6 +45,7 @@ impl Category { ExprKind::LogicalOp { .. } | ExprKind::Match { .. } + | ExprKind::If { .. } | ExprKind::NeverToAny { .. } | ExprKind::Use { .. } | ExprKind::Adt { .. } diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 09281799041ee..9777a97b57ee0 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -69,6 +69,40 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ExprKind::Match { scrutinee, arms } => { this.match_expr(destination, scope, expr_span, block, scrutinee, arms) } + ExprKind::If { cond, then, else_opt } => { + let place = unpack!(block = this.as_temp(block, Some(this.local_scope()), cond, Mutability::Mut)); + let operand = Operand::Move(Place::from(place)); + + let mut then_block = this.cfg.start_new_block(); + let mut else_block = this.cfg.start_new_block(); + let term = TerminatorKind::if_(this.hir.tcx(), operand, then_block, else_block); + this.cfg.terminate(block, source_info, term); + + unpack!(then_block = this.into(destination, scope, then_block, then)); + else_block = if let Some(else_opt) = else_opt { + unpack!(this.into(destination, None, else_block, else_opt)) + } else { + // Body of the `if` expression without an `else` clause must return `()`, thus + // we implicitly generate a `else {}` if it is not specified. + let correct_si = this.source_info(expr_span.shrink_to_hi()); + this.cfg.push_assign_unit(else_block, correct_si, destination, this.hir.tcx()); + else_block + }; + + let join_block = this.cfg.start_new_block(); + this.cfg.terminate( + then_block, + source_info, + TerminatorKind::Goto { target: join_block }, + ); + this.cfg.terminate( + else_block, + source_info, + TerminatorKind::Goto { target: join_block }, + ); + + join_block.unit() + }, ExprKind::NeverToAny { source } => { let source = this.hir.mirror(source); let is_call = matches!(source.kind, ExprKind::Call { .. } | ExprKind::InlineAsm { .. }); diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 625a0989ab353..595458702e9c9 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -537,6 +537,11 @@ fn make_mirror_unadjusted<'a, 'tcx>( }, Err(err) => bug!("invalid loop id for continue: {}", err), }, + hir::ExprKind::If(cond, then, else_opt) => ExprKind::If { + cond: cond.to_ref(), + then: then.to_ref(), + else_opt: else_opt.map(|el| el.to_ref()), + }, hir::ExprKind::Match(ref discr, ref arms, _) => ExprKind::Match { scrutinee: discr.to_ref(), arms: arms.iter().map(|a| convert_arm(cx, a)).collect(), diff --git a/compiler/rustc_mir_build/src/thir/mod.rs b/compiler/rustc_mir_build/src/thir/mod.rs index ace9cad4d2996..ed3d3927825af 100644 --- a/compiler/rustc_mir_build/src/thir/mod.rs +++ b/compiler/rustc_mir_build/src/thir/mod.rs @@ -139,6 +139,11 @@ crate enum ExprKind<'tcx> { Box { value: ExprRef<'tcx>, }, + If { + cond: ExprRef<'tcx>, + then: ExprRef<'tcx>, + else_opt: Option>, + }, Call { ty: Ty<'tcx>, fun: ExprRef<'tcx>, diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index a70c1a28176cd..397706851cb79 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -403,7 +403,7 @@ fn report_arm_reachability<'p, 'tcx>( match is_useful { NotUseful => { match source { - hir::MatchSource::IfDesugar { .. } | hir::MatchSource::WhileDesugar => bug!(), + hir::MatchSource::WhileDesugar => bug!(), hir::MatchSource::IfLetDesugar { .. } | hir::MatchSource::WhileLetDesugar => { // Check which arm we're on. diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs index 2d6bbff460d7f..c887a860303b5 100644 --- a/compiler/rustc_passes/src/check_const.rs +++ b/compiler/rustc_passes/src/check_const.rs @@ -49,9 +49,7 @@ impl NonConstExpr { // All other expressions are allowed. Self::Loop(Loop | While | WhileLet) - | Self::Match( - WhileDesugar | WhileLetDesugar | Normal | IfDesugar { .. } | IfLetDesugar { .. }, - ) => &[], + | Self::Match(WhileDesugar | WhileLetDesugar | Normal | IfLetDesugar { .. }) => &[], }; Some(gates) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index fcea1b29ec367..6202cc312fc0e 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -419,7 +419,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } // live nodes required for interesting control flow: - hir::ExprKind::Match(..) | hir::ExprKind::Loop(..) => { + hir::ExprKind::If(..) | hir::ExprKind::Match(..) | hir::ExprKind::Loop(..) => { self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span)); intravisit::walk_expr(self, expr); } @@ -846,6 +846,29 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // at the label ident hir::ExprKind::Loop(ref blk, _, _) => self.propagate_through_loop(expr, &blk, succ), + hir::ExprKind::If(ref cond, ref then, ref else_opt) => { + // + // (cond) + // | + // v + // (expr) + // / \ + // | | + // v v + // (then)(els) + // | | + // v v + // ( succ ) + // + let else_ln = + self.propagate_through_opt_expr(else_opt.as_ref().map(|e| &**e), succ); + let then_ln = self.propagate_through_expr(&then, succ); + let ln = self.live_node(expr.hir_id, expr.span); + self.init_from_succ(ln, else_ln); + self.merge_from_succ(ln, then_ln); + self.propagate_through_expr(&cond, ln) + } + hir::ExprKind::Match(ref e, arms, _) => { // // (e) @@ -1336,6 +1359,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) { | hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) | hir::ExprKind::Cast(..) + | hir::ExprKind::If(..) | hir::ExprKind::DropTemps(..) | hir::ExprKind::Unary(..) | hir::ExprKind::Ret(..) diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index 788f1df328cc4..93fb23c018bf0 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -201,6 +201,7 @@ impl<'tcx> CheckInlineAssembly<'tcx> { | ExprKind::Type(..) | ExprKind::Loop(..) | ExprKind::Match(..) + | ExprKind::If(..) | ExprKind::Closure(..) | ExprKind::Assign(..) | ExprKind::AssignOp(..) diff --git a/compiler/rustc_passes/src/region.rs b/compiler/rustc_passes/src/region.rs index 1af79abe4b911..91421d7f5f22b 100644 --- a/compiler/rustc_passes/src/region.rs +++ b/compiler/rustc_passes/src/region.rs @@ -241,6 +241,17 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h terminating(r.hir_id.local_id); } + hir::ExprKind::If(ref expr, ref then, Some(ref otherwise)) => { + terminating(expr.hir_id.local_id); + terminating(then.hir_id.local_id); + terminating(otherwise.hir_id.local_id); + } + + hir::ExprKind::If(ref expr, ref then, None) => { + terminating(expr.hir_id.local_id); + terminating(then.hir_id.local_id); + } + hir::ExprKind::Loop(ref body, _, _) => { terminating(body.hir_id.local_id); } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index de94c411c81e4..565b8d37868f8 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2278,6 +2278,12 @@ impl<'v> Visitor<'v> for ReturnsVisitor<'v> { self.visit_expr(expr); } } + hir::ExprKind::If(_, then, else_opt) if self.in_block_tail => { + self.visit_expr(then); + if let Some(el) = else_opt { + self.visit_expr(el); + } + } hir::ExprKind::Match(_, arms, _) if self.in_block_tail => { for arm in arms { self.visit_expr(arm.body); diff --git a/compiler/rustc_typeck/src/check/_match.rs b/compiler/rustc_typeck/src/check/_match.rs index 6467e04407939..322ec9640f464 100644 --- a/compiler/rustc_typeck/src/check/_match.rs +++ b/compiler/rustc_typeck/src/check/_match.rs @@ -1,9 +1,9 @@ -use crate::check::coercion::CoerceMany; +use crate::check::coercion::{AsCoercionSite, CoerceMany}; use crate::check::{Diverges, Expectation, FnCtxt, Needs}; use rustc_hir::{self as hir, ExprKind}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::traits::Obligation; -use rustc_middle::ty::{self, ToPredicate, Ty}; +use rustc_middle::ty::{self, ToPredicate, Ty, TyS}; use rustc_span::Span; use rustc_trait_selection::opaque_types::InferCtxtExt as _; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; @@ -12,6 +12,41 @@ use rustc_trait_selection::traits::{ StatementAsExpression, }; +macro_rules! create_maybe_get_coercion_reason { + ($fn_name:ident, $node:expr) => { + pub(crate) fn $fn_name(&self, hir_id: hir::HirId, sp: Span) -> Option<(Span, String)> { + let node = $node(self.tcx.hir(), hir_id); + if let hir::Node::Block(block) = node { + // check that the body's parent is an fn + let parent = self.tcx.hir().get( + self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(block.hir_id)), + ); + if let ( + Some(expr), + hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(..), .. }), + ) = (&block.expr, parent) + { + // check that the `if` expr without `else` is the fn body's expr + if expr.span == sp { + return self.get_fn_decl(hir_id).and_then(|(fn_decl, _)| { + let span = fn_decl.output.span(); + let snippet = self.tcx.sess.source_map().span_to_snippet(span).ok()?; + Some(( + span, + format!("expected `{}` because of this return type", snippet), + )) + }); + } + } + } + if let hir::Node::Local(hir::Local { ty: Some(_), pat, .. }) = node { + return Some((pat.span, "expected because of this assignment".to_string())); + } + None + } + }; +} + impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn check_match( &self, @@ -25,7 +60,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { use hir::MatchSource::*; let (source_if, if_no_else, force_scrutinee_bool) = match match_src { - IfDesugar { contains_else_clause } => (true, !contains_else_clause, true), IfLetDesugar { contains_else_clause, .. } => (true, !contains_else_clause, false), WhileDesugar => (false, false, true), _ => (false, false, false), @@ -115,8 +149,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let arm_ty = if source_if && if_no_else && i != 0 - && self.if_fallback_coercion(expr.span, &arms[0].body, &mut coercion) - { + && self.if_fallback_coercion( + expr.span, + &arms[0].body, + &mut coercion, + |hir_id, span| self.maybe_get_coercion_reason(hir_id, span), + ) { tcx.ty_error() } else { // Only call this if this is not an `if` expr with an expected type and no `else` @@ -125,58 +163,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; all_arms_diverge &= self.diverges.get(); - // When we have a `match` as a tail expression in a `fn` with a returned `impl Trait` - // we check if the different arms would work with boxed trait objects instead and - // provide a structured suggestion in that case. - let opt_suggest_box_span = match ( - orig_expected, - self.ret_coercion_impl_trait.map(|ty| (self.body_id.owner, ty)), - ) { - (Expectation::ExpectHasType(expected), Some((id, ty))) - if self.in_tail_expr && self.can_coerce(arm_ty, expected) => - { - let impl_trait_ret_ty = self.infcx.instantiate_opaque_types( - id, - self.body_id, - self.param_env, - ty, - arm.body.span, - ); - let mut suggest_box = !impl_trait_ret_ty.obligations.is_empty(); - for o in impl_trait_ret_ty.obligations { - match o.predicate.skip_binders_unchecked() { - ty::PredicateAtom::Trait(t, constness) => { - let pred = ty::PredicateAtom::Trait( - ty::TraitPredicate { - trait_ref: ty::TraitRef { - def_id: t.def_id(), - substs: self.infcx.tcx.mk_substs_trait(arm_ty, &[]), - }, - }, - constness, - ); - let obl = Obligation::new( - o.cause.clone(), - self.param_env, - pred.to_predicate(self.infcx.tcx), - ); - suggest_box &= self.infcx.predicate_must_hold_modulo_regions(&obl); - if !suggest_box { - // We've encountered some obligation that didn't hold, so the - // return expression can't just be boxed. We don't need to - // evaluate the rest of the obligations. - break; - } - } - _ => {} - } - } - // If all the obligations hold (or there are no obligations) the tail expression - // we can suggest to return a boxed trait object instead of an opaque type. - if suggest_box { self.ret_type_span } else { None } - } - _ => None, - }; + let opt_suggest_box_span = + self.opt_suggest_box_span(arm.body.span, arm_ty, orig_expected); if source_if { let then_expr = &arms[0].body; @@ -279,7 +267,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { use hir::MatchSource::*; let msg = match source { - IfDesugar { .. } | IfLetDesugar { .. } => "block in `if` expression", + IfLetDesugar { .. } => "block in `if` expression", WhileDesugar { .. } | WhileLetDesugar { .. } => "block in `while` expression", _ => "arm", }; @@ -291,15 +279,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Handle the fallback arm of a desugared if(-let) like a missing else. /// /// Returns `true` if there was an error forcing the coercion to the `()` type. - fn if_fallback_coercion( + pub(crate) fn if_fallback_coercion( &self, span: Span, then_expr: &'tcx hir::Expr<'tcx>, - coercion: &mut CoerceMany<'tcx, '_, rustc_hir::Arm<'tcx>>, - ) -> bool { + coercion: &mut CoerceMany<'tcx, '_, T>, + ret_reason: F, + ) -> bool + where + F: Fn(hir::HirId, Span) -> Option<(Span, String)>, + T: AsCoercionSite, + { // If this `if` expr is the parent's function return expr, // the cause of the type coercion is the return type, point at it. (#25228) - let ret_reason = self.maybe_get_coercion_reason(then_expr.hir_id, span); + let ret_reason = ret_reason(then_expr.hir_id, span); let cause = self.cause(span, ObligationCauseCode::IfExpressionWithNoElse); let mut error = false; coercion.coerce_forced_unit( @@ -322,38 +315,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { error } - fn maybe_get_coercion_reason(&self, hir_id: hir::HirId, span: Span) -> Option<(Span, String)> { - use hir::Node::{Block, Item, Local}; - - let hir = self.tcx.hir(); - let arm_id = hir.get_parent_node(hir_id); - let match_id = hir.get_parent_node(arm_id); - let containing_id = hir.get_parent_node(match_id); - - let node = hir.get(containing_id); - if let Block(block) = node { - // check that the body's parent is an fn - let parent = hir.get(hir.get_parent_node(hir.get_parent_node(block.hir_id))); - if let (Some(expr), Item(hir::Item { kind: hir::ItemKind::Fn(..), .. })) = - (&block.expr, parent) - { - // check that the `if` expr without `else` is the fn body's expr - if expr.span == span { - return self.get_fn_decl(hir_id).and_then(|(fn_decl, _)| { - let span = fn_decl.output.span(); - let snippet = self.tcx.sess.source_map().span_to_snippet(span).ok()?; - Some((span, format!("expected `{}` because of this return type", snippet))) - }); - } - } + create_maybe_get_coercion_reason!( + maybe_get_coercion_reason, + |hir: rustc_middle::hir::map::Map<'a>, id| { + let arm_id = hir.get_parent_node(id); + let match_id = hir.get_parent_node(arm_id); + let containing_id = hir.get_parent_node(match_id); + hir.get(containing_id) } - if let Local(hir::Local { ty: Some(_), pat, .. }) = node { - return Some((pat.span, "expected because of this assignment".to_string())); + ); + + create_maybe_get_coercion_reason!( + maybe_get_coercion_reason_if, + |hir: rustc_middle::hir::map::Map<'a>, id| { + let rslt = hir.get_parent_node(hir.get_parent_node(id)); + hir.get(rslt) } - None - } + ); - fn if_cause( + pub(crate) fn if_cause( &self, span: Span, then_expr: &'tcx hir::Expr<'tcx>, @@ -546,6 +526,58 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (block.span, None) } } + + // When we have a `match` as a tail expression in a `fn` with a returned `impl Trait` + // we check if the different arms would work with boxed trait objects instead and + // provide a structured suggestion in that case. + pub(crate) fn opt_suggest_box_span( + &self, + span: Span, + outer_ty: &'tcx TyS<'tcx>, + orig_expected: Expectation<'tcx>, + ) -> Option { + match (orig_expected, self.ret_coercion_impl_trait.map(|ty| (self.body_id.owner, ty))) { + (Expectation::ExpectHasType(expected), Some((id, ty))) + if self.in_tail_expr && self.can_coerce(outer_ty, expected) => + { + let impl_trait_ret_ty = + self.infcx.instantiate_opaque_types(id, self.body_id, self.param_env, ty, span); + let mut suggest_box = !impl_trait_ret_ty.obligations.is_empty(); + for o in impl_trait_ret_ty.obligations { + match o.predicate.skip_binders_unchecked() { + ty::PredicateAtom::Trait(t, constness) => { + let pred = ty::PredicateAtom::Trait( + ty::TraitPredicate { + trait_ref: ty::TraitRef { + def_id: t.def_id(), + substs: self.infcx.tcx.mk_substs_trait(outer_ty, &[]), + }, + }, + constness, + ); + let obl = Obligation::new( + o.cause.clone(), + self.param_env, + pred.to_predicate(self.infcx.tcx), + ); + suggest_box &= self.infcx.predicate_must_hold_modulo_regions(&obl); + if !suggest_box { + // We've encountered some obligation that didn't hold, so the + // return expression can't just be boxed. We don't need to + // evaluate the rest of the obligations. + break; + } + } + _ => {} + } + } + // If all the obligations hold (or there are no obligations) the tail expression + // we can suggest to return a boxed trait object instead of an opaque type. + if suggest_box { self.ret_type_span } else { None } + } + _ => None, + } + } } fn arms_contain_ref_bindings(arms: &'tcx [hir::Arm<'tcx>]) -> Option { diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index 67ec739d8614d..0d21c56f4cf4d 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -1443,14 +1443,14 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { &mut err, expr, expected, found, cause.span, blk_id, ); let parent = fcx.tcx.hir().get(parent_id); - if let (Some(match_expr), true, false) = ( - fcx.tcx.hir().get_match_if_cause(expr.hir_id), + if let (Some(cond_expr), true, false) = ( + fcx.tcx.hir().get_if_cause(expr.hir_id), expected.is_unit(), pointing_at_return_type, ) { - if match_expr.span.desugaring_kind().is_none() { - err.span_label(match_expr.span, "expected this to be `()`"); - fcx.suggest_semicolon_at_end(match_expr.span, &mut err); + if cond_expr.span.desugaring_kind().is_none() { + err.span_label(cond_expr.span, "expected this to be `()`"); + fcx.suggest_semicolon_at_end(cond_expr.span, &mut err); } } fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main)) diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index d76a80d5a3990..8aa6c6d924a53 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -10,6 +10,7 @@ use crate::check::method::{probe, MethodError, SelfSource}; use crate::check::report_unexpected_variant_res; use crate::check::BreakableCtxt; use crate::check::Diverges; +use crate::check::DynamicCoerceMany; use crate::check::Expectation::{self, ExpectCastableToType, ExpectHasType, NoExpectation}; use crate::check::FnCtxt; use crate::check::Needs; @@ -188,7 +189,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Warn for non-block expressions with diverging children. match expr.kind { - ExprKind::Block(..) | ExprKind::Loop(..) | ExprKind::Match(..) => {} + ExprKind::Block(..) | ExprKind::If(..) | ExprKind::Loop(..) | ExprKind::Match(..) => {} // If `expr` is a result of desugaring the try block and is an ok-wrapped // diverging expression (e.g. it arose from desugaring of `try { return }`), // we skip issuing a warning because it is autogenerated code. @@ -285,6 +286,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_expr_eq_type(&e, ty); ty } + ExprKind::If(ref cond, ref then_expr, ref opt_else_expr) => self.check_then_else( + &cond, + then_expr, + opt_else_expr.as_ref().map(|e| &**e), + expr.span, + expected, + ), ExprKind::DropTemps(ref e) => self.check_expr_with_expectation(e, expected), ExprKind::Array(ref args) => self.check_expr_array(args, expected, expr), ExprKind::ConstBlock(ref anon_const) => self.to_const(anon_const).ty, @@ -739,8 +747,67 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit(); } + // A generic function for checking the 'then' and 'else' clauses in an 'if' + // or 'if-else' expression. + fn check_then_else( + &self, + cond_expr: &'tcx hir::Expr<'tcx>, + then_expr: &'tcx hir::Expr<'tcx>, + opt_else_expr: Option<&'tcx hir::Expr<'tcx>>, + sp: Span, + orig_expected: Expectation<'tcx>, + ) -> Ty<'tcx> { + let cond_ty = self.check_expr_has_type_or_error(cond_expr, self.tcx.types.bool, |_| {}); + + self.warn_if_unreachable(cond_expr.hir_id, then_expr.span, "block in `if` expression"); + + let cond_diverges = self.diverges.get(); + self.diverges.set(Diverges::Maybe); + + let expected = orig_expected.adjust_for_branches(self); + let then_ty = self.check_expr_with_expectation(then_expr, expected); + let then_diverges = self.diverges.get(); + self.diverges.set(Diverges::Maybe); + + // We've already taken the expected type's preferences + // into account when typing the `then` branch. To figure + // out the initial shot at a LUB, we thus only consider + // `expected` if it represents a *hard* constraint + // (`only_has_type`); otherwise, we just go with a + // fresh type variable. + let coerce_to_ty = expected.coercion_target_type(self, sp); + let mut coerce: DynamicCoerceMany<'_> = CoerceMany::new(coerce_to_ty); + + coerce.coerce(self, &self.misc(sp), then_expr, then_ty); + + if let Some(else_expr) = opt_else_expr { + let else_ty = self.check_expr_with_expectation(else_expr, expected); + let else_diverges = self.diverges.get(); + + let opt_suggest_box_span = + self.opt_suggest_box_span(else_expr.span, else_ty, orig_expected); + let if_cause = + self.if_cause(sp, then_expr, else_expr, then_ty, else_ty, opt_suggest_box_span); + + coerce.coerce(self, &if_cause, else_expr, else_ty); + + // We won't diverge unless both branches do (or the condition does). + self.diverges.set(cond_diverges | then_diverges & else_diverges); + } else { + self.if_fallback_coercion(sp, then_expr, &mut coerce, |hir_id, span| { + self.maybe_get_coercion_reason_if(hir_id, span) + }); + + // If the condition is false we can't diverge. + self.diverges.set(cond_diverges); + } + + let result_ty = coerce.complete(self); + if cond_ty.references_error() { self.tcx.ty_error() } else { result_ty } + } + /// Type check assignment expression `expr` of form `lhs = rhs`. - /// The expected type is `()` and is passsed to the function for the purposes of diagnostics. + /// The expected type is `()` and is passed to the function for the purposes of diagnostics. fn check_expr_assign( &self, expr: &'tcx hir::Expr<'tcx>, @@ -765,17 +832,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if !lhs.is_syntactic_place_expr() { // Do not suggest `if let x = y` as `==` is way more likely to be the intention. - if let hir::Node::Expr(hir::Expr { - kind: - ExprKind::Match( - _, - _, - hir::MatchSource::IfDesugar { .. } | hir::MatchSource::WhileDesugar, - ), - .. - }) = self.tcx.hir().get( - self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(expr.hir_id)), - ) { + let mut span_err = || { // Likely `if let` intended. err.span_suggestion_verbose( expr.span.shrink_to_lo(), @@ -783,6 +840,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "let ".to_string(), applicability, ); + }; + if let hir::Node::Expr(hir::Expr { + kind: ExprKind::Match(_, _, hir::MatchSource::WhileDesugar), + .. + }) = self.tcx.hir().get( + self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(expr.hir_id)), + ) { + span_err(); + } else if let hir::Node::Expr(hir::Expr { kind: ExprKind::If { .. }, .. }) = + self.tcx.hir().get(self.tcx.hir().get_parent_node(expr.hir_id)) + { + span_err(); } } if eq { diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 94f8bfa3fc04b..87b8c4889e893 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -806,33 +806,39 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// // ^^^^ point at this instead of the whole `if` expression /// ``` fn get_expr_coercion_span(&self, expr: &hir::Expr<'_>) -> rustc_span::Span { - if let hir::ExprKind::Match(_, arms, _) = &expr.kind { - let arm_spans: Vec = arms - .iter() - .filter_map(|arm| { - self.in_progress_typeck_results - .and_then(|typeck_results| { - typeck_results.borrow().node_type_opt(arm.body.hir_id) - }) - .and_then(|arm_ty| { - if arm_ty.is_never() { - None - } else { - Some(match &arm.body.kind { - // Point at the tail expression when possible. - hir::ExprKind::Block(block, _) => { - block.expr.as_ref().map(|e| e.span).unwrap_or(block.span) - } - _ => arm.body.span, - }) + let check_in_progress = |elem: &hir::Expr<'_>| { + self.in_progress_typeck_results + .and_then(|typeck_results| typeck_results.borrow().node_type_opt(elem.hir_id)) + .and_then(|ty| { + if ty.is_never() { + None + } else { + Some(match &elem.kind { + // Point at the tail expression when possible. + hir::ExprKind::Block(block, _) => { + block.expr.as_ref().map(|e| e.span).unwrap_or(block.span) } + _ => elem.span, }) + } }) - .collect(); - if arm_spans.len() == 1 { - return arm_spans[0]; + }; + + if let hir::ExprKind::If(_, _, Some(el)) = &expr.kind { + if let Some(rslt) = check_in_progress(el) { + return rslt; } } + + if let hir::ExprKind::Match(_, arms, _) = &expr.kind { + let mut iter = arms.iter().filter_map(|arm| check_in_progress(&arm.body)); + if let Some(span) = iter.next() { + if iter.next().is_none() { + return span; + } + } + } + expr.span } diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs index 9fbf330fe0208..a0465ca6aef07 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs @@ -390,6 +390,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ExprKind::Call(..) | ExprKind::MethodCall(..) | ExprKind::Loop(..) + | ExprKind::If(..) | ExprKind::Match(..) | ExprKind::Block(..) => { err.span_suggestion( diff --git a/compiler/rustc_typeck/src/expr_use_visitor.rs b/compiler/rustc_typeck/src/expr_use_visitor.rs index 3ce244e11bf45..01519e4c8f7c4 100644 --- a/compiler/rustc_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_typeck/src/expr_use_visitor.rs @@ -219,6 +219,14 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.consume_exprs(exprs); } + hir::ExprKind::If(ref cond_expr, ref then_expr, ref opt_else_expr) => { + self.consume_expr(&cond_expr); + self.consume_expr(&then_expr); + if let Some(ref else_expr) = *opt_else_expr { + self.consume_expr(&else_expr); + } + } + hir::ExprKind::Match(ref discr, arms, _) => { let discr_place = return_if_err!(self.mc.cat_expr(&discr)); self.borrow_expr(&discr, ty::ImmBorrow); diff --git a/compiler/rustc_typeck/src/mem_categorization.rs b/compiler/rustc_typeck/src/mem_categorization.rs index a601123c8d055..37f9e3d63b830 100644 --- a/compiler/rustc_typeck/src/mem_categorization.rs +++ b/compiler/rustc_typeck/src/mem_categorization.rs @@ -364,6 +364,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { | hir::ExprKind::Cast(..) | hir::ExprKind::DropTemps(..) | hir::ExprKind::Array(..) + | hir::ExprKind::If(..) | hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) | hir::ExprKind::Block(..) diff --git a/src/test/incremental/hashes/if_expressions.rs b/src/test/incremental/hashes/if_expressions.rs index 59af1fc09c2de..ca8daae152cdd 100644 --- a/src/test/incremental/hashes/if_expressions.rs +++ b/src/test/incremental/hashes/if_expressions.rs @@ -94,7 +94,7 @@ pub fn add_else_branch(x: bool) -> u32 { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] pub fn add_else_branch(x: bool) -> u32 { let mut ret = 1; diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff index 0d06c4960b363..64c270393735a 100644 --- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff @@ -9,18 +9,12 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 - _1 = const ::NEEDS; // scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 -- switchInt(_1) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 +- switchInt(move _1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 + _1 = const false; // scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 -+ switchInt(const false) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 ++ switchInt(const false) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 } bb1: { - _0 = const (); // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6 - StorageDead(_1); // scope 0 at $DIR/control-flow-simplification.rs:15:1: 15:2 - return; // scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 - } - - bb2: { StorageLive(_2); // scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL begin_panic::<&str>(const "explicit panic"); // scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant @@ -33,5 +27,11 @@ // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) } } + + bb2: { + _0 = const (); // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6 + StorageDead(_1); // scope 0 at $DIR/control-flow-simplification.rs:14:5: 14:6 + return; // scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 + } } diff --git a/src/test/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot b/src/test/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot index 5b6d73a7deefb..eeedbb215c0dd 100644 --- a/src/test/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot +++ b/src/test/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot @@ -3,8 +3,8 @@ digraph Cov_0_3 { node [fontname="Courier, monospace"]; edge [fontname="Courier, monospace"]; bcb2__Cov_0_3 [shape="none", label=<
bcb2
Expression(bcb0 - bcb1) at 13:10-13:10
13:10-13:10: @4[0]: Coverage::Expression(4294967295) = 1 - 2 for $DIR/coverage_graphviz.rs:13:10 - 13:11
bb4: Goto
>]; - bcb1__Cov_0_3 [shape="none", label=<
bcb1
Counter(bcb1) at 12:13-12:18
12:13-12:18: @5[0]: _0 = const ()
Expression(bcb1 + 0) at 15:2-15:2
15:2-15:2: @5.Return: return
bb3: FalseEdge
bb5: Return
>]; - bcb0__Cov_0_3 [shape="none", label=<
bcb0
Counter(bcb0) at 9:1-11:17
11:12-11:17: @1.Call: _2 = bar() -> [return: bb2, unwind: bb6]
11:12-11:17: @2[0]: FakeRead(ForMatchedPlace, _2)
bb0: FalseUnwind
bb1: Call
bb2: SwitchInt
>]; + bcb1__Cov_0_3 [shape="none", label=<
bcb1
Counter(bcb1) at 12:13-12:18
12:13-12:18: @3[0]: Coverage::Expression(4294967294) = 2 + 0 for $DIR/coverage_graphviz.rs:15:1 - 15:2
Expression(bcb1 + 0) at 15:2-15:2
15:2-15:2: @3.Return: return
bb3: Return
>]; + bcb0__Cov_0_3 [shape="none", label=<
bcb0
Counter(bcb0) at 9:1-11:17
11:12-11:17: @1.Call: _2 = bar() -> [return: bb2, unwind: bb5]
bb0: FalseUnwind
bb1: Call
bb2: SwitchInt
>]; bcb2__Cov_0_3 -> bcb0__Cov_0_3 [label=<>]; bcb0__Cov_0_3 -> bcb2__Cov_0_3 [label=]; bcb0__Cov_0_3 -> bcb1__Cov_0_3 [label=]; diff --git a/src/test/mir-opt/deaggregator_test_enum_2.test1.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_enum_2.test1.Deaggregator.diff index bf99f7efb4dd6..6d2dbb820f962 100644 --- a/src/test/mir-opt/deaggregator_test_enum_2.test1.Deaggregator.diff +++ b/src/test/mir-opt/deaggregator_test_enum_2.test1.Deaggregator.diff @@ -12,20 +12,10 @@ bb0: { StorageLive(_3); // scope 0 at $DIR/deaggregator_test_enum_2.rs:10:8: 10:9 _3 = _1; // scope 0 at $DIR/deaggregator_test_enum_2.rs:10:8: 10:9 - switchInt(_3) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 + switchInt(move _3) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 } bb1: { - StorageLive(_5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 - _5 = _2; // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 -- _0 = Foo::B(move _5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 -+ ((_0 as B).0: i32) = move _5; // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 -+ discriminant(_0) = 1; // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 - StorageDead(_5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:17: 13:18 - goto -> bb3; // scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 - } - - bb2: { StorageLive(_4); // scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17 _4 = _2; // scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17 - _0 = Foo::A(move _4); // scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18 @@ -35,8 +25,18 @@ goto -> bb3; // scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 } + bb2: { + StorageLive(_5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 + _5 = _2; // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 +- _0 = Foo::B(move _5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 ++ ((_0 as B).0: i32) = move _5; // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 ++ discriminant(_0) = 1; // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 + StorageDead(_5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:13:17: 13:18 + goto -> bb3; // scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 + } + bb3: { - StorageDead(_3); // scope 0 at $DIR/deaggregator_test_enum_2.rs:15:1: 15:2 + StorageDead(_3); // scope 0 at $DIR/deaggregator_test_enum_2.rs:14:5: 14:6 return; // scope 0 at $DIR/deaggregator_test_enum_2.rs:15:2: 15:2 } } diff --git a/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff index 9c213eaed3c04..e11d24cac8c2e 100644 --- a/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff @@ -36,10 +36,16 @@ } bb2: { - switchInt(_3) -> [false: bb3, otherwise: bb4]; // scope 1 at $DIR/branch.rs:15:13: 20:6 + switchInt(move _3) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/branch.rs:15:13: 20:6 } bb3: { +- _2 = _1; // scope 1 at $DIR/branch.rs:16:9: 16:10 ++ nop; // scope 1 at $DIR/branch.rs:16:9: 16:10 + goto -> bb6; // scope 1 at $DIR/branch.rs:15:13: 20:6 + } + + bb4: { StorageLive(_4); // scope 1 at $DIR/branch.rs:18:9: 18:14 _4 = val() -> bb5; // scope 1 at $DIR/branch.rs:18:9: 18:14 // mir::Constant @@ -47,12 +53,6 @@ // + literal: Const { ty: fn() -> i32 {val}, val: Value(Scalar()) } } - bb4: { -- _2 = _1; // scope 1 at $DIR/branch.rs:16:9: 16:10 -+ nop; // scope 1 at $DIR/branch.rs:16:9: 16:10 - goto -> bb6; // scope 1 at $DIR/branch.rs:15:13: 20:6 - } - bb5: { StorageDead(_4); // scope 1 at $DIR/branch.rs:18:14: 18:15 - _2 = _1; // scope 1 at $DIR/branch.rs:19:9: 19:10 @@ -61,7 +61,7 @@ } bb6: { - StorageDead(_3); // scope 1 at $DIR/branch.rs:20:6: 20:7 + StorageDead(_3); // scope 1 at $DIR/branch.rs:20:5: 20:6 _0 = const (); // scope 0 at $DIR/branch.rs:12:11: 21:2 - StorageDead(_2); // scope 1 at $DIR/branch.rs:21:1: 21:2 - StorageDead(_1); // scope 0 at $DIR/branch.rs:21:1: 21:2 diff --git a/src/test/mir-opt/equal_true.opt.InstCombine.diff b/src/test/mir-opt/equal_true.opt.InstCombine.diff index a26776e70d6b9..1bc4c0f8b37e3 100644 --- a/src/test/mir-opt/equal_true.opt.InstCombine.diff +++ b/src/test/mir-opt/equal_true.opt.InstCombine.diff @@ -14,21 +14,21 @@ - _2 = Eq(move _3, const true); // scope 0 at $DIR/equal_true.rs:4:8: 4:17 + _2 = move _3; // scope 0 at $DIR/equal_true.rs:4:8: 4:17 StorageDead(_3); // scope 0 at $DIR/equal_true.rs:4:16: 4:17 - switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/equal_true.rs:4:5: 4:34 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/equal_true.rs:4:5: 4:34 } bb1: { - _0 = const 1_i32; // scope 0 at $DIR/equal_true.rs:4:31: 4:32 + _0 = const 0_i32; // scope 0 at $DIR/equal_true.rs:4:20: 4:21 goto -> bb3; // scope 0 at $DIR/equal_true.rs:4:5: 4:34 } bb2: { - _0 = const 0_i32; // scope 0 at $DIR/equal_true.rs:4:20: 4:21 + _0 = const 1_i32; // scope 0 at $DIR/equal_true.rs:4:31: 4:32 goto -> bb3; // scope 0 at $DIR/equal_true.rs:4:5: 4:34 } bb3: { - StorageDead(_2); // scope 0 at $DIR/equal_true.rs:5:1: 5:2 + StorageDead(_2); // scope 0 at $DIR/equal_true.rs:4:33: 4:34 return; // scope 0 at $DIR/equal_true.rs:5:2: 5:2 } } diff --git a/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff index 993ff660caaac..875e5a0a71f33 100644 --- a/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff @@ -9,21 +9,21 @@ bb0: { StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:17:8: 17:9 _2 = _1; // scope 0 at $DIR/if-condition-int.rs:17:8: 17:9 - switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:17:5: 17:26 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:17:5: 17:26 } bb1: { - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:17:23: 17:24 + _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:17:12: 17:13 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:17:5: 17:26 } bb2: { - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:17:12: 17:13 + _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:17:23: 17:24 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:17:5: 17:26 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:18:1: 18:2 + StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:17:25: 17:26 return; // scope 0 at $DIR/if-condition-int.rs:18:2: 18:2 } } diff --git a/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff index 8ae9168c95098..2c4952402a49d 100644 --- a/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff @@ -16,21 +16,21 @@ // + span: $DIR/if-condition-int.rs:53:13: 53:18 // + literal: Const { ty: f32, val: Value(Scalar(0xc2280000)) } StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:53:17: 53:18 - switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:53:5: 53:35 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:53:5: 53:35 } bb1: { - _0 = const 1_i32; // scope 0 at $DIR/if-condition-int.rs:53:32: 53:33 + _0 = const 0_i32; // scope 0 at $DIR/if-condition-int.rs:53:21: 53:22 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:53:5: 53:35 } bb2: { - _0 = const 0_i32; // scope 0 at $DIR/if-condition-int.rs:53:21: 53:22 + _0 = const 1_i32; // scope 0 at $DIR/if-condition-int.rs:53:32: 53:33 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:53:5: 53:35 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:54:1: 54:2 + StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:53:34: 53:35 return; // scope 0 at $DIR/if-condition-int.rs:54:2: 54:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff index ae0960028a8b4..661591658df89 100644 --- a/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff @@ -13,26 +13,26 @@ _3 = _1; // scope 0 at $DIR/if-condition-int.rs:21:8: 21:9 - _2 = Eq(move _3, const 'x'); // scope 0 at $DIR/if-condition-int.rs:21:8: 21:16 - StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:21:15: 21:16 -- switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:21:5: 21:33 -+ _2 = Eq(_3, const 'x'); // scope 0 at $DIR/if-condition-int.rs:21:8: 21:16 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:21:5: 21:33 ++ nop; // scope 0 at $DIR/if-condition-int.rs:21:8: 21:16 + nop; // scope 0 at $DIR/if-condition-int.rs:21:15: 21:16 -+ switchInt(move _3) -> ['x': bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:21:5: 21:33 ++ switchInt(move _3) -> ['x': bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:21:5: 21:33 } bb1: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:21:5: 21:33 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:21:30: 21:31 + _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:21:19: 21:20 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:21:5: 21:33 } bb2: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:21:5: 21:33 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:21:19: 21:20 + _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:21:30: 21:31 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:21:5: 21:33 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:22:1: 22:2 + StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:21:32: 21:33 return; // scope 0 at $DIR/if-condition-int.rs:22:2: 22:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff index 8d59e51ac2b11..7d0ed7338d7d2 100644 --- a/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff @@ -13,26 +13,26 @@ _3 = _1; // scope 0 at $DIR/if-condition-int.rs:25:8: 25:9 - _2 = Eq(move _3, const 42_i8); // scope 0 at $DIR/if-condition-int.rs:25:8: 25:15 - StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:25:14: 25:15 -- switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:25:5: 25:32 -+ _2 = Eq(_3, const 42_i8); // scope 0 at $DIR/if-condition-int.rs:25:8: 25:15 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:25:5: 25:32 ++ nop; // scope 0 at $DIR/if-condition-int.rs:25:8: 25:15 + nop; // scope 0 at $DIR/if-condition-int.rs:25:14: 25:15 -+ switchInt(move _3) -> [42_i8: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:25:5: 25:32 ++ switchInt(move _3) -> [42_i8: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:25:5: 25:32 } bb1: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:25:5: 25:32 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:25:29: 25:30 + _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:25:18: 25:19 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:25:5: 25:32 } bb2: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:25:5: 25:32 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:25:18: 25:19 + _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:25:29: 25:30 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:25:5: 25:32 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:26:1: 26:2 + StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:25:31: 25:32 return; // scope 0 at $DIR/if-condition-int.rs:26:2: 26:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff index c4975661efe50..bf388a141b617 100644 --- a/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff @@ -15,40 +15,40 @@ _3 = _1; // scope 0 at $DIR/if-condition-int.rs:33:8: 33:9 - _2 = Eq(move _3, const 42_u32); // scope 0 at $DIR/if-condition-int.rs:33:8: 33:15 - StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:33:14: 33:15 -- switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 -+ _2 = Eq(_3, const 42_u32); // scope 0 at $DIR/if-condition-int.rs:33:8: 33:15 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 ++ nop; // scope 0 at $DIR/if-condition-int.rs:33:8: 33:15 + nop; // scope 0 at $DIR/if-condition-int.rs:33:14: 33:15 -+ switchInt(move _3) -> [42_u32: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 ++ switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 } bb1: { ++ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 + _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:34:9: 34:10 + goto -> bb6; // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 + } + + bb2: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 StorageLive(_4); // scope 0 at $DIR/if-condition-int.rs:35:15: 35:22 StorageLive(_5); // scope 0 at $DIR/if-condition-int.rs:35:15: 35:16 _5 = _1; // scope 0 at $DIR/if-condition-int.rs:35:15: 35:16 - _4 = Ne(move _5, const 21_u32); // scope 0 at $DIR/if-condition-int.rs:35:15: 35:22 - StorageDead(_5); // scope 0 at $DIR/if-condition-int.rs:35:21: 35:22 -- switchInt(_4) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/if-condition-int.rs:35:12: 39:6 -+ _4 = Ne(_5, const 21_u32); // scope 0 at $DIR/if-condition-int.rs:35:15: 35:22 +- switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/if-condition-int.rs:35:12: 39:6 ++ nop; // scope 0 at $DIR/if-condition-int.rs:35:15: 35:22 + nop; // scope 0 at $DIR/if-condition-int.rs:35:21: 35:22 -+ switchInt(move _5) -> [21_u32: bb3, otherwise: bb4]; // scope 0 at $DIR/if-condition-int.rs:35:12: 39:6 - } - - bb2: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:34:9: 34:10 - goto -> bb6; // scope 0 at $DIR/if-condition-int.rs:33:5: 39:6 ++ switchInt(move _5) -> [21_u32: bb4, otherwise: bb3]; // scope 0 at $DIR/if-condition-int.rs:35:12: 39:6 } bb3: { + StorageDead(_5); // scope 0 at $DIR/if-condition-int.rs:35:12: 39:6 - _0 = const 2_u32; // scope 0 at $DIR/if-condition-int.rs:38:9: 38:10 + _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:36:9: 36:10 goto -> bb5; // scope 0 at $DIR/if-condition-int.rs:35:12: 39:6 } bb4: { + StorageDead(_5); // scope 0 at $DIR/if-condition-int.rs:35:12: 39:6 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:36:9: 36:10 + _0 = const 2_u32; // scope 0 at $DIR/if-condition-int.rs:38:9: 38:10 goto -> bb5; // scope 0 at $DIR/if-condition-int.rs:35:12: 39:6 } @@ -58,7 +58,7 @@ } bb6: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:40:1: 40:2 + StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:39:5: 39:6 return; // scope 0 at $DIR/if-condition-int.rs:40:2: 40:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff index d7f544e44c0fe..bee2e030b7ed5 100644 --- a/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff @@ -13,26 +13,26 @@ _3 = _1; // scope 0 at $DIR/if-condition-int.rs:29:8: 29:9 - _2 = Eq(move _3, const -42_i32); // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16 - StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:29:15: 29:16 -- switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33 -+ _2 = Eq(_3, const -42_i32); // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33 ++ nop; // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16 + nop; // scope 0 at $DIR/if-condition-int.rs:29:15: 29:16 -+ switchInt(move _3) -> [-42_i32: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33 ++ switchInt(move _3) -> [-42_i32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33 } bb1: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:29:30: 29:31 + _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:29:19: 29:20 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33 } bb2: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:29:19: 29:20 + _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:29:30: 29:31 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:30:1: 30:2 + StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:29:32: 29:33 return; // scope 0 at $DIR/if-condition-int.rs:30:2: 30:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff index 51e00e680c286..09a87591be107 100644 --- a/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff @@ -13,26 +13,26 @@ _3 = _1; // scope 0 at $DIR/if-condition-int.rs:12:8: 12:9 - _2 = Eq(move _3, const 42_u32); // scope 0 at $DIR/if-condition-int.rs:12:8: 12:15 - StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:12:14: 12:15 -- switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:12:5: 12:32 -+ _2 = Eq(_3, const 42_u32); // scope 0 at $DIR/if-condition-int.rs:12:8: 12:15 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:12:5: 12:32 ++ nop; // scope 0 at $DIR/if-condition-int.rs:12:8: 12:15 + nop; // scope 0 at $DIR/if-condition-int.rs:12:14: 12:15 -+ switchInt(move _3) -> [42_u32: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:12:5: 12:32 ++ switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:12:5: 12:32 } bb1: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:12:5: 12:32 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:12:29: 12:30 + _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:12:18: 12:19 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:12:5: 12:32 } bb2: { + StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:12:5: 12:32 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:12:18: 12:19 + _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:12:29: 12:30 goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:12:5: 12:32 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:13:1: 13:2 + StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:12:31: 12:32 return; // scope 0 at $DIR/if-condition-int.rs:13:2: 13:2 } } diff --git a/src/test/mir-opt/inline/inline_diverging.g.Inline.diff b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff index 3dc33354a5a56..a746baa63eb53 100644 --- a/src/test/mir-opt/inline/inline_diverging.g.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff @@ -19,10 +19,19 @@ _3 = _1; // scope 0 at $DIR/inline-diverging.rs:13:8: 13:9 _2 = Gt(move _3, const 0_i32); // scope 0 at $DIR/inline-diverging.rs:13:8: 13:13 StorageDead(_3); // scope 0 at $DIR/inline-diverging.rs:13:12: 13:13 - switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/inline-diverging.rs:13:5: 17:6 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/inline-diverging.rs:13:5: 17:6 } bb1: { + StorageLive(_4); // scope 0 at $DIR/inline-diverging.rs:14:9: 14:10 + _4 = _1; // scope 0 at $DIR/inline-diverging.rs:14:9: 14:10 + _0 = move _4 as u32 (Misc); // scope 0 at $DIR/inline-diverging.rs:14:9: 14:17 + StorageDead(_4); // scope 0 at $DIR/inline-diverging.rs:14:16: 14:17 + StorageDead(_2); // scope 0 at $DIR/inline-diverging.rs:17:5: 17:6 + return; // scope 0 at $DIR/inline-diverging.rs:18:2: 18:2 + } + + bb2: { StorageLive(_6); // scope 0 at $DIR/inline-diverging.rs:16:9: 16:16 - panic(); // scope 0 at $DIR/inline-diverging.rs:16:9: 16:16 + StorageLive(_7); // scope 0 at $DIR/inline-diverging.rs:16:9: 16:16 @@ -39,14 +48,5 @@ + // + span: $DIR/inline-diverging.rs:16:9: 16:16 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) } } - - bb2: { - StorageLive(_4); // scope 0 at $DIR/inline-diverging.rs:14:9: 14:10 - _4 = _1; // scope 0 at $DIR/inline-diverging.rs:14:9: 14:10 - _0 = move _4 as u32 (Misc); // scope 0 at $DIR/inline-diverging.rs:14:9: 14:17 - StorageDead(_4); // scope 0 at $DIR/inline-diverging.rs:14:16: 14:17 - StorageDead(_2); // scope 0 at $DIR/inline-diverging.rs:18:1: 18:2 - return; // scope 0 at $DIR/inline-diverging.rs:18:2: 18:2 - } } diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff index 99497a6fc791c..066ac8d82d36b 100644 --- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -90,16 +90,16 @@ + + bb3: { + _8 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ switchInt(_8) -> [false: bb4, otherwise: bb5]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ switchInt(move _8) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + + bb4: { -+ ((_1 as Yielded).0: i32) = const 13_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ ((_1 as Yielded).0: i32) = const 7_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + + bb5: { -+ ((_1 as Yielded).0: i32) = const 7_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ ((_1 as Yielded).0: i32) = const 13_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + diff --git a/src/test/mir-opt/inst_combine_deref.do_not_miscompile.InstCombine.diff b/src/test/mir-opt/inst_combine_deref.do_not_miscompile.InstCombine.diff index a8b523d06dfc7..ee8fcdcde4095 100644 --- a/src/test/mir-opt/inst_combine_deref.do_not_miscompile.InstCombine.diff +++ b/src/test/mir-opt/inst_combine_deref.do_not_miscompile.InstCombine.diff @@ -53,22 +53,10 @@ StorageDead(_10); // scope 4 at $DIR/inst_combine_deref.rs:60:20: 60:21 _8 = Not(move _9); // scope 4 at $DIR/inst_combine_deref.rs:60:5: 60:23 StorageDead(_9); // scope 4 at $DIR/inst_combine_deref.rs:60:22: 60:23 - switchInt(_8) -> [false: bb1, otherwise: bb2]; // scope 4 at $DIR/inst_combine_deref.rs:60:5: 60:23 + switchInt(move _8) -> [false: bb2, otherwise: bb1]; // scope 4 at $DIR/inst_combine_deref.rs:60:5: 60:23 } bb1: { - _7 = const (); // scope 4 at $DIR/inst_combine_deref.rs:60:23: 60:23 - StorageDead(_8); // scope 4 at $DIR/inst_combine_deref.rs:60:22: 60:23 - StorageDead(_7); // scope 4 at $DIR/inst_combine_deref.rs:60:22: 60:23 - _0 = const (); // scope 0 at $DIR/inst_combine_deref.rs:54:24: 61:2 - StorageDead(_4); // scope 3 at $DIR/inst_combine_deref.rs:61:1: 61:2 - StorageDead(_3); // scope 2 at $DIR/inst_combine_deref.rs:61:1: 61:2 - StorageDead(_2); // scope 1 at $DIR/inst_combine_deref.rs:61:1: 61:2 - StorageDead(_1); // scope 0 at $DIR/inst_combine_deref.rs:61:1: 61:2 - return; // scope 0 at $DIR/inst_combine_deref.rs:61:2: 61:2 - } - - bb2: { StorageLive(_11); // scope 4 at $DIR/inst_combine_deref.rs:60:5: 60:23 core::panicking::panic(const "assertion failed: *y == 99"); // scope 4 at $DIR/inst_combine_deref.rs:60:5: 60:23 // mir::Constant @@ -81,5 +69,17 @@ // + span: $DIR/inst_combine_deref.rs:1:1: 1:1 // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [97, 115, 115, 101, 114, 116, 105, 111, 110, 32, 102, 97, 105, 108, 101, 100, 58, 32, 42, 121, 32, 61, 61, 32, 57, 57], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [67108863], len: Size { raw: 26 } }, size: Size { raw: 26 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 26 }) } } + + bb2: { + _7 = const (); // scope 4 at $DIR/inst_combine_deref.rs:60:23: 60:23 + StorageDead(_8); // scope 4 at $DIR/inst_combine_deref.rs:60:22: 60:23 + StorageDead(_7); // scope 4 at $DIR/inst_combine_deref.rs:60:22: 60:23 + _0 = const (); // scope 0 at $DIR/inst_combine_deref.rs:54:24: 61:2 + StorageDead(_4); // scope 3 at $DIR/inst_combine_deref.rs:61:1: 61:2 + StorageDead(_3); // scope 2 at $DIR/inst_combine_deref.rs:61:1: 61:2 + StorageDead(_2); // scope 1 at $DIR/inst_combine_deref.rs:61:1: 61:2 + StorageDead(_1); // scope 0 at $DIR/inst_combine_deref.rs:61:1: 61:2 + return; // scope 0 at $DIR/inst_combine_deref.rs:61:2: 61:2 + } } diff --git a/src/test/mir-opt/instrument_coverage.main.InstrumentCoverage.diff b/src/test/mir-opt/instrument_coverage.main.InstrumentCoverage.diff index 9bd8c9cf61331..226db9558ef46 100644 --- a/src/test/mir-opt/instrument_coverage.main.InstrumentCoverage.diff +++ b/src/test/mir-opt/instrument_coverage.main.InstrumentCoverage.diff @@ -9,42 +9,37 @@ bb0: { + Coverage::Counter(1) for /the/src/instrument_coverage.rs:10:1 - 12:17; // scope 0 at /the/src/instrument_coverage.rs:11:5: 15:6 - falseUnwind -> [real: bb1, cleanup: bb6]; // scope 0 at /the/src/instrument_coverage.rs:11:5: 15:6 + falseUnwind -> [real: bb1, cleanup: bb5]; // scope 0 at /the/src/instrument_coverage.rs:11:5: 15:6 } bb1: { StorageLive(_2); // scope 0 at /the/src/instrument_coverage.rs:12:12: 12:17 - _2 = bar() -> [return: bb2, unwind: bb6]; // scope 0 at /the/src/instrument_coverage.rs:12:12: 12:17 + _2 = bar() -> [return: bb2, unwind: bb5]; // scope 0 at /the/src/instrument_coverage.rs:12:12: 12:17 // mir::Constant // + span: /the/src/instrument_coverage.rs:12:12: 12:15 // + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar()) } } bb2: { - FakeRead(ForMatchedPlace, _2); // scope 0 at /the/src/instrument_coverage.rs:12:12: 12:17 - switchInt(_2) -> [false: bb4, otherwise: bb3]; // scope 0 at /the/src/instrument_coverage.rs:12:9: 14:10 + switchInt(move _2) -> [false: bb4, otherwise: bb3]; // scope 0 at /the/src/instrument_coverage.rs:12:9: 14:10 } bb3: { -+ Coverage::Expression(4294967294) = 2 + 0 for /the/src/instrument_coverage.rs:16:1 - 16:2; // scope 0 at /the/src/instrument_coverage.rs:12:9: 14:10 -+ Coverage::Counter(2) for /the/src/instrument_coverage.rs:13:13 - 13:18; // scope 0 at /the/src/instrument_coverage.rs:12:9: 14:10 - falseEdge -> [real: bb5, imaginary: bb4]; // scope 0 at /the/src/instrument_coverage.rs:12:9: 14:10 ++ Coverage::Expression(4294967294) = 2 + 0 for /the/src/instrument_coverage.rs:16:1 - 16:2; // scope 0 at /the/src/instrument_coverage.rs:16:2: 16:2 ++ Coverage::Counter(2) for /the/src/instrument_coverage.rs:13:13 - 13:18; // scope 0 at /the/src/instrument_coverage.rs:16:2: 16:2 + _0 = const (); // scope 0 at /the/src/instrument_coverage.rs:13:13: 13:18 + StorageDead(_2); // scope 0 at /the/src/instrument_coverage.rs:14:9: 14:10 + return; // scope 0 at /the/src/instrument_coverage.rs:16:2: 16:2 } bb4: { + Coverage::Expression(4294967295) = 1 - 2 for /the/src/instrument_coverage.rs:14:10 - 14:11; // scope 0 at /the/src/instrument_coverage.rs:11:5: 15:6 _1 = const (); // scope 0 at /the/src/instrument_coverage.rs:14:10: 14:10 - StorageDead(_2); // scope 0 at /the/src/instrument_coverage.rs:15:5: 15:6 + StorageDead(_2); // scope 0 at /the/src/instrument_coverage.rs:14:9: 14:10 goto -> bb0; // scope 0 at /the/src/instrument_coverage.rs:11:5: 15:6 } - bb5: { - _0 = const (); // scope 0 at /the/src/instrument_coverage.rs:13:13: 13:18 - StorageDead(_2); // scope 0 at /the/src/instrument_coverage.rs:15:5: 15:6 - return; // scope 0 at /the/src/instrument_coverage.rs:16:2: 16:2 - } - - bb6 (cleanup): { + bb5 (cleanup): { resume; // scope 0 at /the/src/instrument_coverage.rs:10:1: 16:2 } } diff --git a/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir index 30036e4034af6..e9e5a101a64a5 100644 --- a/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir @@ -19,19 +19,22 @@ fn main() -> () { } bb1: { - falseUnwind -> [real: bb2, cleanup: bb6]; // scope 1 at $DIR/issue-38669.rs:6:5: 11:6 + falseUnwind -> [real: bb2, cleanup: bb5]; // scope 1 at $DIR/issue-38669.rs:6:5: 11:6 } bb2: { StorageLive(_3); // scope 1 at $DIR/issue-38669.rs:7:9: 9:10 StorageLive(_4); // scope 1 at $DIR/issue-38669.rs:7:12: 7:24 _4 = _1; // scope 1 at $DIR/issue-38669.rs:7:12: 7:24 - FakeRead(ForMatchedPlace, _4); // scope 1 at $DIR/issue-38669.rs:7:12: 7:24 - switchInt(_4) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/issue-38669.rs:7:9: 9:10 + switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/issue-38669.rs:7:9: 9:10 } bb3: { - falseEdge -> [real: bb5, imaginary: bb4]; // scope 1 at $DIR/issue-38669.rs:7:9: 9:10 + _0 = const (); // scope 1 at $DIR/issue-38669.rs:8:13: 8:18 + StorageDead(_4); // scope 1 at $DIR/issue-38669.rs:9:9: 9:10 + StorageDead(_3); // scope 1 at $DIR/issue-38669.rs:9:9: 9:10 + StorageDead(_1); // scope 0 at $DIR/issue-38669.rs:12:1: 12:2 + return; // scope 0 at $DIR/issue-38669.rs:12:2: 12:2 } bb4: { @@ -43,15 +46,7 @@ fn main() -> () { goto -> bb1; // scope 1 at $DIR/issue-38669.rs:6:5: 11:6 } - bb5: { - _0 = const (); // scope 1 at $DIR/issue-38669.rs:8:13: 8:18 - StorageDead(_4); // scope 1 at $DIR/issue-38669.rs:9:9: 9:10 - StorageDead(_3); // scope 1 at $DIR/issue-38669.rs:9:9: 9:10 - StorageDead(_1); // scope 0 at $DIR/issue-38669.rs:12:1: 12:2 - return; // scope 0 at $DIR/issue-38669.rs:12:2: 12:2 - } - - bb6 (cleanup): { + bb5 (cleanup): { resume; // scope 0 at $DIR/issue-38669.rs:4:1: 12: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 5011c2adfa581..4fc7f9daa22b9 100644 --- a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir @@ -33,15 +33,10 @@ fn main() -> () { } bb1: { - switchInt(_2) -> [false: bb2, otherwise: bb3]; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6 + switchInt(move _2) -> [false: bb3, otherwise: bb2]; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6 } bb2: { - _0 = const (); // scope 1 at $DIR/issue-41888.rs:14:6: 14:6 - goto -> bb7; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6 - } - - bb3: { StorageLive(_3); // scope 1 at $DIR/issue-41888.rs:9:13: 9:20 StorageLive(_4); // scope 1 at $DIR/issue-41888.rs:9:18: 9:19 _4 = K; // scope 1 at $DIR/issue-41888.rs:9:18: 9:19 @@ -50,6 +45,11 @@ fn main() -> () { goto -> bb12; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 } + bb3: { + _0 = const (); // scope 1 at $DIR/issue-41888.rs:14:6: 14:6 + goto -> bb7; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6 + } + bb4: { 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 @@ -71,6 +71,7 @@ fn main() -> () { } bb7: { + StorageDead(_2); // scope 1 at $DIR/issue-41888.rs:14:5: 14:6 goto -> bb18; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } @@ -79,7 +80,6 @@ fn main() -> () { _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 StorageDead(_1); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 - StorageDead(_2); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 return; // scope 0 at $DIR/issue-41888.rs:15:2: 15:2 } diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff index 4db83c5c683d2..435b2a1360a6b 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -99,19 +99,10 @@ StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _9 = Not(move _10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(_9) -> [false: bb1, otherwise: bb2]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _9) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb1: { - StorageDead(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 - StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 - return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 - } - - bb2: { _13 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &[&str; 3] @@ -143,6 +134,15 @@ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } + bb2: { + StorageDead(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 + return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + bb3: { (_20.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _24) -> bb4; // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index 4db83c5c683d2..435b2a1360a6b 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -99,19 +99,10 @@ StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _9 = Not(move _10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(_9) -> [false: bb1, otherwise: bb2]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _9) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb1: { - StorageDead(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 - StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 - return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 - } - - bb2: { _13 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &[&str; 3] @@ -143,6 +134,15 @@ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } + bb2: { + StorageDead(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 + return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + bb3: { (_20.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _24) -> bb4; // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff index 4e362f3556b20..d87cb2af8baac 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff @@ -151,23 +151,10 @@ StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(_15) -> [false: bb3, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _15) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb3: { - _8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 - StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 - StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 - return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 - } - - bb4: { StorageLive(_19); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_21); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -222,6 +209,19 @@ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } + bb4: { + _8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 + return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + bb5: { StorageDead(_45); // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_46); // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index 4e362f3556b20..d87cb2af8baac 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -151,23 +151,10 @@ StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(_15) -> [false: bb3, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _15) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb3: { - _8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 - StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 - StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 - return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 - } - - bb4: { StorageLive(_19); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_21); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -222,6 +209,19 @@ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } } + bb4: { + _8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 + return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + bb5: { StorageDead(_45); // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_46); // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL diff --git a/src/test/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir b/src/test/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir index 56df50c089318..f109937dbf937 100644 --- a/src/test/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir +++ b/src/test/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir @@ -16,12 +16,14 @@ fn main() -> () { StorageLive(_1); // scope 0 at $DIR/loop_test.rs:10:5: 12:6 StorageLive(_2); // scope 0 at $DIR/loop_test.rs:10:8: 10:12 _2 = const true; // scope 0 at $DIR/loop_test.rs:10:8: 10:12 - FakeRead(ForMatchedPlace, _2); // scope 0 at $DIR/loop_test.rs:10:8: 10:12 - switchInt(_2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/loop_test.rs:10:5: 12:6 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/loop_test.rs:10:5: 12:6 } bb1: { - falseEdge -> [real: bb3, imaginary: bb2]; // scope 0 at $DIR/loop_test.rs:10:5: 12:6 + _0 = const (); // scope 0 at $DIR/loop_test.rs:11:9: 11:15 + StorageDead(_2); // scope 0 at $DIR/loop_test.rs:12:5: 12:6 + StorageDead(_1); // scope 0 at $DIR/loop_test.rs:12:5: 12:6 + return; // scope 0 at $DIR/loop_test.rs:17:2: 17:2 } bb2: { @@ -29,29 +31,22 @@ fn main() -> () { StorageDead(_2); // scope 0 at $DIR/loop_test.rs:12:5: 12:6 StorageDead(_1); // scope 0 at $DIR/loop_test.rs:12:5: 12:6 StorageLive(_4); // scope 0 at $DIR/loop_test.rs:13:5: 16:6 - goto -> bb4; // scope 0 at $DIR/loop_test.rs:13:5: 16:6 + goto -> bb3; // scope 0 at $DIR/loop_test.rs:13:5: 16:6 } bb3: { - _0 = const (); // scope 0 at $DIR/loop_test.rs:11:9: 11:15 - StorageDead(_2); // scope 0 at $DIR/loop_test.rs:12:5: 12:6 - StorageDead(_1); // scope 0 at $DIR/loop_test.rs:12:5: 12:6 - return; // scope 0 at $DIR/loop_test.rs:17:2: 17:2 + falseUnwind -> [real: bb4, cleanup: bb5]; // scope 0 at $DIR/loop_test.rs:13:5: 16:6 } bb4: { - falseUnwind -> [real: bb5, cleanup: bb6]; // scope 0 at $DIR/loop_test.rs:13:5: 16:6 - } - - bb5: { StorageLive(_6); // scope 0 at $DIR/loop_test.rs:14:13: 14:14 _6 = const 1_i32; // scope 0 at $DIR/loop_test.rs:14:17: 14:18 FakeRead(ForLet, _6); // scope 0 at $DIR/loop_test.rs:14:13: 14:14 StorageDead(_6); // scope 0 at $DIR/loop_test.rs:16:5: 16:6 - goto -> bb4; // scope 0 at $DIR/loop_test.rs:1:1: 1:1 + goto -> bb3; // scope 0 at $DIR/loop_test.rs:1:1: 1:1 } - bb6 (cleanup): { + bb5 (cleanup): { resume; // scope 0 at $DIR/loop_test.rs:6:1: 17:2 } } diff --git a/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir b/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir index 654dd8275c9de..740a6e0edb0c4 100644 --- a/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir +++ b/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir @@ -3,24 +3,28 @@ fn f_u64() -> () { let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:34:16: 34:16 scope 1 (inlined f_dispatch::) { // at $DIR/lower_intrinsics.rs:35:5: 35:21 - debug t => _2; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 - let _1: (); // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 - let mut _2: u64; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + debug t => _1; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + let mut _1: u64; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + let _2: (); // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + let mut _3: u64; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 scope 2 (inlined std::mem::size_of::) { // at $DIR/lower_intrinsics.rs:35:5: 35:21 } } bb0: { - _2 = const 0_u64; // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21 - StorageLive(_1); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 - _1 = f_non_zst::(move _2) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + _1 = const 0_u64; // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21 + StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + _3 = move _1; // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + _2 = f_non_zst::(move _3) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 // mir::Constant // + span: $DIR/lower_intrinsics.rs:35:5: 35:21 // + literal: Const { ty: fn(u64) {f_non_zst::}, val: Value(Scalar()) } } bb1: { - StorageDead(_1); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + StorageDead(_3); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:34:16: 36:2 return; // scope 0 at $DIR/lower_intrinsics.rs:36:2: 36:2 } diff --git a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 4e7cd77035eec..95beab2ec9af7 100644 --- a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -47,7 +47,7 @@ } bb3: { -- falseEdge -> [real: bb14, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:15:25: 15:38 +- falseEdge -> [real: bb13, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:15:25: 15:38 - } - - bb4: { @@ -55,7 +55,7 @@ - } - - bb5: { -- falseEdge -> [real: bb22, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:16:9: 16:21 +- falseEdge -> [real: bb20, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:16:9: 16:21 - } - - bb6: { @@ -63,14 +63,14 @@ _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 -- goto -> bb21; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 +- goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb16; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } - bb7: { + bb4: { _0 = const 1_i32; // scope 1 at $DIR/match-arm-scopes.rs:15:77: 15:78 -- drop(_7) -> [return: bb20, unwind: bb27]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- drop(_7) -> [return: bb18, unwind: bb25]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + drop(_7) -> [return: bb15, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 } @@ -85,33 +85,28 @@ StorageLive(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 StorageLive(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 _10 = _1; // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 -- FakeRead(ForMatchedPlace, _10); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 -- switchInt(_10) -> [false: bb10, otherwise: bb9]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 -+ switchInt(_10) -> [false: bb6, otherwise: bb7]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 +- switchInt(move _10) -> [false: bb10, otherwise: bb9]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ switchInt(move _10) -> [false: bb7, otherwise: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } - bb9: { -- falseEdge -> [real: bb11, imaginary: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 -- } -- -- bb10: { + bb6: { - _9 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:15:70: 15:71 + _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60 StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 -- switchInt(move _9) -> [false: bb13, otherwise: bb12]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 -+ switchInt(move _9) -> [false: bb9, otherwise: bb8]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1 ++ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1 } -- bb11: { +- bb10: { + bb7: { - _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60 + _9 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:15:70: 15:71 StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 -- goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1 -+ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1 +- switchInt(move _9) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ switchInt(move _9) -> [false: bb9, otherwise: bb8]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } -- bb12: { +- bb11: { + bb8: { StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 @@ -126,7 +121,7 @@ + goto -> bb4; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } -- bb13: { +- bb12: { + bb9: { StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 @@ -135,7 +130,7 @@ + goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } -- bb14: { +- bb13: { + bb10: { StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 _6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 @@ -146,33 +141,28 @@ StorageLive(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 StorageLive(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 _13 = _1; // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 -- FakeRead(ForMatchedPlace, _13); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 -- switchInt(_13) -> [false: bb16, otherwise: bb15]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 -+ switchInt(_13) -> [false: bb11, otherwise: bb12]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 +- switchInt(move _13) -> [false: bb15, otherwise: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ switchInt(move _13) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } -- bb15: { -- falseEdge -> [real: bb17, imaginary: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 -- } -- -- bb16: { +- bb14: { + bb11: { - _12 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:15:70: 15:71 + _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60 StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 -- switchInt(move _12) -> [false: bb19, otherwise: bb18]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 -+ switchInt(move _12) -> [false: bb14, otherwise: bb13]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1 ++ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1 } -- bb17: { +- bb15: { + bb12: { - _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60 + _12 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:15:70: 15:71 StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 -- goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1 -+ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1 +- switchInt(move _12) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ switchInt(move _12) -> [false: bb14, otherwise: bb13]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } -- bb18: { +- bb16: { + bb13: { StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 - FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 @@ -187,7 +177,7 @@ + goto -> bb4; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } -- bb19: { +- bb17: { + bb14: { StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 @@ -196,67 +186,67 @@ + goto -> bb2; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 } -- bb20: { +- bb18: { + bb15: { StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 -- goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 +- goto -> bb22; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } -- bb21: { +- bb19: { + bb16: { _0 = const 2_i32; // scope 2 at $DIR/match-arm-scopes.rs:16:41: 16:42 -- drop(_16) -> [return: bb23, unwind: bb27]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 +- drop(_16) -> [return: bb21, unwind: bb25]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 + drop(_16) -> [return: bb18, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 } -- bb22: { +- bb20: { + bb17: { StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 -- goto -> bb21; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 +- goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb16; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } -- bb23: { +- bb21: { + bb18: { StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 -- goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 +- goto -> bb22; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 } -- bb24: { -- drop(_2) -> [return: bb26, unwind: bb28]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 +- bb22: { +- drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 + bb19: { + goto -> bb26; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 } -- bb25: { +- bb23: { + bb20: { StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 -- drop(_2) -> [return: bb26, unwind: bb28]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 +- drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 + drop(_2) -> [return: bb21, unwind: bb23]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 } -- bb26: { +- bb24: { + bb21: { return; // scope 0 at $DIR/match-arm-scopes.rs:18:2: 18:2 } -- bb27 (cleanup): { -- drop(_2) -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 +- bb25 (cleanup): { +- drop(_2) -> bb26; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 + bb22 (cleanup): { + goto -> bb27; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 } -- bb28 (cleanup): { +- bb26 (cleanup): { + bb23 (cleanup): { resume; // scope 0 at $DIR/match-arm-scopes.rs:13:1: 18:2 + } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff index d0b1a96b9aef7..20240348230f2 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff +++ b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff @@ -30,7 +30,7 @@ } bb3: { - switchInt(_2) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/matches_reduce_branches.rs:7:5: 9:6 + switchInt(move _2) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/matches_reduce_branches.rs:7:5: 9:6 } bb4: { @@ -39,7 +39,7 @@ } bb5: { - StorageDead(_2); // scope 0 at $DIR/matches_reduce_branches.rs:10:1: 10:2 + StorageDead(_2); // scope 0 at $DIR/matches_reduce_branches.rs:9:5: 9:6 return; // scope 0 at $DIR/matches_reduce_branches.rs:10:2: 10:2 } } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff index d0b1a96b9aef7..20240348230f2 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff +++ b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff @@ -30,7 +30,7 @@ } bb3: { - switchInt(_2) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/matches_reduce_branches.rs:7:5: 9:6 + switchInt(move _2) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/matches_reduce_branches.rs:7:5: 9:6 } bb4: { @@ -39,7 +39,7 @@ } bb5: { - StorageDead(_2); // scope 0 at $DIR/matches_reduce_branches.rs:10:1: 10:2 + StorageDead(_2); // scope 0 at $DIR/matches_reduce_branches.rs:9:5: 9:6 return; // scope 0 at $DIR/matches_reduce_branches.rs:10:2: 10:2 } } diff --git a/src/test/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.32bit.diff b/src/test/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.32bit.diff index 1f46d3777bed8..1d895852354c9 100644 --- a/src/test/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.32bit.diff +++ b/src/test/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.32bit.diff @@ -25,9 +25,9 @@ StorageLive(_5); // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 StorageLive(_6); // scope 0 at $DIR/matches_reduce_branches.rs:40:24: 40:28 _6 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:24: 40:28 -- switchInt(_6) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 +- switchInt(move _6) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 + StorageLive(_7); // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 -+ _7 = _6; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 ++ _7 = move _6; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 + _5 = Ne(_7, const false); // scope 0 at $DIR/matches_reduce_branches.rs:40:42: 40:47 + StorageDead(_7); // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 + goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 @@ -45,41 +45,41 @@ bb3: { StorageDead(_6); // scope 0 at $DIR/matches_reduce_branches.rs:40:47: 40:48 -- switchInt(_5) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 +- switchInt(move _5) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 + StorageLive(_8); // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 -+ _8 = _5; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 ++ _8 = move _5; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 + _4 = Ne(_8, const false); // scope 0 at $DIR/matches_reduce_branches.rs:40:62: 40:67 + StorageDead(_8); // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 + goto -> bb6; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 } bb4: { - _4 = const false; // scope 0 at $DIR/matches_reduce_branches.rs:40:62: 40:67 + _4 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:50: 40:54 goto -> bb6; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 } bb5: { - _4 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:50: 40:54 + _4 = const false; // scope 0 at $DIR/matches_reduce_branches.rs:40:62: 40:67 goto -> bb6; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 } bb6: { StorageDead(_5); // scope 0 at $DIR/matches_reduce_branches.rs:40:67: 40:68 -- switchInt(_4) -> [false: bb7, otherwise: bb8]; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 +- switchInt(move _4) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 + StorageLive(_9); // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 -+ _9 = _4; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 ++ _9 = move _4; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 + _3 = Ne(_9, const false); // scope 0 at $DIR/matches_reduce_branches.rs:40:82: 40:87 + StorageDead(_9); // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 + goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 } bb7: { - _3 = const false; // scope 0 at $DIR/matches_reduce_branches.rs:40:82: 40:87 + _3 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:70: 40:74 goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 } bb8: { - _3 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:70: 40:74 + _3 = const false; // scope 0 at $DIR/matches_reduce_branches.rs:40:82: 40:87 goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 } diff --git a/src/test/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.64bit.diff b/src/test/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.64bit.diff index 1f46d3777bed8..1d895852354c9 100644 --- a/src/test/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.64bit.diff +++ b/src/test/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.64bit.diff @@ -25,9 +25,9 @@ StorageLive(_5); // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 StorageLive(_6); // scope 0 at $DIR/matches_reduce_branches.rs:40:24: 40:28 _6 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:24: 40:28 -- switchInt(_6) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 +- switchInt(move _6) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 + StorageLive(_7); // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 -+ _7 = _6; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 ++ _7 = move _6; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 + _5 = Ne(_7, const false); // scope 0 at $DIR/matches_reduce_branches.rs:40:42: 40:47 + StorageDead(_7); // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 + goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:40:21: 40:48 @@ -45,41 +45,41 @@ bb3: { StorageDead(_6); // scope 0 at $DIR/matches_reduce_branches.rs:40:47: 40:48 -- switchInt(_5) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 +- switchInt(move _5) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 + StorageLive(_8); // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 -+ _8 = _5; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 ++ _8 = move _5; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 + _4 = Ne(_8, const false); // scope 0 at $DIR/matches_reduce_branches.rs:40:62: 40:67 + StorageDead(_8); // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 + goto -> bb6; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 } bb4: { - _4 = const false; // scope 0 at $DIR/matches_reduce_branches.rs:40:62: 40:67 + _4 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:50: 40:54 goto -> bb6; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 } bb5: { - _4 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:50: 40:54 + _4 = const false; // scope 0 at $DIR/matches_reduce_branches.rs:40:62: 40:67 goto -> bb6; // scope 0 at $DIR/matches_reduce_branches.rs:40:18: 40:68 } bb6: { StorageDead(_5); // scope 0 at $DIR/matches_reduce_branches.rs:40:67: 40:68 -- switchInt(_4) -> [false: bb7, otherwise: bb8]; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 +- switchInt(move _4) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 + StorageLive(_9); // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 -+ _9 = _4; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 ++ _9 = move _4; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 + _3 = Ne(_9, const false); // scope 0 at $DIR/matches_reduce_branches.rs:40:82: 40:87 + StorageDead(_9); // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 + goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 } bb7: { - _3 = const false; // scope 0 at $DIR/matches_reduce_branches.rs:40:82: 40:87 + _3 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:70: 40:74 goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 } bb8: { - _3 = const true; // scope 0 at $DIR/matches_reduce_branches.rs:40:70: 40:74 + _3 = const false; // scope 0 at $DIR/matches_reduce_branches.rs:40:82: 40:87 goto -> bb9; // scope 0 at $DIR/matches_reduce_branches.rs:40:15: 40:88 } diff --git a/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff b/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff index 997c021d2ef21..fb25cb90021f3 100644 --- a/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff +++ b/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff @@ -9,21 +9,21 @@ bb0: { StorageLive(_2); // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9 _2 = _1; // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9 - switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6 } bb1: { - _0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:7:12: 9:6 + _0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:5:10: 7:6 goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6 } bb2: { - _0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:5:10: 7:6 + _0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:7:12: 9:6 goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6 } bb3: { - StorageDead(_2); // scope 0 at $DIR/multiple_return_terminators.rs:10:1: 10:2 + StorageDead(_2); // scope 0 at $DIR/multiple_return_terminators.rs:9:5: 9:6 return; // scope 0 at $DIR/multiple_return_terminators.rs:10:2: 10:2 } } diff --git a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir index d8538a5461ed6..8c939d5fc3da5 100644 --- a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir +++ b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir @@ -5,19 +5,19 @@ | '_#1r | Local | ['_#1r] | | Inferred Region Values -| '_#0r | U0 | {bb0[0..=8], bb1[0..=8], bb2[0], bb3[0..=1], bb4[0..=3], bb5[0..=3], bb6[0..=2], bb7[0..=5], bb8[0], '_#0r, '_#1r} -| '_#1r | U0 | {bb0[0..=8], bb1[0..=8], bb2[0], bb3[0..=1], bb4[0..=3], bb5[0..=3], bb6[0..=2], bb7[0..=5], bb8[0], '_#1r} +| '_#0r | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=1], bb4[0..=3], bb5[0..=2], bb6[0..=5], bb7[0], '_#0r, '_#1r} +| '_#1r | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=1], bb4[0..=3], bb5[0..=2], bb6[0..=5], bb7[0], '_#1r} | '_#2r | U0 | {} -| '_#3r | U0 | {bb1[0..=8], bb2[0], bb4[0..=2]} -| '_#4r | U0 | {bb1[1..=8], bb2[0], bb4[0..=2]} -| '_#5r | U0 | {bb1[4..=8], bb2[0], bb4[0..=2]} +| '_#3r | U0 | {bb1[0..=7], bb2[0..=2]} +| '_#4r | U0 | {bb1[1..=7], bb2[0..=2]} +| '_#5r | U0 | {bb1[4..=7], bb2[0..=2]} | | Inference Constraints -| '_#0r live at {bb0[0..=8], bb1[0..=8], bb2[0], bb3[0..=1], bb4[0..=3], bb5[0..=3], bb6[0..=2], bb7[0..=5], bb8[0]} -| '_#1r live at {bb0[0..=8], bb1[0..=8], bb2[0], bb3[0..=1], bb4[0..=3], bb5[0..=3], bb6[0..=2], bb7[0..=5], bb8[0]} +| '_#0r live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=1], bb4[0..=3], bb5[0..=2], bb6[0..=5], bb7[0]} +| '_#1r live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=1], bb4[0..=3], bb5[0..=2], bb6[0..=5], bb7[0]} | '_#3r live at {bb1[0]} | '_#4r live at {bb1[1..=3]} -| '_#5r live at {bb1[4..=8], bb2[0], bb4[0..=2]} +| '_#5r live at {bb1[4..=7], bb2[0..=2]} | '_#3r: '_#4r due to Assignment at Single(bb1[0]) | '_#4r: '_#5r due to Assignment at Single(bb1[3]) | @@ -52,7 +52,7 @@ fn main() -> () { _3 = const Const(Value(Scalar(0x00000000)): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:18:16: 18:17 _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:18:14: 18:18 _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:18:14: 18:18 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb8]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:18:14: 18:18 + assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:18:14: 18:18 } bb1: { @@ -63,55 +63,50 @@ fn main() -> () { FakeRead(ForLet, _6); // bb1[4]: scope 2 at $DIR/region-subtyping-basic.rs:19:9: 19:10 StorageLive(_7); // bb1[5]: scope 3 at $DIR/region-subtyping-basic.rs:20:8: 20:12 _7 = const Const(Value(Scalar(0x01)): bool); // bb1[6]: scope 3 at $DIR/region-subtyping-basic.rs:20:8: 20:12 - FakeRead(ForMatchedPlace, _7); // bb1[7]: scope 3 at $DIR/region-subtyping-basic.rs:20:8: 20:12 - switchInt(_7) -> [Const(Value(Scalar(0x00)): bool): bb3, otherwise: bb2]; // bb1[8]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 + switchInt(move _7) -> [Const(Value(Scalar(0x00)): bool): bb3, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 } bb2: { - falseEdge -> [real: bb4, imaginary: bb3]; // bb2[0]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 + StorageLive(_8); // bb2[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + StorageLive(_9); // bb2[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:15: 21:17 + _9 = (*_6); // bb2[2]: scope 3 at $DIR/region-subtyping-basic.rs:21:15: 21:17 + _8 = Const(Value(Scalar()): fn(usize) -> bool {use_x})(move _9) -> [return: bb4, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14 + // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar()) } } bb3: { StorageLive(_10); // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:23:9: 23:18 - _10 = Const(Value(Scalar()): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x00000016)): usize)) -> [return: bb6, unwind: bb8]; // bb3[1]: scope 3 at $DIR/region-subtyping-basic.rs:23:9: 23:18 + _10 = Const(Value(Scalar()): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x00000016)): usize)) -> [return: bb5, unwind: bb7]; // bb3[1]: scope 3 at $DIR/region-subtyping-basic.rs:23:9: 23:18 // mir::Constant // + span: $DIR/region-subtyping-basic.rs:23:9: 23:14 // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar()) } } bb4: { - StorageLive(_8); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 - StorageLive(_9); // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:15: 21:17 - _9 = (*_6); // bb4[2]: scope 3 at $DIR/region-subtyping-basic.rs:21:15: 21:17 - _8 = Const(Value(Scalar()): fn(usize) -> bool {use_x})(move _9) -> [return: bb5, unwind: bb8]; // bb4[3]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 - // mir::Constant - // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14 - // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar()) } + StorageDead(_9); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:17: 21:18 + StorageDead(_8); // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:18: 21:19 + _0 = const Const(Value(Scalar()): ()); // bb4[2]: scope 3 at $DIR/region-subtyping-basic.rs:20:13: 22:6 + goto -> bb6; // bb4[3]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 } bb5: { - StorageDead(_9); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:17: 21:18 - StorageDead(_8); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:18: 21:19 - _0 = const Const(Value(Scalar()): ()); // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:20:13: 22:6 - goto -> bb7; // bb5[3]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 + StorageDead(_10); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:23:18: 23:19 + _0 = const Const(Value(Scalar()): ()); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:22:12: 24:6 + goto -> bb6; // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 } bb6: { - StorageDead(_10); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:23:18: 23:19 - _0 = const Const(Value(Scalar()): ()); // bb6[1]: scope 3 at $DIR/region-subtyping-basic.rs:22:12: 24:6 - goto -> bb7; // bb6[2]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 - } - - bb7: { - StorageDead(_6); // bb7[0]: scope 2 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - StorageDead(_3); // bb7[1]: scope 1 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - StorageDead(_2); // bb7[2]: scope 1 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - StorageDead(_1); // bb7[3]: scope 0 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - StorageDead(_7); // bb7[4]: scope 0 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - return; // bb7[5]: scope 0 at $DIR/region-subtyping-basic.rs:25:2: 25:2 + StorageDead(_7); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:24:5: 24:6 + StorageDead(_6); // bb6[1]: scope 2 at $DIR/region-subtyping-basic.rs:25:1: 25:2 + StorageDead(_3); // bb6[2]: scope 1 at $DIR/region-subtyping-basic.rs:25:1: 25:2 + StorageDead(_2); // bb6[3]: scope 1 at $DIR/region-subtyping-basic.rs:25:1: 25:2 + StorageDead(_1); // bb6[4]: scope 0 at $DIR/region-subtyping-basic.rs:25:1: 25:2 + return; // bb6[5]: scope 0 at $DIR/region-subtyping-basic.rs:25:2: 25:2 } - bb8 (cleanup): { - resume; // bb8[0]: scope 0 at $DIR/region-subtyping-basic.rs:16:1: 25:2 + bb7 (cleanup): { + resume; // bb7[0]: scope 0 at $DIR/region-subtyping-basic.rs:16:1: 25:2 } } diff --git a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir index 15aba40f169cd..00704baa6c19f 100644 --- a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir +++ b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir @@ -5,19 +5,19 @@ | '_#1r | Local | ['_#1r] | | Inferred Region Values -| '_#0r | U0 | {bb0[0..=8], bb1[0..=8], bb2[0], bb3[0..=1], bb4[0..=3], bb5[0..=3], bb6[0..=2], bb7[0..=5], bb8[0], '_#0r, '_#1r} -| '_#1r | U0 | {bb0[0..=8], bb1[0..=8], bb2[0], bb3[0..=1], bb4[0..=3], bb5[0..=3], bb6[0..=2], bb7[0..=5], bb8[0], '_#1r} +| '_#0r | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=1], bb4[0..=3], bb5[0..=2], bb6[0..=5], bb7[0], '_#0r, '_#1r} +| '_#1r | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=1], bb4[0..=3], bb5[0..=2], bb6[0..=5], bb7[0], '_#1r} | '_#2r | U0 | {} -| '_#3r | U0 | {bb1[0..=8], bb2[0], bb4[0..=2]} -| '_#4r | U0 | {bb1[1..=8], bb2[0], bb4[0..=2]} -| '_#5r | U0 | {bb1[4..=8], bb2[0], bb4[0..=2]} +| '_#3r | U0 | {bb1[0..=7], bb2[0..=2]} +| '_#4r | U0 | {bb1[1..=7], bb2[0..=2]} +| '_#5r | U0 | {bb1[4..=7], bb2[0..=2]} | | Inference Constraints -| '_#0r live at {bb0[0..=8], bb1[0..=8], bb2[0], bb3[0..=1], bb4[0..=3], bb5[0..=3], bb6[0..=2], bb7[0..=5], bb8[0]} -| '_#1r live at {bb0[0..=8], bb1[0..=8], bb2[0], bb3[0..=1], bb4[0..=3], bb5[0..=3], bb6[0..=2], bb7[0..=5], bb8[0]} +| '_#0r live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=1], bb4[0..=3], bb5[0..=2], bb6[0..=5], bb7[0]} +| '_#1r live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=1], bb4[0..=3], bb5[0..=2], bb6[0..=5], bb7[0]} | '_#3r live at {bb1[0]} | '_#4r live at {bb1[1..=3]} -| '_#5r live at {bb1[4..=8], bb2[0], bb4[0..=2]} +| '_#5r live at {bb1[4..=7], bb2[0..=2]} | '_#3r: '_#4r due to Assignment at Single(bb1[0]) | '_#4r: '_#5r due to Assignment at Single(bb1[3]) | @@ -52,7 +52,7 @@ fn main() -> () { _3 = const Const(Value(Scalar(0x0000000000000000)): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:18:16: 18:17 _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:18:14: 18:18 _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:18:14: 18:18 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb8]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:18:14: 18:18 + assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:18:14: 18:18 } bb1: { @@ -63,55 +63,50 @@ fn main() -> () { FakeRead(ForLet, _6); // bb1[4]: scope 2 at $DIR/region-subtyping-basic.rs:19:9: 19:10 StorageLive(_7); // bb1[5]: scope 3 at $DIR/region-subtyping-basic.rs:20:8: 20:12 _7 = const Const(Value(Scalar(0x01)): bool); // bb1[6]: scope 3 at $DIR/region-subtyping-basic.rs:20:8: 20:12 - FakeRead(ForMatchedPlace, _7); // bb1[7]: scope 3 at $DIR/region-subtyping-basic.rs:20:8: 20:12 - switchInt(_7) -> [Const(Value(Scalar(0x00)): bool): bb3, otherwise: bb2]; // bb1[8]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 + switchInt(move _7) -> [Const(Value(Scalar(0x00)): bool): bb3, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 } bb2: { - falseEdge -> [real: bb4, imaginary: bb3]; // bb2[0]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 + StorageLive(_8); // bb2[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + StorageLive(_9); // bb2[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:15: 21:17 + _9 = (*_6); // bb2[2]: scope 3 at $DIR/region-subtyping-basic.rs:21:15: 21:17 + _8 = Const(Value(Scalar()): fn(usize) -> bool {use_x})(move _9) -> [return: bb4, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14 + // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar()) } } bb3: { StorageLive(_10); // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:23:9: 23:18 - _10 = Const(Value(Scalar()): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x0000000000000016)): usize)) -> [return: bb6, unwind: bb8]; // bb3[1]: scope 3 at $DIR/region-subtyping-basic.rs:23:9: 23:18 + _10 = Const(Value(Scalar()): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x0000000000000016)): usize)) -> [return: bb5, unwind: bb7]; // bb3[1]: scope 3 at $DIR/region-subtyping-basic.rs:23:9: 23:18 // mir::Constant // + span: $DIR/region-subtyping-basic.rs:23:9: 23:14 // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar()) } } bb4: { - StorageLive(_8); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 - StorageLive(_9); // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:15: 21:17 - _9 = (*_6); // bb4[2]: scope 3 at $DIR/region-subtyping-basic.rs:21:15: 21:17 - _8 = Const(Value(Scalar()): fn(usize) -> bool {use_x})(move _9) -> [return: bb5, unwind: bb8]; // bb4[3]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 - // mir::Constant - // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14 - // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar()) } + StorageDead(_9); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:17: 21:18 + StorageDead(_8); // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:18: 21:19 + _0 = const Const(Value(Scalar()): ()); // bb4[2]: scope 3 at $DIR/region-subtyping-basic.rs:20:13: 22:6 + goto -> bb6; // bb4[3]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 } bb5: { - StorageDead(_9); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:17: 21:18 - StorageDead(_8); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:18: 21:19 - _0 = const Const(Value(Scalar()): ()); // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:20:13: 22:6 - goto -> bb7; // bb5[3]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 + StorageDead(_10); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:23:18: 23:19 + _0 = const Const(Value(Scalar()): ()); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:22:12: 24:6 + goto -> bb6; // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 } bb6: { - StorageDead(_10); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:23:18: 23:19 - _0 = const Const(Value(Scalar()): ()); // bb6[1]: scope 3 at $DIR/region-subtyping-basic.rs:22:12: 24:6 - goto -> bb7; // bb6[2]: scope 3 at $DIR/region-subtyping-basic.rs:20:5: 24:6 - } - - bb7: { - StorageDead(_6); // bb7[0]: scope 2 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - StorageDead(_3); // bb7[1]: scope 1 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - StorageDead(_2); // bb7[2]: scope 1 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - StorageDead(_1); // bb7[3]: scope 0 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - StorageDead(_7); // bb7[4]: scope 0 at $DIR/region-subtyping-basic.rs:25:1: 25:2 - return; // bb7[5]: scope 0 at $DIR/region-subtyping-basic.rs:25:2: 25:2 + StorageDead(_7); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:24:5: 24:6 + StorageDead(_6); // bb6[1]: scope 2 at $DIR/region-subtyping-basic.rs:25:1: 25:2 + StorageDead(_3); // bb6[2]: scope 1 at $DIR/region-subtyping-basic.rs:25:1: 25:2 + StorageDead(_2); // bb6[3]: scope 1 at $DIR/region-subtyping-basic.rs:25:1: 25:2 + StorageDead(_1); // bb6[4]: scope 0 at $DIR/region-subtyping-basic.rs:25:1: 25:2 + return; // bb6[5]: scope 0 at $DIR/region-subtyping-basic.rs:25:2: 25:2 } - bb8 (cleanup): { - resume; // bb8[0]: scope 0 at $DIR/region-subtyping-basic.rs:16:1: 25:2 + bb7 (cleanup): { + resume; // bb7[0]: scope 0 at $DIR/region-subtyping-basic.rs:16:1: 25:2 } } diff --git a/src/test/mir-opt/simplify_cfg.main.SimplifyCfg-early-opt.diff b/src/test/mir-opt/simplify_cfg.main.SimplifyCfg-early-opt.diff index 5588877aec950..52e705fdbeba8 100644 --- a/src/test/mir-opt/simplify_cfg.main.SimplifyCfg-early-opt.diff +++ b/src/test/mir-opt/simplify_cfg.main.SimplifyCfg-early-opt.diff @@ -21,31 +21,26 @@ } - bb2: { -- nop; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 -- switchInt(_2) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 +- switchInt(move _2) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 + bb1: { -+ switchInt(_2) -> [false: bb2, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 ++ switchInt(move _2) -> [false: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 } - bb3: { -- goto -> bb5; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 -- } -- -- bb4: { + bb2: { - _1 = const (); // scope 0 at $DIR/simplify_cfg.rs:9:10: 9:10 - StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 - goto -> bb0; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 + _0 = const (); // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 + StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10 + return; // scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 } -- bb5: { +- bb4: { + bb3: { - _0 = const (); // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 - StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 - return; // scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 + _1 = const (); // scope 0 at $DIR/simplify_cfg.rs:9:10: 9:10 + StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10 + goto -> bb0; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 - } - -- bb6 (cleanup): { +- bb5 (cleanup): { - resume; // scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2 } } diff --git a/src/test/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff b/src/test/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff index e62935225d805..fef3ae2e461d8 100644 --- a/src/test/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff +++ b/src/test/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff @@ -9,69 +9,63 @@ bb0: { - goto -> bb1; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 -+ falseUnwind -> [real: bb1, cleanup: bb6]; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 ++ falseUnwind -> [real: bb1, cleanup: bb5]; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 } bb1: { -- falseUnwind -> [real: bb2, cleanup: bb11]; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 +- falseUnwind -> [real: bb2, cleanup: bb10]; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 - } - - bb2: { StorageLive(_2); // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 -- _2 = bar() -> [return: bb3, unwind: bb11]; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 -+ _2 = bar() -> [return: bb2, unwind: bb6]; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 +- _2 = bar() -> [return: bb3, unwind: bb10]; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 ++ _2 = bar() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 // mir::Constant // + span: $DIR/simplify_cfg.rs:7:12: 7:15 // + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar()) } } - bb3: { +- switchInt(move _2) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 + bb2: { - FakeRead(ForMatchedPlace, _2); // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 -- switchInt(_2) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 -+ switchInt(_2) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 ++ switchInt(move _2) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 } - bb4: { -- falseEdge -> [real: bb6, imaginary: bb5]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 + bb3: { -+ falseEdge -> [real: bb5, imaginary: bb4]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 + _0 = const (); // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 +- goto -> bb9; // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 ++ StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10 ++ return; // scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 } - bb5: { + bb4: { _1 = const (); // scope 0 at $DIR/simplify_cfg.rs:9:10: 9:10 -- goto -> bb9; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 -+ StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 -+ goto -> bb0; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 - } - -- bb6: { -+ bb5: { - _0 = const (); // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 -- goto -> bb10; // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 +- goto -> bb8; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 - } - -- bb7: { +- bb6: { - unreachable; // scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10 - } - -- bb8: { -- goto -> bb9; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 +- bb7: { +- goto -> bb8; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 - } - -- bb9: { - StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 +- bb8: { + StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10 - goto -> bb1; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 -- } -- -- bb10: { -- StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 - return; // scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 ++ goto -> bb0; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 } -- bb11 (cleanup): { -+ bb6 (cleanup): { +- bb9: { +- StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10 +- return; // scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 +- } +- +- bb10 (cleanup): { ++ bb5 (cleanup): { resume; // scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2 } } diff --git a/src/test/mir-opt/simplify_if.main.SimplifyBranches-after-const-prop.diff b/src/test/mir-opt/simplify_if.main.SimplifyBranches-after-const-prop.diff index bf3caf505eda1..2cd57cb8474ec 100644 --- a/src/test/mir-opt/simplify_if.main.SimplifyBranches-after-const-prop.diff +++ b/src/test/mir-opt/simplify_if.main.SimplifyBranches-after-const-prop.diff @@ -9,16 +9,11 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/simplify_if.rs:6:8: 6:13 _1 = const false; // scope 0 at $DIR/simplify_if.rs:6:8: 6:13 -- switchInt(const false) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_if.rs:6:5: 8:6 -+ goto -> bb1; // scope 0 at $DIR/simplify_if.rs:6:5: 8:6 +- switchInt(const false) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_if.rs:6:5: 8:6 ++ goto -> bb2; // scope 0 at $DIR/simplify_if.rs:6:5: 8:6 } bb1: { - _0 = const (); // scope 0 at $DIR/simplify_if.rs:8:6: 8:6 - goto -> bb4; // scope 0 at $DIR/simplify_if.rs:6:5: 8:6 - } - - bb2: { StorageLive(_2); // scope 0 at $DIR/simplify_if.rs:7:9: 7:15 _2 = noop() -> bb3; // scope 0 at $DIR/simplify_if.rs:7:9: 7:15 // mir::Constant @@ -26,6 +21,11 @@ // + literal: Const { ty: fn() {noop}, val: Value(Scalar()) } } + bb2: { + _0 = const (); // scope 0 at $DIR/simplify_if.rs:8:6: 8:6 + goto -> bb4; // scope 0 at $DIR/simplify_if.rs:6:5: 8:6 + } + bb3: { StorageDead(_2); // scope 0 at $DIR/simplify_if.rs:7:15: 7:16 _0 = const (); // scope 0 at $DIR/simplify_if.rs:6:14: 8:6 @@ -33,7 +33,7 @@ } bb4: { - StorageDead(_1); // scope 0 at $DIR/simplify_if.rs:9:1: 9:2 + StorageDead(_1); // scope 0 at $DIR/simplify_if.rs:8:5: 8:6 return; // scope 0 at $DIR/simplify_if.rs:9:2: 9:2 } } diff --git a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff index 9f7507a5cadb2..70725e5f14f7d 100644 --- a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff @@ -47,21 +47,21 @@ _8 = _6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 _7 = Gt(move _8, const 42_u8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 StorageDead(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20 - switchInt(_7) -> [false: bb4, otherwise: bb5]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 + switchInt(move _7) -> [false: bb5, otherwise: bb4]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 } bb4: { - _0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:10: 7:10 + _0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:21: 7:10 goto -> bb6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 } bb5: { - _0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:21: 7:10 + _0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:10: 7:10 goto -> bb6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 } bb6: { - StorageDead(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6 + StorageDead(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10 StorageDead(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6 goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 } diff --git a/src/test/mir-opt/unreachable.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable.main.UnreachablePropagation.diff index 6f44de1e4a4f5..23a3fbd5f4651 100644 --- a/src/test/mir-opt/unreachable.main.UnreachablePropagation.diff +++ b/src/test/mir-opt/unreachable.main.UnreachablePropagation.diff @@ -44,18 +44,18 @@ - StorageLive(_5); // scope 2 at $DIR/unreachable.rs:12:9: 16:10 - StorageLive(_6); // scope 2 at $DIR/unreachable.rs:12:12: 12:16 - _6 = const true; // scope 2 at $DIR/unreachable.rs:12:12: 12:16 -- switchInt(_6) -> [false: bb4, otherwise: bb5]; // scope 2 at $DIR/unreachable.rs:12:9: 16:10 +- switchInt(move _6) -> [false: bb5, otherwise: bb4]; // scope 2 at $DIR/unreachable.rs:12:9: 16:10 - } - - bb4: { -- _4 = const 42_i32; // scope 2 at $DIR/unreachable.rs:15:13: 15:20 -- _5 = const (); // scope 2 at $DIR/unreachable.rs:14:16: 16:10 +- _4 = const 21_i32; // scope 2 at $DIR/unreachable.rs:13:13: 13:20 +- _5 = const (); // scope 2 at $DIR/unreachable.rs:12:17: 14:10 - goto -> bb6; // scope 2 at $DIR/unreachable.rs:12:9: 16:10 - } - - bb5: { -- _4 = const 21_i32; // scope 2 at $DIR/unreachable.rs:13:13: 13:20 -- _5 = const (); // scope 2 at $DIR/unreachable.rs:12:17: 14:10 +- _4 = const 42_i32; // scope 2 at $DIR/unreachable.rs:15:13: 15:20 +- _5 = const (); // scope 2 at $DIR/unreachable.rs:14:16: 16:10 - goto -> bb6; // scope 2 at $DIR/unreachable.rs:12:9: 16:10 - } - diff --git a/src/test/mir-opt/unreachable_asm.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_asm.main.UnreachablePropagation.diff index 9bca06a3e2b28..3eda18317057b 100644 --- a/src/test/mir-opt/unreachable_asm.main.UnreachablePropagation.diff +++ b/src/test/mir-opt/unreachable_asm.main.UnreachablePropagation.diff @@ -46,18 +46,18 @@ StorageLive(_5); // scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 StorageLive(_6); // scope 2 at $DIR/unreachable_asm.rs:14:12: 14:16 _6 = const true; // scope 2 at $DIR/unreachable_asm.rs:14:12: 14:16 - switchInt(_6) -> [false: bb4, otherwise: bb5]; // scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 + switchInt(move _6) -> [false: bb5, otherwise: bb4]; // scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 } bb4: { - _4 = const 42_i32; // scope 2 at $DIR/unreachable_asm.rs:17:13: 17:20 - _5 = const (); // scope 2 at $DIR/unreachable_asm.rs:16:16: 18:10 + _4 = const 21_i32; // scope 2 at $DIR/unreachable_asm.rs:15:13: 15:20 + _5 = const (); // scope 2 at $DIR/unreachable_asm.rs:14:17: 16:10 goto -> bb6; // scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 } bb5: { - _4 = const 21_i32; // scope 2 at $DIR/unreachable_asm.rs:15:13: 15:20 - _5 = const (); // scope 2 at $DIR/unreachable_asm.rs:14:17: 16:10 + _4 = const 42_i32; // scope 2 at $DIR/unreachable_asm.rs:17:13: 17:20 + _5 = const (); // scope 2 at $DIR/unreachable_asm.rs:16:16: 18:10 goto -> bb6; // scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 } diff --git a/src/test/mir-opt/unreachable_asm_2.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_asm_2.main.UnreachablePropagation.diff index cbc24eab0f568..d0d52e869d624 100644 --- a/src/test/mir-opt/unreachable_asm_2.main.UnreachablePropagation.diff +++ b/src/test/mir-opt/unreachable_asm_2.main.UnreachablePropagation.diff @@ -49,21 +49,10 @@ StorageLive(_5); // scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 StorageLive(_6); // scope 2 at $DIR/unreachable_asm_2.rs:14:12: 14:16 _6 = const true; // scope 2 at $DIR/unreachable_asm_2.rs:14:12: 14:16 - switchInt(_6) -> [false: bb4, otherwise: bb5]; // scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 + switchInt(move _6) -> [false: bb5, otherwise: bb4]; // scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 } bb4: { - StorageLive(_8); // scope 2 at $DIR/unreachable_asm_2.rs:20:13: 20:41 - llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // scope 4 at $DIR/unreachable_asm_2.rs:20:22: 20:39 - _8 = const (); // scope 4 at $DIR/unreachable_asm_2.rs:20:13: 20:41 - StorageDead(_8); // scope 2 at $DIR/unreachable_asm_2.rs:20:40: 20:41 - _4 = const 42_i32; // scope 2 at $DIR/unreachable_asm_2.rs:21:13: 21:20 - _5 = const (); // scope 2 at $DIR/unreachable_asm_2.rs:18:16: 22:10 -- goto -> bb6; // scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 -+ unreachable; // scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 - } - - bb5: { StorageLive(_7); // scope 2 at $DIR/unreachable_asm_2.rs:16:13: 16:41 llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // scope 3 at $DIR/unreachable_asm_2.rs:16:22: 16:39 _7 = const (); // scope 3 at $DIR/unreachable_asm_2.rs:16:13: 16:41 @@ -71,6 +60,17 @@ _4 = const 21_i32; // scope 2 at $DIR/unreachable_asm_2.rs:17:13: 17:20 _5 = const (); // scope 2 at $DIR/unreachable_asm_2.rs:14:17: 18:10 - goto -> bb6; // scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 ++ unreachable; // scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 + } + + bb5: { + StorageLive(_8); // scope 2 at $DIR/unreachable_asm_2.rs:20:13: 20:41 + llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // scope 4 at $DIR/unreachable_asm_2.rs:20:22: 20:39 + _8 = const (); // scope 4 at $DIR/unreachable_asm_2.rs:20:13: 20:41 + StorageDead(_8); // scope 2 at $DIR/unreachable_asm_2.rs:20:40: 20:41 + _4 = const 42_i32; // scope 2 at $DIR/unreachable_asm_2.rs:21:13: 21:20 + _5 = const (); // scope 2 at $DIR/unreachable_asm_2.rs:18:16: 22:10 +- goto -> bb6; // scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 - } - - bb6: { diff --git a/src/test/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff index fd8286f1c4f39..2c0cc04085efa 100644 --- a/src/test/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff +++ b/src/test/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff @@ -45,16 +45,11 @@ StorageLive(_5); // scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 StorageLive(_6); // scope 2 at $DIR/unreachable_diverging.rs:15:12: 15:13 _6 = _1; // scope 2 at $DIR/unreachable_diverging.rs:15:12: 15:13 -- switchInt(_6) -> [false: bb4, otherwise: bb5]; // scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 +- switchInt(move _6) -> [false: bb5, otherwise: bb4]; // scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 + goto -> bb4; // scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 } bb4: { -- _5 = const (); // scope 2 at $DIR/unreachable_diverging.rs:17:10: 17:10 -- goto -> bb6; // scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 -- } -- -- bb5: { - _5 = loop_forever() -> bb6; // scope 2 at $DIR/unreachable_diverging.rs:16:13: 16:27 + _5 = loop_forever() -> bb5; // scope 2 at $DIR/unreachable_diverging.rs:16:13: 16:27 // mir::Constant @@ -62,8 +57,12 @@ // + literal: Const { ty: fn() {loop_forever}, val: Value(Scalar()) } } + bb5: { +- _5 = const (); // scope 2 at $DIR/unreachable_diverging.rs:17:10: 17:10 +- goto -> bb6; // scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 +- } +- - bb6: { -+ bb5: { StorageDead(_6); // scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10 StorageDead(_5); // scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10 StorageLive(_7); // scope 2 at $DIR/unreachable_diverging.rs:18:9: 18:22 diff --git a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir index c27c68d870247..0c034891a80db 100644 --- a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir +++ b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir @@ -40,19 +40,19 @@ fn while_loop(_1: bool) -> () { bb4: { StorageDead(_5); // scope 0 at $DIR/while-storage.rs:11:22: 11:23 - switchInt(_4) -> [false: bb5, otherwise: bb6]; // scope 0 at $DIR/while-storage.rs:11:9: 13:10 + switchInt(move _4) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/while-storage.rs:11:9: 13:10 } bb5: { - StorageDead(_4); // scope 0 at $DIR/while-storage.rs:14:5: 14:6 - StorageDead(_2); // scope 0 at $DIR/while-storage.rs:14:5: 14:6 - goto -> bb0; // scope 0 at $DIR/while-storage.rs:10:5: 14:6 + _0 = const (); // scope 0 at $DIR/while-storage.rs:12:13: 12:18 + StorageDead(_4); // scope 0 at $DIR/while-storage.rs:13:9: 13:10 + goto -> bb7; // scope 0 at $DIR/while-storage.rs:1:1: 1:1 } bb6: { - _0 = const (); // scope 0 at $DIR/while-storage.rs:12:13: 12:18 - StorageDead(_4); // scope 0 at $DIR/while-storage.rs:14:5: 14:6 - goto -> bb7; // scope 0 at $DIR/while-storage.rs:1:1: 1:1 + StorageDead(_4); // scope 0 at $DIR/while-storage.rs:13:9: 13:10 + StorageDead(_2); // scope 0 at $DIR/while-storage.rs:14:5: 14:6 + goto -> bb0; // scope 0 at $DIR/while-storage.rs:10:5: 14:6 } bb7: { diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.abort/abort.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.abort/abort.main.-------.InstrumentCoverage.0.html index 9834124694ec7..176587af25be0 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.abort/abort.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.abort/abort.main.-------.InstrumentCoverage.0.html @@ -77,27 +77,24 @@ 16:11-16:24: @2[3]: _4 = Gt(move _5, const 0_i32) 16:11-16:24: @2[5]: FakeRead(ForMatchedPlace, _4)">@1,2⦊countdown > 0⦉@1,2
{ if @3,5⦊countdown < 5⦉@3,5 @6,8,9⦊{ - might_abort(false); - }⦉@6,8,9@7⦊⦉@7 +17:12-17:25: @5[4]: _7 = Lt(move _8, const 5_i32)">@3,5⦊countdown < 5⦉@3,5 @6,8⦊{ + might_abort(false); + }⦉@6,8@7⦊⦉@7 // See discussion (below the `Notes` section) on coverage results for the closing brace. - if @10⦊countdown < 5⦉@10 @11,13,14⦊{ might_abort(false); }⦉@11,13,14@12⦊⦉@12 // Counts for different regions on one line. + if @9⦊countdown < 5⦉@9 @10,12⦊{ might_abort(false); }⦉@10,12@11⦊⦉@11 // Counts for different regions on one line. // For the following example, the closing brace is the last character on the line. // This shows the character after the closing brace is highlighted, even if that next // character is a newline. - if @15⦊countdown < 5⦉@15 @16,18,19⦊{ might_abort(false); }⦉@16,18,19@17⦊⦉@17 - @20,21⦊countdown -= 1⦉@20,21; + if @13⦊countdown < 5⦉@13 @14,16⦊{ might_abort(false); }⦉@14,16@15⦊⦉@15 + @17,18⦊countdown -= 1⦉@17,18; } @0⦊fn might_abort(should_abort: bool) ⦉@0{ - if @0⦊should_abort⦉@0 { - @1,3,4,5⦊println!("aborting..."); - panic!("panics and aborts");⦉@1,3,4,5 + if @0⦊should_abort⦉@0 { + @1,3,4⦊println!("aborting..."); + panic!("panics and aborts");⦉@1,3,4 } else @2,6,7⦊{ +10:9-10:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +10:9-10:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] +10:9-10:33: @6[5]: _18 = const () +9:12-11:6: @6[7]: _0 = const () +12:2-12:2: @6.Return: return">@2,5,6⦊{ println!("Don't Panic"); +10:9-10:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +10:9-10:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] +10:9-10:33: @6[5]: _18 = const () +9:12-11:6: @6[7]: _0 = const () +12:2-12:2: @6.Return: return"> println!("Don't Panic"); } +10:9-10:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +10:9-10:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] +10:9-10:33: @6[5]: _18 = const () +9:12-11:6: @6[7]: _0 = const () +12:2-12:2: @6.Return: return"> } }⦉@2,6,7 +10:9-10:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +10:9-10:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] +10:9-10:33: @6[5]: _18 = const () +9:12-11:6: @6[7]: _0 = const () +12:2-12:2: @6.Return: return">}⦉@2,5,6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.assert/assert.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.assert/assert.main.-------.InstrumentCoverage.0.html index f24de8e08432a..365e94cd31e50 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.assert/assert.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.assert/assert.main.-------.InstrumentCoverage.0.html @@ -77,22 +77,20 @@ 11:11-11:24: @2[3]: _4 = Gt(move _5, const 0_i32) 11:11-11:24: @2[5]: FakeRead(ForMatchedPlace, _4)">@1,2⦊countdown > 0⦉@1,2 { if @3,5⦊countdown == 1⦉@3,5 @6,8,9⦊{ - might_fail_assert(3); - }⦉@6,8,9 else if @7⦊countdown < 5⦉@7 @10,12,13⦊{ - might_fail_assert(2); - }⦉@10,12,13@11⦊⦉@11 - @15,16⦊countdown -= 1⦉@15,16; +12:12-12:26: @5[4]: _7 = Eq(move _8, const 1_i32)">@3,5⦊countdown == 1⦉@3,5 @6,8⦊{ + might_fail_assert(3); + }⦉@6,8 else if @7⦊countdown < 5⦉@7 @9,11⦊{ + might_fail_assert(2); + }⦉@9,11@10⦊⦉@10 + @13,14⦊countdown -= 1⦉@13,14; } @0,1,2,3,4⦊println!("does 1 + 1 = {}?", one_plus_one);⦉@0,1,2,3,4 - assert_eq!(@0,1,2,3,4⦊1 + 1⦉@0,1,2,3,4, one_plus_one, @5,7,8,9,10,11,12⦊"the argument was wrong"⦉@5,7,8,9,10,11,12); + assert_eq!(@0,1,2,3,4⦊1 + 1⦉@0,1,2,3,4, one_plus_one, @5,7,8,9,10,11⦊"the argument was wrong"⦉@5,7,8,9,10,11); }@6⦊⦉@6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.c-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.c-{closure#0}.-------.InstrumentCoverage.0.html index 82a22ccb4e673..21bfce701fe6e 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.c-{closure#0}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.c-{closure#0}.-------.InstrumentCoverage.0.html @@ -70,15 +70,13 @@
@0⦊{ +6:8-6:14: @0[6]: _4 = Eq(move _5, const 8_u8)">@0⦊{ if x == 8⦉@0 { - @1,3⦊1⦉@1,3 +6:8-6:14: @0[6]: _4 = Eq(move _5, const 8_u8)"> if x == 8⦉@0 { + @1⦊1⦉@1 } else { @2⦊0⦉@2 } -}@4⦊⦉@4
+}@3⦊⦉@3 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.j-c.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.j-c.-------.InstrumentCoverage.0.html index a8e2d7e2f396e..e6384b7598fc2 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.j-c.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.j-c.-------.InstrumentCoverage.0.html @@ -70,12 +70,10 @@
@0⦊fn c(x: u8) -> u8 { +52:12-52:18: @0[3]: _2 = Eq(move _3, const 8_u8)">@0⦊fn c(x: u8) -> u8 { if x == 8⦉@0 { - @1,3⦊1⦉@1,3 // This line appears covered, but the 1-character expression span covering the `1` +52:12-52:18: @0[3]: _2 = Eq(move _3, const 8_u8)"> if x == 8⦉@0 { + @1⦊1⦉@1 // This line appears covered, but the 1-character expression span covering the `1` // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because // `fn j()` executes the open brace for the funciton body, followed by the function's // first executable statement, `match x`. Inner function declarations are not @@ -87,6 +85,6 @@ } else { @2⦊0⦉@2 } - }@4⦊⦉@4
+ }@3⦊⦉@3 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#0}.-------.InstrumentCoverage.0.html index 523e839a918dd..b4b171dc955cb 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#0}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#0}.-------.InstrumentCoverage.0.html @@ -72,28 +72,25 @@
|| @0⦊{ +36:12-36:20: @0[5]: _4 = (*((*_1).0: &bool))">@0⦊{ let mut countdown = 0; +36:12-36:20: @0[5]: _4 = (*((*_1).0: &bool))"> let mut countdown = 0; if is_false⦉@0 @1,3⦊{ - countdown = 10; - }⦉@1,3@2⦊⦉@2 - @4,5⦊"alt string 2".to_owned() - }⦉@4,5
+36:12-36:20: @0[5]: _4 = (*((*_1).0: &bool))"> if is_false⦉@0 @1⦊{ + countdown = 10; + }⦉@1@2⦊⦉@2 + @3,4⦊"alt string 2".to_owned() + }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#10}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#10}.-------.InstrumentCoverage.0.html index fdae1a012bc72..c1edc3eb929b0 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#10}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#10}.-------.InstrumentCoverage.0.html @@ -72,28 +72,25 @@
|| @0⦊{ +21:20-21:28: @0[5]: _4 = (*(_1.0: &bool))">@0⦊{ let mut countdown = 0; +21:20-21:28: @0[5]: _4 = (*(_1.0: &bool))"> let mut countdown = 0; if is_false⦉@0 @1,3⦊{ - countdown = 10; - }⦉@1,3@2⦊⦉@2 - @4,5⦊"alt string 1".to_owned() - }⦉@4,5
+21:20-21:28: @0[5]: _4 = (*(_1.0: &bool))"> if is_false⦉@0 @1⦊{ + countdown = 10; + }⦉@1@2⦊⦉@2 + @3,4⦊"alt string 1".to_owned() + }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#11}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#11}.-------.InstrumentCoverage.0.html index 48f3944b8b762..24c1cadacac4a 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#11}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#11}.-------.InstrumentCoverage.0.html @@ -72,28 +72,25 @@
|| @0⦊{ +63:20-63:28: @0[5]: _4 = (*(_1.0: &bool))">@0⦊{ let mut countdown = 0; +63:20-63:28: @0[5]: _4 = (*(_1.0: &bool))"> let mut countdown = 0; if is_false⦉@0 @1,3⦊{ - countdown = 10; - }⦉@1,3@2⦊⦉@2 - @4,5⦊"alt string 3".to_owned() - }⦉@4,5
+63:20-63:28: @0[5]: _4 = (*(_1.0: &bool))"> if is_false⦉@0 @1⦊{ + countdown = 10; + }⦉@1@2⦊⦉@2 + @3,4⦊"alt string 3".to_owned() + }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#1}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#1}.-------.InstrumentCoverage.0.html index 233ebf11b2cdc..7a3921c5aec76 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#1}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#1}.-------.InstrumentCoverage.0.html @@ -72,28 +72,25 @@
|| @0⦊{ +78:12-78:20: @0[5]: _4 = (*((*_1).0: &bool))">@0⦊{ let mut countdown = 0; +78:12-78:20: @0[5]: _4 = (*((*_1).0: &bool))"> let mut countdown = 0; if is_false⦉@0 @1,3⦊{ - countdown = 10; - }⦉@1,3@2⦊⦉@2 - @4,5⦊"alt string 4".to_owned() - }⦉@4,5
+78:12-78:20: @0[5]: _4 = (*((*_1).0: &bool))"> if is_false⦉@0 @1⦊{ + countdown = 10; + }⦉@1@2⦊⦉@2 + @3,4⦊"alt string 4".to_owned() + }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#2}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#2}.-------.InstrumentCoverage.0.html index 1cdca25cd6640..06b817e4318e8 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#2}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#2}.-------.InstrumentCoverage.0.html @@ -72,60 +72,57 @@
|val| @0⦊{ +100:12-100:20: @0[5]: _5 = (*((*_1).0: &bool))">@0⦊{ let mut countdown = 0; +100:12-100:20: @0[5]: _5 = (*((*_1).0: &bool))"> let mut countdown = 0; if is_false⦉@0 @1,3⦊{ - countdown = 10; - }⦉@1,3@2⦊⦉@2 - @4,5,6,7,8⦊format!("'{}'", val) - }⦉@4,5,6,7,8
+100:12-100:20: @0[5]: _5 = (*((*_1).0: &bool))"> if is_false⦉@0 @1⦊{ + countdown = 10; + }⦉@1@2⦊⦉@2 + @3,4,5,6,7⦊format!("'{}'", val) + }⦉@3,4,5,6,7 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#3}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#3}.-------.InstrumentCoverage.0.html index 032a6a7e435c1..0940775840093 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#3}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#3}.-------.InstrumentCoverage.0.html @@ -72,22 +72,20 @@
| mut countdown | - @0⦊{ - if is_false⦉@0 @1,3⦊{ - countdown = 10; - }⦉@1,3@2⦊⦉@2 - @4,5⦊"closure should be unused".to_owned() - }⦉@4,5
+ @0⦊{ + if is_false⦉@0 @1⦊{ + countdown = 10; + }⦉@1@2⦊⦉@2 + @3,4⦊"closure should be unused".to_owned() + }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.conditions/conditions.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.conditions/conditions.main.-------.InstrumentCoverage.0.html index e16b366e2162e..184dba6abd17f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.conditions/conditions.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.conditions/conditions.main.-------.InstrumentCoverage.0.html @@ -72,255 +72,236 @@
@0⦊fn main() ⦉@0{ let @0⦊mut countdown = 0; +5:8-5:12: @0[5]: _3 = const true">@0⦊mut countdown = 0; if true⦉@0 @1,3⦊{ - countdown = 10; - }⦉@1,3@2⦊⦉@2 +5:8-5:12: @0[5]: _3 = const true"> if true⦉@0 @1⦊{ + countdown = 10; + }⦉@1@2⦊⦉@2 const B: u32 = 100; - let @25⦊x⦉@25 = if @4⦊countdown > 7⦉@4 { - @5,7,8⦊countdown -= 4; - B⦉@5,7,8 - } else if @6⦊countdown > 2⦉@6 { - if @9,11⦊countdown < 1⦉@9,11 || @18⦊countdown > 5⦉@18 || @14⦊countdown != 9⦉@14 @20,22⦊{ - countdown = 0; - }⦉@20,22@21⦊⦉@21 - @23,24⦊countdown -= 5; - countdown⦉@23,24 + let @21⦊x⦉@21 = if @3⦊countdown > 7⦉@3 { + @4,6⦊countdown -= 4; + B⦉@4,6 + } else if @5⦊countdown > 2⦉@5 { + if @7⦊countdown < 1⦉@7 || @15⦊countdown > 5⦉@15 || @11⦊countdown != 9⦉@11 @17⦊{ + countdown = 0; + }⦉@17@18⦊⦉@18 + @19,20⦊countdown -= 5; + countdown⦉@19,20 } else { - @10⦊return⦉@10; + @8⦊return⦉@8; }; - let @25⦊mut countdown = 0; - if true⦉@25 @26,28⦊{ - countdown = 10; - }⦉@26,28@27⦊⦉@27 + let @21⦊mut countdown = 0; + if true⦉@21 @22⦊{ + countdown = 10; + }⦉@22@23⦊⦉@23 - if @29⦊countdown > 7⦉@29 @30,32,33⦊{ - countdown -= 4; - }⦉@30,32,33 else if @31⦊countdown > 2⦉@31 { - if @34,36⦊countdown < 1⦉@34,36 || @43⦊countdown > 5⦉@43 || @39⦊countdown != 9⦉@39 @45,47⦊{ - countdown = 0; - }⦉@45,47@46⦊⦉@46 - @48,49⦊countdown -= 5⦉@48,49; + if @24⦊countdown > 7⦉@24 @25,27⦊{ + countdown -= 4; + }⦉@25,27 else if @26⦊countdown > 2⦉@26 { + if @28⦊countdown < 1⦉@28 || @36⦊countdown > 5⦉@36 || @32⦊countdown != 9⦉@32 @38⦊{ + countdown = 0; + }⦉@38@39⦊⦉@39 + @40,41⦊countdown -= 5⦉@40,41; } else { - @35⦊return⦉@35; + @29⦊return⦉@29; } - if @50⦊true⦉@50 { - let @51,53⦊mut countdown = 0; - if true⦉@51,53 @54,56⦊{ - countdown = 10; - }⦉@54,56@55⦊⦉@55 + if @42⦊true⦉@42 { + let @43⦊mut countdown = 0; + if true⦉@43 @45⦊{ + countdown = 10; + }⦉@45@46⦊⦉@46 - if @57⦊countdown > 7⦉@57 @58,60,61⦊{ - countdown -= 4; - }⦉@58,60,61 - else if @59⦊countdown > 2⦉@59 { - if @62,64⦊countdown < 1⦉@62,64 || @71⦊countdown > 5⦉@71 || @67⦊countdown != 9⦉@67 @73,75⦊{ - countdown = 0; - }⦉@73,75@74⦊⦉@74 - @76,77⦊countdown -= 5⦉@76,77; + if @47⦊countdown > 7⦉@47 @48,50⦊{ + countdown -= 4; + }⦉@48,50 + else if @49⦊countdown > 2⦉@49 { + if @51⦊countdown < 1⦉@51 || @59⦊countdown > 5⦉@59 || @55⦊countdown != 9⦉@55 @61⦊{ + countdown = 0; + }⦉@61@62⦊⦉@62 + @63,64⦊countdown -= 5⦉@63,64; } else { - @63⦊return⦉@63; + @52⦊return⦉@52; } - }@52⦊⦉@52 // Note: closing brace shows uncovered (vs. `0` for implicit else) because condition literal + }@44⦊⦉@44 // Note: closing brace shows uncovered (vs. `0` for implicit else) because condition literal // `true` was const-evaluated. The compiler knows the `if` block will be executed. - let @79⦊mut countdown = 0; - if true⦉@79 @80,82⦊{ - countdown = 1; - }⦉@80,82@81⦊⦉@81 + let @66⦊mut countdown = 0; + if true⦉@66 @67⦊{ + countdown = 1; + }⦉@67@68⦊⦉@68 - let @106⦊z⦉@106 = if @83⦊countdown > 7⦉@83 @84,86,87⦊{ - countdown -= 4; - }⦉@84,86,87 else if @85⦊countdown > 2⦉@85 { - if @88,90⦊countdown < 1⦉@88,90 || @97⦊countdown > 5⦉@97 || @93⦊countdown != 9⦉@93 @99,101⦊{ - countdown = 0; - }⦉@99,101@100⦊⦉@100 - @102,103⦊countdown -= 5⦉@102,103; + let @89⦊z⦉@89 = if @69⦊countdown > 7⦉@69 @70,72⦊{ + countdown -= 4; + }⦉@70,72 else if @71⦊countdown > 2⦉@71 { + if @73⦊countdown < 1⦉@73 || @81⦊countdown > 5⦉@81 || @77⦊countdown != 9⦉@77 @83⦊{ + countdown = 0; + }⦉@83@84⦊⦉@84 + @85,86⦊countdown -= 5⦉@85,86; } else { - let @89,104,105⦊should_be_reachable = countdown; - println!("reached"); - return⦉@89,104,105; + let @74,87,88⦊should_be_reachable = countdown; + println!("reached"); + return⦉@74,87,88; }; - let @127⦊w⦉@127 = if @106⦊countdown > 7⦉@106 @107,109,110⦊{ - countdown -= 4; - }⦉@107,109,110 else if @108⦊countdown > 2⦉@108 { - if @111,113⦊countdown < 1⦉@111,113 || @120⦊countdown > 5⦉@120 || @116⦊countdown != 9⦉@116 @122,124⦊{ - countdown = 0; - }⦉@122,124@123⦊⦉@123 - @125,126⦊countdown -= 5⦉@125,126; + let @107⦊w⦉@107 = if @89⦊countdown > 7⦉@89 @90,92⦊{ + countdown -= 4; + }⦉@90,92 else if @91⦊countdown > 2⦉@91 { + if @93⦊countdown < 1⦉@93 || @101⦊countdown > 5⦉@101 || @97⦊countdown != 9⦉@97 @103⦊{ + countdown = 0; + }⦉@103@104⦊⦉@104 + @105,106⦊countdown -= 5⦉@105,106; } else { - @112⦊return⦉@112; + @94⦊return⦉@94; }; -}@131⦊⦉@131
+}@111⦊⦉@111 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.main.-------.InstrumentCoverage.0.html index 59d00600738f0..421fe27825c3f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.main.-------.InstrumentCoverage.0.html @@ -69,83 +69,75 @@ -
@0,1,2,3⦊fn main() { -@0,1,2,3⦊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 mut countdown = 0; - let mut countdown = 0; + if is_true⦉@0,1,2,3 @4,6⦊{ - countdown = 10; - }⦉@4,6@5⦊⦉@5 -}@7⦊⦉@7
+34:8-34:15: @3[5]: _6 = _1"> if is_true⦉@0,1,2,3 @4⦊{ + countdown = 10; + }⦉@4@5⦊⦉@5 +}@6⦊⦉@6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.unused_fn.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.unused_fn.-------.InstrumentCoverage.0.html index 1a535b937887b..ff3493c9f623b 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.unused_fn.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.unused_fn.-------.InstrumentCoverage.0.html @@ -69,83 +69,75 @@ -
@0,1,2,3⦊fn unused_fn() { -@0,1,2,3⦊fn unused_fn() { + // 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 mut countdown = 0; - let mut countdown = 0; + if is_true⦉@0,1,2,3 @4,6⦊{ - countdown = 10; - }⦉@4,6@5⦊⦉@5 -}@7⦊⦉@7
+22:8-22:15: @3[5]: _6 = _1"> if is_true⦉@0,1,2,3 @4⦊{ + countdown = 10; + }⦉@4@5⦊⦉@5 +}@6⦊⦉@6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.unused_pub_fn_not_in_library.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.unused_pub_fn_not_in_library.-------.InstrumentCoverage.0.html index 6eff51ad89c73..829113e8a71d5 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.unused_pub_fn_not_in_library.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.unused_pub_fn_not_in_library.-------.InstrumentCoverage.0.html @@ -69,83 +69,75 @@ -
@0,1,2,3⦊pub fn unused_pub_fn_not_in_library() { -@0,1,2,3⦊pub fn unused_pub_fn_not_in_library() { + // 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 mut countdown = 0; - let mut countdown = 0; + if is_true⦉@0,1,2,3 @4,6⦊{ - countdown = 10; - }⦉@4,6@5⦊⦉@5 -}@7⦊⦉@7
+10:8-10:15: @3[5]: _6 = _1"> if is_true⦉@0,1,2,3 @4⦊{ + countdown = 10; + }⦉@4@5⦊⦉@5 +}@6⦊⦉@6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest/doctest.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest/doctest.main.-------.InstrumentCoverage.0.html index 333476a2df573..3566912628a9e 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest/doctest.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest/doctest.main.-------.InstrumentCoverage.0.html @@ -70,58 +70,57 @@
@0⦊fn main() ⦉@0{ - if @0⦊true⦉@0 { - @5⦊@4,6,7,8,9⦊assert_eq!(1, 1);⦉@4,6,7,8,9⦉@5 + if @0⦊true⦉@0 { + @4⦊@3,5,6,7⦊assert_eq!(1, 1);⦉@3,5,6,7⦉@4 } else { - @11⦊@10,12,13,14,15⦊assert_eq!(1, 2);⦉@10,12,13,14,15⦉@11 + @9⦊@8,10,11,12⦊assert_eq!(1, 2);⦉@8,10,11,12⦉@9 } -}@16⦊⦉@16
+}@13⦊⦉@13 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html index ae119d9ca9f2e..02c25cc904c4a 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html @@ -71,103 +71,103 @@
@0⦊pub fn fn_run_in_doctests(conditional: usize) ⦉@0{ match @0⦊conditional⦉@0 { - 1 => @7⦊@6,8,9,10,11⦊assert_eq!(1, 1)⦉@6,8,9,10,11⦉@7, // this is run, - 2 => @14⦊@13,15,16,17,18⦊assert_eq!(1, 1)⦉@13,15,16,17,18⦉@14, // this, - 3 => @21⦊@20,22,23,24,25⦊assert_eq!(1, 1)⦉@20,22,23,24,25⦉@21, // and this too - _ => @27⦊@26,28,29,30,31⦊assert_eq!(1, 2)⦉@26,28,29,30,31⦉@27, // however this is not + 1 => @7⦊@6,8,9,10⦊assert_eq!(1, 1)⦉@6,8,9,10⦉@7, // this is run, + 2 => @13⦊@12,14,15,16⦊assert_eq!(1, 1)⦉@12,14,15,16⦉@13, // this, + 3 => @19⦊@18,20,21,22⦊assert_eq!(1, 1)⦉@18,20,21,22⦉@19, // and this too + _ => @24⦊@23,25,26,27⦊assert_eq!(1, 2)⦉@23,25,26,27⦉@24, // however this is not } -}@32⦊⦉@32
+}@28⦊⦉@28 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.drop_trait/drop_trait.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.drop_trait/drop_trait.main.-------.InstrumentCoverage.0.html index fa3c4b3c31257..3b5d1e2cdac28 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.drop_trait/drop_trait.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.drop_trait/drop_trait.main.-------.InstrumentCoverage.0.html @@ -73,86 +73,80 @@ 15:9-15:21: @0[2]: FakeRead(ForLet, _1) 17:16-17:42: @0[4]: _2 = Firework { strength: const 100_i32 } 17:9-17:13: @0[5]: FakeRead(ForLet, _2) -19:8-19:12: @0[8]: _4 = const true -19:8-19:12: @0[9]: FakeRead(ForMatchedPlace, _4)">@0⦊fn main() -> Result<(),u8> { +19:8-19:12: @0[8]: _4 = const true">@0⦊fn main() -> Result<(),u8> { let _firecracker = Firework { strength: 1 }; +19:8-19:12: @0[8]: _4 = const true"> let _firecracker = Firework { strength: 1 }; +19:8-19:12: @0[8]: _4 = const true"> let _tnt = Firework { strength: 100 }; +19:8-19:12: @0[8]: _4 = const true"> let _tnt = Firework { strength: 100 }; +19:8-19:12: @0[8]: _4 = const true"> if true⦉@0 { - @1,3,4,5,9,10⦊println!("Exiting with error..."); - return Err(1)⦉@1,3,4,5,9,10; +19:8-19:12: @0[8]: _4 = const true"> if true⦉@0 { + @1,3,4,8,9⦊println!("Exiting with error..."); + return Err(1)⦉@1,3,4,8,9; }@2,6,7,8⦊ +26:8-26:10: @5[2]: _19 = () +26:5-26:11: @5[3]: _0 = std::result::Result::<(), u8>::Ok(move _19)">@2,5,6,7⦊ +26:8-26:10: @5[2]: _19 = () +26:5-26:11: @5[3]: _0 = std::result::Result::<(), u8>::Ok(move _19)"> let _ = Firework { strength: 1000 }; +26:8-26:10: @5[2]: _19 = () +26:5-26:11: @5[3]: _0 = std::result::Result::<(), u8>::Ok(move _19)"> let _ = Firework { strength: 1000 }; +26:8-26:10: @5[2]: _19 = () +26:5-26:11: @5[3]: _0 = std::result::Result::<(), u8>::Ok(move _19)"> Ok(())⦉@2,6,7,8 -}@11⦊⦉@11 +26:8-26:10: @5[2]: _19 = () +26:5-26:11: @5[3]: _0 = std::result::Result::<(), u8>::Ok(move _19)"> Ok(())⦉@2,5,6,7 +}@10⦊⦉@10 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.generics/generics.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.generics/generics.main.-------.InstrumentCoverage.0.html index 52c5d4f47b1d3..0373b38e1b11f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.generics/generics.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.generics/generics.main.-------.InstrumentCoverage.0.html @@ -72,175 +72,166 @@
@0,1,2,3⦊fn main() -> Result<(),u8> { +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true">@0,1,2,3⦊fn main() -> Result<(),u8> { let mut firecracker = Firework { strength: 1 }; +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true"> let mut firecracker = Firework { strength: 1 }; firecracker.set_strength(2); +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true"> firecracker.set_strength(2); +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true"> let mut tnt = Firework { strength: 100.1 }; +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true"> let mut tnt = Firework { strength: 100.1 }; tnt.set_strength(200.1); +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true"> tnt.set_strength(200.1); tnt.set_strength(300.3); +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true"> tnt.set_strength(300.3); +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true"> if true⦉@0,1,2,3 { - @4,6,7,8,12,13⦊println!("Exiting with error..."); - return Err(1)⦉@4,6,7,8,12,13; +28:5-28:28: @2.Call: _7 = Firework::<f64>::set_strength(move _8, const 300.30000000000001f64) -> [return: bb3, unwind: bb14] +30:8-30:12: @3[4]: _10 = const true"> if true⦉@0,1,2,3 { + @4,6,7,11,12⦊println!("Exiting with error..."); + return Err(1)⦉@4,6,7,11,12; }@5,9,10,11⦊ // The remaining lines below have no coverage because `if true` (with the constant literal +41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)">@5,8,9,10⦊ // The remaining lines below have no coverage because `if true` (with the constant literal // `true`) is guaranteed to execute the `then` block, which is also guaranteed to `return`. +41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)"> // `true`) is guaranteed to execute the `then` block, which is also guaranteed to `return`. // Thankfully, in the normal case, conditions are not guaranteed ahead of time, and as shown +41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)"> // Thankfully, in the normal case, conditions are not guaranteed ahead of time, and as shown // in other tests, the lines below would have coverage (which would show they had `0` +41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)"> // in other tests, the lines below would have coverage (which would show they had `0` // executions, assuming the condition still evaluated to `true`). +41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)"> // executions, assuming the condition still evaluated to `true`). +41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)"> let _ = Firework { strength: 1000 }; +41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)"> let _ = Firework { strength: 1000 }; +41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)"> Ok(())⦉@5,9,10,11 -}@14⦊⦉@14
+41:8-41:10: @8[2]: _25 = () +41:5-41:11: @8[3]: _0 = std::result::Result::<(), u8>::Ok(move _25)"> Ok(())⦉@5,8,9,10 +}@13⦊⦉@13 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if/if.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if/if.main.-------.InstrumentCoverage.0.html index 8eb6c1dcb877a..dd9ba4a190cd8 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if/if.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if/if.main.-------.InstrumentCoverage.0.html @@ -69,189 +69,170 @@ -
@0,1,2,3⦊fn main() { -@0,1,2,3⦊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 - let + is_true - is_true + = - = + std::env::args().len() - std::env::args().len() + == - == + 1 - 1 + ; - ; + let - let + mut - mut + countdown - countdown + = - = + 0 - 0 + ; - ; + if - if + is_true⦉@0,1,2,3 - @4,6⦊{ - countdown - = - 10 - ; - }⦉@4,6@5⦊⦉@5 -}@7⦊⦉@7
+21:9-21:16: @3[5]: _6 = _1"> is_true⦉@0,1,2,3 + @4⦊{ + countdown + = + 10 + ; + }⦉@4@5⦊⦉@5 +}@6⦊⦉@6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if_else/if_else.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if_else/if_else.main.-------.InstrumentCoverage.0.html index 5b2cce4f648fc..b642be382cbc4 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if_else/if_else.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if_else/if_else.main.-------.InstrumentCoverage.0.html @@ -69,99 +69,90 @@ -
@0,1,2,3⦊fn main() { -@0,1,2,3⦊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 mut countdown = 0; - let mut countdown = 0; + if - if + is_true⦉@0,1,2,3 - @4,6⦊{ - countdown - = - 10 - ; - }⦉@4,6 +11:9-11:16: @3[6]: _7 = _1"> is_true⦉@0,1,2,3 + @4⦊{ + countdown + = + 10 + ; + }⦉@4 else // Note coverage region difference without semicolon { } if - @7⦊is_true⦉@7 - @8,10⦊{ - countdown - = - 10 - ; - }⦉@8,10 + @6⦊is_true⦉@6 + @7⦊{ + countdown + = + 10 + ; + }⦉@7 else - @9⦊{ - countdown - = - 100 - ; - }⦉@9 -}@11⦊⦉@11
+ @8⦊{ + countdown + = + 100 + ; + }⦉@8 +}@9⦊⦉@9 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main.-------.InstrumentCoverage.0.html index 693b15f15b9ca..d21710b7240d3 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main.-------.InstrumentCoverage.0.html @@ -73,47 +73,43 @@ // 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 // dependent conditions. - let let @0,1,2,3⦊is_true = std::env::args().len() == 1; -@0,1,2,3⦊is_true = std::env::args().len() == 1; + - + let mut countdown = 0; - let mut countdown = 0; + if is_true⦉@0,1,2,3 @4,6⦊{ - countdown = 10; - }⦉@4,6@5⦊⦉@5 +10:8-10:15: @3[6]: _7 = _1"> if is_true⦉@0,1,2,3 @4⦊{ + countdown = 10; + }⦉@4@5⦊⦉@5 mod in_mod { const IN_MOD_CONST: u32 = 1000; @@ -149,46 +145,45 @@ type InType = String; - if @7⦊is_true⦉@7 @8,10,11⦊{ - in_func(countdown); - }⦉@8,10,11@9⦊⦉@9 + if @6⦊is_true⦉@6 @7,9⦊{ + in_func(countdown); + }⦉@7,9@8⦊⦉@8 - let @12,13⦊mut val = InStruct { - in_struct_field: 101, - }; - - val.default_trait_func(); -}⦉@12,13 + let @10,11⦊mut val = InStruct { + in_struct_field: 101, + }; + + val.default_trait_func(); +}⦉@10,11 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.lazy_boolean/lazy_boolean.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.lazy_boolean/lazy_boolean.main.-------.InstrumentCoverage.0.html index f30f0ed9a8489..0cfe2119fbc8a 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.lazy_boolean/lazy_boolean.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.lazy_boolean/lazy_boolean.main.-------.InstrumentCoverage.0.html @@ -69,204 +69,191 @@ -
@0,1,2,3⦊fn main() { -@0,1,2,3⦊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 (mut a, mut b, mut c) = (0, 0, 0); - let (mut a, mut b, mut c) = (0, 0, 0); + if is_true⦉@0,1,2,3 @4,6⦊{ - a = 1; - b = 10; - c = 100; - }⦉@4,6@5⦊⦉@5 +10:8-10:15: @3[12]: _10 = _1"> if is_true⦉@0,1,2,3 @4⦊{ + a = 1; + b = 10; + c = 100; + }⦉@4@5⦊⦉@5 let - @11⦊somebool⦉@11 + @10⦊somebool⦉@10 = - @7⦊a < b⦉@7 + @6⦊a < b⦉@6 || - @10⦊b < c⦉@10 + @9⦊b < c⦉@9 ; let - @15⦊somebool⦉@15 + @14⦊somebool⦉@14 = - @11⦊b < a⦉@11 + @10⦊b < a⦉@10 || - @14⦊b < c⦉@14 + @13⦊b < c⦉@13 ; - let @19⦊somebool⦉@19 = @15⦊a < b⦉@15 && @18⦊b < c⦉@18; - let @23⦊somebool⦉@23 = @19⦊b < a⦉@19 && @22⦊b < c⦉@22; + let @18⦊somebool⦉@18 = @14⦊a < b⦉@14 && @17⦊b < c⦉@17; + let @22⦊somebool⦉@22 = @18⦊b < a⦉@18 && @21⦊b < c⦉@21; if - @23⦊! - is_true⦉@23 - @24,26⦊{ - a = 2 - ; - }⦉@24,26@25⦊⦉@25 + @22⦊! + is_true⦉@22 + @23⦊{ + a = 2 + ; + }⦉@23@24⦊⦉@24 if - @27⦊is_true⦉@27 - @28,30⦊{ - b = 30 - ; - }⦉@28,30 + @25⦊is_true⦉@25 + @26⦊{ + b = 30 + ; + }⦉@26 else - @29⦊{ - c = 400 - ; - }⦉@29 + @27⦊{ + c = 400 + ; + }⦉@27 - if @31⦊!is_true⦉@31 @32,34⦊{ - a = 2; - }⦉@32,34@33⦊⦉@33 + if @28⦊!is_true⦉@28 @29⦊{ + a = 2; + }⦉@29@30⦊⦉@30 - if @35⦊is_true⦉@35 @36,38⦊{ - b = 30; - }⦉@36,38 else @37⦊{ - c = 400; - }⦉@37 -}@39⦊⦉@39
+ if @31⦊is_true⦉@31 @32⦊{ + b = 30; + }⦉@32 else @33⦊{ + c = 400; + }⦉@33 +}@34⦊⦉@34 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.loops_branches/loops_branches.{impl#0}-fmt.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.loops_branches/loops_branches.{impl#0}-fmt.-------.InstrumentCoverage.0.html index 312d2ee7e8f0e..b3f344f7fc0b8 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.loops_branches/loops_branches.{impl#0}-fmt.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.loops_branches/loops_branches.{impl#0}-fmt.-------.InstrumentCoverage.0.html @@ -69,35 +69,32 @@ -
@0⦊fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - if true⦉@0 { - if @1,3⦊false⦉@1,3 { - while @6,7⦊true⦉@6,7 @8,10⦊{ - }⦉@8,10 - }@5⦊⦉@5 - @11,12,13,14⦊write!(f, "error")⦉@11,12,13,14@16,18,19,20⦊?⦉@16,18,19,20; +
@0⦊fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + if true⦉@0 { + if @1⦊false⦉@1 { + while @4,5⦊true⦉@4,5 @6,8⦊{ + }⦉@6,8 + }@3⦊⦉@3 + @9,10,11,12⦊write!(f, "error")⦉@9,10,11,12@14,16,17,18⦊?⦉@14,16,17,18; } else @2⦊{ }⦉@2 - @21⦊Ok(())⦉@21 - }@22⦊⦉@22
+ @19⦊Ok(())⦉@19 + }@20⦊⦉@20
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.match_or_pattern/match_or_pattern.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.match_or_pattern/match_or_pattern.main.-------.InstrumentCoverage.0.html index 133a85c83945e..c7992614b5b6f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.match_or_pattern/match_or_pattern.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.match_or_pattern/match_or_pattern.main.-------.InstrumentCoverage.0.html @@ -69,9 +69,9 @@ -
@0,1,2,3⦊fn main() { -@0,1,2,3⦊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 mut a: u8 = 0; - let mut a: u8 = 0; + let mut b: u8 = 0; - let mut b: u8 = 0; + if is_true⦉@0,1,2,3 @4,6⦊{ - a = 2; - b = 0; - }⦉@4,6@5⦊⦉@5 - match @7⦊(a, b)⦉@7 { +11:8-11:15: @3[11]: _8 = _1"> if is_true⦉@0,1,2,3 @4⦊{ + a = 2; + b = 0; + }⦉@4@5⦊⦉@5 + match @6⦊(a, b)⦉@6 { // Or patterns generate MIR `SwitchInt` with multiple targets to the same `BasicBlock`. // This test confirms a fix for Issue #79569. - (0 | 1, 2 | 3) => @10,11⦊{}⦉@10,11 - _ => @8⦊{}⦉@8 + (0 | 1, 2 | 3) => @9,10⦊{}⦉@9,10 + _ => @7⦊{}⦉@7 } - if @12⦊is_true⦉@12 @13,15⦊{ - a = 0; - b = 0; - }⦉@13,15@14⦊⦉@14 - match @16⦊(a, b)⦉@16 { - (0 | 1, 2 | 3) => @19,20⦊{}⦉@19,20 - _ => @17⦊{}⦉@17 + if @11⦊is_true⦉@11 @12⦊{ + a = 0; + b = 0; + }⦉@12@13⦊⦉@13 + match @14⦊(a, b)⦉@14 { + (0 | 1, 2 | 3) => @17,18⦊{}⦉@17,18 + _ => @15⦊{}⦉@15 } - if @21⦊is_true⦉@21 @22,24⦊{ - a = 2; - b = 2; - }⦉@22,24@23⦊⦉@23 - match @25⦊(a, b)⦉@25 { - (0 | 1, 2 | 3) => @28,29⦊{}⦉@28,29 - _ => @26⦊{}⦉@26 + if @19⦊is_true⦉@19 @20⦊{ + a = 2; + b = 2; + }⦉@20@21⦊⦉@21 + match @22⦊(a, b)⦉@22 { + (0 | 1, 2 | 3) => @25,26⦊{}⦉@25,26 + _ => @23⦊{}⦉@23 } - if @30⦊is_true⦉@30 @31,33⦊{ - a = 0; - b = 2; - }⦉@31,33@32⦊⦉@32 - match @34⦊(a, b)⦉@34 { - (0 | 1, 2 | 3) => @37,38⦊{}⦉@37,38 - _ => @35⦊{}⦉@35 + if @27⦊is_true⦉@27 @28⦊{ + a = 0; + b = 2; + }⦉@28@29⦊⦉@29 + match @30⦊(a, b)⦉@30 { + (0 | 1, 2 | 3) => @33,34⦊{}⦉@33,34 + _ => @31⦊{}⦉@31 } -}@39⦊⦉@39
+}@35⦊⦉@35 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.nested_loops/nested_loops.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.nested_loops/nested_loops.main.-------.InstrumentCoverage.0.html index cb60276aa1228..4dcf6c741dc73 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.nested_loops/nested_loops.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.nested_loops/nested_loops.main.-------.InstrumentCoverage.0.html @@ -69,23 +69,23 @@ -
@0,1,2,3⦊fn main() { - let is_true = std::env::args().len() == 1; -@14,16⦊_⦉@14,16 in @10,11,12⦊0..50⦉@10,11,12 { if @14,16⦊a < 30⦉@14,16 { - @17,19⦊break⦉@17,19; +9:16-9:22: @16[16]: _26 = Lt(move _27, const 30_i32)">@14,16⦊a < 30⦉@14,16 { + @17⦊break⦉@17; }@18,20,21⦊ +12:13-12:19: @19[0]: _9 = move (_29.0: i32) +13:13-13:19: @19[1]: _30 = CheckedSub(_10, const 5_i32) +13:13-13:19: @20[0]: _10 = move (_30.0: i32) +14:16-14:17: @20[3]: _32 = _10 +14:16-14:22: @20[4]: _31 = Lt(move _32, const 90_i32)">@18,19,20⦊ a -= 5; +12:13-12:19: @19[0]: _9 = move (_29.0: i32) +13:13-13:19: @19[1]: _30 = CheckedSub(_10, const 5_i32) +13:13-13:19: @20[0]: _10 = move (_30.0: i32) +14:16-14:17: @20[3]: _32 = _10 +14:16-14:22: @20[4]: _31 = Lt(move _32, const 90_i32)"> a -= 5; b -= 5; +12:13-12:19: @19[0]: _9 = move (_29.0: i32) +13:13-13:19: @19[1]: _30 = CheckedSub(_10, const 5_i32) +13:13-13:19: @20[0]: _10 = move (_30.0: i32) +14:16-14:17: @20[3]: _32 = _10 +14:16-14:22: @20[4]: _31 = Lt(move _32, const 90_i32)"> b -= 5; if b < 90⦉@18,20,21 { - @22,24,25⦊a -= 10; - if is_true⦉@22,24,25 { - @26,28⦊break 'outer⦉@26,28; - } else @27,29⦊{ - a -= 2; - }⦉@27,29 - }@23⦊⦉@23 +12:13-12:19: @19[0]: _9 = move (_29.0: i32) +13:13-13:19: @19[1]: _30 = CheckedSub(_10, const 5_i32) +13:13-13:19: @20[0]: _10 = move (_30.0: i32) +14:16-14:17: @20[3]: _32 = _10 +14:16-14:22: @20[4]: _31 = Lt(move _32, const 90_i32)"> if b < 90⦉@18,19,20 { + @21,23⦊a -= 10; + if is_true⦉@21,23 { + @24⦊break 'outer⦉@24; + } else @25,26⦊{ + a -= 2; + }⦉@25,26 + }@22⦊⦉@22 } - @31,32⦊countdown -= 1⦉@31,32; + @28,29⦊countdown -= 1⦉@28,29; } -}@33⦊⦉@33
+}@30⦊⦉@30 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.overflow/overflow.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.overflow/overflow.main.-------.InstrumentCoverage.0.html index 6739634f65b30..ca3515689d337 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.overflow/overflow.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.overflow/overflow.main.-------.InstrumentCoverage.0.html @@ -77,178 +77,176 @@ 17:11-17:24: @2[3]: _4 = Gt(move _5, const 0_i32) 17:11-17:24: @2[5]: FakeRead(ForMatchedPlace, _4)">@1,2⦊countdown > 0⦉@1,2 { if @3,5⦊countdown == 1⦉@3,5 @6,8,9,10,11,12⦊{ - let result = might_overflow(10); - println!("Result: {}", result); - }⦉@6,8,9,10,11,12 else if @7⦊countdown < 5⦉@7 @13,15,16,17,18,19⦊{ - let result = might_overflow(1); - println!("Result: {}", result); - }⦉@13,15,16,17,18,19@14⦊⦉@14 - @21,22⦊countdown -= 1⦉@21,22; +18:12-18:26: @5[4]: _7 = Eq(move _8, const 1_i32)">@3,5⦊countdown == 1⦉@3,5 @6,8,9,10,11⦊{ + let result = might_overflow(10); + println!("Result: {}", result); + }⦉@6,8,9,10,11 else if @7⦊countdown < 5⦉@7 @12,14,15,16,17⦊{ + let result = might_overflow(1); + println!("Result: {}", result); + }⦉@12,14,15,16,17@13⦊⦉@13 + @19,20⦊countdown -= 1⦉@19,20; } @0⦊fn might_overflow(to_add: u32) -> u32 { +5:8-5:18: @0[4]: _3 = Gt(move _4, const 5_u32)">@0⦊fn might_overflow(to_add: u32) -> u32 { if to_add > 5⦉@0 @1,3,4,5⦊{ - println!("this will probably overflow"); - }⦉@1,3,4,5@2⦊⦉@2 - let @6,7,8,9,10,11,12,13,14⦊add_to = u32::MAX - 5; - println!("does {} + {} overflow?", add_to, to_add); - let result = to_add + add_to; - println!("continuing after overflow check"); - result -}⦉@6,7,8,9,10,11,12,13,14 +5:8-5:18: @0[4]: _3 = Gt(move _4, const 5_u32)"> if to_add > 5⦉@0 @1,3,4⦊{ + println!("this will probably overflow"); + }⦉@1,3,4@2⦊⦉@2 + let @5,6,7,8,9,10,11,12,13⦊add_to = u32::MAX - 5; + println!("does {} + {} overflow?", add_to, to_add); + let result = to_add + add_to; + println!("continuing after overflow check"); + result +}⦉@5,6,7,8,9,10,11,12,13 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.panic_unwind/panic_unwind.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.panic_unwind/panic_unwind.main.-------.InstrumentCoverage.0.html index bd6aac4103eb6..5b097f118e3a8 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.panic_unwind/panic_unwind.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.panic_unwind/panic_unwind.main.-------.InstrumentCoverage.0.html @@ -77,22 +77,20 @@ 15:11-15:24: @2[3]: _4 = Gt(move _5, const 0_i32) 15:11-15:24: @2[5]: FakeRead(ForMatchedPlace, _4)">@1,2⦊countdown > 0⦉@1,2 { if @3,5⦊countdown == 1⦉@3,5 @6,8,9⦊{ - might_panic(true); - }⦉@6,8,9 else if @7⦊countdown < 5⦉@7 @10,12,13⦊{ - might_panic(false); - }⦉@10,12,13@11⦊⦉@11 - @15,16⦊countdown -= 1⦉@15,16; +16:12-16:26: @5[4]: _7 = Eq(move _8, const 1_i32)">@3,5⦊countdown == 1⦉@3,5 @6,8⦊{ + might_panic(true); + }⦉@6,8 else if @7⦊countdown < 5⦉@7 @9,11⦊{ + might_panic(false); + }⦉@9,11@10⦊⦉@10 + @13,14⦊countdown -= 1⦉@13,14; } @0⦊fn might_panic(should_panic: bool) ⦉@0{ - if @0⦊should_panic⦉@0 { - @1,3,4,5⦊println!("panicking..."); - panic!("panics");⦉@1,3,4,5 + if @0⦊should_panic⦉@0 { + @1,3,4⦊println!("panicking..."); + panic!("panics");⦉@1,3,4 } else @2,6,7⦊{ +9:9-9:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +9:9-9:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] +9:9-9:33: @6[5]: _18 = const () +8:12-10:6: @6[7]: _0 = const () +11:2-11:2: @6.Return: return">@2,5,6⦊{ println!("Don't Panic"); +9:9-9:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +9:9-9:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] +9:9-9:33: @6[5]: _18 = const () +8:12-10:6: @6[7]: _0 = const () +11:2-11:2: @6.Return: return"> println!("Don't Panic"); } +9:9-9:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +9:9-9:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] +9:9-9:33: @6[5]: _18 = const () +8:12-10:6: @6[7]: _0 = const () +11:2-11:2: @6.Return: return"> } }⦉@2,6,7 +9:9-9:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +9:9-9:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] +9:9-9:33: @6[5]: _18 = const () +8:12-10:6: @6[7]: _0 = const () +11:2-11:2: @6.Return: return">}⦉@2,5,6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_loop/simple_loop.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_loop/simple_loop.main.-------.InstrumentCoverage.0.html index 1233dfb5bab1f..f528b698d440f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_loop/simple_loop.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_loop/simple_loop.main.-------.InstrumentCoverage.0.html @@ -69,138 +69,125 @@ -
@0,1,2,3⦊fn main() { -@0,1,2,3⦊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 mut countdown = 0; - let mut countdown = 0; + - + if - if + is_true⦉@0,1,2,3 - @4,6⦊{ - countdown - = - 10 - ; - }⦉@4,6@5⦊⦉@5 +12:9-12:16: @3[6]: _7 = _1"> is_true⦉@0,1,2,3 + @4⦊{ + countdown + = + 10 + ; + }⦉@4@5⦊⦉@5 loop { if - @8,9⦊countdown - == - 0⦉@8,9 + @7,8⦊countdown + == + 0⦉@7,8 { - @10,12⦊break⦉@10,12 + @9⦊break⦉@9 ; - }@11,13⦊ - countdown - -= - 1⦉@11,13 + }@10,11⦊ + countdown + -= + 1⦉@10,11 ; } -}@10,12⦊⦉@10,12
+}@9⦊⦉@9 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_match/simple_match.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_match/simple_match.main.-------.InstrumentCoverage.0.html index a8bae32490b0b..8e49e45b86e11 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_match/simple_match.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_match/simple_match.main.-------.InstrumentCoverage.0.html @@ -69,162 +69,154 @@ -
@0,1,2,3⦊fn main() { -@0,1,2,3⦊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 mut countdown = 1; - let mut countdown = 1; + if is_true⦉@0,1,2,3 @4,6⦊{ - countdown = 0; - }⦉@4,6@5⦊⦉@5 +10:8-10:15: @3[6]: _7 = _1"> if is_true⦉@0,1,2,3 @4⦊{ + countdown = 0; + }⦉@4@5⦊⦉@5 for - @13,15,17⦊_⦉@13,15,17 + @12,14,16⦊_⦉@12,14,16 in - @9,10,11⦊0..2⦉@9,10,11 + @8,9,10⦊0..2⦉@8,9,10 { let z ; match - @13,15,17⦊countdown⦉@13,15,17 + @12,14,16⦊countdown⦉@12,14,16 { - @18⦊x⦉@18 + @17⦊x⦉@17 if - @13,15,17⦊x - < - 1⦉@13,15,17 + @12,14,16⦊x + < + 1⦉@12,14,16 => - @18⦊{ - z = countdown - ; - let y = countdown - ; - countdown = 10 - ; - }⦉@18 + @17⦊{ + z = countdown + ; + let y = countdown + ; + countdown = 10 + ; + }⦉@17 _ => - @16⦊{}⦉@16 + @15⦊{}⦉@15 } } -}@12⦊⦉@12
+}@11⦊⦉@11 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.tight_inf_loop/tight_inf_loop.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.tight_inf_loop/tight_inf_loop.main.-------.InstrumentCoverage.0.html index d0ee798ca1978..8cbd265c6a01c 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.tight_inf_loop/tight_inf_loop.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.tight_inf_loop/tight_inf_loop.main.-------.InstrumentCoverage.0.html @@ -69,12 +69,10 @@ -
@0⦊fn main() { - if false⦉@0 { - @4,5⦊loop {}⦉@4,5 +
@0⦊fn main() { + if false⦉@0 { + @3,4⦊loop {}⦉@3,4 }@2⦊ @0⦊fn call(return_error: bool) -> Result<(),()> { - if return_error⦉@0 { - @1,3⦊Err(())⦉@1,3 +
@0⦊fn call(return_error: bool) -> Result<(),()> { + if return_error⦉@0 { + @1⦊Err(())⦉@1 } else { @2⦊Ok(())⦉@2 } -}@4⦊⦉@4
+}@3⦊⦉@3
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.try_error_result/try_error_result.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.try_error_result/try_error_result.main.-------.InstrumentCoverage.0.html index 3091eab3e7149..41404759c3da7 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.try_error_result/try_error_result.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.try_error_result/try_error_result.main.-------.InstrumentCoverage.0.html @@ -84,51 +84,46 @@ in @2,3,4⦊0..10⦉@2,3,4 { @6,8,9⦊countdown +25:13-25:26: @9[4]: _18 = Lt(move _19, const 5_i32)">@6,8,9⦊countdown -= 1 +25:13-25:26: @9[4]: _18 = Lt(move _19, const 5_i32)"> -= 1 ; +25:13-25:26: @9[4]: _18 = Lt(move _19, const 5_i32)"> ; if +25:13-25:26: @9[4]: _18 = Lt(move _19, const 5_i32)"> if countdown < 5⦉@6,8,9 +25:13-25:26: @9[4]: _18 = Lt(move _19, const 5_i32)"> countdown < 5⦉@6,8,9 { - @10,12,13,14⦊call(/*return_error=*/ true)⦉@10,12,13,14@16,18,19,20⦊?⦉@16,18,19,20; - @15,21,22⦊call(/*return_error=*/ false)⦉@15,21,22@24,26,27,28⦊?⦉@24,26,27,28; + @10,12,13⦊call(/*return_error=*/ true)⦉@10,12,13@15,17,18,19⦊?⦉@15,17,18,19; + @14,20,21⦊call(/*return_error=*/ false)⦉@14,20,21@23,25,26,27⦊?⦉@23,25,26,27; } else { - @11,29,30⦊call(/*return_error=*/ false)⦉@11,29,30@32,34,35,36⦊?⦉@32,34,35,36; + @11,28,29⦊call(/*return_error=*/ false)⦉@11,28,29@31,33,34,35⦊?⦉@31,33,34,35; } } @5⦊Ok(())⦉@5 -}@39⦊⦉@39
+}@38⦊⦉@38 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_function.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_function.-------.InstrumentCoverage.0.html index 47fe96eebd19f..4af7b17986622 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_function.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_function.-------.InstrumentCoverage.0.html @@ -69,51 +69,47 @@ -
@0,1,2,3⦊pub fn unused_function() { -@0,1,2,3⦊pub fn unused_function() { + let is_true = std::env::args().len() == 1; - let is_true = std::env::args().len() == 1; + let mut countdown = 2; - let mut countdown = 2; + if !is_true⦉@0,1,2,3 @4,6⦊{ - countdown = 20; - }⦉@4,6@5⦊⦉@5 -}@7⦊⦉@7
+40:8-40:16: @3[7]: _6 = Not(move _7)"> if !is_true⦉@0,1,2,3 @4⦊{ + countdown = 20; + }⦉@4@5⦊⦉@5 +}@6⦊⦉@6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_private_function.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_private_function.-------.InstrumentCoverage.0.html index 361c57930229a..6424e03fc7113 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_private_function.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_private_function.-------.InstrumentCoverage.0.html @@ -69,51 +69,47 @@ -
@0,1,2,3⦊fn unused_private_function() { -@0,1,2,3⦊fn unused_private_function() { + let is_true = std::env::args().len() == 1; - let is_true = std::env::args().len() == 1; + let mut countdown = 2; - let mut countdown = 2; + if !is_true⦉@0,1,2,3 @4,6⦊{ - countdown = 20; - }⦉@4,6@5⦊⦉@5 -}@7⦊⦉@7
+48:8-48:16: @3[7]: _6 = Not(move _7)"> if !is_true⦉@0,1,2,3 @4⦊{ + countdown = 20; + }⦉@4@5⦊⦉@5 +}@6⦊⦉@6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_function.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_function.-------.InstrumentCoverage.0.html index 2ffd9bfb82386..d35f191b64e85 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_function.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_function.-------.InstrumentCoverage.0.html @@ -73,41 +73,38 @@ // 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 // dependent conditions. - let let @0,1,2,3⦊is_true = std::env::args().len() == 1; -@0,1,2,3⦊is_true = std::env::args().len() == 1; + let mut countdown = 0; - let mut countdown = 0; + if is_true⦉@0,1,2,3 @4,6⦊{ - countdown = 10; - }⦉@4,6@5⦊⦉@5 - @7,8⦊use_this_lib_crate(); -}⦉@7,8 +11:8-11:15: @3[6]: _7 = _1"> if is_true⦉@0,1,2,3 @4⦊{ + countdown = 10; + }⦉@4@5⦊⦉@5 + @6,7⦊use_this_lib_crate(); +}⦉@6,7 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.while_early_ret/while_early_ret.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.while_early_ret/while_early_ret.main.-------.InstrumentCoverage.0.html index 4cab153e77f53..fcb5418e1d0cf 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.while_early_ret/while_early_ret.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.while_early_ret/while_early_ret.main.-------.InstrumentCoverage.0.html @@ -86,51 +86,45 @@ { if @3,5⦊countdown +12:13-14:14: @5[4]: _7 = Lt(move _8, const 5_i32)">@3,5⦊countdown < +12:13-14:14: @5[4]: _7 = Lt(move _8, const 5_i32)"> < 5⦉@3,5 +12:13-14:14: @5[4]: _7 = Lt(move _8, const 5_i32)"> 5⦉@3,5 { return if - @6,8⦊countdown - > - 8⦉@6,8 + @6⦊countdown + > + 8⦉@6 { - @9,11⦊Ok(())⦉@9,11 + @8⦊Ok(())⦉@8 } else { - @10⦊Err(1)⦉@10 + @9⦊Err(1)⦉@9 } ; }@7,12⦊ +30:9-32:10: @11[0]: _1 = move (_13.0: i32)">@7,11⦊ countdown +30:9-32:10: @11[0]: _1 = move (_13.0: i32)"> countdown -= +30:9-32:10: @11[0]: _1 = move (_13.0: i32)"> -= 1⦉@7,12 +30:9-32:10: @11[0]: _1 = move (_13.0: i32)"> 1⦉@7,11 ; } @4⦊Ok(())⦉@4 -}@14⦊⦉@14 +}@12⦊⦉@12 diff --git a/src/test/ui/issues/issue-14091.stderr b/src/test/ui/issues/issue-14091.stderr index 7db4734780817..fc49cc6d68ea0 100644 --- a/src/test/ui/issues/issue-14091.stderr +++ b/src/test/ui/issues/issue-14091.stderr @@ -3,6 +3,8 @@ error[E0308]: mismatched types | LL | assert!(1,1); | ^^^^^^^^^^^^^ expected `bool`, found integer + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr index 13b6a7bbef321..c646912d3b679 100644 --- a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr @@ -28,9 +28,6 @@ LL | let x; ... LL | x = 1; | ^^^^^ cannot assign twice to immutable variable -LL | } else { -LL | x = 2; - | ----- first assignment to `x` error[E0384]: cannot assign twice to immutable variable `x` --> $DIR/liveness-assign-imm-local-notes.rs:32:13 @@ -38,6 +35,9 @@ error[E0384]: cannot assign twice to immutable variable `x` LL | let x; | - help: make this binding mutable: `mut x` ... +LL | x = 1; + | ----- first assignment to `x` +LL | } else { LL | x = 2; | ^^^^^ cannot assign twice to immutable variable diff --git a/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs b/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs index 62c73dbac48b4..aa431f0596cca 100644 --- a/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs +++ b/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs @@ -1,8 +1,7 @@ use crate::consts::{constant, Constant}; use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call, snippet_opt, span_lint_and_help}; use if_chain::if_chain; -use rustc_ast::ast::LitKind; -use rustc_hir::{Expr, ExprKind, PatKind, UnOp}; +use rustc_hir::{Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -102,31 +101,22 @@ enum AssertKind { /// Check if the expression matches /// /// ```rust,ignore -/// match { let _t = !c; _t } { -/// true => { -/// { -/// ::std::rt::begin_panic(message, _) -/// } -/// } -/// _ => { } -/// }; +/// if !c { +/// { +/// ::std::rt::begin_panic(message, _) +/// } +/// } /// ``` /// /// where `message` is any expression and `c` is a constant bool. fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option { if_chain! { - if let ExprKind::Match(ref expr, ref arms, _) = expr.kind; - // matches { let _t = expr; _t } - if let ExprKind::DropTemps(ref expr) = expr.kind; - if let ExprKind::Unary(UnOp::UnNot, ref expr) = expr.kind; + if let ExprKind::If(ref cond, ref then, _) = expr.kind; + if let ExprKind::Unary(UnOp::UnNot, ref expr) = cond.kind; // bind the first argument of the `assert!` macro if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), expr); - // arm 1 pattern - if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind; - if let ExprKind::Lit(ref lit) = lit_expr.kind; - if let LitKind::Bool(true) = lit.node; - // arm 1 block - if let ExprKind::Block(ref block, _) = arms[0].body.kind; + // block + if let ExprKind::Block(ref block, _) = then.kind; if block.stmts.is_empty(); if let Some(block_expr) = &block.expr; // inner block is optional. unwrap it if it exists, or use the expression as is otherwise. diff --git a/src/tools/clippy/clippy_lints/src/blocks_in_if_conditions.rs b/src/tools/clippy/clippy_lints/src/blocks_in_if_conditions.rs index 736730d4084f4..4efca10bcdf13 100644 --- a/src/tools/clippy/clippy_lints/src/blocks_in_if_conditions.rs +++ b/src/tools/clippy/clippy_lints/src/blocks_in_if_conditions.rs @@ -1,4 +1,4 @@ -use crate::utils::{differing_macro_contexts, higher, snippet_block_with_applicability, span_lint, span_lint_and_sugg}; +use crate::utils::{differing_macro_contexts, snippet_block_with_applicability, span_lint, span_lint_and_sugg}; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_hir::{BlockCheckMode, Expr, ExprKind}; @@ -75,7 +75,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInIfConditions { if in_external_macro(cx.sess(), expr.span) { return; } - if let Some((cond, _, _)) = higher::if_block(&expr) { + if let ExprKind::If(cond, _, _) = &expr.kind { if let ExprKind::Block(block, _) = &cond.kind { if block.rules == BlockCheckMode::DefaultBlock { if block.stmts.is_empty() { diff --git a/src/tools/clippy/clippy_lints/src/cognitive_complexity.rs b/src/tools/clippy/clippy_lints/src/cognitive_complexity.rs index b1bc2ec29e16e..b3ebdf4ca30d8 100644 --- a/src/tools/clippy/clippy_lints/src/cognitive_complexity.rs +++ b/src/tools/clippy/clippy_lints/src/cognitive_complexity.rs @@ -147,6 +147,9 @@ impl<'tcx> Visitor<'tcx> for CCHelper { fn visit_expr(&mut self, e: &'tcx Expr<'_>) { walk_expr(self, e); match e.kind { + ExprKind::If(_, _, _) => { + self.cc += 1; + }, ExprKind::Match(_, ref arms, _) => { if arms.len() > 1 { self.cc += 1; diff --git a/src/tools/clippy/clippy_lints/src/consts.rs b/src/tools/clippy/clippy_lints/src/consts.rs index 0035ded9356cf..166eadf86c177 100644 --- a/src/tools/clippy/clippy_lints/src/consts.rs +++ b/src/tools/clippy/clippy_lints/src/consts.rs @@ -1,6 +1,6 @@ #![allow(clippy::float_cmp)] -use crate::utils::{clip, higher, sext, unsext}; +use crate::utils::{clip, sext, unsext}; use if_chain::if_chain; use rustc_ast::ast::{FloatTy, LitFloatType, LitKind}; use rustc_data_structures::sync::Lrc; @@ -228,9 +228,6 @@ pub struct ConstEvalLateContext<'a, 'tcx> { impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { /// Simple constant folding: Insert an expression, get a constant or none. pub fn expr(&mut self, e: &Expr<'_>) -> Option { - if let Some((ref cond, ref then, otherwise)) = higher::if_block(&e) { - return self.ifthenelse(cond, then, otherwise); - } match e.kind { ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id, self.typeck_results.expr_ty(e)), ExprKind::Block(ref block, _) => self.block(block), @@ -249,6 +246,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { UnOp::UnNeg => self.constant_negate(&o, self.typeck_results.expr_ty(e)), UnOp::UnDeref => Some(if let Constant::Ref(r) = o { *r } else { o }), }), + ExprKind::If(ref cond, ref then, ref otherwise) => self.ifthenelse(cond, then, *otherwise), ExprKind::Binary(op, ref left, ref right) => self.binop(op, left, right), ExprKind::Call(ref callee, ref args) => { // We only handle a few const functions for now. diff --git a/src/tools/clippy/clippy_lints/src/copies.rs b/src/tools/clippy/clippy_lints/src/copies.rs index 46ce92ea6d782..6f48ffeb0e9c9 100644 --- a/src/tools/clippy/clippy_lints/src/copies.rs +++ b/src/tools/clippy/clippy_lints/src/copies.rs @@ -1,6 +1,6 @@ use crate::utils::{eq_expr_value, in_macro, search_same, SpanlessEq, SpanlessHash}; -use crate::utils::{get_parent_expr, higher, if_sequence, span_lint_and_note}; -use rustc_hir::{Block, Expr}; +use crate::utils::{get_parent_expr, if_sequence, span_lint_and_note}; +use rustc_hir::{Block, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -109,11 +109,12 @@ impl<'tcx> LateLintPass<'tcx> for CopyAndPaste { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if !expr.span.from_expansion() { // skip ifs directly in else, it will be checked in the parent if - if let Some(expr) = get_parent_expr(cx, expr) { - if let Some((_, _, Some(ref else_expr))) = higher::if_block(&expr) { - if else_expr.hir_id == expr.hir_id { - return; - } + if let Some(&Expr { + kind: ExprKind::If(_, _, Some(ref else_expr)), + .. + }) = get_parent_expr(cx, expr) { + if else_expr.hir_id == expr.hir_id { + return; } } diff --git a/src/tools/clippy/clippy_lints/src/entry.rs b/src/tools/clippy/clippy_lints/src/entry.rs index 35a5d00f4aa5a..37948e06869c3 100644 --- a/src/tools/clippy/clippy_lints/src/entry.rs +++ b/src/tools/clippy/clippy_lints/src/entry.rs @@ -1,5 +1,5 @@ use crate::utils::SpanlessEq; -use crate::utils::{get_item_name, higher, is_type_diagnostic_item, match_type, paths, snippet, snippet_opt}; +use crate::utils::{get_item_name, is_type_diagnostic_item, match_type, paths, snippet, snippet_opt}; use crate::utils::{snippet_with_applicability, span_lint_and_then}; use if_chain::if_chain; use rustc_errors::Applicability; @@ -54,7 +54,7 @@ declare_lint_pass!(HashMapPass => [MAP_ENTRY]); impl<'tcx> LateLintPass<'tcx> for HashMapPass { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - if let Some((ref check, ref then_block, ref else_block)) = higher::if_block(&expr) { + if let ExprKind::If(ref check, ref then_block, ref else_block) = expr.kind { if let ExprKind::Unary(UnOp::UnNot, ref check) = check.kind { if let Some((ty, map, key)) = check_cond(cx, check) { // in case of `if !m.contains_key(&k) { m.insert(k, v); }` diff --git a/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs b/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs index 18fea8b34bfd4..ffef78aac8067 100644 --- a/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs +++ b/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs @@ -2,7 +2,7 @@ use crate::consts::{ constant, constant_simple, Constant, Constant::{Int, F32, F64}, }; -use crate::utils::{eq_expr_value, get_parent_expr, higher, numeric_literal, span_lint_and_sugg, sugg}; +use crate::utils::{eq_expr_value, get_parent_expr, numeric_literal, span_lint_and_sugg, sugg}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment, UnOp}; @@ -556,11 +556,11 @@ fn are_negated<'a>(cx: &LateContext<'_>, expr1: &'a Expr<'a>, expr2: &'a Expr<'a fn check_custom_abs(cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { - if let Some((cond, body, Some(else_body))) = higher::if_block(&expr); + if let ExprKind::If(cond, body, else_body) = expr.kind; if let ExprKind::Block(block, _) = body.kind; if block.stmts.is_empty(); if let Some(if_body_expr) = block.expr; - if let ExprKind::Block(else_block, _) = else_body.kind; + if let Some(ExprKind::Block(else_block, _)) = else_body.map(|el| &el.kind); if else_block.stmts.is_empty(); if let Some(else_body_expr) = else_block.expr; if let Some((if_expr_positive, body)) = are_negated(cx, if_body_expr, else_body_expr); diff --git a/src/tools/clippy/clippy_lints/src/implicit_return.rs b/src/tools/clippy/clippy_lints/src/implicit_return.rs index 03e95c9e27f6a..109d90ff772b5 100644 --- a/src/tools/clippy/clippy_lints/src/implicit_return.rs +++ b/src/tools/clippy/clippy_lints/src/implicit_return.rs @@ -81,6 +81,13 @@ fn expr_match(cx: &LateContext<'_>, expr: &Expr<'_>) { lint(cx, expr.span, break_expr.span, LINT_BREAK); } }, + ExprKind::If(.., if_expr, else_expr) => { + expr_match(cx, if_expr); + + if let Some(else_expr) = else_expr { + expr_match(cx, else_expr); + } + }, ExprKind::Match(.., arms, source) => { let check_all_arms = match source { MatchSource::IfLetDesugar { diff --git a/src/tools/clippy/clippy_lints/src/implicit_saturating_sub.rs b/src/tools/clippy/clippy_lints/src/implicit_saturating_sub.rs index 3a01acd8fdc97..16e162badb5ee 100644 --- a/src/tools/clippy/clippy_lints/src/implicit_saturating_sub.rs +++ b/src/tools/clippy/clippy_lints/src/implicit_saturating_sub.rs @@ -1,4 +1,4 @@ -use crate::utils::{higher, in_macro, match_qpath, span_lint_and_sugg, SpanlessEq}; +use crate::utils::{in_macro, match_qpath, span_lint_and_sugg, SpanlessEq}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; @@ -42,7 +42,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub { return; } if_chain! { - if let Some((ref cond, ref then, None)) = higher::if_block(&expr); + if let ExprKind::If(cond, then, None) = &expr.kind; // Check if the conditional expression is a binary operation if let ExprKind::Binary(ref cond_op, ref cond_left, ref cond_right) = cond.kind; diff --git a/src/tools/clippy/clippy_lints/src/let_if_seq.rs b/src/tools/clippy/clippy_lints/src/let_if_seq.rs index 0d2d95324c4f7..db717cd1240a4 100644 --- a/src/tools/clippy/clippy_lints/src/let_if_seq.rs +++ b/src/tools/clippy/clippy_lints/src/let_if_seq.rs @@ -1,5 +1,4 @@ -use crate::utils::visitors::LocalUsedVisitor; -use crate::utils::{higher, qpath_res, snippet, span_lint_and_then}; +use crate::utils::{qpath_res, snippet, span_lint_and_then, visitors::LocalUsedVisitor}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; @@ -64,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq { if let hir::StmtKind::Local(ref local) = stmt.kind; if let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.kind; if let hir::StmtKind::Expr(ref if_) = expr.kind; - if let Some((ref cond, ref then, ref else_)) = higher::if_block(&if_); + if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.kind; if !LocalUsedVisitor::new(canonical_id).check_expr(cond); if let hir::ExprKind::Block(ref then, _) = then.kind; if let Some(value) = check_assign(cx, canonical_id, &*then); diff --git a/src/tools/clippy/clippy_lints/src/loops.rs b/src/tools/clippy/clippy_lints/src/loops.rs index 1bd96b2b4c89b..281964ee5e8f3 100644 --- a/src/tools/clippy/clippy_lints/src/loops.rs +++ b/src/tools/clippy/clippy_lints/src/loops.rs @@ -742,6 +742,14 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult { // Break can come from the inner loop so remove them. absorb_break(&never_loop_block(b, main_loop_id)) }, + ExprKind::If(ref e, ref e2, ref e3) => { + let e1 = never_loop_expr(e, main_loop_id); + let e2 = never_loop_expr(e2, main_loop_id); + let e3 = e3 + .as_ref() + .map_or(NeverLoopResult::Otherwise, |e| never_loop_expr(e, main_loop_id)); + combine_seq(e1, combine_branches(e2, e3)) + }, ExprKind::Match(ref e, ref arms, _) => { let e = never_loop_expr(e, main_loop_id); if arms.is_empty() { @@ -2594,7 +2602,7 @@ fn is_loop(expr: &Expr<'_>) -> bool { } fn is_conditional(expr: &Expr<'_>) -> bool { - matches!(expr.kind, ExprKind::Match(..)) + matches!(expr.kind, ExprKind::If(..) | ExprKind::Match(..)) } fn is_nested(cx: &LateContext<'_>, match_expr: &Expr<'_>, iter_expr: &Expr<'_>) -> bool { diff --git a/src/tools/clippy/clippy_lints/src/manual_strip.rs b/src/tools/clippy/clippy_lints/src/manual_strip.rs index 3c4368a3545a9..a0cfe145a301c 100644 --- a/src/tools/clippy/clippy_lints/src/manual_strip.rs +++ b/src/tools/clippy/clippy_lints/src/manual_strip.rs @@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip { } if_chain! { - if let Some((cond, then, _)) = higher::if_block(&expr); + if let ExprKind::If(cond, then, _) = &expr.kind; if let ExprKind::MethodCall(_, _, [target_arg, pattern], _) = cond.kind; if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(cond.hir_id); if let ExprKind::Path(target_path) = &target_arg.kind; diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index 2658c365e1357..6e8102790a594 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -2048,6 +2048,7 @@ fn lint_expect_fun_call( hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) // These variants are debatable or require further examination + | hir::ExprKind::If(..) | hir::ExprKind::Match(..) | hir::ExprKind::Block{ .. } => true, _ => false, diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_filter_map.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_filter_map.rs index d082a88cd2db5..d98e6160d3085 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -90,6 +90,12 @@ fn check_expression<'tcx>(cx: &LateContext<'tcx>, arg_id: hir::HirId, expr: &'tc } (found_mapping, found_filtering) }, + // There must be an else_arm or there will be a type error + hir::ExprKind::If(_, ref if_arm, Some(ref else_arm)) => { + let if_check = check_expression(cx, arg_id, if_arm); + let else_check = check_expression(cx, arg_id, else_arm); + (if_check.0 | else_check.0, if_check.1 | else_check.1) + }, hir::ExprKind::Path(path) if match_qpath(path, &paths::OPTION_NONE) => (false, true), _ => (true, true), } diff --git a/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs b/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs index 76417aa7ed09d..71f91eb4bfbe3 100644 --- a/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs +++ b/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs @@ -90,6 +90,10 @@ impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> { self.found = true; return; }, + ExprKind::If(..) => { + self.found = true; + return; + }, ExprKind::Path(_) => { if let Some(adj) = self.cx.typeck_results().adjustments().get(expr.hir_id) { if adj diff --git a/src/tools/clippy/clippy_lints/src/needless_bool.rs b/src/tools/clippy/clippy_lints/src/needless_bool.rs index 42f97b2ac497a..6b9a37b525201 100644 --- a/src/tools/clippy/clippy_lints/src/needless_bool.rs +++ b/src/tools/clippy/clippy_lints/src/needless_bool.rs @@ -4,7 +4,7 @@ use crate::utils::sugg::Sugg; use crate::utils::{ - higher, is_expn_of, parent_node_is_if_expr, snippet_with_applicability, span_lint, span_lint_and_sugg, + is_expn_of, parent_node_is_if_expr, snippet_with_applicability, span_lint, span_lint_and_sugg, }; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; @@ -71,7 +71,7 @@ declare_lint_pass!(NeedlessBool => [NEEDLESS_BOOL]); impl<'tcx> LateLintPass<'tcx> for NeedlessBool { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { use self::Expression::{Bool, RetBool}; - if let Some((ref pred, ref then_block, Some(ref else_expr))) = higher::if_block(&e) { + if let ExprKind::If(ref pred, ref then_block, Some(ref else_expr)) = e.kind { let reduce = |ret, not| { let mut applicability = Applicability::MachineApplicable; let snip = Sugg::hir_with_applicability(cx, pred, "", &mut applicability); diff --git a/src/tools/clippy/clippy_lints/src/option_if_let_else.rs b/src/tools/clippy/clippy_lints/src/option_if_let_else.rs index 681dbce97697e..391f893ef35ff 100644 --- a/src/tools/clippy/clippy_lints/src/option_if_let_else.rs +++ b/src/tools/clippy/clippy_lints/src/option_if_let_else.rs @@ -109,25 +109,26 @@ fn extract_body_from_arm<'a>(arm: &'a Arm<'a>) -> Option<&'a Expr<'a>> { /// it in curly braces. Otherwise, we don't. fn should_wrap_in_braces(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { utils::get_enclosing_block(cx, expr.hir_id).map_or(false, |parent| { + let mut should_wrap = false; + if let Some(Expr { kind: ExprKind::Match( _, arms, - MatchSource::IfDesugar { - contains_else_clause: true, - } - | MatchSource::IfLetDesugar { + MatchSource::IfLetDesugar { contains_else_clause: true, }, ), .. }) = parent.expr { - expr.hir_id == arms[1].body.hir_id - } else { - false + should_wrap = expr.hir_id == arms[1].body.hir_id; + } else if let Some(Expr { kind: ExprKind::If(_, _, Some(else_clause)), .. }) = parent.expr { + should_wrap = expr.hir_id == else_clause.hir_id; } + + should_wrap }) } diff --git a/src/tools/clippy/clippy_lints/src/question_mark.rs b/src/tools/clippy/clippy_lints/src/question_mark.rs index b91233ac58280..6c480d48c7561 100644 --- a/src/tools/clippy/clippy_lints/src/question_mark.rs +++ b/src/tools/clippy/clippy_lints/src/question_mark.rs @@ -8,7 +8,7 @@ use rustc_span::sym; use crate::utils::sugg::Sugg; use crate::utils::{ - eq_expr_value, higher, is_type_diagnostic_item, match_def_path, match_qpath, paths, snippet_with_applicability, + eq_expr_value, is_type_diagnostic_item, match_def_path, match_qpath, paths, snippet_with_applicability, span_lint_and_sugg, }; @@ -50,7 +50,7 @@ impl QuestionMark { /// If it matches, it will suggest to use the question mark operator instead fn check_is_none_and_early_return_none(cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { - if let Some((if_expr, body, else_)) = higher::if_block(&expr); + if let ExprKind::If(if_expr, body, else_) = &expr.kind; if let ExprKind::MethodCall(segment, _, args, _) = &if_expr.kind; if segment.ident.name == sym!(is_none); if Self::expression_returns_none(cx, body); diff --git a/src/tools/clippy/clippy_lints/src/returns.rs b/src/tools/clippy/clippy_lints/src/returns.rs index 7f4913a02cbd3..35827e027aab8 100644 --- a/src/tools/clippy/clippy_lints/src/returns.rs +++ b/src/tools/clippy/clippy_lints/src/returns.rs @@ -184,6 +184,14 @@ fn check_final_expr<'tcx>( ExprKind::Block(ref block, _) => { check_block_return(cx, block); }, + ExprKind::If(_, then, else_clause_opt) => { + if let ExprKind::Block(ref ifblock, _) = then.kind { + check_block_return(cx, ifblock); + } + if let Some(else_clause) = else_clause_opt { + check_final_expr(cx, else_clause, None, RetReplacement::Empty); + } + }, // a match expr, check all arms // an if/if let expr, check both exprs // note, if without else is going to be a type checking error anyways @@ -194,9 +202,6 @@ fn check_final_expr<'tcx>( check_final_expr(cx, &arm.body, Some(arm.body.span), RetReplacement::Block); } }, - MatchSource::IfDesugar { - contains_else_clause: true, - } | MatchSource::IfLetDesugar { contains_else_clause: true, } => { diff --git a/src/tools/clippy/clippy_lints/src/shadow.rs b/src/tools/clippy/clippy_lints/src/shadow.rs index f839659267825..f2f3dfa09a7d4 100644 --- a/src/tools/clippy/clippy_lints/src/shadow.rs +++ b/src/tools/clippy/clippy_lints/src/shadow.rs @@ -333,6 +333,13 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut check_expr(cx, e, bindings) } }, + ExprKind::If(ref cond, ref then, ref otherwise) => { + check_expr(cx, cond, bindings); + check_expr(cx, &**then, bindings); + if let Some(ref o) = *otherwise { + check_expr(cx, o, bindings); + } + }, ExprKind::Match(ref init, arms, _) => { check_expr(cx, init, bindings); let len = bindings.len(); diff --git a/src/tools/clippy/clippy_lints/src/unwrap.rs b/src/tools/clippy/clippy_lints/src/unwrap.rs index f4a77e54dd149..6a87f53436980 100644 --- a/src/tools/clippy/clippy_lints/src/unwrap.rs +++ b/src/tools/clippy/clippy_lints/src/unwrap.rs @@ -1,5 +1,5 @@ use crate::utils::{ - differing_macro_contexts, higher::if_block, is_type_diagnostic_item, span_lint_and_then, + differing_macro_contexts, is_type_diagnostic_item, span_lint_and_then, usage::is_potentially_mutated, }; use if_chain::if_chain; @@ -158,7 +158,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { if in_external_macro(self.cx.tcx.sess, expr.span) { return; } - if let Some((cond, then, els)) = if_block(&expr) { + if let ExprKind::If(cond, then, els) = &expr.kind { walk_expr(self, cond); self.visit_branch(cond, then, false); if let Some(els) = els { diff --git a/src/tools/clippy/clippy_lints/src/utils/author.rs b/src/tools/clippy/clippy_lints/src/utils/author.rs index 4249dbb4e6519..43afa65de3e55 100644 --- a/src/tools/clippy/clippy_lints/src/utils/author.rs +++ b/src/tools/clippy/clippy_lints/src/utils/author.rs @@ -1,7 +1,7 @@ //! A group of attributes that can be attached to Rust code in order //! to generate a clippy lint detecting said code automatically. -use crate::utils::{get_attr, higher}; +use crate::utils::get_attr; use rustc_ast::ast::{Attribute, LitFloatType, LitKind}; use rustc_ast::walk_list; use rustc_data_structures::fx::FxHashMap; @@ -201,32 +201,6 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { #[allow(clippy::too_many_lines)] fn visit_expr(&mut self, expr: &Expr<'_>) { - // handle if desugarings - // TODO add more desugarings here - if let Some((cond, then, opt_else)) = higher::if_block(&expr) { - let cond_pat = self.next("cond"); - let then_pat = self.next("then"); - if let Some(else_) = opt_else { - let else_pat = self.next("else_"); - println!( - " if let Some((ref {}, ref {}, Some({}))) = higher::if_block(&{});", - cond_pat, then_pat, else_pat, self.current - ); - self.current = else_pat; - self.visit_expr(else_); - } else { - println!( - " if let Some((ref {}, ref {}, None)) = higher::if_block(&{});", - cond_pat, then_pat, self.current - ); - } - self.current = cond_pat; - self.visit_expr(cond); - self.current = then_pat; - self.visit_expr(then); - return; - } - print!(" if let ExprKind::"); let current = format!("{}.kind", self.current); match expr.kind { @@ -351,6 +325,25 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { self.current = body_pat; self.visit_block(body); }, + ExprKind::If(ref cond, ref then, ref opt_else) => { + let cond_pat = self.next("cond"); + let then_pat = self.next("then"); + if let Some(ref else_) = *opt_else { + let else_pat = self.next("else_"); + println!( + "If(ref {}, ref {}, Some(ref {})) = {};", + cond_pat, then_pat, else_pat, current + ); + self.current = else_pat; + self.visit_expr(else_); + } else { + println!("If(ref {}, ref {}, None) = {};", cond_pat, then_pat, current); + } + self.current = cond_pat; + self.visit_expr(cond); + self.current = then_pat; + self.visit_expr(then); + }, ExprKind::Match(ref expr, ref arms, desugaring) => { let des = desugaring_name(desugaring); let expr_pat = self.next("expr"); @@ -743,10 +736,6 @@ fn desugaring_name(des: hir::MatchSource) -> String { contains_else_clause ), hir::MatchSource::IfLetGuardDesugar => "MatchSource::IfLetGuardDesugar".to_string(), - hir::MatchSource::IfDesugar { contains_else_clause } => format!( - "MatchSource::IfDesugar {{ contains_else_clause: {} }}", - contains_else_clause - ), hir::MatchSource::AwaitDesugar => "MatchSource::AwaitDesugar".to_string(), } } diff --git a/src/tools/clippy/clippy_lints/src/utils/eager_or_lazy.rs b/src/tools/clippy/clippy_lints/src/utils/eager_or_lazy.rs index 8fe5ddee1ca8d..2f157c5030f44 100644 --- a/src/tools/clippy/clippy_lints/src/utils/eager_or_lazy.rs +++ b/src/tools/clippy/clippy_lints/src/utils/eager_or_lazy.rs @@ -62,6 +62,7 @@ fn identify_some_pure_patterns(expr: &Expr<'_>) -> bool { | ExprKind::Type(..) | ExprKind::DropTemps(..) | ExprKind::Loop(..) + | ExprKind::If(..) | ExprKind::Match(..) | ExprKind::Closure(..) | ExprKind::Block(..) diff --git a/src/tools/clippy/clippy_lints/src/utils/higher.rs b/src/tools/clippy/clippy_lints/src/utils/higher.rs index 01ffac5b5599d..9b3585865da32 100644 --- a/src/tools/clippy/clippy_lints/src/utils/higher.rs +++ b/src/tools/clippy/clippy_lints/src/utils/higher.rs @@ -170,33 +170,6 @@ pub fn while_loop<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> Option<(&'tcx hir::Expr< None } -/// Recover the essential nodes of a desugared if block -/// `if cond { then } else { els }` becomes `(cond, then, Some(els))` -pub fn if_block<'tcx>( - expr: &'tcx hir::Expr<'tcx>, -) -> Option<( - &'tcx hir::Expr<'tcx>, - &'tcx hir::Expr<'tcx>, - Option<&'tcx hir::Expr<'tcx>>, -)> { - if let hir::ExprKind::Match(ref cond, ref arms, hir::MatchSource::IfDesugar { contains_else_clause }) = expr.kind { - let cond = if let hir::ExprKind::DropTemps(ref cond) = cond.kind { - cond - } else { - panic!("If block desugar must contain DropTemps"); - }; - let then = &arms[0].body; - let els = if contains_else_clause { - Some(&*arms[1].body) - } else { - None - }; - Some((cond, then, els)) - } else { - None - } -} - /// Represent the pre-expansion arguments of a `vec!` invocation. pub enum VecArgs<'a> { /// `vec![elem; len]` @@ -267,12 +240,11 @@ pub fn extract_assert_macro_args<'tcx>(e: &'tcx Expr<'tcx>) -> Option SpanlessEq<'a, 'tcx> { (&ExprKind::Index(ref la, ref li), &ExprKind::Index(ref ra, ref ri)) => { self.eq_expr(la, ra) && self.eq_expr(li, ri) }, + (&ExprKind::If(ref lc, ref lt, ref le), &ExprKind::If(ref rc, ref rt, ref re)) => { + self.eq_expr(lc, rc) && self.eq_expr(&**lt, &**rt) && both(le, re, |l, r| self.eq_expr(l, r)) + }, (&ExprKind::Lit(ref l), &ExprKind::Lit(ref r)) => l.node == r.node, (&ExprKind::Loop(ref lb, ref ll, ref lls), &ExprKind::Loop(ref rb, ref rl, ref rls)) => { lls == rls && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.as_str() == r.ident.as_str()) @@ -564,6 +567,15 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { self.hash_name(i.ident.name); } }, + ExprKind::If(ref cond, ref then, ref else_opt) => { + let c: fn(_, _, _) -> _ = ExprKind::If; + c.hash(&mut self.s); + self.hash_expr(cond); + self.hash_expr(&**then); + if let Some(ref e) = *else_opt { + self.hash_expr(e); + } + }, ExprKind::Match(ref e, arms, ref s) => { self.hash_expr(e); diff --git a/src/tools/clippy/clippy_lints/src/utils/inspector.rs b/src/tools/clippy/clippy_lints/src/utils/inspector.rs index a02c0a3f44d71..9bec24be9e4eb 100644 --- a/src/tools/clippy/clippy_lints/src/utils/inspector.rs +++ b/src/tools/clippy/clippy_lints/src/utils/inspector.rs @@ -213,6 +213,15 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) { hir::ExprKind::Loop(..) => { println!("{}Loop", ind); }, + hir::ExprKind::If(ref cond, _, ref else_opt) => { + println!("{}If", ind); + println!("{}condition:", ind); + print_expr(cx, cond, indent + 1); + if let Some(ref els) = *else_opt { + println!("{}else:", ind); + print_expr(cx, els, indent + 1); + } + }, hir::ExprKind::Match(ref cond, _, ref source) => { println!("{}Match", ind); println!("{}condition:", ind); diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index 87f99019d72da..3e39a47f1963d 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -1405,7 +1405,7 @@ pub fn if_sequence<'tcx>( let mut conds = SmallVec::new(); let mut blocks: SmallVec<[&Block<'_>; 1]> = SmallVec::new(); - while let Some((ref cond, ref then_expr, ref else_expr)) = higher::if_block(&expr) { + while let ExprKind::If(ref cond, ref then_expr, ref else_expr) = expr.kind { conds.push(&**cond); if let ExprKind::Block(ref block, _) = then_expr.kind { blocks.push(block); @@ -1434,11 +1434,11 @@ pub fn parent_node_is_if_expr(expr: &Expr<'_>, cx: &LateContext<'_>) -> bool { let map = cx.tcx.hir(); let parent_id = map.get_parent_node(expr.hir_id); let parent_node = map.get(parent_id); - - match parent_node { - Node::Expr(e) => higher::if_block(&e).is_some(), - Node::Arm(e) => higher::if_block(&e.body).is_some(), - _ => false, + if let Node::Expr(Expr { kind: ExprKind::If(_, _, _), .. }) = parent_node { + true + } + else { + false } } diff --git a/src/tools/clippy/clippy_lints/src/utils/sugg.rs b/src/tools/clippy/clippy_lints/src/utils/sugg.rs index 1fcd41e4dbfed..03678db575f0d 100644 --- a/src/tools/clippy/clippy_lints/src/utils/sugg.rs +++ b/src/tools/clippy/clippy_lints/src/utils/sugg.rs @@ -103,6 +103,7 @@ impl<'a> Sugg<'a> { match expr.kind { hir::ExprKind::AddrOf(..) | hir::ExprKind::Box(..) + | hir::ExprKind::If(..) | hir::ExprKind::Closure(..) | hir::ExprKind::Unary(..) | hir::ExprKind::Match(..) => Sugg::MaybeParen(snippet), diff --git a/src/tools/clippy/clippy_lints/src/utils/visitors.rs b/src/tools/clippy/clippy_lints/src/utils/visitors.rs index 28b3e79d7a6d6..b769a18802b6b 100644 --- a/src/tools/clippy/clippy_lints/src/utils/visitors.rs +++ b/src/tools/clippy/clippy_lints/src/utils/visitors.rs @@ -101,6 +101,13 @@ where } } else { match expr.kind { + hir::ExprKind::If(cond, then, else_opt) => { + self.inside_stmt(true).visit_expr(cond); + self.visit_expr(then); + if let Some(el) = else_opt { + self.visit_expr(el); + } + } hir::ExprKind::Match(cond, arms, _) => { self.inside_stmt(true).visit_expr(cond); for arm in arms { diff --git a/src/tools/clippy/tests/ui/author/if.stdout b/src/tools/clippy/tests/ui/author/if.stdout index c18d035953e53..cac64a3f40b41 100644 --- a/src/tools/clippy/tests/ui/author/if.stdout +++ b/src/tools/clippy/tests/ui/author/if.stdout @@ -1,7 +1,7 @@ if_chain! { if let StmtKind::Local(ref local) = stmt.kind; if let Some(ref init) = local.init; - if let Some((ref cond, ref then, Some(else_))) = higher::if_block(&init); + if let ExprKind::If(ref cond, ref then, Some(ref else_)) = init.kind; if let ExprKind::Block(ref block) = else_.kind; if let Some(trailing_expr) = &block.expr; if block.stmts.len() == 1; diff --git a/src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr b/src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr index 86f61ad718a9c..a17f043737d4e 100644 --- a/src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr +++ b/src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr @@ -14,7 +14,7 @@ note: return Err() instead of panicking --> $DIR/panic_in_result_fn_assertions.rs:9:9 | LL | assert!(x == 5, "wrong argument"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`