@@ -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 {
@@ -352,13 +352,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
352
352
qpath,
353
353
path_res. unwrap ( ) ,
354
354
expected,
355
- ti ,
355
+ & pat_info . top_info ,
356
356
) ;
357
357
self . write_ty ( * hir_id, ty) ;
358
358
ty
359
359
}
360
- PatKind :: Expr ( lt) => self . check_pat_lit ( pat. span , lt, expected, ti) ,
361
- PatKind :: Range ( lhs, rhs, _) => self . check_pat_range ( pat. span , lhs, rhs, expected, ti) ,
360
+ PatKind :: Expr ( lt) => self . check_pat_lit ( pat. span , lt, expected, & pat_info. top_info ) ,
361
+ PatKind :: Range ( lhs, rhs, _) => {
362
+ self . check_pat_range ( pat. span , lhs, rhs, expected, & pat_info. top_info )
363
+ }
362
364
PatKind :: Binding ( ba, var_id, ident, sub) => {
363
365
self . check_pat_ident ( pat, ba, var_id, ident, sub, expected, pat_info)
364
366
}
@@ -818,7 +820,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
818
820
ident : Ident ,
819
821
sub : Option < & ' tcx Pat < ' tcx > > ,
820
822
expected : Ty < ' tcx > ,
821
- pat_info : PatInfo < ' _ , ' tcx > ,
823
+ pat_info : PatInfo < ' tcx > ,
822
824
) -> Ty < ' tcx > {
823
825
let PatInfo { binding_mode : def_br, top_info : ti, .. } = pat_info;
824
826
@@ -914,12 +916,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
914
916
} ;
915
917
916
918
// 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) ;
919
+ let _ = self . demand_eqtype_pat ( pat. span , eq_ty, local_ty, & ti) ;
918
920
919
921
// If there are multiple arms, make sure they all agree on
920
922
// what the type of the binding `x` ought to be.
921
923
if var_id != pat. hir_id {
922
- self . check_binding_alt_eq_ty ( user_bind_annot, pat. span , var_id, local_ty, ti) ;
924
+ self . check_binding_alt_eq_ty ( user_bind_annot, pat. span , var_id, local_ty, & ti) ;
923
925
}
924
926
925
927
if let Some ( p) = sub {
@@ -1149,7 +1151,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1149
1151
fields : & ' tcx [ hir:: PatField < ' tcx > ] ,
1150
1152
has_rest_pat : bool ,
1151
1153
expected : Ty < ' tcx > ,
1152
- pat_info : PatInfo < ' _ , ' tcx > ,
1154
+ pat_info : PatInfo < ' tcx > ,
1153
1155
) -> Ty < ' tcx > {
1154
1156
// Resolve the path and check the definition for errors.
1155
1157
let ( variant, pat_ty) = match self . check_struct_path ( qpath, pat. hir_id ) {
@@ -1164,7 +1166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1164
1166
} ;
1165
1167
1166
1168
// Type-check the path.
1167
- let _ = self . demand_eqtype_pat ( pat. span , expected, pat_ty, pat_info. top_info ) ;
1169
+ let _ = self . demand_eqtype_pat ( pat. span , expected, pat_ty, & pat_info. top_info ) ;
1168
1170
1169
1171
// Type-check subpatterns.
1170
1172
match self . check_struct_pat_fields ( pat_ty, pat, variant, fields, has_rest_pat, pat_info) {
@@ -1353,7 +1355,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1353
1355
subpats : & ' tcx [ Pat < ' tcx > ] ,
1354
1356
ddpos : hir:: DotDotPos ,
1355
1357
expected : Ty < ' tcx > ,
1356
- pat_info : PatInfo < ' _ , ' tcx > ,
1358
+ pat_info : PatInfo < ' tcx > ,
1357
1359
) -> Ty < ' tcx > {
1358
1360
let tcx = self . tcx ;
1359
1361
let on_error = |e| {
@@ -1403,7 +1405,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1403
1405
let pat_ty = pat_ty. no_bound_vars ( ) . expect ( "expected fn type" ) ;
1404
1406
1405
1407
// 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 ) ;
1408
+ let diag = self . demand_eqtype_pat_diag ( pat. span , expected, pat_ty, & pat_info. top_info ) ;
1407
1409
let had_err = diag. map_err ( |diag| diag. emit ( ) ) ;
1408
1410
1409
1411
// Type-check subpatterns.
@@ -1610,7 +1612,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1610
1612
elements : & ' tcx [ Pat < ' tcx > ] ,
1611
1613
ddpos : hir:: DotDotPos ,
1612
1614
expected : Ty < ' tcx > ,
1613
- pat_info : PatInfo < ' _ , ' tcx > ,
1615
+ pat_info : PatInfo < ' tcx > ,
1614
1616
) -> Ty < ' tcx > {
1615
1617
let tcx = self . tcx ;
1616
1618
let mut expected_len = elements. len ( ) ;
@@ -1625,7 +1627,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1625
1627
let element_tys_iter = ( 0 ..max_len) . map ( |_| self . next_ty_var ( span) ) ;
1626
1628
let element_tys = tcx. mk_type_list_from_iter ( element_tys_iter) ;
1627
1629
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 ) {
1630
+ if let Err ( reported) = self . demand_eqtype_pat ( span, expected, pat_ty, & pat_info. top_info ) {
1629
1631
// Walk subpatterns with an expected type of `err` in this case to silence
1630
1632
// further errors being emitted when using the bindings. #50333
1631
1633
let element_tys_iter = ( 0 ..max_len) . map ( |_| Ty :: new_error ( tcx, reported) ) ;
@@ -1648,7 +1650,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1648
1650
variant : & ' tcx ty:: VariantDef ,
1649
1651
fields : & ' tcx [ hir:: PatField < ' tcx > ] ,
1650
1652
has_rest_pat : bool ,
1651
- pat_info : PatInfo < ' _ , ' tcx > ,
1653
+ pat_info : PatInfo < ' tcx > ,
1652
1654
) -> Result < ( ) , ErrorGuaranteed > {
1653
1655
let tcx = self . tcx ;
1654
1656
@@ -2257,7 +2259,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2257
2259
span : Span ,
2258
2260
inner : & ' tcx Pat < ' tcx > ,
2259
2261
expected : Ty < ' tcx > ,
2260
- pat_info : PatInfo < ' _ , ' tcx > ,
2262
+ pat_info : PatInfo < ' tcx > ,
2261
2263
) -> Ty < ' tcx > {
2262
2264
let tcx = self . tcx ;
2263
2265
let ( box_ty, inner_ty) = self
@@ -2267,7 +2269,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2267
2269
// think any errors can be introduced by using `demand::eqtype`.
2268
2270
let inner_ty = self . next_ty_var ( inner. span ) ;
2269
2271
let box_ty = Ty :: new_box ( tcx, inner_ty) ;
2270
- self . demand_eqtype_pat ( span, expected, box_ty, pat_info. top_info ) ?;
2272
+ self . demand_eqtype_pat ( span, expected, box_ty, & pat_info. top_info ) ?;
2271
2273
Ok ( ( box_ty, inner_ty) )
2272
2274
} )
2273
2275
. unwrap_or_else ( |guar| {
@@ -2283,7 +2285,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2283
2285
span : Span ,
2284
2286
inner : & ' tcx Pat < ' tcx > ,
2285
2287
expected : Ty < ' tcx > ,
2286
- pat_info : PatInfo < ' _ , ' tcx > ,
2288
+ pat_info : PatInfo < ' tcx > ,
2287
2289
) -> Ty < ' tcx > {
2288
2290
let tcx = self . tcx ;
2289
2291
// Register a `DerefPure` bound, which is required by all `deref!()` pats.
@@ -2324,7 +2326,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2324
2326
inner : & ' tcx Pat < ' tcx > ,
2325
2327
pat_mutbl : Mutability ,
2326
2328
mut expected : Ty < ' tcx > ,
2327
- mut pat_info : PatInfo < ' _ , ' tcx > ,
2329
+ mut pat_info : PatInfo < ' tcx > ,
2328
2330
) -> Ty < ' tcx > {
2329
2331
let tcx = self . tcx ;
2330
2332
@@ -2482,7 +2484,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2482
2484
pat. span ,
2483
2485
expected,
2484
2486
ref_ty,
2485
- pat_info. top_info ,
2487
+ & pat_info. top_info ,
2486
2488
) ;
2487
2489
2488
2490
// Look for a case like `fn foo(&foo: u32)` and suggest
@@ -2605,7 +2607,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2605
2607
slice : Option < & ' tcx Pat < ' tcx > > ,
2606
2608
after : & ' tcx [ Pat < ' tcx > ] ,
2607
2609
expected : Ty < ' tcx > ,
2608
- pat_info : PatInfo < ' _ , ' tcx > ,
2610
+ pat_info : PatInfo < ' tcx > ,
2609
2611
) -> Ty < ' tcx > {
2610
2612
let expected = self . try_structurally_resolve_type ( span, expected) ;
2611
2613
@@ -2767,7 +2769,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2767
2769
& self ,
2768
2770
span : Span ,
2769
2771
expected_ty : Ty < ' tcx > ,
2770
- pat_info : PatInfo < ' _ , ' tcx > ,
2772
+ pat_info : PatInfo < ' tcx > ,
2771
2773
) -> ErrorGuaranteed {
2772
2774
let PatInfo { top_info : ti, current_depth, .. } = pat_info;
2773
2775
0 commit comments