@@ -197,8 +197,8 @@ impl interpret::MayLeak for ! {
197197}
198198
199199impl < ' mir , ' tcx : ' mir > CompileTimeEvalContext < ' mir , ' tcx > {
200- fn guaranteed_eq ( & mut self , a : Scalar , b : Scalar ) -> bool {
201- match ( a, b) {
200+ fn guaranteed_eq ( & mut self , a : Scalar , b : Scalar ) -> InterpResult < ' tcx , bool > {
201+ Ok ( match ( a, b) {
202202 // Comparisons between integers are always known.
203203 ( Scalar :: Int { .. } , Scalar :: Int { .. } ) => a == b,
204204 // Equality with integers can never be known for sure.
@@ -207,25 +207,25 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
207207 // some things (like functions and vtables) do not have stable addresses
208208 // so we need to be careful around them (see e.g. #73722).
209209 ( Scalar :: Ptr ( ..) , Scalar :: Ptr ( ..) ) => false ,
210- }
210+ } )
211211 }
212212
213- fn guaranteed_ne ( & mut self , a : Scalar , b : Scalar ) -> bool {
214- match ( a, b) {
213+ fn guaranteed_ne ( & mut self , a : Scalar , b : Scalar ) -> InterpResult < ' tcx , bool > {
214+ Ok ( match ( a, b) {
215215 // Comparisons between integers are always known.
216216 ( Scalar :: Int ( _) , Scalar :: Int ( _) ) => a != b,
217217 // Comparisons of abstract pointers with null pointers are known if the pointer
218218 // is in bounds, because if they are in bounds, the pointer can't be null.
219219 // Inequality with integers other than null can never be known for sure.
220220 ( Scalar :: Int ( int) , ptr @ Scalar :: Ptr ( ..) )
221221 | ( ptr @ Scalar :: Ptr ( ..) , Scalar :: Int ( int) ) => {
222- int. is_null ( ) && !self . scalar_may_be_null ( ptr)
222+ int. is_null ( ) && !self . scalar_may_be_null ( ptr) ?
223223 }
224224 // FIXME: return `true` for at least some comparisons where we can reliably
225225 // determine the result of runtime inequality tests at compile-time.
226226 // Examples include comparison of addresses in different static items.
227227 ( Scalar :: Ptr ( ..) , Scalar :: Ptr ( ..) ) => false ,
228- }
228+ } )
229229 }
230230}
231231
@@ -329,9 +329,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
329329 let a = ecx. read_immediate ( & args[ 0 ] ) ?. to_scalar ( ) ?;
330330 let b = ecx. read_immediate ( & args[ 1 ] ) ?. to_scalar ( ) ?;
331331 let cmp = if intrinsic_name == sym:: ptr_guaranteed_eq {
332- ecx. guaranteed_eq ( a, b)
332+ ecx. guaranteed_eq ( a, b) ?
333333 } else {
334- ecx. guaranteed_ne ( a, b)
334+ ecx. guaranteed_ne ( a, b) ?
335335 } ;
336336 ecx. write_scalar ( Scalar :: from_bool ( cmp) , dest) ?;
337337 }
0 commit comments