99// except according to those terms.
1010
1111use borrow_check:: nll:: region_infer:: RegionInferenceContext ;
12- use borrow_check:: nll:: ToRegionVid ;
1312use borrow_check:: nll:: universal_regions:: DefiningTy ;
13+ use borrow_check:: nll:: ToRegionVid ;
1414use rustc:: hir;
1515use rustc:: hir:: def_id:: DefId ;
1616use rustc:: infer:: InferCtxt ;
@@ -107,23 +107,23 @@ impl<'tcx> RegionInferenceContext<'tcx> {
107107 } else {
108108 None
109109 }
110- } ,
110+ }
111111
112112 ty:: ReStatic => Some ( keywords:: StaticLifetime . name ( ) . as_interned_str ( ) ) ,
113113
114114 ty:: ReFree ( free_region) => match free_region. bound_region {
115115 ty:: BoundRegion :: BrNamed ( _, name) => {
116116 self . highlight_named_span ( tcx, error_region, & name, diag) ;
117117 Some ( name)
118- } ,
118+ }
119119
120120 ty:: BoundRegion :: BrEnv => {
121121 let mir_node_id = tcx. hir . as_local_node_id ( mir_def_id) . expect ( "non-local mir" ) ;
122122 let def_ty = self . universal_regions . defining_ty ;
123123
124124 if let DefiningTy :: Closure ( def_id, substs) = def_ty {
125- let args_span = if let hir:: ExprKind :: Closure ( _, _, _, span, _)
126- = tcx. hir . expect_expr ( mir_node_id) . node
125+ let args_span = if let hir:: ExprKind :: Closure ( _, _, _, span, _) =
126+ tcx. hir . expect_expr ( mir_node_id) . node
127127 {
128128 span
129129 } else {
@@ -201,16 +201,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
201201 let node = tcx. hir . as_local_node_id ( scope) . unwrap_or ( DUMMY_NODE_ID ) ;
202202
203203 let mut sp = cm. def_span ( tcx. hir . span ( node) ) ;
204- if let Some ( param) = tcx. hir . get_generics ( scope) . and_then ( |generics| {
205- generics. get_named ( name)
206- } ) {
204+ if let Some ( param) = tcx. hir
205+ . get_generics ( scope)
206+ . and_then ( |generics| generics. get_named ( name) )
207+ {
207208 sp = param. span ;
208209 }
209210
210- diag. span_label (
211- sp,
212- format ! ( "lifetime `{}` defined here" , name) ,
213- ) ;
211+ diag. span_label ( sp, format ! ( "lifetime `{}` defined here" , name) ) ;
214212 }
215213
216214 /// Find an argument that contains `fr` and label it with a fully
@@ -248,14 +246,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
248246 return Some ( region_name) ;
249247 }
250248
251- self . give_name_if_we_cannot_match_hir_ty (
252- infcx,
253- mir,
254- fr,
255- arg_ty,
256- counter,
257- diag,
258- )
249+ self . give_name_if_we_cannot_match_hir_ty ( infcx, mir, fr, arg_ty, counter, diag)
259250 }
260251
261252 fn give_name_if_we_can_match_hir_ty_from_argument (
@@ -320,8 +311,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
320311 infcx. extract_type_name ( & argument_ty)
321312 } ) ;
322313
323- debug ! ( "give_name_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}" ,
324- type_name, needle_fr) ;
314+ debug ! (
315+ "give_name_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}" ,
316+ type_name, needle_fr
317+ ) ;
325318 let assigned_region_name = if type_name. find ( & format ! ( "'{}" , counter) ) . is_some ( ) {
326319 // Only add a label if we can confirm that a region was labelled.
327320 let argument_index = self . get_argument_index_for_region ( infcx. tcx , needle_fr) ?;
@@ -553,13 +546,16 @@ impl<'tcx> RegionInferenceContext<'tcx> {
553546 diag : & mut DiagnosticBuilder < ' _ > ,
554547 ) -> Option < InternedString > {
555548 let upvar_index = self . get_upvar_index_for_region ( tcx, fr) ?;
556- let ( upvar_name, upvar_span) = self . get_upvar_name_and_span_for_region ( tcx , mir ,
557- upvar_index) ;
549+ let ( upvar_name, upvar_span) =
550+ self . get_upvar_name_and_span_for_region ( tcx , mir , upvar_index) ;
558551 let region_name = self . synthesize_region_name ( counter) ;
559552
560553 diag. span_label (
561554 upvar_span,
562- format ! ( "lifetime `{}` appears in the type of `{}`" , region_name, upvar_name) ,
555+ format ! (
556+ "lifetime `{}` appears in the type of `{}`" ,
557+ region_name, upvar_name
558+ ) ,
563559 ) ;
564560
565561 Some ( region_name)
@@ -585,27 +581,33 @@ impl<'tcx> RegionInferenceContext<'tcx> {
585581 "give_name_if_anonymous_region_appears_in_output: return_ty = {:?}" ,
586582 return_ty
587583 ) ;
588- if !infcx. tcx . any_free_region_meets ( & return_ty, |r| r. to_region_vid ( ) == fr) {
584+ if !infcx
585+ . tcx
586+ . any_free_region_meets ( & return_ty, |r| r. to_region_vid ( ) == fr)
587+ {
589588 return None ;
590589 }
591590
592- let type_name = with_highlight_region ( fr, * counter, || {
593- infcx. extract_type_name ( & return_ty)
594- } ) ;
591+ let type_name = with_highlight_region ( fr, * counter, || infcx. extract_type_name ( & return_ty) ) ;
595592
596593 let mir_node_id = tcx. hir . as_local_node_id ( mir_def_id) . expect ( "non-local mir" ) ;
597594
598- let ( return_span, mir_description) = if let hir:: ExprKind :: Closure ( _, _, _, span, gen_move)
599- = tcx. hir . expect_expr ( mir_node_id) . node
600- {
601- (
602- tcx. sess . source_map ( ) . end_point ( span) ,
603- if gen_move. is_some ( ) { " of generator" } else { " of closure" }
604- )
605- } else {
606- // unreachable?
607- ( mir. span , "" )
608- } ;
595+ let ( return_span, mir_description) =
596+ if let hir:: ExprKind :: Closure ( _, _, _, span, gen_move) =
597+ tcx. hir . expect_expr ( mir_node_id) . node
598+ {
599+ (
600+ tcx. sess . source_map ( ) . end_point ( span) ,
601+ if gen_move. is_some ( ) {
602+ " of generator"
603+ } else {
604+ " of closure"
605+ } ,
606+ )
607+ } else {
608+ // unreachable?
609+ ( mir. span , "" )
610+ } ;
609611
610612 diag. span_label (
611613 return_span,
0 commit comments