@@ -1801,35 +1801,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1801
1801
1802
1802
pub ( crate ) fn retrieve_closure_constraint_info (
1803
1803
& self ,
1804
- constraint : & OutlivesConstraint < ' tcx > ,
1805
- ) -> BlameConstraint < ' tcx > {
1806
- let loc = match constraint. locations {
1807
- Locations :: All ( span) => {
1808
- return BlameConstraint {
1809
- category : constraint. category ,
1810
- from_closure : false ,
1811
- cause : ObligationCause :: dummy_with_span ( span) ,
1812
- variance_info : constraint. variance_info ,
1813
- } ;
1804
+ constraint : OutlivesConstraint < ' tcx > ,
1805
+ ) -> Option < ( ConstraintCategory < ' tcx > , Span ) > {
1806
+ match constraint. locations {
1807
+ Locations :: All ( _) => None ,
1808
+ Locations :: Single ( loc) => {
1809
+ self . closure_bounds_mapping [ & loc] . get ( & ( constraint. sup , constraint. sub ) ) . copied ( )
1814
1810
}
1815
- Locations :: Single ( loc) => loc,
1816
- } ;
1817
-
1818
- let opt_span_category =
1819
- self . closure_bounds_mapping [ & loc] . get ( & ( constraint. sup , constraint. sub ) ) ;
1820
- opt_span_category
1821
- . map ( |& ( category, span) | BlameConstraint {
1822
- category,
1823
- from_closure : true ,
1824
- cause : ObligationCause :: dummy_with_span ( span) ,
1825
- variance_info : constraint. variance_info ,
1826
- } )
1827
- . unwrap_or ( BlameConstraint {
1828
- category : constraint. category ,
1829
- from_closure : false ,
1830
- cause : ObligationCause :: dummy_with_span ( constraint. span ) ,
1831
- variance_info : constraint. variance_info ,
1832
- } )
1811
+ }
1833
1812
}
1834
1813
1835
1814
/// Finds a good `ObligationCause` to blame for the fact that `fr1` outlives `fr2`.
@@ -2072,19 +2051,28 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2072
2051
let mut categorized_path: Vec < BlameConstraint < ' tcx > > = path
2073
2052
. iter ( )
2074
2053
. map ( |constraint| {
2075
- if constraint. category == ConstraintCategory :: ClosureBounds {
2076
- self . retrieve_closure_constraint_info ( & constraint)
2077
- } else {
2078
- BlameConstraint {
2079
- category : constraint. category ,
2080
- from_closure : false ,
2081
- cause : ObligationCause :: new (
2082
- constraint. span ,
2083
- CRATE_HIR_ID ,
2084
- cause_code. clone ( ) ,
2085
- ) ,
2086
- variance_info : constraint. variance_info ,
2087
- }
2054
+ let ( category, span, from_closure, cause_code) =
2055
+ if constraint. category == ConstraintCategory :: ClosureBounds {
2056
+ if let Some ( ( category, span) ) =
2057
+ self . retrieve_closure_constraint_info ( * constraint)
2058
+ {
2059
+ ( category, span, true , ObligationCauseCode :: MiscObligation )
2060
+ } else {
2061
+ (
2062
+ constraint. category ,
2063
+ constraint. span ,
2064
+ false ,
2065
+ ObligationCauseCode :: MiscObligation ,
2066
+ )
2067
+ }
2068
+ } else {
2069
+ ( constraint. category , constraint. span , false , cause_code. clone ( ) )
2070
+ } ;
2071
+ BlameConstraint {
2072
+ category,
2073
+ from_closure,
2074
+ cause : ObligationCause :: new ( span, CRATE_HIR_ID , cause_code) ,
2075
+ variance_info : constraint. variance_info ,
2088
2076
}
2089
2077
} )
2090
2078
. collect ( ) ;
0 commit comments