@@ -496,7 +496,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
496496 }
497497 } ;
498498
499- self . explain_impl_static_obligation ( & mut diag, cause. code ( ) , outlived_fr) ;
499+ if let ConstraintCategory :: CallArgument ( Some ( ty) ) = category {
500+ self . explain_impl_static_obligation ( & mut diag, ty, cause. span , outlived_fr) ;
501+ } else if let ObligationCauseCode :: MethodCallConstraint ( ty, call_span) = cause. code ( ) {
502+ self . explain_impl_static_obligation ( & mut diag, * ty, * call_span, outlived_fr) ;
503+ }
500504
501505 match variance_info {
502506 ty:: VarianceDiagInfo :: None => { }
@@ -618,14 +622,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
618622 fn explain_impl_static_obligation (
619623 & self ,
620624 diag : & mut DiagnosticBuilder < ' _ > ,
621- code : & ObligationCauseCode < ' tcx > ,
625+ ty : Ty < ' tcx > ,
626+ call_span : Span ,
622627 outlived_fr : RegionVid ,
623628 ) {
624629 let tcx = self . infcx . tcx ;
625- debug ! ( ?code) ;
626- let ObligationCauseCode :: MethodCallConstraint ( ty, call_span) = code else {
627- return ;
628- } ;
629630 let ty:: FnDef ( def_id, args) = ty. kind ( ) else {
630631 return ;
631632 } ;
@@ -719,7 +720,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
719720 if let ty:: Ref ( region, _, _) = self
720721 . infcx
721722 . instantiate_binder_with_fresh_vars (
722- * call_span,
723+ call_span,
723724 BoundRegionConversionTime :: FnCall ,
724725 tcx. fn_sig ( def_id) . instantiate_identity ( ) . inputs ( ) . map_bound ( |inputs| inputs[ 0 ] ) ,
725726 )
@@ -801,10 +802,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
801802 let span: MultiSpan = predicates. into ( ) ;
802803 diag. span_note ( span, format ! ( "the `impl` on `{ty}` has {a_static_lt}" ) ) ;
803804 }
804- if new_primary_span && diag. span . primary_span ( ) != Some ( * call_span) {
805- diag. replace_span_with ( * call_span, false ) ;
805+ if new_primary_span && diag. span . primary_span ( ) != Some ( call_span) {
806+ diag. replace_span_with ( call_span, false ) ;
806807 diag. span_label (
807- * call_span,
808+ call_span,
808809 "calling this method introduces a `'static` lifetime requirement" ,
809810 ) ;
810811 }
0 commit comments