@@ -161,7 +161,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
161161 ) -> InterpResult < ' tcx , Pointer < M :: Provenance > > {
162162 let alloc_id = ptr. provenance ;
163163 // We need to handle `extern static`.
164- match self . tcx . get_global_alloc ( alloc_id) {
164+ match self . tcx . try_get_global_alloc ( alloc_id) {
165165 Some ( GlobalAlloc :: Static ( def_id) ) if self . tcx . is_thread_local_static ( def_id) => {
166166 bug ! ( "global memory cannot point to thread-local static" )
167167 }
@@ -289,7 +289,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
289289
290290 let Some ( ( alloc_kind, mut alloc) ) = self . memory . alloc_map . remove ( & alloc_id) else {
291291 // Deallocating global memory -- always an error
292- return Err ( match self . tcx . get_global_alloc ( alloc_id) {
292+ return Err ( match self . tcx . try_get_global_alloc ( alloc_id) {
293293 Some ( GlobalAlloc :: Function ( ..) ) => {
294294 err_ub_format ! ( "deallocating {alloc_id:?}, which is a function" )
295295 }
@@ -478,7 +478,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
478478 id : AllocId ,
479479 is_write : bool ,
480480 ) -> InterpResult < ' tcx , Cow < ' tcx , Allocation < M :: Provenance , M :: AllocExtra > > > {
481- let ( alloc, def_id) = match self . tcx . get_global_alloc ( id) {
481+ let ( alloc, def_id) = match self . tcx . try_get_global_alloc ( id) {
482482 Some ( GlobalAlloc :: Memory ( mem) ) => {
483483 // Memory of a constant or promoted or anonymous memory referenced by a static.
484484 ( mem, None )
@@ -669,7 +669,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
669669 // # Statics
670670 // Can't do this in the match argument, we may get cycle errors since the lock would
671671 // be held throughout the match.
672- match self . tcx . get_global_alloc ( id) {
672+ match self . tcx . try_get_global_alloc ( id) {
673673 Some ( GlobalAlloc :: Static ( did) ) => {
674674 assert ! ( !self . tcx. is_thread_local_static( did) ) ;
675675 // Use size and align of the type.
@@ -715,7 +715,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
715715 if let Some ( extra) = self . memory . extra_fn_ptr_map . get ( & id) {
716716 Some ( FnVal :: Other ( * extra) )
717717 } else {
718- match self . tcx . get_global_alloc ( id) {
718+ match self . tcx . try_get_global_alloc ( id) {
719719 Some ( GlobalAlloc :: Function ( instance) ) => Some ( FnVal :: Instance ( instance) ) ,
720720 _ => None ,
721721 }
@@ -839,7 +839,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a,
839839 }
840840 None => {
841841 // global alloc
842- match self . ecx . tcx . get_global_alloc ( id) {
842+ match self . ecx . tcx . try_get_global_alloc ( id) {
843843 Some ( GlobalAlloc :: Memory ( alloc) ) => {
844844 write ! ( fmt, " (unchanged global, " ) ?;
845845 write_allocation_track_relocs (
0 commit comments