Skip to content

Commit efeed55

Browse files
Remove BorrowKind glob, make names longer
1 parent b14362f commit efeed55

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

clippy_lints/src/loops/mut_range_bound.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
8080
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
8181

8282
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
83-
if bk == ty::BorrowKind::MutBorrow {
83+
if bk == ty::BorrowKind::Mutable {
8484
if let PlaceBase::Local(id) = cmt.place.base {
8585
if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
8686
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));

clippy_lints/src/needless_pass_by_ref_mut.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,16 @@ impl<'tcx> euv::Delegate<'tcx> for MutablyUsedVariablesCtxt<'tcx> {
417417
// a closure, it'll return this variant whereas if you have just an index access, it'll
418418
// return `ImmBorrow`. So if there is "Unique" and it's a mutable reference, we add it
419419
// to the mutably used variables set.
420-
if borrow == ty::BorrowKind::MutBorrow
421-
|| (borrow == ty::BorrowKind::UniqueImmBorrow && base_ty.ref_mutability() == Some(Mutability::Mut))
420+
if borrow == ty::BorrowKind::Mutable
421+
|| (borrow == ty::BorrowKind::UniqueImmutable && base_ty.ref_mutability() == Some(Mutability::Mut))
422422
{
423423
self.add_mutably_used_var(*vid);
424424
} else if self.is_in_unsafe_block(id) {
425425
// If we are in an unsafe block, any operation on this variable must not be warned
426426
// upon!
427427
self.add_mutably_used_var(*vid);
428428
}
429-
} else if borrow == ty::ImmBorrow {
429+
} else if borrow == ty::BorrowKind::Immutable {
430430
// If there is an `async block`, it'll contain a call to a closure which we need to
431431
// go into to ensure all "mutate" checks are found.
432432
if let Node::Expr(Expr {

clippy_lints/src/operators/assign_op_pattern.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
102102
struct S(HirIdSet);
103103
impl Delegate<'_> for S {
104104
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
105-
if matches!(kind, BorrowKind::ImmBorrow | BorrowKind::UniqueImmBorrow) {
105+
if matches!(kind, BorrowKind::Immutable | BorrowKind::UniqueImmutable) {
106106
self.0.insert(match place.place.base {
107107
PlaceBase::Local(id) => id,
108108
PlaceBase::Upvar(id) => id.var_path.hir_id,
@@ -127,7 +127,7 @@ fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
127127
struct S(HirIdSet);
128128
impl Delegate<'_> for S {
129129
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
130-
if matches!(kind, BorrowKind::MutBorrow) {
130+
if matches!(kind, BorrowKind::Mutable) {
131131
self.0.insert(match place.place.base {
132132
PlaceBase::Local(id) => id,
133133
PlaceBase::Upvar(id) => id.var_path.hir_id,

clippy_lints/src/unwrap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn is_option_as_mut_use(tcx: TyCtxt<'_>, expr_id: HirId) -> bool {
217217

218218
impl<'tcx> Delegate<'tcx> for MutationVisitor<'tcx> {
219219
fn borrow(&mut self, cat: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
220-
if let ty::BorrowKind::MutBorrow = bk
220+
if let ty::BorrowKind::Mutable = bk
221221
&& is_potentially_local_place(self.local_id, &cat.place)
222222
&& !is_option_as_mut_use(self.tcx, diag_expr_id)
223223
{

clippy_utils/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,8 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
12091209
let capture = match capture.info.capture_kind {
12101210
UpvarCapture::ByValue => CaptureKind::Value,
12111211
UpvarCapture::ByRef(kind) => match kind {
1212-
BorrowKind::ImmBorrow => CaptureKind::Ref(Mutability::Not),
1213-
BorrowKind::UniqueImmBorrow | BorrowKind::MutBorrow => {
1212+
BorrowKind::Immutable => CaptureKind::Ref(Mutability::Not),
1213+
BorrowKind::UniqueImmutable | BorrowKind::Mutable => {
12141214
CaptureKind::Ref(Mutability::Mut)
12151215
},
12161216
},

clippy_utils/src/usage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
6767
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
6868

6969
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, bk: ty::BorrowKind) {
70-
if bk == ty::BorrowKind::MutBorrow {
70+
if bk == ty::BorrowKind::Mutable {
7171
self.update(cmt);
7272
}
7373
}

0 commit comments

Comments
 (0)