Auto merge of #3591 - flip1995:rustup, r=phansch

Match on ast/hir::ExprKind::Err

rustup rust-lang/rust#56999
This commit is contained in:
bors 2018-12-28 14:07:53 +00:00
commit 32b3bc231b
5 changed files with 13 additions and 3 deletions

View File

@ -756,7 +756,8 @@ fn never_loop_expr(expr: &Expr, main_loop_id: NodeId) -> NeverLoopResult {
| ExprKind::Closure(_, _, _, _, _)
| ExprKind::InlineAsm(_, _, _)
| ExprKind::Path(_)
| ExprKind::Lit(_) => NeverLoopResult::Otherwise,
| ExprKind::Lit(_)
| ExprKind::Err => NeverLoopResult::Otherwise,
}
}

View File

@ -504,6 +504,9 @@ fn visit_expr(&mut self, expr: &Expr) {
self.current = value_pat;
self.visit_expr(value);
},
ExprKind::Err => {
println!("Err = {}", current);
},
}
}

View File

@ -615,6 +615,7 @@ pub fn hash_expr(&mut self, e: &Expr) {
self.hash_name(l.ident.name);
}
},
ExprKind::Err => {},
}
}

View File

@ -347,6 +347,9 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
println!("{}repeat count:", ind);
print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1);
},
hir::ExprKind::Err => {
println!("{}Err", ind);
},
}
}

View File

@ -79,7 +79,8 @@ pub fn hir_opt(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> Option<Self> {
| hir::ExprKind::Ret(..)
| hir::ExprKind::Struct(..)
| hir::ExprKind::Tup(..)
| hir::ExprKind::While(..) => Sugg::NonParen(snippet),
| hir::ExprKind::While(..)
| hir::ExprKind::Err => Sugg::NonParen(snippet),
hir::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet),
hir::ExprKind::AssignOp(op, ..) => Sugg::BinOp(hirbinop2assignop(op), snippet),
hir::ExprKind::Binary(op, ..) => Sugg::BinOp(AssocOp::from_ast_binop(higher::binop(op.node)), snippet),
@ -158,7 +159,8 @@ pub fn ast(cx: &EarlyContext<'_>, expr: &ast::Expr, default: &'a str) -> Self {
| ast::ExprKind::Tup(..)
| ast::ExprKind::Array(..)
| ast::ExprKind::While(..)
| ast::ExprKind::WhileLet(..) => Sugg::NonParen(snippet),
| ast::ExprKind::WhileLet(..)
| ast::ExprKind::Err => Sugg::NonParen(snippet),
ast::ExprKind::Range(.., RangeLimits::HalfOpen) => Sugg::BinOp(AssocOp::DotDot, snippet),
ast::ExprKind::Range(.., RangeLimits::Closed) => Sugg::BinOp(AssocOp::DotDotEq, snippet),
ast::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet),