@@ -24,8 +24,8 @@ use crate::fluent_generated as fluent;
2424use crate :: interpret:: {
2525 self , AllocId , AllocRange , ConstAllocation , CtfeProvenance , FnArg , Frame , GlobalAlloc , ImmTy ,
2626 InterpCx , InterpResult , MPlaceTy , OpTy , Pointer , PointerArithmetic , RangeSet , Scalar ,
27- StackPopCleanup , compile_time_machine, err_ub , throw_exhaust, throw_inval, throw_ub_custom ,
28- throw_unsup, throw_unsup_format,
27+ StackPopCleanup , compile_time_machine, interp_ok , throw_exhaust, throw_inval, throw_ub ,
28+ throw_ub_custom , throw_unsup, throw_unsup_format,
2929} ;
3030
3131/// When hitting this many interpreted terminators we emit a deny by default lint
@@ -247,7 +247,7 @@ impl<'tcx> CompileTimeInterpCx<'tcx> {
247247 let msg = Symbol :: intern ( self . read_str ( & msg_place) ?) ;
248248 let span = self . find_closest_untracked_caller_location ( ) ;
249249 let ( file, line, col) = self . location_triple_for_span ( span) ;
250- return Err ( ConstEvalErrKind :: Panic { msg, file, line, col } . into ( ) ) ;
250+ return Err ( ConstEvalErrKind :: Panic { msg, file, line, col } ) . into ( ) ;
251251 } else if self . tcx . is_lang_item ( def_id, LangItem :: PanicFmt ) {
252252 // For panic_fmt, call const_panic_fmt instead.
253253 let const_def_id = self . tcx . require_lang_item ( LangItem :: ConstPanicFmt , None ) ;
@@ -259,16 +259,16 @@ impl<'tcx> CompileTimeInterpCx<'tcx> {
259259 self . cur_span ( ) ,
260260 ) ;
261261
262- return Ok ( Some ( new_instance) ) ;
262+ return interp_ok ( Some ( new_instance) ) ;
263263 } else if self . tcx . is_lang_item ( def_id, LangItem :: AlignOffset ) {
264264 let args = self . copy_fn_args ( args) ;
265265 // For align_offset, we replace the function call if the pointer has no address.
266266 match self . align_offset ( instance, & args, dest, ret) ? {
267- ControlFlow :: Continue ( ( ) ) => return Ok ( Some ( instance) ) ,
268- ControlFlow :: Break ( ( ) ) => return Ok ( None ) ,
267+ ControlFlow :: Continue ( ( ) ) => return interp_ok ( Some ( instance) ) ,
268+ ControlFlow :: Break ( ( ) ) => return interp_ok ( None ) ,
269269 }
270270 }
271- Ok ( Some ( instance) )
271+ interp_ok ( Some ( instance) )
272272 }
273273
274274 /// `align_offset(ptr, target_align)` needs special handling in const eval, because the pointer
@@ -323,25 +323,25 @@ impl<'tcx> CompileTimeInterpCx<'tcx> {
323323 dest,
324324 StackPopCleanup :: Goto { ret, unwind : mir:: UnwindAction :: Unreachable } ,
325325 ) ?;
326- Ok ( ControlFlow :: Break ( ( ) ) )
326+ interp_ok ( ControlFlow :: Break ( ( ) ) )
327327 } else {
328328 // Not alignable in const, return `usize::MAX`.
329329 let usize_max = Scalar :: from_target_usize ( self . target_usize_max ( ) , self ) ;
330330 self . write_scalar ( usize_max, dest) ?;
331331 self . return_to_block ( ret) ?;
332- Ok ( ControlFlow :: Break ( ( ) ) )
332+ interp_ok ( ControlFlow :: Break ( ( ) ) )
333333 }
334334 }
335335 Err ( _addr) => {
336336 // The pointer has an address, continue with function call.
337- Ok ( ControlFlow :: Continue ( ( ) ) )
337+ interp_ok ( ControlFlow :: Continue ( ( ) ) )
338338 }
339339 }
340340 }
341341
342342 /// See documentation on the `ptr_guaranteed_cmp` intrinsic.
343343 fn guaranteed_cmp ( & mut self , a : Scalar , b : Scalar ) -> InterpResult < ' tcx , u8 > {
344- Ok ( match ( a, b) {
344+ interp_ok ( match ( a, b) {
345345 // Comparisons between integers are always known.
346346 ( Scalar :: Int { .. } , Scalar :: Int { .. } ) => {
347347 if a == b {
@@ -403,8 +403,8 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
403403 instance : ty:: InstanceKind < ' tcx > ,
404404 ) -> InterpResult < ' tcx , & ' tcx mir:: Body < ' tcx > > {
405405 match instance {
406- ty:: InstanceKind :: Item ( def) => Ok ( ecx. tcx . mir_for_ctfe ( def) ) ,
407- _ => Ok ( ecx. tcx . instance_mir ( instance) ) ,
406+ ty:: InstanceKind :: Item ( def) => interp_ok ( ecx. tcx . mir_for_ctfe ( def) ) ,
407+ _ => interp_ok ( ecx. tcx . instance_mir ( instance) ) ,
408408 }
409409 }
410410
@@ -422,7 +422,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
422422 // Replace some functions.
423423 let Some ( instance) = ecx. hook_special_const_fn ( orig_instance, args, dest, ret) ? else {
424424 // Call has already been handled.
425- return Ok ( None ) ;
425+ return interp_ok ( None ) ;
426426 } ;
427427
428428 // Only check non-glue functions
@@ -444,14 +444,14 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
444444 // This is a const fn. Call it.
445445 // In case of replacement, we return the *original* instance to make backtraces work out
446446 // (and we hope this does not confuse the FnAbi checks too much).
447- Ok ( Some ( ( ecx. load_mir ( instance. def , None ) ?, orig_instance) ) )
447+ interp_ok ( Some ( ( ecx. load_mir ( instance. def , None ) ?, orig_instance) ) )
448448 }
449449
450450 fn panic_nounwind ( ecx : & mut InterpCx < ' tcx , Self > , msg : & str ) -> InterpResult < ' tcx > {
451451 let msg = Symbol :: intern ( msg) ;
452452 let span = ecx. find_closest_untracked_caller_location ( ) ;
453453 let ( file, line, col) = ecx. location_triple_for_span ( span) ;
454- Err ( ConstEvalErrKind :: Panic { msg, file, line, col } . into ( ) )
454+ Err ( ConstEvalErrKind :: Panic { msg, file, line, col } ) . into ( )
455455 }
456456
457457 fn call_intrinsic (
@@ -464,7 +464,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
464464 ) -> InterpResult < ' tcx , Option < ty:: Instance < ' tcx > > > {
465465 // Shared intrinsics.
466466 if ecx. eval_intrinsic ( instance, args, dest, target) ? {
467- return Ok ( None ) ;
467+ return interp_ok ( None ) ;
468468 }
469469 let intrinsic_name = ecx. tcx . item_name ( instance. def_id ( ) ) ;
470470
@@ -541,7 +541,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
541541 "intrinsic `{intrinsic_name}` is not supported at compile-time"
542542 ) ;
543543 }
544- return Ok ( Some ( ty:: Instance {
544+ return interp_ok ( Some ( ty:: Instance {
545545 def : ty:: InstanceKind :: Item ( instance. def_id ( ) ) ,
546546 args : instance. args ,
547547 } ) ) ;
@@ -550,7 +550,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
550550
551551 // Intrinsic is done, jump to next block.
552552 ecx. return_to_block ( target) ?;
553- Ok ( None )
553+ interp_ok ( None )
554554 }
555555
556556 fn assert_panic (
@@ -581,7 +581,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
581581 }
582582 }
583583 } ;
584- Err ( ConstEvalErrKind :: AssertFailure ( err) . into ( ) )
584+ Err ( ConstEvalErrKind :: AssertFailure ( err) ) . into ( )
585585 }
586586
587587 fn binary_ptr_op (
@@ -652,7 +652,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
652652 }
653653 }
654654
655- Ok ( ( ) )
655+ interp_ok ( ( ) )
656656 }
657657
658658 #[ inline( always) ]
@@ -670,7 +670,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
670670 if !ecx. recursion_limit . value_within_limit ( ecx. stack ( ) . len ( ) + 1 ) {
671671 throw_exhaust ! ( StackFrameLimitReached )
672672 } else {
673- Ok ( frame)
673+ interp_ok ( frame)
674674 }
675675 }
676676
@@ -700,22 +700,22 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
700700 if is_write {
701701 // Write access. These are never allowed, but we give a targeted error message.
702702 match alloc. mutability {
703- Mutability :: Not => Err ( err_ub ! ( WriteToReadOnly ( alloc_id) ) . into ( ) ) ,
704- Mutability :: Mut => Err ( ConstEvalErrKind :: ModifiedGlobal . into ( ) ) ,
703+ Mutability :: Not => throw_ub ! ( WriteToReadOnly ( alloc_id) ) ,
704+ Mutability :: Mut => Err ( ConstEvalErrKind :: ModifiedGlobal ) . into ( ) ,
705705 }
706706 } else {
707707 // Read access. These are usually allowed, with some exceptions.
708708 if machine. can_access_mut_global == CanAccessMutGlobal :: Yes {
709709 // Machine configuration allows us read from anything (e.g., `static` initializer).
710- Ok ( ( ) )
710+ interp_ok ( ( ) )
711711 } else if alloc. mutability == Mutability :: Mut {
712712 // Machine configuration does not allow us to read statics (e.g., `const`
713713 // initializer).
714- Err ( ConstEvalErrKind :: ConstAccessesMutGlobal . into ( ) )
714+ Err ( ConstEvalErrKind :: ConstAccessesMutGlobal ) . into ( )
715715 } else {
716716 // Immutable global, this read is fine.
717717 assert_eq ! ( alloc. mutability, Mutability :: Not ) ;
718- Ok ( ( ) )
718+ interp_ok ( ( ) )
719719 }
720720 }
721721 }
@@ -748,9 +748,9 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
748748 // even when there is interior mutability.)
749749 place. map_provenance ( CtfeProvenance :: as_shared_ref)
750750 } ;
751- Ok ( ImmTy :: from_immediate ( new_place. to_ref ( ecx) , val. layout ) )
751+ interp_ok ( ImmTy :: from_immediate ( new_place. to_ref ( ecx) , val. layout ) )
752752 } else {
753- Ok ( val. clone ( ) )
753+ interp_ok ( val. clone ( ) )
754754 }
755755 }
756756
@@ -763,20 +763,20 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
763763 ) -> InterpResult < ' tcx > {
764764 if range. size == Size :: ZERO {
765765 // Nothing to check.
766- return Ok ( ( ) ) ;
766+ return interp_ok ( ( ) ) ;
767767 }
768768 // Reject writes through immutable pointers.
769769 if immutable {
770- return Err ( ConstEvalErrKind :: WriteThroughImmutablePointer . into ( ) ) ;
770+ return Err ( ConstEvalErrKind :: WriteThroughImmutablePointer ) . into ( ) ;
771771 }
772772 // Everything else is fine.
773- Ok ( ( ) )
773+ interp_ok ( ( ) )
774774 }
775775
776776 fn before_alloc_read ( ecx : & InterpCx < ' tcx , Self > , alloc_id : AllocId ) -> InterpResult < ' tcx > {
777777 // Check if this is the currently evaluated static.
778778 if Some ( alloc_id) == ecx. machine . static_root_ids . map ( |( id, _) | id) {
779- return Err ( ConstEvalErrKind :: RecursiveStatic . into ( ) ) ;
779+ return Err ( ConstEvalErrKind :: RecursiveStatic ) . into ( ) ;
780780 }
781781 // If this is another static, make sure we fire off the query to detect cycles.
782782 // But only do that when checks for static recursion are enabled.
@@ -788,7 +788,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
788788 ecx. ctfe_query ( |tcx| tcx. eval_static_initializer ( def_id) ) ?;
789789 }
790790 }
791- Ok ( ( ) )
791+ interp_ok ( ( ) )
792792 }
793793
794794 fn cached_union_data_range < ' e > (
0 commit comments