Fix dogfood
This commit is contained in:
parent
5722a7dacd
commit
588367b62e
18 changed files with 41 additions and 56 deletions
|
|
@ -23,16 +23,16 @@ impl<'tcx> ForLoop<'tcx> {
|
|||
#[inline]
|
||||
pub fn hir(expr: &Expr<'tcx>) -> Option<Self> {
|
||||
if_chain! {
|
||||
if let hir::ExprKind::Match(ref iterexpr, ref arms, hir::MatchSource::ForLoopDesugar) = expr.kind;
|
||||
if let hir::ExprKind::Match(iterexpr, arms, hir::MatchSource::ForLoopDesugar) = expr.kind;
|
||||
if let Some(first_arm) = arms.get(0);
|
||||
if let hir::ExprKind::Call(_, ref iterargs) = iterexpr.kind;
|
||||
if let hir::ExprKind::Call(_, iterargs) = iterexpr.kind;
|
||||
if let Some(first_arg) = iterargs.get(0);
|
||||
if iterargs.len() == 1 && arms.len() == 1 && first_arm.guard.is_none();
|
||||
if let hir::ExprKind::Loop(ref block, ..) = first_arm.body.kind;
|
||||
if let hir::ExprKind::Loop(block, ..) = first_arm.body.kind;
|
||||
if block.expr.is_none();
|
||||
if let [ _, _, ref let_stmt, ref body ] = *block.stmts;
|
||||
if let hir::StmtKind::Local(ref local) = let_stmt.kind;
|
||||
if let hir::StmtKind::Expr(ref body_expr) = body.kind;
|
||||
if let hir::StmtKind::Local(local) = let_stmt.kind;
|
||||
if let hir::StmtKind::Expr(body_expr) = body.kind;
|
||||
then {
|
||||
return Some(Self {
|
||||
pat: &*local.pat,
|
||||
|
|
@ -189,7 +189,7 @@ impl<'a> Range<'a> {
|
|||
}
|
||||
|
||||
match expr.kind {
|
||||
hir::ExprKind::Call(ref path, ref args)
|
||||
hir::ExprKind::Call(path, args)
|
||||
if matches!(
|
||||
path.kind,
|
||||
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, _))
|
||||
|
|
@ -201,7 +201,7 @@ impl<'a> Range<'a> {
|
|||
limits: ast::RangeLimits::Closed,
|
||||
})
|
||||
},
|
||||
hir::ExprKind::Struct(ref path, ref fields, None) => match path {
|
||||
hir::ExprKind::Struct(path, fields, None) => match &path {
|
||||
hir::QPath::LangItem(hir::LangItem::RangeFull, _) => Some(Range {
|
||||
start: None,
|
||||
end: None,
|
||||
|
|
@ -247,7 +247,7 @@ impl<'a> VecArgs<'a> {
|
|||
/// from `vec!`.
|
||||
pub fn hir(cx: &LateContext<'_>, expr: &'a hir::Expr<'_>) -> Option<VecArgs<'a>> {
|
||||
if_chain! {
|
||||
if let hir::ExprKind::Call(ref fun, ref args) = expr.kind;
|
||||
if let hir::ExprKind::Call(fun, args) = expr.kind;
|
||||
if let hir::ExprKind::Path(ref qpath) = fun.kind;
|
||||
if is_expn_of(fun.span, "vec").is_some();
|
||||
if let Some(fun_def_id) = cx.qpath_res(qpath, fun.hir_id).opt_def_id();
|
||||
|
|
@ -259,10 +259,10 @@ impl<'a> VecArgs<'a> {
|
|||
else if match_def_path(cx, fun_def_id, &paths::SLICE_INTO_VEC) && args.len() == 1 {
|
||||
// `vec![a, b, c]` case
|
||||
if_chain! {
|
||||
if let hir::ExprKind::Box(ref boxed) = args[0].kind;
|
||||
if let hir::ExprKind::Array(ref args) = boxed.kind;
|
||||
if let hir::ExprKind::Box(boxed) = args[0].kind;
|
||||
if let hir::ExprKind::Array(args) = boxed.kind;
|
||||
then {
|
||||
return Some(VecArgs::Vec(&*args));
|
||||
return Some(VecArgs::Vec(args));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -566,7 +566,7 @@ pub fn is_from_for_desugar(local: &hir::Local<'_>) -> bool {
|
|||
// }
|
||||
// ```
|
||||
if_chain! {
|
||||
if let Some(ref expr) = local.init;
|
||||
if let Some(expr) = local.init;
|
||||
if let hir::ExprKind::Match(_, _, hir::MatchSource::ForLoopDesugar) = expr.kind;
|
||||
then {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -232,9 +232,7 @@ impl HirEqInterExpr<'_, '_, '_> {
|
|||
(&ExprKind::If(lc, lt, ref le), &ExprKind::If(rc, rt, ref re)) => {
|
||||
self.eq_expr(lc, rc) && self.eq_expr(&**lt, &**rt) && both(le, re, |l, r| self.eq_expr(l, r))
|
||||
},
|
||||
(&ExprKind::Let(ref lp, ref le, _), &ExprKind::Let(ref rp, ref re, _)) => {
|
||||
self.eq_pat(lp, rp) && self.eq_expr(le, re)
|
||||
},
|
||||
(&ExprKind::Let(lp, le, _), &ExprKind::Let(rp, re, _)) => self.eq_pat(lp, rp) && self.eq_expr(le, re),
|
||||
(&ExprKind::Lit(ref l), &ExprKind::Lit(ref r)) => l.node == r.node,
|
||||
(&ExprKind::Loop(lb, ref ll, ref lls, _), &ExprKind::Loop(rb, ref rl, ref rls, _)) => {
|
||||
lls == rls && self.eq_block(lb, rb) && both(ll, rl, |l, r| l.ident.name == r.ident.name)
|
||||
|
|
@ -668,7 +666,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
},
|
||||
ExprKind::Let(ref pat, ref expr, _) => {
|
||||
ExprKind::Let(pat, expr, _) => {
|
||||
self.hash_expr(expr);
|
||||
self.hash_pat(pat);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1603,13 +1603,13 @@ pub fn if_sequence<'tcx>(mut expr: &'tcx Expr<'tcx>) -> (Vec<&'tcx Expr<'tcx>>,
|
|||
|
||||
while let Some(higher::IfOrIfLet { cond, then, r#else }) = higher::IfOrIfLet::hir(expr) {
|
||||
conds.push(&*cond);
|
||||
if let ExprKind::Block(ref block, _) = then.kind {
|
||||
if let ExprKind::Block(block, _) = then.kind {
|
||||
blocks.push(block);
|
||||
} else {
|
||||
panic!("ExprKind::If node is not an ExprKind::Block");
|
||||
}
|
||||
|
||||
if let Some(ref else_expr) = r#else {
|
||||
if let Some(else_expr) = r#else {
|
||||
expr = else_expr;
|
||||
} else {
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue