@@ -86,7 +86,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
8686 MPlaceTy :: dangling ( this. layout_of ( tcx. mk_unit ( ) ) ?, this) . into ( ) ;
8787 this. call_function (
8888 f_instance,
89- & [ f_arg] ,
89+ & [ f_arg. into ( ) ] ,
9090 Some ( ret_place) ,
9191 // Directly return to caller.
9292 StackPopCleanup :: Goto { ret : Some ( ret) , unwind : None } ,
@@ -163,6 +163,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
163163
164164 match msg {
165165 BoundsCheck { ref index, ref len } => {
166+ // Forward to `panic_bounds_check` lang item.
167+
166168 // First arg: Caller location.
167169 let location = this. alloc_caller_location_for_span ( span) ?;
168170 // Second arg: index.
@@ -175,12 +177,31 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
175177 let panic_bounds_check = ty:: Instance :: mono ( this. tcx . tcx , panic_bounds_check) ;
176178 this. call_function (
177179 panic_bounds_check,
178- & [ location. ptr , index. not_undef ( ) ?, len. not_undef ( ) ?] ,
180+ & [ location. ptr . into ( ) , index. into ( ) , len. into ( ) ] ,
181+ None ,
182+ StackPopCleanup :: Goto { ret : None , unwind } ,
183+ ) ?;
184+ }
185+ _ => {
186+ // Forward everything else to `panic` lang item.
187+
188+ // First arg: Message.
189+ let msg = msg. description ( ) ;
190+ let msg = this. allocate_str ( msg, MiriMemoryKind :: Static . into ( ) ) ;
191+
192+ // Second arg: Caller location.
193+ let location = this. alloc_caller_location_for_span ( span) ?;
194+
195+ // Call the lang item.
196+ let panic = this. tcx . lang_items ( ) . panic_fn ( ) . unwrap ( ) ;
197+ let panic = ty:: Instance :: mono ( this. tcx . tcx , panic) ;
198+ this. call_function (
199+ panic,
200+ & [ msg. to_ref ( ) , location. ptr . into ( ) ] ,
179201 None ,
180202 StackPopCleanup :: Goto { ret : None , unwind } ,
181203 ) ?;
182204 }
183- _ => unimplemented ! ( )
184205 }
185206 Ok ( ( ) )
186207 }
0 commit comments