@@ -426,44 +426,26 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
426426 Ok ( ( ) )
427427 }
428428
429- fn thread_local_alloc_id (
429+ fn thread_local_static_alloc_id (
430430 ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
431431 def_id : DefId ,
432432 ) -> InterpResult < ' tcx , AllocId > {
433433 ecx. get_or_create_thread_local_alloc_id ( def_id)
434434 }
435435
436- fn adjust_global_const (
437- ecx : & InterpCx < ' mir , ' tcx , Self > ,
438- mut val : mir:: interpret:: ConstValue < ' tcx > ,
439- ) -> InterpResult < ' tcx , mir:: interpret:: ConstValue < ' tcx > > {
440- // FIXME: Remove this, do The Right Thing in `thread_local_alloc_id` instead.
441- ecx. remap_thread_local_alloc_ids ( & mut val) ?;
442- Ok ( val)
443- }
444-
445- fn canonical_alloc_id ( mem : & Memory < ' mir , ' tcx , Self > , id : AllocId ) -> AllocId {
446- let tcx = mem. tcx ;
447- // Figure out if this is an extern static, and if yes, which one.
448- let def_id = match tcx. get_global_alloc ( id) {
449- Some ( GlobalAlloc :: Static ( def_id) ) if tcx. is_foreign_item ( def_id) => def_id,
450- _ => {
451- // No need to canonicalize anything.
452- return id;
453- }
454- } ;
455- let attrs = tcx. get_attrs ( def_id) ;
436+ fn extern_static_alloc_id (
437+ memory : & Memory < ' mir , ' tcx , Self > ,
438+ def_id : DefId ,
439+ ) -> InterpResult < ' tcx , AllocId > {
440+ let attrs = memory. tcx . get_attrs ( def_id) ;
456441 let link_name = match attr:: first_attr_value_str_by_name ( & attrs, sym:: link_name) {
457442 Some ( name) => name,
458- None => tcx. item_name ( def_id) ,
443+ None => memory . tcx . item_name ( def_id) ,
459444 } ;
460- // Check if we know this one.
461- if let Some ( canonical_id) = mem. extra . extern_statics . get ( & link_name) {
462- trace ! ( "canonical_alloc_id: {:?} ({}) -> {:?}" , id, link_name, canonical_id) ;
463- * canonical_id
445+ if let Some ( & id) = memory. extra . extern_statics . get ( & link_name) {
446+ Ok ( id)
464447 } else {
465- // Return original id; `Memory::get_static_alloc` will throw an error.
466- id
448+ throw_unsup_format ! ( "`extern` static {:?} is not supported by Miri" , def_id)
467449 }
468450 }
469451
0 commit comments