Skip to content

Commit 909bfd3

Browse files
committed
Match on ast/hir::ExprKind::Err
1 parent dfe1232 commit 909bfd3

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

clippy_lints/src/loops.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,8 @@ fn never_loop_expr(expr: &Expr, main_loop_id: NodeId) -> NeverLoopResult {
756756
| ExprKind::Closure(_, _, _, _, _)
757757
| ExprKind::InlineAsm(_, _, _)
758758
| ExprKind::Path(_)
759-
| ExprKind::Lit(_) => NeverLoopResult::Otherwise,
759+
| ExprKind::Lit(_)
760+
| ExprKind::Err => NeverLoopResult::Otherwise,
760761
}
761762
}
762763

clippy_lints/src/utils/author.rs

+3
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
504504
self.current = value_pat;
505505
self.visit_expr(value);
506506
},
507+
ExprKind::Err => {
508+
println!("Err = {}", current);
509+
},
507510
}
508511
}
509512

clippy_lints/src/utils/hir_utils.rs

+1
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
615615
self.hash_name(l.ident.name);
616616
}
617617
},
618+
ExprKind::Err => {},
618619
}
619620
}
620621

clippy_lints/src/utils/inspector.rs

+3
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
347347
println!("{}repeat count:", ind);
348348
print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1);
349349
},
350+
hir::ExprKind::Err => {
351+
println!("{}Err", ind);
352+
},
350353
}
351354
}
352355

clippy_lints/src/utils/sugg.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ impl<'a> Sugg<'a> {
7979
| hir::ExprKind::Ret(..)
8080
| hir::ExprKind::Struct(..)
8181
| hir::ExprKind::Tup(..)
82-
| hir::ExprKind::While(..) => Sugg::NonParen(snippet),
82+
| hir::ExprKind::While(..)
83+
| hir::ExprKind::Err => Sugg::NonParen(snippet),
8384
hir::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet),
8485
hir::ExprKind::AssignOp(op, ..) => Sugg::BinOp(hirbinop2assignop(op), snippet),
8586
hir::ExprKind::Binary(op, ..) => Sugg::BinOp(AssocOp::from_ast_binop(higher::binop(op.node)), snippet),
@@ -158,7 +159,8 @@ impl<'a> Sugg<'a> {
158159
| ast::ExprKind::Tup(..)
159160
| ast::ExprKind::Array(..)
160161
| ast::ExprKind::While(..)
161-
| ast::ExprKind::WhileLet(..) => Sugg::NonParen(snippet),
162+
| ast::ExprKind::WhileLet(..)
163+
| ast::ExprKind::Err => Sugg::NonParen(snippet),
162164
ast::ExprKind::Range(.., RangeLimits::HalfOpen) => Sugg::BinOp(AssocOp::DotDot, snippet),
163165
ast::ExprKind::Range(.., RangeLimits::Closed) => Sugg::BinOp(AssocOp::DotDotEq, snippet),
164166
ast::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet),

0 commit comments

Comments
 (0)