File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -121,10 +121,23 @@ pub struct AnalysisCtxt<'a, 'tcx> {
121
121
next_ptr_id : NextLocalPointerId ,
122
122
}
123
123
124
- impl < ' a , ' tcx > AnalysisCtxt < ' a , ' tcx > {
124
+ impl < ' a , ' tcx > AnalysisCtxt < ' _ , ' tcx > {
125
125
pub fn const_ref_tys ( & ' a self ) -> impl Iterator < Item = LTy < ' tcx > > + ' a {
126
126
self . const_ref_locs . iter ( ) . map ( |loc| self . rvalue_tys [ loc] )
127
127
}
128
+
129
+ pub fn check_const_ref_perms ( & self , asn : & Assignment ) {
130
+ for const_ref_lty in self . const_ref_tys ( ) {
131
+ let ptr_id = const_ref_lty. label ;
132
+ let expected_perms = PermissionSet :: for_const_ref_ty ( const_ref_lty. ty ) ;
133
+ let mut actual_perms = asn. perms ( ) [ ptr_id] ;
134
+ // Ignore `UNIQUE` as it gets automatically added to all permissions
135
+ // and then removed later if it can't apply.
136
+ // We don't care about `UNIQUE` for const refs, so just unset it here.
137
+ actual_perms. set ( PermissionSet :: UNIQUE , false ) ;
138
+ assert_eq ! ( expected_perms, actual_perms) ;
139
+ }
140
+ }
128
141
}
129
142
130
143
pub struct AnalysisCtxtData < ' tcx > {
Original file line number Diff line number Diff line change @@ -620,16 +620,7 @@ fn run(tcx: TyCtxt) {
620
620
let mut asn = gasn. and ( & mut info. lasn ) ;
621
621
info. dataflow . propagate_cell ( & mut asn) ;
622
622
623
- for const_ref_lty in acx. const_ref_tys ( ) {
624
- let ptr_id = const_ref_lty. label ;
625
- let expected_perms = PermissionSet :: for_const_ref_ty ( const_ref_lty. ty ) ;
626
- let mut actual_perms = asn. perms ( ) [ ptr_id] ;
627
- // Ignore `UNIQUE` as it gets automatically added to all permissions
628
- // and then removed later if it can't apply.
629
- // We don't care about `UNIQUE` for const refs, so just unset it here.
630
- actual_perms. set ( PermissionSet :: UNIQUE , false ) ;
631
- assert_eq ! ( expected_perms, actual_perms) ;
632
- }
623
+ acx. check_const_ref_perms ( & asn) ;
633
624
634
625
// Print labeling and rewrites for the current function.
635
626
You can’t perform that action at this time.
0 commit comments