Skip to content

Commit 9a53c3e

Browse files
committed
rustc: remove unused field of mc::Categorization::Deref.
1 parent c6651ff commit 9a53c3e

File tree

9 files changed

+61
-64
lines changed

9 files changed

+61
-64
lines changed

src/librustc/middle/mem_categorization.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub enum Categorization<'tcx> {
9494
StaticItem,
9595
Upvar(Upvar), // upvar referenced by closure env
9696
Local(ast::NodeId), // local variable
97-
Deref(cmt<'tcx>, usize, PointerKind<'tcx>), // deref of a ptr
97+
Deref(cmt<'tcx>, PointerKind<'tcx>), // deref of a ptr
9898
Interior(cmt<'tcx>, InteriorKind), // something interior: field, tuple, etc
9999
Downcast(cmt<'tcx>, DefId), // selects a particular enum variant (*1)
100100

@@ -229,8 +229,8 @@ impl<'tcx> cmt_<'tcx> {
229229

230230
pub fn immutability_blame(&self) -> Option<ImmutabilityBlame<'tcx>> {
231231
match self.cat {
232-
Categorization::Deref(ref base_cmt, _, BorrowedPtr(ty::ImmBorrow, _)) |
233-
Categorization::Deref(ref base_cmt, _, Implicit(ty::ImmBorrow, _)) => {
232+
Categorization::Deref(ref base_cmt, BorrowedPtr(ty::ImmBorrow, _)) |
233+
Categorization::Deref(ref base_cmt, Implicit(ty::ImmBorrow, _)) => {
234234
// try to figure out where the immutable reference came from
235235
match base_cmt.cat {
236236
Categorization::Local(node_id) =>
@@ -255,13 +255,13 @@ impl<'tcx> cmt_<'tcx> {
255255
}
256256
Categorization::Rvalue(..) |
257257
Categorization::Upvar(..) |
258-
Categorization::Deref(.., UnsafePtr(..)) => {
258+
Categorization::Deref(_, UnsafePtr(..)) => {
259259
// This should not be reachable up to inference limitations.
260260
None
261261
}
262262
Categorization::Interior(ref base_cmt, _) |
263263
Categorization::Downcast(ref base_cmt, _) |
264-
Categorization::Deref(ref base_cmt, _, _) => {
264+
Categorization::Deref(ref base_cmt, _) => {
265265
base_cmt.immutability_blame()
266266
}
267267
Categorization::StaticItem => {
@@ -569,7 +569,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
569569
// is an rvalue. That is what we will be
570570
// dereferencing.
571571
let base_cmt = self.cat_rvalue_node(expr.id(), expr.span(), ret_ty);
572-
Ok(self.cat_deref_common(expr, base_cmt, 1, elem_ty, true))
572+
Ok(self.cat_deref_common(expr, base_cmt, elem_ty, true))
573573
}
574574
None => {
575575
self.cat_index(expr, self.cat_expr(&base)?, InteriorOffsetKind::Index)
@@ -763,7 +763,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
763763
cmt_ {
764764
id: id,
765765
span: span,
766-
cat: Categorization::Deref(Rc::new(cmt_result), 0, ptr),
766+
cat: Categorization::Deref(Rc::new(cmt_result), ptr),
767767
mutbl: MutabilityCategory::from_borrow_kind(upvar_borrow.kind),
768768
ty: var_ty,
769769
note: NoteUpvarRef(upvar_id)
@@ -823,7 +823,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
823823
let ret = cmt_ {
824824
id: id,
825825
span: span,
826-
cat: Categorization::Deref(Rc::new(cmt_result), 0, env_ptr),
826+
cat: Categorization::Deref(Rc::new(cmt_result), env_ptr),
827827
mutbl: deref_mutbl,
828828
ty: var_ty,
829829
note: NoteClosureEnv(upvar_id)
@@ -957,7 +957,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
957957
let base_cmt_ty = base_cmt.ty;
958958
match base_cmt_ty.builtin_deref(true, ty::NoPreference) {
959959
Some(mt) => {
960-
let ret = self.cat_deref_common(node, base_cmt, deref_cnt, mt.ty, false);
960+
let ret = self.cat_deref_common(node, base_cmt, mt.ty, false);
961961
debug!("cat_deref ret {:?}", ret);
962962
Ok(ret)
963963
}
@@ -972,7 +972,6 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
972972
fn cat_deref_common<N:ast_node>(&self,
973973
node: &N,
974974
base_cmt: cmt<'tcx>,
975-
deref_cnt: usize,
976975
deref_ty: Ty<'tcx>,
977976
implicit: bool)
978977
-> cmt<'tcx>
@@ -991,7 +990,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
991990
span: node.span(),
992991
// For unique ptrs, we inherit mutability from the owning reference.
993992
mutbl: MutabilityCategory::from_pointer_kind(base_cmt.mutbl, ptr),
994-
cat: Categorization::Deref(base_cmt, deref_cnt, ptr),
993+
cat: Categorization::Deref(base_cmt, ptr),
995994
ty: deref_ty,
996995
note: NoteNone
997996
});
@@ -1300,15 +1299,15 @@ impl<'tcx> cmt_<'tcx> {
13001299
Categorization::Rvalue(..) |
13011300
Categorization::StaticItem |
13021301
Categorization::Local(..) |
1303-
Categorization::Deref(.., UnsafePtr(..)) |
1304-
Categorization::Deref(.., BorrowedPtr(..)) |
1305-
Categorization::Deref(.., Implicit(..)) |
1302+
Categorization::Deref(_, UnsafePtr(..)) |
1303+
Categorization::Deref(_, BorrowedPtr(..)) |
1304+
Categorization::Deref(_, Implicit(..)) |
13061305
Categorization::Upvar(..) => {
13071306
Rc::new((*self).clone())
13081307
}
13091308
Categorization::Downcast(ref b, _) |
13101309
Categorization::Interior(ref b, _) |
1311-
Categorization::Deref(ref b, _, Unique) => {
1310+
Categorization::Deref(ref b, Unique) => {
13121311
b.guarantor()
13131312
}
13141313
}
@@ -1321,11 +1320,11 @@ impl<'tcx> cmt_<'tcx> {
13211320
// aliased and eventually recused.
13221321

13231322
match self.cat {
1324-
Categorization::Deref(ref b, _, BorrowedPtr(ty::MutBorrow, _)) |
1325-
Categorization::Deref(ref b, _, Implicit(ty::MutBorrow, _)) |
1326-
Categorization::Deref(ref b, _, BorrowedPtr(ty::UniqueImmBorrow, _)) |
1327-
Categorization::Deref(ref b, _, Implicit(ty::UniqueImmBorrow, _)) |
1328-
Categorization::Deref(ref b, _, Unique) |
1323+
Categorization::Deref(ref b, BorrowedPtr(ty::MutBorrow, _)) |
1324+
Categorization::Deref(ref b, Implicit(ty::MutBorrow, _)) |
1325+
Categorization::Deref(ref b, BorrowedPtr(ty::UniqueImmBorrow, _)) |
1326+
Categorization::Deref(ref b, Implicit(ty::UniqueImmBorrow, _)) |
1327+
Categorization::Deref(ref b, Unique) |
13291328
Categorization::Downcast(ref b, _) |
13301329
Categorization::Interior(ref b, _) => {
13311330
// Aliasability depends on base cmt
@@ -1335,7 +1334,7 @@ impl<'tcx> cmt_<'tcx> {
13351334
Categorization::Rvalue(..) |
13361335
Categorization::Local(..) |
13371336
Categorization::Upvar(..) |
1338-
Categorization::Deref(.., UnsafePtr(..)) => { // yes, it's aliasable, but...
1337+
Categorization::Deref(_, UnsafePtr(..)) => { // yes, it's aliasable, but...
13391338
NonAliasable
13401339
}
13411340

@@ -1347,8 +1346,8 @@ impl<'tcx> cmt_<'tcx> {
13471346
}
13481347
}
13491348

1350-
Categorization::Deref(_, _, BorrowedPtr(ty::ImmBorrow, _)) |
1351-
Categorization::Deref(_, _, Implicit(ty::ImmBorrow, _)) => {
1349+
Categorization::Deref(_, BorrowedPtr(ty::ImmBorrow, _)) |
1350+
Categorization::Deref(_, Implicit(ty::ImmBorrow, _)) => {
13521351
FreelyAliasable(AliasableBorrowed)
13531352
}
13541353
}
@@ -1360,9 +1359,9 @@ impl<'tcx> cmt_<'tcx> {
13601359
match self.note {
13611360
NoteClosureEnv(..) | NoteUpvarRef(..) => {
13621361
Some(match self.cat {
1363-
Categorization::Deref(ref inner, ..) => {
1362+
Categorization::Deref(ref inner, _) => {
13641363
match inner.cat {
1365-
Categorization::Deref(ref inner, ..) => inner.clone(),
1364+
Categorization::Deref(ref inner, _) => inner.clone(),
13661365
Categorization::Upvar(..) => inner.clone(),
13671366
_ => bug!()
13681367
}
@@ -1390,7 +1389,7 @@ impl<'tcx> cmt_<'tcx> {
13901389
"local variable".to_string()
13911390
}
13921391
}
1393-
Categorization::Deref(.., pk) => {
1392+
Categorization::Deref(_, pk) => {
13941393
let upvar = self.upvar();
13951394
match upvar.as_ref().map(|i| &i.cat) {
13961395
Some(&Categorization::Upvar(ref var)) => {
@@ -1467,8 +1466,8 @@ impl<'tcx> fmt::Debug for Categorization<'tcx> {
14671466
Categorization::Upvar(upvar) => {
14681467
write!(f, "upvar({:?})", upvar)
14691468
}
1470-
Categorization::Deref(ref cmt, derefs, ptr) => {
1471-
write!(f, "{:?}-{:?}{}->", cmt.cat, ptr, derefs)
1469+
Categorization::Deref(ref cmt, ptr) => {
1470+
write!(f, "{:?}-{:?}->", cmt.cat, ptr)
14721471
}
14731472
Categorization::Interior(ref cmt, interior) => {
14741473
write!(f, "{:?}.{:?}", cmt.cat, interior)

src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
222222
cmt: &mc::cmt<'tcx>)
223223
-> Option<mc::cmt<'tcx>> {
224224
match cmt.cat {
225-
Categorization::Deref(.., mc::BorrowedPtr(..)) |
226-
Categorization::Deref(.., mc::Implicit(..)) |
227-
Categorization::Deref(.., mc::UnsafePtr(..)) |
225+
Categorization::Deref(_, mc::BorrowedPtr(..)) |
226+
Categorization::Deref(_, mc::Implicit(..)) |
227+
Categorization::Deref(_, mc::UnsafePtr(..)) |
228228
Categorization::StaticItem => {
229229
Some(cmt.clone())
230230
}
@@ -258,7 +258,7 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
258258
Some(cmt.clone())
259259
}
260260

261-
Categorization::Deref(ref b, _, mc::Unique) => {
261+
Categorization::Deref(ref b, mc::Unique) => {
262262
check_and_get_illegal_move_origin(bccx, b)
263263
}
264264
}

src/librustc_borrowck/borrowck/gather_loans/lifetime.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
7272

7373
match cmt.cat {
7474
Categorization::Rvalue(..) |
75-
Categorization::Local(..) | // L-Local
75+
Categorization::Local(..) | // L-Local
7676
Categorization::Upvar(..) |
77-
Categorization::Deref(.., mc::BorrowedPtr(..)) | // L-Deref-Borrowed
78-
Categorization::Deref(.., mc::Implicit(..)) |
79-
Categorization::Deref(.., mc::UnsafePtr(..)) => {
77+
Categorization::Deref(_, mc::BorrowedPtr(..)) | // L-Deref-Borrowed
78+
Categorization::Deref(_, mc::Implicit(..)) |
79+
Categorization::Deref(_, mc::UnsafePtr(..)) => {
8080
self.check_scope(self.scope(cmt))
8181
}
8282

@@ -85,8 +85,8 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
8585
}
8686

8787
Categorization::Downcast(ref base, _) |
88-
Categorization::Deref(ref base, _, mc::Unique) | // L-Deref-Send
89-
Categorization::Interior(ref base, _) => { // L-Field
88+
Categorization::Deref(ref base, mc::Unique) | // L-Deref-Send
89+
Categorization::Interior(ref base, _) => { // L-Field
9090
self.check(base, discr_scope)
9191
}
9292
}
@@ -119,15 +119,15 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
119119
self.bccx.region_maps.var_scope(local_id)))
120120
}
121121
Categorization::StaticItem |
122-
Categorization::Deref(.., mc::UnsafePtr(..)) => {
122+
Categorization::Deref(_, mc::UnsafePtr(..)) => {
123123
self.bccx.tcx.types.re_static
124124
}
125-
Categorization::Deref(.., mc::BorrowedPtr(_, r)) |
126-
Categorization::Deref(.., mc::Implicit(_, r)) => {
125+
Categorization::Deref(_, mc::BorrowedPtr(_, r)) |
126+
Categorization::Deref(_, mc::Implicit(_, r)) => {
127127
r
128128
}
129129
Categorization::Downcast(ref cmt, _) |
130-
Categorization::Deref(ref cmt, _, mc::Unique) |
130+
Categorization::Deref(ref cmt, mc::Unique) |
131131
Categorization::Interior(ref cmt, _) => {
132132
self.scope(cmt)
133133
}

src/librustc_borrowck/borrowck/gather_loans/move_error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
138138
move_from: mc::cmt<'tcx>)
139139
-> DiagnosticBuilder<'a> {
140140
match move_from.cat {
141-
Categorization::Deref(.., mc::BorrowedPtr(..)) |
142-
Categorization::Deref(.., mc::Implicit(..)) |
143-
Categorization::Deref(.., mc::UnsafePtr(..)) |
141+
Categorization::Deref(_, mc::BorrowedPtr(..)) |
142+
Categorization::Deref(_, mc::Implicit(..)) |
143+
Categorization::Deref(_, mc::UnsafePtr(..)) |
144144
Categorization::StaticItem => {
145145
let mut err = struct_span_err!(bccx, move_from.span, E0507,
146146
"cannot move out of {}",

src/librustc_borrowck/borrowck/gather_loans/restrictions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
133133
RestrictionResult::Safe
134134
}
135135

136-
Categorization::Deref(cmt_base, _, pk) => {
136+
Categorization::Deref(cmt_base, pk) => {
137137
match pk {
138138
mc::Unique => {
139139
// R-Deref-Send-Pointer

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ pub fn opt_loan_path<'tcx>(cmt: &mc::cmt<'tcx>) -> Option<Rc<LoanPath<'tcx>>> {
426426
Some(new_lp(LpUpvar(id)))
427427
}
428428

429-
Categorization::Deref(ref cmt_base, _, pk) => {
429+
Categorization::Deref(ref cmt_base, pk) => {
430430
opt_loan_path(cmt_base).map(|lp| {
431431
new_lp(LpExtend(lp, cmt.mutbl, LpDeref(pk)))
432432
})

src/librustc_passes/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
512512
Categorization::StaticItem => {
513513
break;
514514
}
515-
Categorization::Deref(ref cmt, ..) |
515+
Categorization::Deref(ref cmt, _) |
516516
Categorization::Downcast(ref cmt, _) |
517517
Categorization::Interior(ref cmt, _) => {
518518
cur = cmt;

src/librustc_typeck/check/regionck.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,10 +1224,8 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
12241224
borrow_kind,
12251225
borrow_cmt);
12261226
match borrow_cmt.cat.clone() {
1227-
Categorization::Deref(ref_cmt, _,
1228-
mc::Implicit(ref_kind, ref_region)) |
1229-
Categorization::Deref(ref_cmt, _,
1230-
mc::BorrowedPtr(ref_kind, ref_region)) => {
1227+
Categorization::Deref(ref_cmt, mc::Implicit(ref_kind, ref_region)) |
1228+
Categorization::Deref(ref_cmt, mc::BorrowedPtr(ref_kind, ref_region)) => {
12311229
match self.link_reborrowed_region(span,
12321230
borrow_region, borrow_kind,
12331231
ref_cmt, ref_region, ref_kind,
@@ -1243,15 +1241,15 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
12431241
}
12441242

12451243
Categorization::Downcast(cmt_base, _) |
1246-
Categorization::Deref(cmt_base, _, mc::Unique) |
1244+
Categorization::Deref(cmt_base, mc::Unique) |
12471245
Categorization::Interior(cmt_base, _) => {
12481246
// Borrowing interior or owned data requires the base
12491247
// to be valid and borrowable in the same fashion.
12501248
borrow_cmt = cmt_base;
12511249
borrow_kind = borrow_kind;
12521250
}
12531251

1254-
Categorization::Deref(.., mc::UnsafePtr(..)) |
1252+
Categorization::Deref(_, mc::UnsafePtr(..)) |
12551253
Categorization::StaticItem |
12561254
Categorization::Upvar(..) |
12571255
Categorization::Local(..) |

src/librustc_typeck/check/upvar.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
281281
debug!("adjust_upvar_borrow_kind_for_consume: guarantor={:?}",
282282
guarantor);
283283
match guarantor.cat {
284-
Categorization::Deref(.., mc::BorrowedPtr(..)) |
285-
Categorization::Deref(.., mc::Implicit(..)) => {
284+
Categorization::Deref(_, mc::BorrowedPtr(..)) |
285+
Categorization::Deref(_, mc::Implicit(..)) => {
286286
match cmt.note {
287287
mc::NoteUpvarRef(upvar_id) => {
288288
debug!("adjust_upvar_borrow_kind_for_consume: \
@@ -327,16 +327,16 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
327327
cmt);
328328

329329
match cmt.cat.clone() {
330-
Categorization::Deref(base, _, mc::Unique) |
330+
Categorization::Deref(base, mc::Unique) |
331331
Categorization::Interior(base, _) |
332332
Categorization::Downcast(base, _) => {
333333
// Interior or owned data is mutable if base is
334334
// mutable, so iterate to the base.
335335
self.adjust_upvar_borrow_kind_for_mut(base);
336336
}
337337

338-
Categorization::Deref(base, _, mc::BorrowedPtr(..)) |
339-
Categorization::Deref(base, _, mc::Implicit(..)) => {
338+
Categorization::Deref(base, mc::BorrowedPtr(..)) |
339+
Categorization::Deref(base, mc::Implicit(..)) => {
340340
if !self.try_adjust_upvar_deref(cmt, ty::MutBorrow) {
341341
// assignment to deref of an `&mut`
342342
// borrowed pointer implies that the
@@ -346,7 +346,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
346346
}
347347
}
348348

349-
Categorization::Deref(.., mc::UnsafePtr(..)) |
349+
Categorization::Deref(_, mc::UnsafePtr(..)) |
350350
Categorization::StaticItem |
351351
Categorization::Rvalue(..) |
352352
Categorization::Local(_) |
@@ -361,24 +361,24 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
361361
cmt);
362362

363363
match cmt.cat.clone() {
364-
Categorization::Deref(base, _, mc::Unique) |
364+
Categorization::Deref(base, mc::Unique) |
365365
Categorization::Interior(base, _) |
366366
Categorization::Downcast(base, _) => {
367367
// Interior or owned data is unique if base is
368368
// unique.
369369
self.adjust_upvar_borrow_kind_for_unique(base);
370370
}
371371

372-
Categorization::Deref(base, _, mc::BorrowedPtr(..)) |
373-
Categorization::Deref(base, _, mc::Implicit(..)) => {
372+
Categorization::Deref(base, mc::BorrowedPtr(..)) |
373+
Categorization::Deref(base, mc::Implicit(..)) => {
374374
if !self.try_adjust_upvar_deref(cmt, ty::UniqueImmBorrow) {
375375
// for a borrowed pointer to be unique, its
376376
// base must be unique
377377
self.adjust_upvar_borrow_kind_for_unique(base);
378378
}
379379
}
380380

381-
Categorization::Deref(.., mc::UnsafePtr(..)) |
381+
Categorization::Deref(_, mc::UnsafePtr(..)) |
382382
Categorization::StaticItem |
383383
Categorization::Rvalue(..) |
384384
Categorization::Local(_) |

0 commit comments

Comments
 (0)