@@ -64,7 +64,7 @@ use std::fmt;
64
64
use hir;
65
65
use hir:: map as hir_map;
66
66
use hir:: def_id:: DefId ;
67
- use middle:: region;
67
+ use middle:: region:: { self , RegionMaps } ;
68
68
use traits:: { ObligationCause , ObligationCauseCode } ;
69
69
use ty:: { self , Region , TyCtxt , TypeFoldable } ;
70
70
use ty:: error:: TypeError ;
@@ -83,6 +83,7 @@ mod anon_anon_conflict;
83
83
84
84
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
85
85
pub fn note_and_explain_region ( self ,
86
+ region_maps : & RegionMaps ,
86
87
err : & mut DiagnosticBuilder ,
87
88
prefix : & str ,
88
89
region : ty:: Region < ' tcx > ,
@@ -130,13 +131,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
130
131
format ! ( "{}unknown scope: {:?}{}. Please report a bug." ,
131
132
prefix, scope, suffix)
132
133
} ;
133
- let span = match scope. span ( & self . hir ) {
134
- Some ( s) => s,
135
- None => {
136
- err. note ( & unknown_scope ( ) ) ;
137
- return ;
138
- }
139
- } ;
134
+ let span = scope. span ( self , region_maps) ;
140
135
let tag = match self . hir . find ( scope. node_id ( ) ) {
141
136
Some ( hir_map:: NodeBlock ( _) ) => "block" ,
142
137
Some ( hir_map:: NodeExpr ( expr) ) => match expr. node {
@@ -260,8 +255,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
260
255
}
261
256
262
257
impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
263
-
264
- pub fn report_region_errors ( & self , errors : & Vec < RegionResolutionError < ' tcx > > ) {
258
+ pub fn report_region_errors ( & self ,
259
+ region_maps : & RegionMaps ,
260
+ errors : & Vec < RegionResolutionError < ' tcx > > ) {
265
261
debug ! ( "report_region_errors(): {} errors to start" , errors. len( ) ) ;
266
262
267
263
// try to pre-process the errors, which will group some of them
@@ -285,16 +281,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
285
281
// the error. If all of these fails, we fall back to a rather
286
282
// general bit of code that displays the error information
287
283
ConcreteFailure ( origin, sub, sup) => {
288
-
289
- self . report_concrete_failure ( origin, sub, sup) . emit ( ) ;
284
+ self . report_concrete_failure ( region_maps, origin, sub, sup) . emit ( ) ;
290
285
}
291
286
292
287
GenericBoundFailure ( kind, param_ty, sub) => {
293
- self . report_generic_bound_failure ( kind, param_ty, sub) ;
288
+ self . report_generic_bound_failure ( region_maps , kind, param_ty, sub) ;
294
289
}
295
290
296
291
SubSupConflict ( var_origin, sub_origin, sub_r, sup_origin, sup_r) => {
297
- self . report_sub_sup_conflict ( var_origin,
292
+ self . report_sub_sup_conflict ( region_maps,
293
+ var_origin,
298
294
sub_origin,
299
295
sub_r,
300
296
sup_origin,
@@ -773,6 +769,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
773
769
}
774
770
775
771
fn report_generic_bound_failure ( & self ,
772
+ region_maps : & RegionMaps ,
776
773
origin : SubregionOrigin < ' tcx > ,
777
774
bound_kind : GenericKind < ' tcx > ,
778
775
sub : Region < ' tcx > )
@@ -840,6 +837,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
840
837
err. help ( & format ! ( "consider adding an explicit lifetime bound for `{}`" ,
841
838
bound_kind) ) ;
842
839
self . tcx . note_and_explain_region (
840
+ region_maps,
843
841
& mut err,
844
842
& format ! ( "{} must be valid for " , labeled_user_string) ,
845
843
sub,
@@ -853,21 +851,22 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
853
851
}
854
852
855
853
fn report_sub_sup_conflict ( & self ,
854
+ region_maps : & RegionMaps ,
856
855
var_origin : RegionVariableOrigin ,
857
856
sub_origin : SubregionOrigin < ' tcx > ,
858
857
sub_region : Region < ' tcx > ,
859
858
sup_origin : SubregionOrigin < ' tcx > ,
860
859
sup_region : Region < ' tcx > ) {
861
860
let mut err = self . report_inference_failure ( var_origin) ;
862
861
863
- self . tcx . note_and_explain_region ( & mut err,
862
+ self . tcx . note_and_explain_region ( region_maps , & mut err,
864
863
"first, the lifetime cannot outlive " ,
865
864
sup_region,
866
865
"..." ) ;
867
866
868
867
self . note_region_origin ( & mut err, & sup_origin) ;
869
868
870
- self . tcx . note_and_explain_region ( & mut err,
869
+ self . tcx . note_and_explain_region ( region_maps , & mut err,
871
870
"but, the lifetime must be valid for " ,
872
871
sub_region,
873
872
"..." ) ;
0 commit comments