Reintroduce hir::ExprKind::If

This commit is contained in:
Caio 2021-01-01 15:38:11 -03:00
parent c8915eebea
commit f85fc264fe
97 changed files with 1046 additions and 787 deletions

View File

@ -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 {
// `<pat> => <then>`:
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 => <then>`:
_ => {
// 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)
}

View File

@ -1398,6 +1398,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,
@ -1459,6 +1460,7 @@ impl Expr<'_> {
| ExprKind::MethodCall(..)
| ExprKind::Struct(..)
| ExprKind::Tup(..)
| ExprKind::If(..)
| ExprKind::Match(..)
| ExprKind::Closure(..)
| ExprKind::Block(..)
@ -1575,6 +1577,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 <expr> { <expr> } else { <expr> }`.
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 { <block> }`.
@ -1728,8 +1734,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.
@ -1752,7 +1756,7 @@ impl MatchSource {
use MatchSource::*;
match self {
Normal => "match",
IfDesugar { .. } | IfLetDesugar { .. } | IfLetGuardDesugar => "if",
IfLetDesugar { .. } | IfLetGuardDesugar => "if",
WhileDesugar | WhileLetDesugar => "while",
ForLoopDesugar => "for",
TryDesugar => "?",

View File

@ -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);

View File

@ -1083,6 +1083,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))
}
@ -1352,6 +1396,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);
@ -2436,7 +2483,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.

View File

@ -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);
}
_ => {}
}
}

View File

@ -531,6 +531,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::Borrow { .. }
| ExprKind::AddressOf { .. }
| ExprKind::Match { .. }
| ExprKind::If { .. }
| ExprKind::Loop { .. }
| ExprKind::Block { .. }
| ExprKind::Assign { .. }

View File

@ -251,6 +251,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::StaticRef { .. }
| ExprKind::Block { .. }
| ExprKind::Match { .. }
| ExprKind::If { .. }
| ExprKind::NeverToAny { .. }
| ExprKind::Use { .. }
| ExprKind::Borrow { .. }

View File

@ -45,6 +45,7 @@ impl Category {
ExprKind::LogicalOp { .. }
| ExprKind::Match { .. }
| ExprKind::If { .. }
| ExprKind::NeverToAny { .. }
| ExprKind::Use { .. }
| ExprKind::Adt { .. }

View File

@ -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 { .. });

View File

@ -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(),

View File

@ -139,6 +139,11 @@ crate enum ExprKind<'tcx> {
Box {
value: ExprRef<'tcx>,
},
If {
cond: ExprRef<'tcx>,
then: ExprRef<'tcx>,
else_opt: Option<ExprRef<'tcx>>,
},
Call {
ty: Ty<'tcx>,
fun: ExprRef<'tcx>,

View File

@ -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.

View File

@ -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)

View File

@ -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(..)

View File

@ -201,6 +201,7 @@ impl<'tcx> CheckInlineAssembly<'tcx> {
| ExprKind::Type(..)
| ExprKind::Loop(..)
| ExprKind::Match(..)
| ExprKind::If(..)
| ExprKind::Closure(..)
| ExprKind::Assign(..)
| ExprKind::AssignOp(..)

View File

@ -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);
}

View File

@ -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);

View File

@ -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<F, T>(
&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()));
}
None
}
);
fn if_cause(
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)
}
);
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<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(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<hir::Mutability> {

View File

@ -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))

View File

@ -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 {

View File

@ -803,33 +803,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<Span> = 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
}

View File

@ -358,6 +358,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ExprKind::Call(..)
| ExprKind::MethodCall(..)
| ExprKind::Loop(..)
| ExprKind::If(..)
| ExprKind::Match(..)
| ExprKind::Block(..) => {
err.span_suggestion(

View File

@ -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);

View File

@ -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(..)

View File

@ -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;

View File

@ -9,18 +9,12 @@
bb0: {
StorageLive(_1); // scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21
- _1 = const <bool as NeedsDrop>::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
}
}

View File

@ -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
}
}

View File

@ -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(<ZST>)) }
}
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

View File

@ -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
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
goto -> bb3; // scope 0 at $DIR/equal_true.rs:4:5: 4:34
}
bb2: {
_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
}
}

View File

@ -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
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
goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:17:5: 17:26
}
bb2: {
_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
}
}

View File

@ -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
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
goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:53:5: 53:35
}
bb2: {
_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
}
}

View File

@ -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
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
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 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
}
}

View File

@ -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
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
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 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
}
}

View File

@ -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
}
}

View File

@ -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
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
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 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
}
}

View File

@ -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
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
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 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
}
}

View File

@ -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
}
}

View File

@ -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
+ }
+

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}

View File

@ -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::<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>>}, val: Value(Scalar(<ZST>)) }
}
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

View File

@ -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::<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>>}, val: Value(Scalar(<ZST>)) }
}
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

View File

@ -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::<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>>}, val: Value(Scalar(<ZST>)) }
}
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

View File

@ -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::<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>>}, val: Value(Scalar(<ZST>)) }
}
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

View File

@ -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
}
}

View File

@ -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::<u64>) { // 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::<u64>) { // 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::<u64>(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::<u64>(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::<u64>}, val: Value(Scalar(<ZST>)) }
}
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
}

View File

@ -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: {
_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
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
}
- bb10: {
+ bb7: {
_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
- switchInt(move _9) -> [false: bb13, otherwise: bb12]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
- 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
}
- bb11: {
+ bb7: {
_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
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
}
- bb12: {
+ 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
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
}
- bb17: {
+ bb12: {
_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
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 -> 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
}
- bb18: {
- bb15: {
+ bb12: {
_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
- 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
}
- 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
+ }

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
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
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: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
}
}

View File

@ -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(<ZST>)): 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(<ZST>)) }
}
bb3: {
StorageLive(_10); // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:23:9: 23:18
_10 = Const(Value(Scalar(<ZST>)): 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(<ZST>)): 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(<ZST>)) }
}
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(<ZST>)): 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(<ZST>)) }
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(<ZST>)): ()); // 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(<ZST>)): ()); // 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(<ZST>)): ()); // 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(<ZST>)): ()); // 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
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
}
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
}
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
}
}

View File

@ -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(<ZST>)): 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(<ZST>)) }
}
bb3: {
StorageLive(_10); // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:23:9: 23:18
_10 = Const(Value(Scalar(<ZST>)): 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(<ZST>)): 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(<ZST>)) }
}
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(<ZST>)): 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(<ZST>)) }
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(<ZST>)): ()); // 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(<ZST>)): ()); // 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(<ZST>)): ()); // 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(<ZST>)): ()); // 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
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
}
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
}
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
}
}

View File

@ -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
}
}

View File

@ -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(<ZST>)) }
}
- 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
- }
-
- bb7: {
- goto -> bb8; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
- }
-
- bb8: {
- goto -> bb9; // 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
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
}
}

View File

@ -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(<ZST>)) }
}
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
}
}

View File

@ -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
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
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: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
}

View File

@ -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
- }
-

View File

@ -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
}

View File

@ -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: {

View File

@ -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(<ZST>)) }
}
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

View File

@ -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: {

View File

@ -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

View File

@ -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

View File

@ -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<AssertKind> {
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.

View File

@ -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() {

View File

@ -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;

View File

@ -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<Constant> {
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.

View File

@ -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;
}
}

View File

@ -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); }`

View File

@ -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);

View File

@ -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 {

View File

@ -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;

View File

@ -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);

View File

@ -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 {

View File

@ -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;

View File

@ -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,

View File

@ -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),
}

View File

@ -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

View File

@ -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, "<predicate>", &mut applicability);

View File

@ -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
})
}

View File

@ -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);

View File

@ -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,
} => {

View File

@ -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();

View File

@ -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 {

View File

@ -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(),
}
}

View File

@ -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(..)

View File

@ -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<Vec<&'tcx
if let ExprKind::Block(ref block, _) = e.kind {
if block.stmts.len() == 1 {
if let StmtKind::Semi(ref matchexpr) = block.stmts[0].kind {
if let StmtKind::Semi(ref matchexpr) = block.stmts.get(0)?.kind {
// macros with unique arg: `{debug_}assert!` (e.g., `debug_assert!(some_condition)`)
if_chain! {
if let ExprKind::Match(ref ifclause, _, _) = matchexpr.kind;
if let ExprKind::DropTemps(ref droptmp) = ifclause.kind;
if let ExprKind::Unary(UnOp::UnNot, condition) = droptmp.kind;
if let ExprKind::If(ref clause, _, _) = matchexpr.kind;
if let ExprKind::Unary(UnOp::UnNot, condition) = clause.kind;
then {
return Some(vec![condition]);
}

View File

@ -119,6 +119,9 @@ impl<'a, 'tcx> 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);

View File

@ -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);

View File

@ -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
}
}

View File

@ -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),

View File

@ -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 {

View File

@ -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;

View File

@ -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`