mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 09:44:08 +00:00
Small refactor of mutable_debug_assertions
This commit is contained in:
parent
b90101251f
commit
b31a3dff48
@ -61,38 +61,38 @@ fn extract_call<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) -> O
|
||||
if block.stmts.len() == 1;
|
||||
if let StmtKind::Semi(ref matchexpr) = block.stmts[0].kind;
|
||||
then {
|
||||
// debug_assert
|
||||
if_chain! {
|
||||
if let ExprKind::Match(ref ifclause, _, _) = matchexpr.kind;
|
||||
if let ExprKind::DropTemps(ref droptmp) = ifclause.kind;
|
||||
if let ExprKind::Unary(UnOp::UnNot, ref condition) = droptmp.kind;
|
||||
then {
|
||||
// debug_assert
|
||||
let mut visitor = MutArgVisitor::new(cx);
|
||||
visitor.visit_expr(condition);
|
||||
return visitor.expr_span();
|
||||
} else {
|
||||
// debug_assert_{eq,ne}
|
||||
if_chain! {
|
||||
if let ExprKind::Block(ref matchblock, _) = matchexpr.kind;
|
||||
if let Some(ref matchheader) = matchblock.expr;
|
||||
if let ExprKind::Match(ref headerexpr, _, _) = matchheader.kind;
|
||||
if let ExprKind::Tup(ref conditions) = headerexpr.kind;
|
||||
if conditions.len() == 2;
|
||||
then {
|
||||
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref lhs) = conditions[0].kind {
|
||||
let mut visitor = MutArgVisitor::new(cx);
|
||||
visitor.visit_expr(lhs);
|
||||
if let Some(span) = visitor.expr_span() {
|
||||
return Some(span);
|
||||
}
|
||||
}
|
||||
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref rhs) = conditions[1].kind {
|
||||
let mut visitor = MutArgVisitor::new(cx);
|
||||
visitor.visit_expr(rhs);
|
||||
if let Some(span) = visitor.expr_span() {
|
||||
return Some(span);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// debug_assert_{eq,ne}
|
||||
if_chain! {
|
||||
if let ExprKind::Block(ref matchblock, _) = matchexpr.kind;
|
||||
if let Some(ref matchheader) = matchblock.expr;
|
||||
if let ExprKind::Match(ref headerexpr, _, _) = matchheader.kind;
|
||||
if let ExprKind::Tup(ref conditions) = headerexpr.kind;
|
||||
if conditions.len() == 2;
|
||||
then {
|
||||
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref lhs) = conditions[0].kind {
|
||||
let mut visitor = MutArgVisitor::new(cx);
|
||||
visitor.visit_expr(lhs);
|
||||
if let Some(span) = visitor.expr_span() {
|
||||
return Some(span);
|
||||
}
|
||||
}
|
||||
if let ExprKind::AddrOf(BorrowKind::Ref, _, ref rhs) = conditions[1].kind {
|
||||
let mut visitor = MutArgVisitor::new(cx);
|
||||
visitor.visit_expr(rhs);
|
||||
if let Some(span) = visitor.expr_span() {
|
||||
return Some(span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user