@@ -10,7 +10,7 @@ use rustc_middle::mir::interpret::{CTFE_ALLOC_SALT, read_target_uint, write_targ
1010use rustc_middle:: mir:: { self , BinOp , ConstValue , NonDivergingIntrinsic , NullOp } ;
1111use rustc_middle:: ty:: layout:: TyAndLayout ;
1212use rustc_middle:: ty:: { Ty , TyCtxt } ;
13- use rustc_middle:: { bug, err_inval, ty} ;
13+ use rustc_middle:: { bug, err_inval, span_bug , ty} ;
1414use rustc_span:: { Symbol , sym} ;
1515use tracing:: trace;
1616
@@ -663,12 +663,16 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
663663 dest : & PlaceTy < ' tcx , M :: Provenance > ,
664664 ) -> InterpResult < ' tcx , ( ) > {
665665 assert_eq ! ( instance. args. len( ) , 1 ) ;
666- match instance. args . type_at ( 0 ) . kind ( ) {
666+ let ty = instance. args . type_at ( 0 ) ;
667+ match ty. kind ( ) {
667668 & ty:: Field ( container, field_path) => {
668669 let offset = self . nullary_op ( NullOp :: OffsetOf ( field_path) , container) ?;
669670 self . write_immediate ( * offset, dest)
670671 }
671- _ => Err ( err_inval ! ( TooGeneric ) ) . into ( ) ,
672+ ty:: Alias ( ..) | ty:: Param ( ..) | ty:: Placeholder ( ..) | ty:: Infer ( ..) => {
673+ Err ( err_inval ! ( TooGeneric ) ) . into ( )
674+ }
675+ _ => span_bug ! ( self . cur_span( ) , "expected field representing type, found {ty}" ) ,
672676 }
673677 }
674678
0 commit comments