@@ -13,13 +13,13 @@ use rustc::hir::def_id::DefId;
13
13
use rustc:: infer:: InferCtxt ;
14
14
use rustc:: mir:: { Local , Body } ;
15
15
use rustc:: ty:: subst:: { SubstsRef , GenericArgKind } ;
16
- use rustc:: ty:: { self , RegionKind , RegionVid , Ty , TyCtxt } ;
16
+ use rustc:: ty:: { self , RegionVid , Ty , TyCtxt } ;
17
17
use rustc:: ty:: print:: RegionHighlightMode ;
18
18
use rustc_index:: vec:: IndexVec ;
19
19
use rustc_errors:: DiagnosticBuilder ;
20
20
use syntax:: symbol:: kw;
21
21
use rustc_data_structures:: fx:: FxHashMap ;
22
- use syntax_pos:: { Span , symbol:: Symbol } ;
22
+ use syntax_pos:: { Span , symbol:: Symbol , DUMMY_SP } ;
23
23
24
24
/// A name for a particular region used in emitting diagnostics. This name could be a generated
25
25
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
@@ -275,7 +275,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
275
275
match error_region {
276
276
ty:: ReEarlyBound ( ebr) => {
277
277
if ebr. has_name ( ) {
278
- let span = self . get_named_span ( tcx , error_region , ebr. name ) ;
278
+ let span = tcx . hir ( ) . span_if_local ( ebr. def_id ) . unwrap_or ( DUMMY_SP ) ;
279
279
Some ( RegionName {
280
280
name : ebr. name ,
281
281
source : RegionNameSource :: NamedEarlyBoundRegion ( span) ,
@@ -291,9 +291,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
291
291
} ) ,
292
292
293
293
ty:: ReFree ( free_region) => match free_region. bound_region {
294
- ty:: BoundRegion :: BrNamed ( _ , name) => {
294
+ ty:: BoundRegion :: BrNamed ( region_def_id , name) => {
295
295
// Get the span to point to, even if we don't use the name.
296
- let span = self . get_named_span ( tcx , error_region , name ) ;
296
+ let span = tcx . hir ( ) . span_if_local ( region_def_id ) . unwrap_or ( DUMMY_SP ) ;
297
297
debug ! ( "bound region named: {:?}, is_named: {:?}" ,
298
298
name, free_region. bound_region. is_named( ) ) ;
299
299
@@ -373,40 +373,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
373
373
}
374
374
}
375
375
376
- /// Gets a span of a named region to provide context for error messages that
377
- /// mention that span, for example:
378
- ///
379
- /// ```
380
- /// |
381
- /// | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
382
- /// | -- -- lifetime `'b` defined here
383
- /// | |
384
- /// | lifetime `'a` defined here
385
- /// |
386
- /// | with_signature(cell, t, |cell, t| require(cell, t));
387
- /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must
388
- /// | outlive `'a`
389
- /// ```
390
- fn get_named_span (
391
- & self ,
392
- tcx : TyCtxt < ' tcx > ,
393
- error_region : & RegionKind ,
394
- name : Symbol ,
395
- ) -> Span {
396
- let scope = error_region. free_region_binding_scope ( tcx) ;
397
- let node = tcx. hir ( ) . as_local_hir_id ( scope) . unwrap_or ( hir:: DUMMY_HIR_ID ) ;
398
-
399
- let span = tcx. sess . source_map ( ) . def_span ( tcx. hir ( ) . span ( node) ) ;
400
- if let Some ( param) = tcx. hir ( )
401
- . get_generics ( scope)
402
- . and_then ( |generics| generics. get_named ( name) )
403
- {
404
- param. span
405
- } else {
406
- span
407
- }
408
- }
409
-
410
376
/// Finds an argument that contains `fr` and label it with a fully
411
377
/// elaborated type, returning something like `'1`. Result looks
412
378
/// like:
0 commit comments