@@ -9,7 +9,6 @@ use rustc::mir::{
99 ConstraintCategory , Local , Location ,
1010} ;
1111use rustc:: ty:: { self , subst:: SubstsRef , RegionVid , Ty , TyCtxt , TypeFoldable } ;
12- use rustc_errors:: DiagnosticBuilder ;
1312use rustc_data_structures:: binary_search_util;
1413use rustc_index:: bit_set:: BitSet ;
1514use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
@@ -435,7 +434,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
435434 }
436435
437436 /// 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 < ' _ > ) {
439438 self . universal_regions . annotate ( tcx, err)
440439 }
441440
@@ -507,18 +506,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
507506 // constraints were too strong, and if so, emit or propagate those errors.
508507 if infcx. tcx . sess . opts . debugging_opts . polonius {
509508 self . check_polonius_subset_errors (
510- infcx,
511509 body,
512- mir_def_id,
513510 outlives_requirements. as_mut ( ) ,
514511 & mut errors_buffer,
515512 polonius_output. expect ( "Polonius output is unavailable despite `-Z polonius`" ) ,
516513 ) ;
517514 } else {
518515 self . check_universal_regions (
519- infcx,
520516 body,
521- mir_def_id,
522517 outlives_requirements. as_mut ( ) ,
523518 & mut errors_buffer,
524519 ) ;
@@ -1291,9 +1286,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12911286 /// report them as errors.
12921287 fn check_universal_regions (
12931288 & self ,
1294- infcx : & InferCtxt < ' _ , ' tcx > ,
12951289 body : & Body < ' tcx > ,
1296- mir_def_id : DefId ,
12971290 mut propagated_outlives_requirements : Option < & mut Vec < ClosureOutlivesRequirement < ' tcx > > > ,
12981291 errors_buffer : & mut RegionErrors < ' tcx > ,
12991292 ) {
@@ -1312,7 +1305,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
13121305 }
13131306
13141307 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 ) ;
13161309 }
13171310
13181311 NLLRegionVariableOrigin :: Existential { .. } => {
@@ -1345,9 +1338,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
13451338 /// report them as errors.
13461339 fn check_polonius_subset_errors (
13471340 & self ,
1348- infcx : & InferCtxt < ' _ , ' tcx > ,
13491341 body : & Body < ' tcx > ,
1350- mir_def_id : DefId ,
13511342 mut propagated_outlives_requirements : Option < & mut Vec < ClosureOutlivesRequirement < ' tcx > > > ,
13521343 errors_buffer : & mut RegionErrors < ' tcx > ,
13531344 polonius_output : Rc < PoloniusOutput > ,
@@ -1413,7 +1404,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
14131404 }
14141405
14151406 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 ) ;
14171408 }
14181409
14191410 NLLRegionVariableOrigin :: Existential { .. } => {
@@ -1573,11 +1564,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
15731564
15741565 fn check_bound_universal_region (
15751566 & self ,
1576- infcx : & InferCtxt < ' _ , ' tcx > ,
1577- body : & Body < ' tcx > ,
1578- _mir_def_id : DefId ,
15791567 longer_fr : RegionVid ,
15801568 placeholder : ty:: PlaceholderRegion ,
1569+ errors_buffer : & mut RegionErrors < ' tcx > ,
15811570 ) {
15821571 debug ! ( "check_bound_universal_region(fr={:?}, placeholder={:?})" , longer_fr, placeholder, ) ;
15831572
@@ -1614,18 +1603,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
16141603 . unwrap ( ) ,
16151604 } ;
16161605
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+ } ) ;
16291611 }
16301612
16311613 fn check_member_constraints (
0 commit comments