@@ -6,10 +6,9 @@ use rustc_data_structures::frozen::Frozen;
6
6
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
7
7
use rustc_data_structures:: graph:: scc:: Sccs ;
8
8
use rustc_errors:: Diagnostic ;
9
- use rustc_hir:: def_id:: { DefId , CRATE_DEF_ID } ;
9
+ use rustc_hir:: def_id:: CRATE_DEF_ID ;
10
10
use rustc_hir:: CRATE_HIR_ID ;
11
11
use rustc_index:: vec:: IndexVec ;
12
- use rustc_infer:: infer:: canonical:: QueryOutlivesConstraint ;
13
12
use rustc_infer:: infer:: outlives:: test_type_match;
14
13
use rustc_infer:: infer:: region_constraints:: { GenericKind , VarInfos , VerifyBound , VerifyIfEq } ;
15
14
use rustc_infer:: infer:: { InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin } ;
@@ -19,9 +18,7 @@ use rustc_middle::mir::{
19
18
} ;
20
19
use rustc_middle:: traits:: ObligationCause ;
21
20
use rustc_middle:: traits:: ObligationCauseCode ;
22
- use rustc_middle:: ty:: {
23
- self , subst:: SubstsRef , RegionVid , Ty , TyCtxt , TypeFoldable , TypeVisitable ,
24
- } ;
21
+ use rustc_middle:: ty:: { self , RegionVid , Ty , TyCtxt , TypeFoldable , TypeVisitable } ;
25
22
use rustc_span:: Span ;
26
23
27
24
use crate :: {
@@ -89,10 +86,6 @@ pub struct RegionInferenceContext<'tcx> {
89
86
/// `member_region_scc`.
90
87
member_constraints_applied : Vec < AppliedMemberConstraint > ,
91
88
92
- /// Map closure bounds to a `Span` that should be used for error reporting.
93
- closure_bounds_mapping :
94
- FxHashMap < Location , FxHashMap < ( RegionVid , RegionVid ) , ( ConstraintCategory < ' tcx > , Span ) > > ,
95
-
96
89
/// Map universe indexes to information on why we created it.
97
90
universe_causes : FxHashMap < ty:: UniverseIndex , UniverseInfo < ' tcx > > ,
98
91
@@ -265,10 +258,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
265
258
universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
266
259
outlives_constraints : OutlivesConstraintSet < ' tcx > ,
267
260
member_constraints_in : MemberConstraintSet < ' tcx , RegionVid > ,
268
- closure_bounds_mapping : FxHashMap <
269
- Location ,
270
- FxHashMap < ( RegionVid , RegionVid ) , ( ConstraintCategory < ' tcx > , Span ) > ,
271
- > ,
272
261
universe_causes : FxHashMap < ty:: UniverseIndex , UniverseInfo < ' tcx > > ,
273
262
type_tests : Vec < TypeTest < ' tcx > > ,
274
263
liveness_constraints : LivenessValues < RegionVid > ,
@@ -310,7 +299,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
310
299
rev_scc_graph : None ,
311
300
member_constraints,
312
301
member_constraints_applied : Vec :: new ( ) ,
313
- closure_bounds_mapping,
314
302
universe_causes,
315
303
scc_universes,
316
304
scc_representatives,
@@ -1804,18 +1792,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1804
1792
}
1805
1793
}
1806
1794
1807
- pub ( crate ) fn retrieve_closure_constraint_info (
1808
- & self ,
1809
- constraint : OutlivesConstraint < ' tcx > ,
1810
- ) -> Option < ( ConstraintCategory < ' tcx > , Span ) > {
1811
- match constraint. locations {
1812
- Locations :: All ( _) => None ,
1813
- Locations :: Single ( loc) => {
1814
- self . closure_bounds_mapping [ & loc] . get ( & ( constraint. sup , constraint. sub ) ) . copied ( )
1815
- }
1816
- }
1817
- }
1818
-
1819
1795
/// Finds a good `ObligationCause` to blame for the fact that `fr1` outlives `fr2`.
1820
1796
pub ( crate ) fn find_outlives_blame_span (
1821
1797
& self ,
@@ -1921,6 +1897,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1921
1897
span : p_c. definition_span ,
1922
1898
category : ConstraintCategory :: OpaqueType ,
1923
1899
variance_info : ty:: VarianceDiagInfo :: default ( ) ,
1900
+ from_closure : false ,
1924
1901
} ;
1925
1902
handle_constraint ( constraint) ;
1926
1903
}
@@ -2066,31 +2043,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2066
2043
// Classify each of the constraints along the path.
2067
2044
let mut categorized_path: Vec < BlameConstraint < ' tcx > > = path
2068
2045
. iter ( )
2069
- . map ( |constraint| {
2070
- let ( category, span, from_closure, cause_code) =
2071
- if constraint. category == ConstraintCategory :: ClosureBounds {
2072
- if let Some ( ( category, span) ) =
2073
- self . retrieve_closure_constraint_info ( * constraint)
2074
- {
2075
- ( category, span, true , ObligationCauseCode :: MiscObligation )
2076
- } else {
2077
- (
2078
- constraint. category ,
2079
- constraint. span ,
2080
- false ,
2081
- ObligationCauseCode :: MiscObligation ,
2082
- )
2083
- }
2084
- } else {
2085
- ( constraint. category , constraint. span , false , cause_code. clone ( ) )
2086
- } ;
2087
- BlameConstraint {
2088
- category,
2089
- from_closure,
2090
- cause : ObligationCause :: new ( span, CRATE_HIR_ID , cause_code) ,
2091
- variance_info : constraint. variance_info ,
2092
- outlives_constraint : * constraint,
2093
- }
2046
+ . map ( |constraint| BlameConstraint {
2047
+ category : constraint. category ,
2048
+ from_closure : constraint. from_closure ,
2049
+ cause : ObligationCause :: new ( constraint. span , CRATE_HIR_ID , cause_code. clone ( ) ) ,
2050
+ variance_info : constraint. variance_info ,
2051
+ outlives_constraint : * constraint,
2094
2052
} )
2095
2053
. collect ( ) ;
2096
2054
debug ! ( "categorized_path={:#?}" , categorized_path) ;
@@ -2274,92 +2232,6 @@ impl<'tcx> RegionDefinition<'tcx> {
2274
2232
}
2275
2233
}
2276
2234
2277
- pub trait ClosureRegionRequirementsExt < ' tcx > {
2278
- fn apply_requirements (
2279
- & self ,
2280
- tcx : TyCtxt < ' tcx > ,
2281
- closure_def_id : DefId ,
2282
- closure_substs : SubstsRef < ' tcx > ,
2283
- ) -> Vec < QueryOutlivesConstraint < ' tcx > > ;
2284
- }
2285
-
2286
- impl < ' tcx > ClosureRegionRequirementsExt < ' tcx > for ClosureRegionRequirements < ' tcx > {
2287
- /// Given an instance T of the closure type, this method
2288
- /// instantiates the "extra" requirements that we computed for the
2289
- /// closure into the inference context. This has the effect of
2290
- /// adding new outlives obligations to existing variables.
2291
- ///
2292
- /// As described on `ClosureRegionRequirements`, the extra
2293
- /// requirements are expressed in terms of regionvids that index
2294
- /// into the free regions that appear on the closure type. So, to
2295
- /// do this, we first copy those regions out from the type T into
2296
- /// a vector. Then we can just index into that vector to extract
2297
- /// out the corresponding region from T and apply the
2298
- /// requirements.
2299
- fn apply_requirements (
2300
- & self ,
2301
- tcx : TyCtxt < ' tcx > ,
2302
- closure_def_id : DefId ,
2303
- closure_substs : SubstsRef < ' tcx > ,
2304
- ) -> Vec < QueryOutlivesConstraint < ' tcx > > {
2305
- debug ! (
2306
- "apply_requirements(closure_def_id={:?}, closure_substs={:?})" ,
2307
- closure_def_id, closure_substs
2308
- ) ;
2309
-
2310
- // Extract the values of the free regions in `closure_substs`
2311
- // into a vector. These are the regions that we will be
2312
- // relating to one another.
2313
- let closure_mapping = & UniversalRegions :: closure_mapping (
2314
- tcx,
2315
- closure_substs,
2316
- self . num_external_vids ,
2317
- closure_def_id. expect_local ( ) ,
2318
- ) ;
2319
- debug ! ( "apply_requirements: closure_mapping={:?}" , closure_mapping) ;
2320
-
2321
- // Create the predicates.
2322
- self . outlives_requirements
2323
- . iter ( )
2324
- . map ( |outlives_requirement| {
2325
- let outlived_region = closure_mapping[ outlives_requirement. outlived_free_region ] ;
2326
-
2327
- match outlives_requirement. subject {
2328
- ClosureOutlivesSubject :: Region ( region) => {
2329
- let region = closure_mapping[ region] ;
2330
- debug ! (
2331
- "apply_requirements: region={:?} \
2332
- outlived_region={:?} \
2333
- outlives_requirement={:?}",
2334
- region, outlived_region, outlives_requirement,
2335
- ) ;
2336
- (
2337
- ty:: Binder :: dummy ( ty:: OutlivesPredicate (
2338
- region. into ( ) ,
2339
- outlived_region,
2340
- ) ) ,
2341
- ConstraintCategory :: BoringNoLocation ,
2342
- )
2343
- }
2344
-
2345
- ClosureOutlivesSubject :: Ty ( ty) => {
2346
- debug ! (
2347
- "apply_requirements: ty={:?} \
2348
- outlived_region={:?} \
2349
- outlives_requirement={:?}",
2350
- ty, outlived_region, outlives_requirement,
2351
- ) ;
2352
- (
2353
- ty:: Binder :: dummy ( ty:: OutlivesPredicate ( ty. into ( ) , outlived_region) ) ,
2354
- ConstraintCategory :: BoringNoLocation ,
2355
- )
2356
- }
2357
- }
2358
- } )
2359
- . collect ( )
2360
- }
2361
- }
2362
-
2363
2235
#[ derive( Clone , Debug ) ]
2364
2236
pub struct BlameConstraint < ' tcx > {
2365
2237
pub category : ConstraintCategory < ' tcx > ,
0 commit comments