Skip to content

Commit cfe4c15

Browse files
committed
Follow review comments
1 parent 4e222c6 commit cfe4c15

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

clippy_lints/src/if_let_mutex.rs

+5-20
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ declare_lint_pass!(IfLetMutex => [IF_LET_MUTEX]);
4545

4646
impl<'tcx> LateLintPass<'tcx> for IfLetMutex {
4747
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
48-
let mut arm_visit = ArmVisitor { cx };
49-
let mut op_visit = OppVisitor { cx };
48+
let mut arm_visit = MutexVisitor { cx };
49+
let mut op_visit = MutexVisitor { cx };
5050
if let Some(higher::IfLet {
5151
let_expr,
5252
if_then,
@@ -87,11 +87,11 @@ impl<'tcx> LateLintPass<'tcx> for IfLetMutex {
8787
}
8888

8989
/// Checks if `Mutex::lock` is called in the `if let` expr.
90-
pub struct OppVisitor<'a, 'tcx> {
90+
pub struct MutexVisitor<'a, 'tcx> {
9191
cx: &'a LateContext<'tcx>,
9292
}
9393

94-
impl<'tcx> Visitor<'tcx> for OppVisitor<'_, 'tcx> {
94+
impl<'tcx> Visitor<'tcx> for MutexVisitor<'_, 'tcx> {
9595
type Result = ControlFlow<&'tcx Expr<'tcx>>;
9696
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) -> ControlFlow<&'tcx Expr<'tcx>> {
9797
if let Some(mutex) = is_mutex_lock_call(self.cx, expr) {
@@ -101,22 +101,7 @@ impl<'tcx> Visitor<'tcx> for OppVisitor<'_, 'tcx> {
101101
}
102102
}
103103

104-
/// Checks if `Mutex::lock` is called in any of the branches.
105-
pub struct ArmVisitor<'a, 'tcx> {
106-
cx: &'a LateContext<'tcx>,
107-
}
108-
109-
impl<'tcx> Visitor<'tcx> for ArmVisitor<'_, 'tcx> {
110-
type Result = ControlFlow<&'tcx Expr<'tcx>>;
111-
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) -> ControlFlow<&'tcx Expr<'tcx>> {
112-
if let Some(mutex) = is_mutex_lock_call(self.cx, expr) {
113-
return ControlFlow::Break(mutex);
114-
}
115-
visit::walk_expr(self, expr)
116-
}
117-
}
118-
119-
impl<'tcx, 'l> ArmVisitor<'tcx, 'l> {
104+
impl<'tcx, 'l> MutexVisitor<'tcx, 'l> {
120105
fn found_mutex_if_same_as(&self, op_mutex: &Expr<'_>, found_mutex: Option<&'tcx Expr<'tcx>>) -> Option<&Expr<'_>> {
121106
found_mutex.and_then(|arm_mutex| {
122107
SpanlessEq::new(self.cx)

clippy_lints/src/loops/mut_range_bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'tcx> Visitor<'tcx> for BreakAfterExprVisitor {
144144
self.break_after_expr = true;
145145
}
146146

147-
return ControlFlow::Break(());
147+
ControlFlow::Break(())
148148
} else {
149149
intravisit::walk_expr(self, expr)
150150
}

clippy_lints/src/methods/option_map_unwrap_or.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(super) fn check<'tcx>(
6464
// Visit the body, and return if we've found a reference
6565
if reference_visitor.visit_body(body).is_break() {
6666
return;
67-
};
67+
}
6868
}
6969

7070
if !unwrap_arg.span.eq_ctxt(map_span) {

clippy_utils/src/visitors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn for_each_expr_without_closures<'tcx, B, C: Continue>(
145145
v.res
146146
}
147147

148-
/// Calls the given function once for each expression contained. This will enter bodies, bzut not
148+
/// Calls the given function once for each expression contained. This will enter bodies, but not
149149
/// nested items.
150150
pub fn for_each_expr<'tcx, B, C: Continue>(
151151
cx: &LateContext<'tcx>,

0 commit comments

Comments
 (0)