2
2
#![ deny( rustc:: diagnostic_outside_of_impl) ]
3
3
//! Error reporting machinery for lifetime errors.
4
4
5
- use either:: Either ;
6
5
use rustc_data_structures:: fx:: FxHashSet ;
7
6
use rustc_errors:: { Applicability , Diagnostic , DiagnosticBuilder , ErrorGuaranteed , MultiSpan } ;
8
7
use rustc_hir:: def_id:: DefId ;
@@ -17,7 +16,7 @@ use rustc_infer::infer::{
17
16
NllRegionVariableOrigin , RelateParamBound ,
18
17
} ;
19
18
use rustc_middle:: hir:: place:: PlaceBase ;
20
- use rustc_middle:: mir:: { ConstraintCategory , ReturnConstraint , TerminatorKind } ;
19
+ use rustc_middle:: mir:: { ConstraintCategory , ReturnConstraint } ;
21
20
use rustc_middle:: ty:: subst:: InternalSubsts ;
22
21
use rustc_middle:: ty:: Region ;
23
22
use rustc_middle:: ty:: TypeVisitor ;
@@ -40,7 +39,7 @@ use crate::{
40
39
MirBorrowckCtxt ,
41
40
} ;
42
41
43
- impl ConstraintDescription for ConstraintCategory {
42
+ impl < ' tcx > ConstraintDescription for ConstraintCategory < ' tcx > {
44
43
fn description ( & self ) -> & ' static str {
45
44
// Must end with a space. Allows for empty names to be provided.
46
45
match self {
@@ -116,15 +115,15 @@ pub(crate) enum RegionErrorKind<'tcx> {
116
115
117
116
/// Information about the various region constraints involved in a borrow checker error.
118
117
#[ derive( Clone , Debug ) ]
119
- pub struct ErrorConstraintInfo {
118
+ pub struct ErrorConstraintInfo < ' tcx > {
120
119
// fr: outlived_fr
121
120
pub ( super ) fr : RegionVid ,
122
121
pub ( super ) fr_is_local : bool ,
123
122
pub ( super ) outlived_fr : RegionVid ,
124
123
pub ( super ) outlived_fr_is_local : bool ,
125
124
126
125
// Category and span for best blame constraint
127
- pub ( super ) category : ConstraintCategory ,
126
+ pub ( super ) category : ConstraintCategory < ' tcx > ,
128
127
pub ( super ) span : Span ,
129
128
}
130
129
@@ -499,7 +498,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
499
498
/// ```
500
499
fn report_fnmut_error (
501
500
& self ,
502
- errci : & ErrorConstraintInfo ,
501
+ errci : & ErrorConstraintInfo < ' tcx > ,
503
502
kind : ReturnConstraint ,
504
503
) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
505
504
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
@@ -572,7 +571,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
572
571
#[ instrument( level = "debug" , skip( self ) ) ]
573
572
fn report_escaping_data_error (
574
573
& self ,
575
- errci : & ErrorConstraintInfo ,
574
+ errci : & ErrorConstraintInfo < ' tcx > ,
576
575
) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
577
576
let ErrorConstraintInfo { span, category, .. } = errci;
578
577
@@ -676,7 +675,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
676
675
/// ```
677
676
fn report_general_error (
678
677
& self ,
679
- errci : & ErrorConstraintInfo ,
678
+ errci : & ErrorConstraintInfo < ' tcx > ,
680
679
) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
681
680
let ErrorConstraintInfo {
682
681
fr,
@@ -789,20 +788,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
789
788
diag : & mut Diagnostic ,
790
789
f : Region < ' tcx > ,
791
790
o : Region < ' tcx > ,
792
- category : & ConstraintCategory ,
791
+ category : & ConstraintCategory < ' tcx > ,
793
792
) {
794
793
if !o. is_static ( ) {
795
794
return ;
796
795
}
797
796
798
797
let tcx = self . infcx . tcx ;
799
798
800
- let instance =
801
- if let ConstraintCategory :: CallArgument ( location) = category
802
- && let Either :: Right ( term) = self . body . stmt_at ( * location)
803
- && let TerminatorKind :: Call { func, .. } = & term. kind
804
- {
805
- let func_ty = func. ty ( self . body , tcx) ;
799
+ let instance = if let ConstraintCategory :: CallArgument ( Some ( func_ty) ) = category {
806
800
let ( fn_did, substs) = match func_ty. kind ( ) {
807
801
ty:: FnDef ( fn_did, substs) => ( fn_did, substs) ,
808
802
_ => return ,
0 commit comments