@@ -516,7 +516,7 @@ impl<'tcx> Instance<'tcx> {
516
516
/// from `Ok(None)` to avoid misleading diagnostics when an error
517
517
/// has already been/will be emitted, for the original cause
518
518
#[ instrument( level = "debug" , skip( tcx) , ret) ]
519
- pub fn resolve (
519
+ pub fn try_resolve (
520
520
tcx : TyCtxt < ' tcx > ,
521
521
param_env : ty:: ParamEnv < ' tcx > ,
522
522
def_id : DefId ,
@@ -555,7 +555,7 @@ impl<'tcx> Instance<'tcx> {
555
555
let span_or_local_def_span =
556
556
|| if span. is_dummy ( ) && def_id. is_local ( ) { tcx. def_span ( def_id) } else { span } ;
557
557
558
- match ty:: Instance :: resolve ( tcx, param_env, def_id, args) {
558
+ match ty:: Instance :: try_resolve ( tcx, param_env, def_id, args) {
559
559
Ok ( Some ( instance) ) => instance,
560
560
Ok ( None ) => {
561
561
let type_length = type_length ( args) ;
@@ -605,7 +605,7 @@ impl<'tcx> Instance<'tcx> {
605
605
// Use either `resolve_closure` or `resolve_for_vtable`
606
606
assert ! ( !tcx. is_closure_like( def_id) , "Called `resolve_for_fn_ptr` on closure: {def_id:?}" ) ;
607
607
let reason = tcx. sess . is_sanitizer_kcfi_enabled ( ) . then_some ( ReifyReason :: FnPtr ) ;
608
- Instance :: resolve ( tcx, param_env, def_id, args) . ok ( ) . flatten ( ) . map ( |mut resolved| {
608
+ Instance :: try_resolve ( tcx, param_env, def_id, args) . ok ( ) . flatten ( ) . map ( |mut resolved| {
609
609
match resolved. def {
610
610
InstanceKind :: Item ( def) if resolved. def . requires_caller_location ( tcx) => {
611
611
debug ! ( " => fn pointer created for function with #[track_caller]" ) ;
@@ -738,13 +738,25 @@ impl<'tcx> Instance<'tcx> {
738
738
pub fn resolve_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
739
739
let def_id = tcx. require_lang_item ( LangItem :: DropInPlace , None ) ;
740
740
let args = tcx. mk_args ( & [ ty. into ( ) ] ) ;
741
- Instance :: expect_resolve ( tcx, ty:: ParamEnv :: reveal_all ( ) , def_id, args, DUMMY_SP )
741
+ Instance :: expect_resolve (
742
+ tcx,
743
+ ty:: ParamEnv :: reveal_all ( ) ,
744
+ def_id,
745
+ args,
746
+ ty. ty_adt_def ( ) . and_then ( |adt| tcx. hir ( ) . span_if_local ( adt. did ( ) ) ) . unwrap_or ( DUMMY_SP ) ,
747
+ )
742
748
}
743
749
744
750
pub fn resolve_async_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
745
751
let def_id = tcx. require_lang_item ( LangItem :: AsyncDropInPlace , None ) ;
746
752
let args = tcx. mk_args ( & [ ty. into ( ) ] ) ;
747
- Instance :: expect_resolve ( tcx, ty:: ParamEnv :: reveal_all ( ) , def_id, args, DUMMY_SP )
753
+ Instance :: expect_resolve (
754
+ tcx,
755
+ ty:: ParamEnv :: reveal_all ( ) ,
756
+ def_id,
757
+ args,
758
+ ty. ty_adt_def ( ) . and_then ( |adt| tcx. hir ( ) . span_if_local ( adt. did ( ) ) ) . unwrap_or ( DUMMY_SP ) ,
759
+ )
748
760
}
749
761
750
762
#[ instrument( level = "debug" , skip( tcx) , ret) ]
0 commit comments