@@ -87,10 +87,10 @@ struct TopInfo<'tcx> {
87
87
}
88
88
89
89
#[ derive( Copy , Clone ) ]
90
- struct PatInfo < ' a , ' tcx > {
90
+ struct PatInfo < ' tcx > {
91
91
binding_mode : ByRef ,
92
92
max_ref_mutbl : MutblCap ,
93
- top_info : & ' a TopInfo < ' tcx > ,
93
+ top_info : TopInfo < ' tcx > ,
94
94
decl_origin : Option < DeclOrigin < ' tcx > > ,
95
95
96
96
/// The depth of current pattern
@@ -303,11 +303,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
303
303
origin_expr : Option < & ' tcx hir:: Expr < ' tcx > > ,
304
304
decl_origin : Option < DeclOrigin < ' tcx > > ,
305
305
) {
306
- let info = TopInfo { expected, origin_expr, span, hir_id : pat. hir_id } ;
306
+ let top_info = TopInfo { expected, origin_expr, span, hir_id : pat. hir_id } ;
307
307
let pat_info = PatInfo {
308
308
binding_mode : ByRef :: No ,
309
309
max_ref_mutbl : MutblCap :: Mut ,
310
- top_info : & info ,
310
+ top_info,
311
311
decl_origin,
312
312
current_depth : 0 ,
313
313
} ;
@@ -320,7 +320,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
320
320
/// Outside of this module, `check_pat_top` should always be used.
321
321
/// Conversely, inside this module, `check_pat_top` should never be used.
322
322
#[ instrument( level = "debug" , skip( self , pat_info) ) ]
323
- fn check_pat ( & self , pat : & ' tcx Pat < ' tcx > , expected : Ty < ' tcx > , pat_info : PatInfo < ' _ , ' tcx > ) {
323
+ fn check_pat ( & self , pat : & ' tcx Pat < ' tcx > , expected : Ty < ' tcx > , pat_info : PatInfo < ' tcx > ) {
324
324
let PatInfo { binding_mode, max_ref_mutbl, top_info : ti, current_depth, .. } = pat_info;
325
325
326
326
let path_res = match pat. kind {
@@ -339,6 +339,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
339
339
decl_origin : pat_info. decl_origin ,
340
340
current_depth : current_depth + 1 ,
341
341
} ;
342
+ let ti = & pat_info. top_info ;
342
343
343
344
let ty = match pat. kind {
344
345
PatKind :: Wild | PatKind :: Err ( _) => expected,
@@ -818,7 +819,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
818
819
ident : Ident ,
819
820
sub : Option < & ' tcx Pat < ' tcx > > ,
820
821
expected : Ty < ' tcx > ,
821
- pat_info : PatInfo < ' _ , ' tcx > ,
822
+ pat_info : PatInfo < ' tcx > ,
822
823
) -> Ty < ' tcx > {
823
824
let PatInfo { binding_mode : def_br, top_info : ti, .. } = pat_info;
824
825
@@ -914,12 +915,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
914
915
} ;
915
916
916
917
// We have a concrete type for the local, so we do not need to taint it and hide follow up errors *using* the local.
917
- let _ = self . demand_eqtype_pat ( pat. span , eq_ty, local_ty, ti) ;
918
+ let _ = self . demand_eqtype_pat ( pat. span , eq_ty, local_ty, & ti) ;
918
919
919
920
// If there are multiple arms, make sure they all agree on
920
921
// what the type of the binding `x` ought to be.
921
922
if var_id != pat. hir_id {
922
- self . check_binding_alt_eq_ty ( user_bind_annot, pat. span , var_id, local_ty, ti) ;
923
+ self . check_binding_alt_eq_ty ( user_bind_annot, pat. span , var_id, local_ty, & ti) ;
923
924
}
924
925
925
926
if let Some ( p) = sub {
@@ -1149,7 +1150,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1149
1150
fields : & ' tcx [ hir:: PatField < ' tcx > ] ,
1150
1151
has_rest_pat : bool ,
1151
1152
expected : Ty < ' tcx > ,
1152
- pat_info : PatInfo < ' _ , ' tcx > ,
1153
+ pat_info : PatInfo < ' tcx > ,
1153
1154
) -> Ty < ' tcx > {
1154
1155
// Resolve the path and check the definition for errors.
1155
1156
let ( variant, pat_ty) = match self . check_struct_path ( qpath, pat. hir_id ) {
@@ -1164,7 +1165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1164
1165
} ;
1165
1166
1166
1167
// Type-check the path.
1167
- let _ = self . demand_eqtype_pat ( pat. span , expected, pat_ty, pat_info. top_info ) ;
1168
+ let _ = self . demand_eqtype_pat ( pat. span , expected, pat_ty, & pat_info. top_info ) ;
1168
1169
1169
1170
// Type-check subpatterns.
1170
1171
match self . check_struct_pat_fields ( pat_ty, pat, variant, fields, has_rest_pat, pat_info) {
@@ -1353,7 +1354,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1353
1354
subpats : & ' tcx [ Pat < ' tcx > ] ,
1354
1355
ddpos : hir:: DotDotPos ,
1355
1356
expected : Ty < ' tcx > ,
1356
- pat_info : PatInfo < ' _ , ' tcx > ,
1357
+ pat_info : PatInfo < ' tcx > ,
1357
1358
) -> Ty < ' tcx > {
1358
1359
let tcx = self . tcx ;
1359
1360
let on_error = |e| {
@@ -1403,7 +1404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1403
1404
let pat_ty = pat_ty. no_bound_vars ( ) . expect ( "expected fn type" ) ;
1404
1405
1405
1406
// Type-check the tuple struct pattern against the expected type.
1406
- let diag = self . demand_eqtype_pat_diag ( pat. span , expected, pat_ty, pat_info. top_info ) ;
1407
+ let diag = self . demand_eqtype_pat_diag ( pat. span , expected, pat_ty, & pat_info. top_info ) ;
1407
1408
let had_err = diag. map_err ( |diag| diag. emit ( ) ) ;
1408
1409
1409
1410
// Type-check subpatterns.
@@ -1610,7 +1611,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1610
1611
elements : & ' tcx [ Pat < ' tcx > ] ,
1611
1612
ddpos : hir:: DotDotPos ,
1612
1613
expected : Ty < ' tcx > ,
1613
- pat_info : PatInfo < ' _ , ' tcx > ,
1614
+ pat_info : PatInfo < ' tcx > ,
1614
1615
) -> Ty < ' tcx > {
1615
1616
let tcx = self . tcx ;
1616
1617
let mut expected_len = elements. len ( ) ;
@@ -1625,7 +1626,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1625
1626
let element_tys_iter = ( 0 ..max_len) . map ( |_| self . next_ty_var ( span) ) ;
1626
1627
let element_tys = tcx. mk_type_list_from_iter ( element_tys_iter) ;
1627
1628
let pat_ty = Ty :: new_tup ( tcx, element_tys) ;
1628
- if let Err ( reported) = self . demand_eqtype_pat ( span, expected, pat_ty, pat_info. top_info ) {
1629
+ if let Err ( reported) = self . demand_eqtype_pat ( span, expected, pat_ty, & pat_info. top_info ) {
1629
1630
// Walk subpatterns with an expected type of `err` in this case to silence
1630
1631
// further errors being emitted when using the bindings. #50333
1631
1632
let element_tys_iter = ( 0 ..max_len) . map ( |_| Ty :: new_error ( tcx, reported) ) ;
@@ -1648,7 +1649,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1648
1649
variant : & ' tcx ty:: VariantDef ,
1649
1650
fields : & ' tcx [ hir:: PatField < ' tcx > ] ,
1650
1651
has_rest_pat : bool ,
1651
- pat_info : PatInfo < ' _ , ' tcx > ,
1652
+ pat_info : PatInfo < ' tcx > ,
1652
1653
) -> Result < ( ) , ErrorGuaranteed > {
1653
1654
let tcx = self . tcx ;
1654
1655
@@ -2257,7 +2258,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2257
2258
span : Span ,
2258
2259
inner : & ' tcx Pat < ' tcx > ,
2259
2260
expected : Ty < ' tcx > ,
2260
- pat_info : PatInfo < ' _ , ' tcx > ,
2261
+ pat_info : PatInfo < ' tcx > ,
2261
2262
) -> Ty < ' tcx > {
2262
2263
let tcx = self . tcx ;
2263
2264
let ( box_ty, inner_ty) = self
@@ -2267,7 +2268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2267
2268
// think any errors can be introduced by using `demand::eqtype`.
2268
2269
let inner_ty = self . next_ty_var ( inner. span ) ;
2269
2270
let box_ty = Ty :: new_box ( tcx, inner_ty) ;
2270
- self . demand_eqtype_pat ( span, expected, box_ty, pat_info. top_info ) ?;
2271
+ self . demand_eqtype_pat ( span, expected, box_ty, & pat_info. top_info ) ?;
2271
2272
Ok ( ( box_ty, inner_ty) )
2272
2273
} )
2273
2274
. unwrap_or_else ( |guar| {
@@ -2283,7 +2284,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2283
2284
span : Span ,
2284
2285
inner : & ' tcx Pat < ' tcx > ,
2285
2286
expected : Ty < ' tcx > ,
2286
- pat_info : PatInfo < ' _ , ' tcx > ,
2287
+ pat_info : PatInfo < ' tcx > ,
2287
2288
) -> Ty < ' tcx > {
2288
2289
let tcx = self . tcx ;
2289
2290
// Register a `DerefPure` bound, which is required by all `deref!()` pats.
@@ -2324,7 +2325,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2324
2325
inner : & ' tcx Pat < ' tcx > ,
2325
2326
pat_mutbl : Mutability ,
2326
2327
mut expected : Ty < ' tcx > ,
2327
- mut pat_info : PatInfo < ' _ , ' tcx > ,
2328
+ mut pat_info : PatInfo < ' tcx > ,
2328
2329
) -> Ty < ' tcx > {
2329
2330
let tcx = self . tcx ;
2330
2331
@@ -2482,7 +2483,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2482
2483
pat. span ,
2483
2484
expected,
2484
2485
ref_ty,
2485
- pat_info. top_info ,
2486
+ & pat_info. top_info ,
2486
2487
) ;
2487
2488
2488
2489
// Look for a case like `fn foo(&foo: u32)` and suggest
@@ -2605,7 +2606,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2605
2606
slice : Option < & ' tcx Pat < ' tcx > > ,
2606
2607
after : & ' tcx [ Pat < ' tcx > ] ,
2607
2608
expected : Ty < ' tcx > ,
2608
- pat_info : PatInfo < ' _ , ' tcx > ,
2609
+ pat_info : PatInfo < ' tcx > ,
2609
2610
) -> Ty < ' tcx > {
2610
2611
let expected = self . try_structurally_resolve_type ( span, expected) ;
2611
2612
@@ -2767,7 +2768,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2767
2768
& self ,
2768
2769
span : Span ,
2769
2770
expected_ty : Ty < ' tcx > ,
2770
- pat_info : PatInfo < ' _ , ' tcx > ,
2771
+ pat_info : PatInfo < ' tcx > ,
2771
2772
) -> ErrorGuaranteed {
2772
2773
let PatInfo { top_info : ti, current_depth, .. } = pat_info;
2773
2774
0 commit comments