@@ -10,8 +10,8 @@ use bitflags::bitflags;
10
10
use rustc_hir:: def_id:: DefId ;
11
11
use rustc_index:: vec:: IndexVec ;
12
12
use rustc_middle:: mir:: {
13
- Body , CastKind , ConstantKind , Field , HasLocalDecls , Local , LocalDecls , Location , Operand ,
14
- Place , PlaceElem , PlaceRef , Rvalue ,
13
+ Body , CastKind , Field , HasLocalDecls , Local , LocalDecls , Location , Operand , Place , PlaceElem ,
14
+ PlaceRef , Rvalue ,
15
15
} ;
16
16
use rustc_middle:: ty:: adjustment:: PointerCast ;
17
17
use rustc_middle:: ty:: { self , AdtDef , FieldDef , Ty , TyCtxt , TyKind } ;
@@ -66,10 +66,6 @@ impl PermissionSet {
66
66
panic ! ( "expected an array, str, or primitive type: {ty:?}" ) ;
67
67
}
68
68
}
69
-
70
- pub fn for_const_ref ( constant : ConstantKind ) -> Self {
71
- Self :: for_const_ref_ty ( constant. ty ( ) )
72
- }
73
69
}
74
70
75
71
bitflags ! {
@@ -118,15 +114,18 @@ pub struct AnalysisCtxt<'a, 'tcx> {
118
114
/// those `PointerId`s consistent, the `Rvalue`'s type must be stored rather than recomputed on
119
115
/// the fly.
120
116
pub rvalue_tys : HashMap < Location , LTy < ' tcx > > ,
121
- pub const_ref_tys : HashMap < ConstantKind < ' tcx > , LTy < ' tcx > > ,
117
+
118
+ /// [`Location`]s of const ref [`rvalue_tys`](Self::rvalue_tys).
119
+ pub const_ref_locs : Vec < Location > ,
120
+
122
121
next_ptr_id : NextLocalPointerId ,
123
122
}
124
123
125
124
pub struct AnalysisCtxtData < ' tcx > {
126
125
local_tys : IndexVec < Local , LTy < ' tcx > > ,
127
126
addr_of_local : IndexVec < Local , PointerId > ,
128
127
rvalue_tys : HashMap < Location , LTy < ' tcx > > ,
129
- const_ref_tys : HashMap < ConstantKind < ' tcx > , LTy < ' tcx > > ,
128
+ const_ref_locs : Vec < Location > ,
130
129
next_ptr_id : NextLocalPointerId ,
131
130
}
132
131
@@ -219,7 +218,7 @@ impl<'a, 'tcx> AnalysisCtxt<'a, 'tcx> {
219
218
c_void_casts : CVoidCasts :: new ( mir, tcx) ,
220
219
addr_of_local : IndexVec :: new ( ) ,
221
220
rvalue_tys : HashMap :: new ( ) ,
222
- const_ref_tys : HashMap :: new ( ) ,
221
+ const_ref_locs : Default :: default ( ) ,
223
222
next_ptr_id : NextLocalPointerId :: new ( ) ,
224
223
}
225
224
}
@@ -233,7 +232,7 @@ impl<'a, 'tcx> AnalysisCtxt<'a, 'tcx> {
233
232
local_tys,
234
233
addr_of_local,
235
234
rvalue_tys,
236
- const_ref_tys ,
235
+ const_ref_locs ,
237
236
next_ptr_id,
238
237
} = data;
239
238
AnalysisCtxt {
@@ -243,7 +242,7 @@ impl<'a, 'tcx> AnalysisCtxt<'a, 'tcx> {
243
242
c_void_casts : CVoidCasts :: default ( ) ,
244
243
addr_of_local,
245
244
rvalue_tys,
246
- const_ref_tys ,
245
+ const_ref_locs ,
247
246
next_ptr_id,
248
247
}
249
248
}
@@ -253,7 +252,7 @@ impl<'a, 'tcx> AnalysisCtxt<'a, 'tcx> {
253
252
local_tys : self . local_tys ,
254
253
addr_of_local : self . addr_of_local ,
255
254
rvalue_tys : self . rvalue_tys ,
256
- const_ref_tys : self . const_ref_tys ,
255
+ const_ref_locs : self . const_ref_locs ,
257
256
next_ptr_id : self . next_ptr_id ,
258
257
}
259
258
}
@@ -442,13 +441,13 @@ impl<'tcx> AnalysisCtxtData<'tcx> {
442
441
map : PointerTable < PointerId > ,
443
442
counter : NextLocalPointerId ,
444
443
) {
445
- let AnalysisCtxtData {
446
- ref mut local_tys,
447
- ref mut addr_of_local,
448
- ref mut rvalue_tys,
449
- ref mut const_ref_tys ,
450
- ref mut next_ptr_id,
451
- } = * self ;
444
+ let Self {
445
+ local_tys,
446
+ addr_of_local,
447
+ rvalue_tys,
448
+ const_ref_locs : _ ,
449
+ next_ptr_id,
450
+ } = self ;
452
451
453
452
for lty in local_tys {
454
453
* lty = remap_lty_pointers ( lcx, & map, lty) ;
@@ -464,10 +463,6 @@ impl<'tcx> AnalysisCtxtData<'tcx> {
464
463
* lty = remap_lty_pointers ( lcx, & map, lty) ;
465
464
}
466
465
467
- for lty in const_ref_tys. values_mut ( ) {
468
- * lty = remap_lty_pointers ( lcx, & map, lty) ;
469
- }
470
-
471
466
* next_ptr_id = counter;
472
467
}
473
468
@@ -533,13 +528,7 @@ impl<'tcx> TypeOf<'tcx> for Operand<'tcx> {
533
528
fn type_of ( & self , acx : & AnalysisCtxt < ' _ , ' tcx > ) -> LTy < ' tcx > {
534
529
match * self {
535
530
Operand :: Move ( pl) | Operand :: Copy ( pl) => acx. type_of ( pl) ,
536
- Operand :: Constant ( ref c) => {
537
- let c = & * * c;
538
- match acx. const_ref_tys . get ( & c. literal ) {
539
- Some ( lty) => lty,
540
- None => label_no_pointers ( acx, c. ty ( ) ) ,
541
- }
542
- }
531
+ Operand :: Constant ( ref c) => label_no_pointers ( acx, c. ty ( ) ) ,
543
532
}
544
533
}
545
534
}
0 commit comments