File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi Expand file tree Collapse file tree 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> {
521521 self . try_to_valtree ( ) ?. try_to_scalar ( )
522522 }
523523
524+ pub fn try_to_bool ( self ) -> Option < bool > {
525+ self . try_to_scalar ( ) ?. to_bool ( ) . ok ( )
526+ }
527+
524528 #[ inline]
525529 pub fn try_to_target_usize ( self , tcx : TyCtxt < ' tcx > ) -> Option < u64 > {
526530 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>(
145145 let _ = write ! ( s, "{val}" ) ;
146146 }
147147 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" ) ;
149149 let _ = write ! ( s, "{val}" ) ;
150150 }
151151 _ => {
@@ -411,7 +411,7 @@ pub fn encode_ty<'tcx>(
411411
412412 ty:: Array ( ty0, len) => {
413413 // 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" ) ;
415415 let mut s = String :: from ( "A" ) ;
416416 let _ = write ! ( s, "{len}" ) ;
417417 s. push_str ( & encode_ty ( tcx, * ty0, dict, options) ) ;
You can’t perform that action at this time.
0 commit comments