Skip to content

Commit 45842e5

Browse files
committed
Fix categorizations
1 parent c1c5c35 commit 45842e5

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

clippy_lints/src/escape.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ fn is_argument(map: &hir::map::Map<'_>, id: HirId) -> bool {
104104

105105
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
106106
fn consume(&mut self, cmt: &Place<'tcx>, mode: ConsumeMode) {
107-
if let Categorization::Local(lid) = cmt.cat {
107+
if let PlaceBase::Local(lid) = cmt.base {
108108
if let ConsumeMode::Move = mode {
109109
// moved out or in. clearly can't be localized
110110
self.set.remove(&lid);
111111
}
112112
}
113113
let map = &self.cx.tcx.hir();
114-
if let Categorization::Local(lid) = cmt.cat {
114+
if let PlaceBase::Local(lid) = cmt.base {
115115
if let Some(Node::Binding(_)) = map.find(cmt.hir_id) {
116116
if self.set.contains(&lid) {
117117
// let y = x where x is known
@@ -124,7 +124,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
124124
}
125125

126126
fn borrow(&mut self, cmt: &Place<'tcx>, _: ty::BorrowKind) {
127-
if let Categorization::Local(lid) = cmt.cat {
127+
if let PlaceBase::Local(lid) = cmt.base {
128128
self.set.remove(&lid);
129129
}
130130
}

clippy_lints/src/loops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate {
15881588

15891589
fn borrow(&mut self, cmt: &Place<'tcx>, bk: ty::BorrowKind) {
15901590
if let ty::BorrowKind::MutBorrow = bk {
1591-
if let Categorization::Local(id) = cmt.cat {
1591+
if let PlaceBase::Local(id) = cmt.base {
15921592
if Some(id) == self.hir_id_low {
15931593
self.span_low = Some(cmt.span)
15941594
}
@@ -1600,7 +1600,7 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate {
16001600
}
16011601

16021602
fn mutate(&mut self, cmt: &Place<'tcx>) {
1603-
if let Categorization::Local(id) = cmt.cat {
1603+
if let PlaceBase::Local(id) = cmt.base {
16041604
if Some(id) == self.hir_id_low {
16051605
self.span_low = Some(cmt.span)
16061606
}

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,7 @@ struct MovedVariablesCtxt {
325325

326326
impl MovedVariablesCtxt {
327327
fn move_common(&mut self, cmt: &euv::Place<'_>) {
328-
let cmt = unwrap_downcast_or_interior(cmt);
329-
330-
if let mc::Categorization::Local(vid) = cmt.cat {
328+
if let euv::PlaceBase::Local(vid) = cmt.base {
331329
self.moved_vars.insert(vid);
332330
}
333331
}
@@ -345,13 +343,3 @@ impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
345343
fn mutate(&mut self, _: &euv::Place<'tcx>) {}
346344
}
347345

348-
fn unwrap_downcast_or_interior<'a, 'tcx>(mut cmt: &'a euv::Place<'tcx>) -> euv::Place<'tcx> {
349-
loop {
350-
match cmt.cat {
351-
mc::Categorization::Downcast(ref c, _) | mc::Categorization::Interior(ref c, _) => {
352-
cmt = c;
353-
},
354-
_ => return (*cmt).clone(),
355-
}
356-
}
357-
}

clippy_lints/src/utils/usage.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,17 @@ struct MutVarsDelegate {
4242

4343
impl<'tcx> MutVarsDelegate {
4444
#[allow(clippy::similar_names)]
45-
fn update(&mut self, cat: &'tcx Categorization<'_>) {
46-
match *cat {
47-
Categorization::Local(id) => {
45+
fn update(&mut self, cat: &Place<'tcx>) {
46+
match cat.base {
47+
PlaceBase::Local(id) => {
4848
self.used_mutably.insert(id);
4949
},
50-
Categorization::Upvar(_) => {
50+
PlaceBase::Upvar(_) => {
5151
//FIXME: This causes false negatives. We can't get the `NodeId` from
5252
//`Categorization::Upvar(_)`. So we search for any `Upvar`s in the
5353
//`while`-body, not just the ones in the condition.
5454
self.skip = true
5555
},
56-
Categorization::Deref(ref cmt, _) | Categorization::Interior(ref cmt, _) => self.update(&cmt.cat),
5756
_ => {},
5857
}
5958
}
@@ -64,11 +63,11 @@ impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
6463

6564
fn borrow(&mut self, cmt: &Place<'tcx>, bk: ty::BorrowKind) {
6665
if let ty::BorrowKind::MutBorrow = bk {
67-
self.update(&cmt.cat)
66+
self.update(&cmt)
6867
}
6968
}
7069

7170
fn mutate(&mut self, cmt: &Place<'tcx>) {
72-
self.update(&cmt.cat)
71+
self.update(&cmt)
7372
}
7473
}

0 commit comments

Comments
 (0)