@@ -151,11 +151,10 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
151151) -> ( String , Span ) {
152152 let sm = tcx. sess . source_map ( ) ;
153153
154- let scope = region. free_region_binding_scope ( tcx) ;
155- let node = tcx. hir ( ) . local_def_id_to_hir_id ( scope. expect_local ( ) ) ;
154+ let scope = region. free_region_binding_scope ( tcx) . expect_local ( ) ;
156155 match * region {
157156 ty:: ReEarlyBound ( ref br) => {
158- let mut sp = sm. guess_head_span ( tcx. hir ( ) . span ( node ) ) ;
157+ let mut sp = sm. guess_head_span ( tcx. def_span ( scope ) ) ;
159158 if let Some ( param) =
160159 tcx. hir ( ) . get_generics ( scope) . and_then ( |generics| generics. get_named ( br. name ) )
161160 {
@@ -166,7 +165,7 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
166165 ty:: ReFree ( ty:: FreeRegion {
167166 bound_region : ty:: BoundRegionKind :: BrNamed ( _, name) , ..
168167 } ) => {
169- let mut sp = sm. guess_head_span ( tcx. hir ( ) . span ( node ) ) ;
168+ let mut sp = sm. guess_head_span ( tcx. def_span ( scope ) ) ;
170169 if let Some ( param) =
171170 tcx. hir ( ) . get_generics ( scope) . and_then ( |generics| generics. get_named ( name) )
172171 {
@@ -181,13 +180,13 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
181180 } else {
182181 (
183182 format ! ( "the anonymous lifetime #{} defined here" , idx + 1 ) ,
184- tcx. hir ( ) . span ( node ) ,
183+ tcx. def_span ( scope ) ,
185184 )
186185 }
187186 }
188187 _ => (
189188 format ! ( "the lifetime `{}` as defined here" , region) ,
190- sm. guess_head_span ( tcx. hir ( ) . span ( node ) ) ,
189+ sm. guess_head_span ( tcx. def_span ( scope ) ) ,
191190 ) ,
192191 } ,
193192 _ => bug ! ( ) ,
@@ -1759,8 +1758,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17591758 if let Some ( ValuePairs :: PolyTraitRefs ( exp_found) ) = values {
17601759 if let ty:: Closure ( def_id, _) = exp_found. expected . skip_binder ( ) . self_ty ( ) . kind ( ) {
17611760 if let Some ( def_id) = def_id. as_local ( ) {
1762- let hir_id = self . tcx . hir ( ) . local_def_id_to_hir_id ( def_id) ;
1763- let span = self . tcx . hir ( ) . span ( hir_id) ;
1761+ let span = self . tcx . def_span ( def_id) ;
17641762 diag. span_note ( span, "this closure does not fulfill the lifetime requirements" ) ;
17651763 }
17661764 }
@@ -2245,7 +2243,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
22452243 if let Node :: GenericParam ( param) = hir. get ( id) {
22462244 has_bounds = !param. bounds . is_empty ( ) ;
22472245 }
2248- let sp = hir . span ( id ) ;
2246+ let sp = self . tcx . def_span ( def_id ) ;
22492247 // `sp` only covers `T`, change it so that it covers
22502248 // `T:` when appropriate
22512249 let is_impl_trait = bound_kind. to_string ( ) . starts_with ( "impl " ) ;
@@ -2291,12 +2289,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
22912289 . as_ref ( )
22922290 . and_then ( |( _, g, _) | g. params . first ( ) )
22932291 . and_then ( |param| param. def_id . as_local ( ) )
2294- . map ( |def_id| {
2295- (
2296- hir. span ( hir. local_def_id_to_hir_id ( def_id) ) . shrink_to_lo ( ) ,
2297- format ! ( "{}, " , new_lt) ,
2298- )
2299- } ) ;
2292+ . map ( |def_id| ( self . tcx . def_span ( def_id) . shrink_to_lo ( ) , format ! ( "{}, " , new_lt) ) ) ;
23002293
23012294 let labeled_user_string = match bound_kind {
23022295 GenericKind :: Param ( ref p) => format ! ( "the parameter type `{}`" , p) ,
0 commit comments