@@ -13,7 +13,7 @@ use rustc_macros::{
1313} ;
1414use rustc_middle:: ty:: normalize_erasing_regions:: NormalizationError ;
1515use rustc_span:: def_id:: LOCAL_CRATE ;
16- use rustc_span:: Symbol ;
16+ use rustc_span:: { Span , Symbol } ;
1717use tracing:: { debug, instrument} ;
1818
1919use std:: assert_matches:: assert_matches;
@@ -513,10 +513,12 @@ impl<'tcx> Instance<'tcx> {
513513 param_env : ty:: ParamEnv < ' tcx > ,
514514 def_id : DefId ,
515515 args : GenericArgsRef < ' tcx > ,
516+ span : Option < Span > ,
516517 ) -> Instance < ' tcx > {
517518 match ty:: Instance :: resolve ( tcx, param_env, def_id, args) {
518519 Ok ( Some ( instance) ) => instance,
519- instance => bug ! (
520+ instance => span_bug ! (
521+ span. unwrap_or( tcx. def_span( def_id) ) ,
520522 "failed to resolve instance for {}: {instance:#?}" ,
521523 tcx. def_path_str_with_args( def_id, args)
522524 ) ,
@@ -588,7 +590,7 @@ impl<'tcx> Instance<'tcx> {
588590 return Instance { def : InstanceKind :: VTableShim ( def_id) , args } ;
589591 }
590592
591- let mut resolved = Instance :: expect_resolve ( tcx, param_env, def_id, args) ;
593+ let mut resolved = Instance :: expect_resolve ( tcx, param_env, def_id, args, None ) ;
592594
593595 let reason = tcx. sess . is_sanitizer_kcfi_enabled ( ) . then_some ( ReifyReason :: Vtable ) ;
594596 match resolved. def {
@@ -665,13 +667,13 @@ impl<'tcx> Instance<'tcx> {
665667 pub fn resolve_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
666668 let def_id = tcx. require_lang_item ( LangItem :: DropInPlace , None ) ;
667669 let args = tcx. mk_args ( & [ ty. into ( ) ] ) ;
668- Instance :: expect_resolve ( tcx, ty:: ParamEnv :: reveal_all ( ) , def_id, args)
670+ Instance :: expect_resolve ( tcx, ty:: ParamEnv :: reveal_all ( ) , def_id, args, None )
669671 }
670672
671673 pub fn resolve_async_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
672674 let def_id = tcx. require_lang_item ( LangItem :: AsyncDropInPlace , None ) ;
673675 let args = tcx. mk_args ( & [ ty. into ( ) ] ) ;
674- Instance :: expect_resolve ( tcx, ty:: ParamEnv :: reveal_all ( ) , def_id, args)
676+ Instance :: expect_resolve ( tcx, ty:: ParamEnv :: reveal_all ( ) , def_id, args, None )
675677 }
676678
677679 #[ instrument( level = "debug" , skip( tcx) , ret) ]
0 commit comments