File tree 2 files changed +6
-2
lines changed
rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -521,6 +521,10 @@ impl<'tcx> Const<'tcx> {
521
521
self . try_to_valtree ( ) ?. try_to_scalar ( )
522
522
}
523
523
524
+ pub fn try_to_bool ( self ) -> Option < bool > {
525
+ self . try_to_scalar ( ) ?. to_bool ( ) . ok ( )
526
+ }
527
+
524
528
#[ inline]
525
529
pub fn try_to_target_usize ( self , tcx : TyCtxt < ' tcx > ) -> Option < u64 > {
526
530
self . try_to_valtree ( ) ?. try_to_target_usize ( tcx)
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ fn encode_const<'tcx>(
145
145
let _ = write ! ( s, "{val}" ) ;
146
146
}
147
147
ty:: Bool => {
148
- let val = c. try_eval_bool ( tcx , ty :: ParamEnv :: reveal_all ( ) ) . unwrap ( ) ;
148
+ let val = c. try_to_bool ( ) . expect ( "expected monomorphic const in cfi" ) ;
149
149
let _ = write ! ( s, "{val}" ) ;
150
150
}
151
151
_ => {
@@ -411,7 +411,7 @@ pub fn encode_ty<'tcx>(
411
411
412
412
ty:: Array ( ty0, len) => {
413
413
// A<array-length><element-type>
414
- let len = len. eval_target_usize ( tcx, ty :: ParamEnv :: reveal_all ( ) ) ;
414
+ let len = len. try_to_target_usize ( tcx) . expect ( "expected monomorphic const in cfi" ) ;
415
415
let mut s = String :: from ( "A" ) ;
416
416
let _ = write ! ( s, "{len}" ) ;
417
417
s. push_str ( & encode_ty ( tcx, * ty0, dict, options) ) ;
You can’t perform that action at this time.
0 commit comments