@@ -13,7 +13,7 @@ use rustc_macros::{
13
13
} ;
14
14
use rustc_middle:: ty:: normalize_erasing_regions:: NormalizationError ;
15
15
use rustc_span:: def_id:: LOCAL_CRATE ;
16
- use rustc_span:: Symbol ;
16
+ use rustc_span:: { Span , Symbol } ;
17
17
use tracing:: { debug, instrument} ;
18
18
19
19
use std:: assert_matches:: assert_matches;
@@ -513,10 +513,12 @@ impl<'tcx> Instance<'tcx> {
513
513
param_env : ty:: ParamEnv < ' tcx > ,
514
514
def_id : DefId ,
515
515
args : GenericArgsRef < ' tcx > ,
516
+ span : Option < Span > ,
516
517
) -> Instance < ' tcx > {
517
518
match ty:: Instance :: resolve ( tcx, param_env, def_id, args) {
518
519
Ok ( Some ( instance) ) => instance,
519
- instance => bug ! (
520
+ instance => span_bug ! (
521
+ span. unwrap_or( tcx. def_span( def_id) ) ,
520
522
"failed to resolve instance for {}: {instance:#?}" ,
521
523
tcx. def_path_str_with_args( def_id, args)
522
524
) ,
@@ -588,7 +590,7 @@ impl<'tcx> Instance<'tcx> {
588
590
return Instance { def : InstanceKind :: VTableShim ( def_id) , args } ;
589
591
}
590
592
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 ) ;
592
594
593
595
let reason = tcx. sess . is_sanitizer_kcfi_enabled ( ) . then_some ( ReifyReason :: Vtable ) ;
594
596
match resolved. def {
@@ -665,13 +667,13 @@ impl<'tcx> Instance<'tcx> {
665
667
pub fn resolve_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
666
668
let def_id = tcx. require_lang_item ( LangItem :: DropInPlace , None ) ;
667
669
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 )
669
671
}
670
672
671
673
pub fn resolve_async_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
672
674
let def_id = tcx. require_lang_item ( LangItem :: AsyncDropInPlace , None ) ;
673
675
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 )
675
677
}
676
678
677
679
#[ instrument( level = "debug" , skip( tcx) , ret) ]
0 commit comments