@@ -9,7 +9,6 @@ use rustc::mir::{
9
9
ConstraintCategory , Local , Location ,
10
10
} ;
11
11
use rustc:: ty:: { self , subst:: SubstsRef , RegionVid , Ty , TyCtxt , TypeFoldable } ;
12
- use rustc_errors:: DiagnosticBuilder ;
13
12
use rustc_data_structures:: binary_search_util;
14
13
use rustc_index:: bit_set:: BitSet ;
15
14
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
@@ -435,7 +434,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
435
434
}
436
435
437
436
/// Adds annotations for `#[rustc_regions]`; see `UniversalRegions::annotate`.
438
- crate fn annotate ( & self , tcx : TyCtxt < ' tcx > , err : & mut DiagnosticBuilder < ' _ > ) {
437
+ crate fn annotate ( & self , tcx : TyCtxt < ' tcx > , err : & mut rustc_errors :: DiagnosticBuilder < ' _ > ) {
439
438
self . universal_regions . annotate ( tcx, err)
440
439
}
441
440
@@ -507,18 +506,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
507
506
// constraints were too strong, and if so, emit or propagate those errors.
508
507
if infcx. tcx . sess . opts . debugging_opts . polonius {
509
508
self . check_polonius_subset_errors (
510
- infcx,
511
509
body,
512
- mir_def_id,
513
510
outlives_requirements. as_mut ( ) ,
514
511
& mut errors_buffer,
515
512
polonius_output. expect ( "Polonius output is unavailable despite `-Z polonius`" ) ,
516
513
) ;
517
514
} else {
518
515
self . check_universal_regions (
519
- infcx,
520
516
body,
521
- mir_def_id,
522
517
outlives_requirements. as_mut ( ) ,
523
518
& mut errors_buffer,
524
519
) ;
@@ -1291,9 +1286,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1291
1286
/// report them as errors.
1292
1287
fn check_universal_regions (
1293
1288
& self ,
1294
- infcx : & InferCtxt < ' _ , ' tcx > ,
1295
1289
body : & Body < ' tcx > ,
1296
- mir_def_id : DefId ,
1297
1290
mut propagated_outlives_requirements : Option < & mut Vec < ClosureOutlivesRequirement < ' tcx > > > ,
1298
1291
errors_buffer : & mut RegionErrors < ' tcx > ,
1299
1292
) {
@@ -1312,7 +1305,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1312
1305
}
1313
1306
1314
1307
NLLRegionVariableOrigin :: Placeholder ( placeholder) => {
1315
- self . check_bound_universal_region ( infcx , body , mir_def_id , fr, placeholder) ;
1308
+ self . check_bound_universal_region ( fr, placeholder, errors_buffer ) ;
1316
1309
}
1317
1310
1318
1311
NLLRegionVariableOrigin :: Existential { .. } => {
@@ -1345,9 +1338,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1345
1338
/// report them as errors.
1346
1339
fn check_polonius_subset_errors (
1347
1340
& self ,
1348
- infcx : & InferCtxt < ' _ , ' tcx > ,
1349
1341
body : & Body < ' tcx > ,
1350
- mir_def_id : DefId ,
1351
1342
mut propagated_outlives_requirements : Option < & mut Vec < ClosureOutlivesRequirement < ' tcx > > > ,
1352
1343
errors_buffer : & mut RegionErrors < ' tcx > ,
1353
1344
polonius_output : Rc < PoloniusOutput > ,
@@ -1413,7 +1404,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1413
1404
}
1414
1405
1415
1406
NLLRegionVariableOrigin :: Placeholder ( placeholder) => {
1416
- self . check_bound_universal_region ( infcx , body , mir_def_id , fr, placeholder) ;
1407
+ self . check_bound_universal_region ( fr, placeholder, errors_buffer ) ;
1417
1408
}
1418
1409
1419
1410
NLLRegionVariableOrigin :: Existential { .. } => {
@@ -1573,11 +1564,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1573
1564
1574
1565
fn check_bound_universal_region (
1575
1566
& self ,
1576
- infcx : & InferCtxt < ' _ , ' tcx > ,
1577
- body : & Body < ' tcx > ,
1578
- _mir_def_id : DefId ,
1579
1567
longer_fr : RegionVid ,
1580
1568
placeholder : ty:: PlaceholderRegion ,
1569
+ errors_buffer : & mut RegionErrors < ' tcx > ,
1581
1570
) {
1582
1571
debug ! ( "check_bound_universal_region(fr={:?}, placeholder={:?})" , longer_fr, placeholder, ) ;
1583
1572
@@ -1614,18 +1603,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1614
1603
. unwrap ( ) ,
1615
1604
} ;
1616
1605
1617
- // Find the code to blame for the fact that `longer_fr` outlives `error_fr`.
1618
- let ( _, span) = self . find_outlives_blame_span (
1619
- body, longer_fr, NLLRegionVariableOrigin :: Placeholder ( placeholder) , error_region
1620
- ) ;
1621
-
1622
- // Obviously, this error message is far from satisfactory.
1623
- // At present, though, it only appears in unit tests --
1624
- // the AST-based checker uses a more conservative check,
1625
- // so to even see this error, one must pass in a special
1626
- // flag.
1627
- let mut diag = infcx. tcx . sess . struct_span_err ( span, "higher-ranked subtype error" ) ;
1628
- diag. emit ( ) ;
1606
+ errors_buffer. push ( RegionErrorKind :: BoundUniversalRegionError {
1607
+ longer_fr,
1608
+ error_region,
1609
+ fr_origin : NLLRegionVariableOrigin :: Placeholder ( placeholder) ,
1610
+ } ) ;
1629
1611
}
1630
1612
1631
1613
fn check_member_constraints (
0 commit comments