Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d52ac1b

Browse files
committed
Fix clippy
1 parent 1f0d057 commit d52ac1b

17 files changed

+44
-5
lines changed

clippy_lints/src/escape.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ impl<'tcx> Delegate<'tcx> for EscapeDelegate<'_, 'tcx> {
150150
}
151151
}
152152

153+
fn use_cloned(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
154+
153155
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
154156
if cmt.place.projections.is_empty() {
155157
if let PlaceBase::Local(lid) = cmt.place.base {

clippy_lints/src/loops/mut_range_bound.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ struct MutatePairDelegate<'a, 'tcx> {
7979
impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
8080
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
8181

82+
fn use_cloned(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
83+
8284
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
8385
if bk == ty::BorrowKind::Mutable {
8486
if let PlaceBase::Local(id) = cmt.place.base {

clippy_lints/src/loops/never_loop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ fn never_loop_expr<'tcx>(
160160
| ExprKind::UnsafeBinderCast(_, e, _) => never_loop_expr(cx, e, local_labels, main_loop_id),
161161
ExprKind::Let(let_expr) => never_loop_expr(cx, let_expr.init, local_labels, main_loop_id),
162162
ExprKind::Array(es) | ExprKind::Tup(es) => never_loop_expr_all(cx, es.iter(), local_labels, main_loop_id),
163+
ExprKind::Use(expr, _) => never_loop_expr(cx, expr, local_labels, main_loop_id),
163164
ExprKind::MethodCall(_, receiver, es, _) => {
164165
never_loop_expr_all(cx, once(receiver).chain(es.iter()), local_labels, main_loop_id)
165166
},

clippy_lints/src/matches/manual_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ where
9999
});
100100
if let ExprKind::Path(QPath::Resolved(None, Path { res: Res::Local(l), .. })) = e.kind {
101101
match captures.get(l) {
102-
Some(CaptureKind::Value | CaptureKind::Ref(Mutability::Mut)) => return None,
102+
Some(CaptureKind::Value | CaptureKind::Use | CaptureKind::Ref(Mutability::Mut)) => return None,
103103
Some(CaptureKind::Ref(Mutability::Not)) if binding_ref_mutability == Mutability::Mut => {
104104
return None;
105105
},

clippy_lints/src/methods/iter_overeager_cloned.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ impl<'tcx> Delegate<'tcx> for MoveDelegate {
147147
}
148148
}
149149

150+
fn use_cloned(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
151+
150152
fn borrow(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId, _: BorrowKind) {}
151153

152154
fn mutate(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}

clippy_lints/src/needless_pass_by_ref_mut.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ impl<'tcx> euv::Delegate<'tcx> for MutablyUsedVariablesCtxt<'tcx> {
396396
}
397397
}
398398

399+
fn use_cloned(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId) {}
400+
399401
#[allow(clippy::if_same_then_else)]
400402
fn borrow(&mut self, cmt: &euv::PlaceWithHirId<'tcx>, id: HirId, borrow: ty::BorrowKind) {
401403
self.prev_bind = None;

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
326326
self.move_common(cmt);
327327
}
328328

329+
fn use_cloned(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId) {}
330+
329331
fn borrow(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {}
330332

331333
fn mutate(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId) {}

clippy_lints/src/operators/assign_op_pattern.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
112112
}
113113

114114
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
115+
fn use_cloned(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
115116
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
116117
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: HirId) {}
117118
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
@@ -137,6 +138,7 @@ fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
137138
}
138139

139140
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
141+
fn use_cloned(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
140142
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
141143
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: HirId) {}
142144
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}

clippy_lints/src/option_if_let_else.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ fn try_get_option_occurrence<'tcx>(
177177
.then_some(())
178178
.and_then(|()| none_captures.get(local_id))
179179
}) {
180-
Some(CaptureKind::Value | CaptureKind::Ref(Mutability::Mut)) => return None,
180+
Some(CaptureKind::Value | CaptureKind::Use | CaptureKind::Ref(Mutability::Mut)) => return None,
181181
Some(CaptureKind::Ref(Mutability::Not)) if as_mut => return None,
182182
Some(CaptureKind::Ref(Mutability::Not)) | None => (),
183183
}

clippy_lints/src/unwrap.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ impl<'tcx> Delegate<'tcx> for MutationVisitor<'tcx> {
230230

231231
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
232232

233+
fn use_cloned(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
234+
233235
fn fake_read(&mut self, _: &PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {}
234236
}
235237

0 commit comments

Comments
 (0)