@@ -516,7 +516,7 @@ impl<'tcx> Instance<'tcx> {
516516 /// from `Ok(None)` to avoid misleading diagnostics when an error
517517 /// has already been/will be emitted, for the original cause
518518 #[ instrument( level = "debug" , skip( tcx) , ret) ]
519- pub fn resolve (
519+ pub fn try_resolve (
520520 tcx : TyCtxt < ' tcx > ,
521521 param_env : ty:: ParamEnv < ' tcx > ,
522522 def_id : DefId ,
@@ -555,7 +555,7 @@ impl<'tcx> Instance<'tcx> {
555555 let span_or_local_def_span =
556556 || if span. is_dummy ( ) && def_id. is_local ( ) { tcx. def_span ( def_id) } else { span } ;
557557
558- match ty:: Instance :: resolve ( tcx, param_env, def_id, args) {
558+ match ty:: Instance :: try_resolve ( tcx, param_env, def_id, args) {
559559 Ok ( Some ( instance) ) => instance,
560560 Ok ( None ) => {
561561 let type_length = type_length ( args) ;
@@ -605,7 +605,7 @@ impl<'tcx> Instance<'tcx> {
605605 // Use either `resolve_closure` or `resolve_for_vtable`
606606 assert ! ( !tcx. is_closure_like( def_id) , "Called `resolve_for_fn_ptr` on closure: {def_id:?}" ) ;
607607 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| {
609609 match resolved. def {
610610 InstanceKind :: Item ( def) if resolved. def . requires_caller_location ( tcx) => {
611611 debug ! ( " => fn pointer created for function with #[track_caller]" ) ;
@@ -738,13 +738,25 @@ impl<'tcx> Instance<'tcx> {
738738 pub fn resolve_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
739739 let def_id = tcx. require_lang_item ( LangItem :: DropInPlace , None ) ;
740740 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+ )
742748 }
743749
744750 pub fn resolve_async_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
745751 let def_id = tcx. require_lang_item ( LangItem :: AsyncDropInPlace , None ) ;
746752 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+ )
748760 }
749761
750762 #[ instrument( level = "debug" , skip( tcx) , ret) ]
0 commit comments