@@ -3318,23 +3318,19 @@ pub(crate) fn expr_to_vir_innermost<'tcx>(
33183318 let tgt_vir = expr_to_vir_consume ( bctx, tgt_expr) ?;
33193319 let idx_vir = expr_to_vir_consume ( bctx, idx_expr) ?;
33203320
3321+ // typ args to Index:
3322+ // target typ without & or &mut
3323+ let tgt_typ_vir = bctx. mid_ty_to_vir ( tgt_expr. span , & tgt_ty) ?;
3324+ // idx typ
3325+ let idx_typ_vir = bctx. mid_ty_to_vir ( idx_expr. span , & idx_ty) ?;
3326+
33213327 let fun_typ_args = if ty_is_vec ( bctx. ctxt . tcx , * tgt_ty) && idx_ty. is_usize ( ) {
33223328 let fun = if mutbl {
33233329 vir:: fun!( CrateId :: Vstd => "std_specs" , "vec" , "vec_index_mut" )
33243330 } else {
33253331 vir:: fun!( CrateId :: Vstd => "std_specs" , "vec" , "vec_index" )
33263332 } ;
33273333
3328- let mut tgt_typ_vir = undecorate_typ ( & tgt_vir. typ ) ;
3329- if mutbl {
3330- tgt_typ_vir = match & * tgt_typ_vir {
3331- TypX :: MutRef ( t) => t. clone ( ) ,
3332- _ => crate :: internal_err!(
3333- expr. span,
3334- "Index operator expected TypX::MutRef"
3335- ) ,
3336- } ;
3337- }
33383334 let typ_args = match & * tgt_typ_vir {
33393335 TypX :: Datatype ( _, typ_args, _) => typ_args. clone ( ) ,
33403336 _ => crate :: internal_err!(
@@ -3375,8 +3371,7 @@ pub(crate) fn expr_to_vir_innermost<'tcx>(
33753371 // general Index trait case
33763372 let ( impl_paths, target_kind) =
33773373 resolve_index_call ( bctx, * tgt_ty, idx_ty, false , expr. span ) ?;
3378- let typ_args =
3379- Arc :: new ( vec ! [ undecorate_typ( & tgt_vir. typ) , idx_vir. typ. clone( ) ] ) ;
3374+ let typ_args = Arc :: new ( vec ! [ tgt_typ_vir, idx_typ_vir] ) ;
33803375 let fun = vir:: fun!( CrateId :: Core => "ops" , "index" , "Index" , "index" ) ;
33813376 CallTarget :: Fun ( target_kind, fun, typ_args, impl_paths, call_target_attrs)
33823377 } ;
0 commit comments