@@ -496,7 +496,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
496
496
}
497
497
} ;
498
498
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
+ }
500
504
501
505
match variance_info {
502
506
ty:: VarianceDiagInfo :: None => { }
@@ -618,14 +622,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
618
622
fn explain_impl_static_obligation (
619
623
& self ,
620
624
diag : & mut DiagnosticBuilder < ' _ > ,
621
- code : & ObligationCauseCode < ' tcx > ,
625
+ ty : Ty < ' tcx > ,
626
+ call_span : Span ,
622
627
outlived_fr : RegionVid ,
623
628
) {
624
629
let tcx = self . infcx . tcx ;
625
- debug ! ( ?code) ;
626
- let ObligationCauseCode :: MethodCallConstraint ( ty, call_span) = code else {
627
- return ;
628
- } ;
629
630
let ty:: FnDef ( def_id, args) = ty. kind ( ) else {
630
631
return ;
631
632
} ;
@@ -719,7 +720,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
719
720
if let ty:: Ref ( region, _, _) = self
720
721
. infcx
721
722
. instantiate_binder_with_fresh_vars (
722
- * call_span,
723
+ call_span,
723
724
BoundRegionConversionTime :: FnCall ,
724
725
tcx. fn_sig ( def_id) . instantiate_identity ( ) . inputs ( ) . map_bound ( |inputs| inputs[ 0 ] ) ,
725
726
)
@@ -801,10 +802,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
801
802
let span: MultiSpan = predicates. into ( ) ;
802
803
diag. span_note ( span, format ! ( "the `impl` on `{ty}` has {a_static_lt}" ) ) ;
803
804
}
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 ) ;
806
807
diag. span_label (
807
- * call_span,
808
+ call_span,
808
809
"calling this method introduces a `'static` lifetime requirement" ,
809
810
) ;
810
811
}
0 commit comments