Skip to content

Commit 1d15a9c

Browse files
committed
fix suggestions
1 parent 538c1e8 commit 1d15a9c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

clippy_lints/src/mutable_debug_assertion.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ fn extract_call<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, e: &'tcx Expr) -> Optio
6565
if let ExprKind::Unary(UnOp::UnNot, ref condition) = droptmp.kind;
6666
then {
6767
// debug_assert
68-
return MutArgVisitor::go(cx, condition);
68+
let mut visitor = MutArgVisitor::new(cx);
69+
visitor.visit_expr(condition);
70+
return visitor.expr_span();
6971
} else {
7072
// debug_assert_{eq,ne}
7173
if_chain! {
@@ -76,12 +78,16 @@ fn extract_call<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, e: &'tcx Expr) -> Optio
7678
if conditions.len() == 2;
7779
then {
7880
if let ExprKind::AddrOf(_, ref lhs) = conditions[0].kind {
79-
if let Some(span) = MutArgVisitor::go(cx, lhs) {
81+
let mut visitor = MutArgVisitor::new(cx);
82+
visitor.visit_expr(lhs);
83+
if let Some(span) = visitor.expr_span() {
8084
return Some(span);
8185
}
8286
}
8387
if let ExprKind::AddrOf(_, ref rhs) = conditions[1].kind {
84-
if let Some(span) = MutArgVisitor::go(cx, rhs) {
88+
let mut visitor = MutArgVisitor::new(cx);
89+
visitor.visit_expr(rhs);
90+
if let Some(span) = visitor.expr_span() {
8591
return Some(span);
8692
}
8793
}
@@ -110,19 +116,13 @@ impl<'a, 'tcx> MutArgVisitor<'a, 'tcx> {
110116
}
111117
}
112118

113-
fn get_span(&self) -> Option<Span> {
119+
fn expr_span(&self) -> Option<Span> {
114120
if self.found {
115121
self.expr_span
116122
} else {
117123
None
118124
}
119125
}
120-
121-
fn go(cx: &'a LateContext<'a, 'tcx>, start: &'tcx Expr) -> Option<Span> {
122-
let mut s = Self::new(cx);
123-
s.visit_expr(start);
124-
s.get_span()
125-
}
126126
}
127127

128128
impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> {
@@ -150,6 +150,6 @@ impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> {
150150
}
151151

152152
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
153-
NestedVisitorMap::All(&self.cx.tcx.hir())
153+
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir())
154154
}
155155
}

0 commit comments

Comments
 (0)