@@ -168,7 +168,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
168
168
// without the final expr (e.g. `try { return; }`). We don't want to generate an
169
169
// unreachable_code lint for it since warnings for autogenerated code are confusing.
170
170
let is_try_block_generated_unit_expr = match expr. kind {
171
- ExprKind :: Call ( _, ref args) if expr. span . is_desugaring ( DesugaringKind :: TryBlock ) => {
171
+ ExprKind :: Call ( _, args) if expr. span . is_desugaring ( DesugaringKind :: TryBlock ) => {
172
172
args. len ( ) == 1 && args[ 0 ] . span . is_desugaring ( DesugaringKind :: TryBlock )
173
173
}
174
174
@@ -193,9 +193,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
193
193
// diverging expression (e.g. it arose from desugaring of `try { return }`),
194
194
// we skip issuing a warning because it is autogenerated code.
195
195
ExprKind :: Call ( ..) if expr. span . is_desugaring ( DesugaringKind :: TryBlock ) => { }
196
- ExprKind :: Call ( ref callee, _) => {
197
- self . warn_if_unreachable ( expr. hir_id , callee. span , "call" )
198
- }
196
+ ExprKind :: Call ( callee, _) => self . warn_if_unreachable ( expr. hir_id , callee. span , "call" ) ,
199
197
ExprKind :: MethodCall ( _, ref span, _, _) => {
200
198
self . warn_if_unreachable ( expr. hir_id , * span, "call" )
201
199
}
@@ -231,23 +229,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
231
229
232
230
let tcx = self . tcx ;
233
231
match expr. kind {
234
- ExprKind :: Box ( ref subexpr) => self . check_expr_box ( subexpr, expected) ,
232
+ ExprKind :: Box ( subexpr) => self . check_expr_box ( subexpr, expected) ,
235
233
ExprKind :: Lit ( ref lit) => self . check_lit ( & lit, expected) ,
236
- ExprKind :: Binary ( op, ref lhs, ref rhs) => self . check_binop ( expr, op, lhs, rhs) ,
237
- ExprKind :: Assign ( ref lhs, ref rhs, ref span) => {
234
+ ExprKind :: Binary ( op, lhs, rhs) => self . check_binop ( expr, op, lhs, rhs) ,
235
+ ExprKind :: Assign ( lhs, rhs, ref span) => {
238
236
self . check_expr_assign ( expr, expected, lhs, rhs, span)
239
237
}
240
- ExprKind :: AssignOp ( op, ref lhs, ref rhs) => self . check_binop_assign ( expr, op, lhs, rhs) ,
241
- ExprKind :: Unary ( unop, ref oprnd) => self . check_expr_unary ( unop, oprnd, expected, expr) ,
242
- ExprKind :: AddrOf ( kind, mutbl, ref oprnd) => {
238
+ ExprKind :: AssignOp ( op, lhs, rhs) => self . check_binop_assign ( expr, op, lhs, rhs) ,
239
+ ExprKind :: Unary ( unop, oprnd) => self . check_expr_unary ( unop, oprnd, expected, expr) ,
240
+ ExprKind :: AddrOf ( kind, mutbl, oprnd) => {
243
241
self . check_expr_addr_of ( kind, mutbl, oprnd, expected, expr)
244
242
}
245
243
ExprKind :: Path ( QPath :: LangItem ( lang_item, _) ) => {
246
244
self . check_lang_item_path ( lang_item, expr)
247
245
}
248
246
ExprKind :: Path ( ref qpath) => self . check_expr_path ( qpath, expr) ,
249
247
ExprKind :: InlineAsm ( asm) => self . check_expr_asm ( asm) ,
250
- ExprKind :: LlvmInlineAsm ( ref asm) => {
248
+ ExprKind :: LlvmInlineAsm ( asm) => {
251
249
for expr in asm. outputs_exprs . iter ( ) . chain ( asm. inputs_exprs . iter ( ) ) {
252
250
self . check_expr ( expr) ;
253
251
}
@@ -265,42 +263,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
265
263
}
266
264
}
267
265
ExprKind :: Ret ( ref expr_opt) => self . check_expr_return ( expr_opt. as_deref ( ) , expr) ,
268
- ExprKind :: Loop ( ref body, _, source, _) => {
266
+ ExprKind :: Loop ( body, _, source, _) => {
269
267
self . check_expr_loop ( body, source, expected, expr)
270
268
}
271
- ExprKind :: Match ( ref discrim, ref arms, match_src) => {
269
+ ExprKind :: Match ( discrim, arms, match_src) => {
272
270
self . check_match ( expr, & discrim, arms, expected, match_src)
273
271
}
274
- ExprKind :: Closure ( capture, ref decl, body_id, _, gen) => {
272
+ ExprKind :: Closure ( capture, decl, body_id, _, gen) => {
275
273
self . check_expr_closure ( expr, capture, & decl, body_id, gen, expected)
276
274
}
277
- ExprKind :: Block ( ref body, _) => self . check_block_with_expected ( & body, expected) ,
278
- ExprKind :: Call ( ref callee, ref args) => self . check_call ( expr, & callee, args, expected) ,
279
- ExprKind :: MethodCall ( ref segment, span, ref args, _) => {
275
+ ExprKind :: Block ( body, _) => self . check_block_with_expected ( & body, expected) ,
276
+ ExprKind :: Call ( callee, args) => self . check_call ( expr, & callee, args, expected) ,
277
+ ExprKind :: MethodCall ( segment, span, args, _) => {
280
278
self . check_method_call ( expr, segment, span, args, expected)
281
279
}
282
- ExprKind :: Cast ( ref e , ref t) => self . check_expr_cast ( e, t, expr) ,
283
- ExprKind :: Type ( ref e , ref t) => {
280
+ ExprKind :: Cast ( e , t) => self . check_expr_cast ( e, t, expr) ,
281
+ ExprKind :: Type ( e , t) => {
284
282
let ty = self . to_ty_saving_user_provided_ty ( & t) ;
285
283
self . check_expr_eq_type ( & e, ty) ;
286
284
ty
287
285
}
288
286
ExprKind :: If ( cond, then_expr, opt_else_expr) => {
289
287
self . check_then_else ( cond, then_expr, opt_else_expr, expr. span , expected)
290
288
}
291
- ExprKind :: DropTemps ( ref e) => self . check_expr_with_expectation ( e, expected) ,
292
- ExprKind :: Array ( ref args) => self . check_expr_array ( args, expected, expr) ,
289
+ ExprKind :: DropTemps ( e) => self . check_expr_with_expectation ( e, expected) ,
290
+ ExprKind :: Array ( args) => self . check_expr_array ( args, expected, expr) ,
293
291
ExprKind :: ConstBlock ( ref anon_const) => self . to_const ( anon_const) . ty ,
294
- ExprKind :: Repeat ( ref element, ref count) => {
292
+ ExprKind :: Repeat ( element, ref count) => {
295
293
self . check_expr_repeat ( element, count, expected, expr)
296
294
}
297
- ExprKind :: Tup ( ref elts) => self . check_expr_tuple ( elts, expected, expr) ,
298
- ExprKind :: Struct ( ref qpath, fields, ref base_expr) => {
295
+ ExprKind :: Tup ( elts) => self . check_expr_tuple ( elts, expected, expr) ,
296
+ ExprKind :: Struct ( qpath, fields, ref base_expr) => {
299
297
self . check_expr_struct ( expr, expected, qpath, fields, base_expr)
300
298
}
301
- ExprKind :: Field ( ref base, field) => self . check_field ( expr, & base, field) ,
302
- ExprKind :: Index ( ref base, ref idx) => self . check_expr_index ( base, idx, expr) ,
303
- ExprKind :: Yield ( ref value, ref src) => self . check_expr_yield ( value, expr, src) ,
299
+ ExprKind :: Field ( base, field) => self . check_field ( expr, & base, field) ,
300
+ ExprKind :: Index ( base, idx) => self . check_expr_index ( base, idx, expr) ,
301
+ ExprKind :: Yield ( value, ref src) => self . check_expr_yield ( value, expr, src) ,
304
302
hir:: ExprKind :: Err => tcx. ty_error ( ) ,
305
303
}
306
304
}
@@ -541,7 +539,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
541
539
let tcx = self . tcx ;
542
540
if let Ok ( target_id) = destination. target_id {
543
541
let ( e_ty, cause) ;
544
- if let Some ( ref e) = expr_opt {
542
+ if let Some ( e) = expr_opt {
545
543
// If this is a break with a value, we need to type-check
546
544
// the expression. Get an expected type from the loop context.
547
545
let opt_coerce_to = {
@@ -650,12 +648,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
650
648
651
649
// We still need to assign a type to the inner expression to
652
650
// prevent the ICE in #43162.
653
- if let Some ( ref e) = expr_opt {
651
+ if let Some ( e) = expr_opt {
654
652
self . check_expr_with_hint ( e, err) ;
655
653
656
654
// ... except when we try to 'break rust;'.
657
655
// ICE this expression in particular (see #43162).
658
- if let ExprKind :: Path ( QPath :: Resolved ( _, ref path) ) = e. kind {
656
+ if let ExprKind :: Path ( QPath :: Resolved ( _, path) ) = e. kind {
659
657
if path. segments . len ( ) == 1 && path. segments [ 0 ] . ident . name == sym:: rust {
660
658
fatally_break_rust ( self . tcx . sess ) ;
661
659
}
@@ -674,7 +672,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
674
672
) -> Ty < ' tcx > {
675
673
if self . ret_coercion . is_none ( ) {
676
674
self . tcx . sess . emit_err ( ReturnStmtOutsideOfFnBody { span : expr. span } ) ;
677
- } else if let Some ( ref e) = expr_opt {
675
+ } else if let Some ( e) = expr_opt {
678
676
if self . ret_coercion_span . get ( ) . is_none ( ) {
679
677
self . ret_coercion_span . set ( Some ( e. span ) ) ;
680
678
}
@@ -1133,13 +1131,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1133
1131
let flds = expected. only_has_type ( self ) . and_then ( |ty| {
1134
1132
let ty = self . resolve_vars_with_obligations ( ty) ;
1135
1133
match ty. kind ( ) {
1136
- ty:: Tuple ( ref flds) => Some ( & flds[ ..] ) ,
1134
+ ty:: Tuple ( flds) => Some ( & flds[ ..] ) ,
1137
1135
_ => None ,
1138
1136
}
1139
1137
} ) ;
1140
1138
1141
1139
let elt_ts_iter = elts. iter ( ) . enumerate ( ) . map ( |( i, e) | match flds {
1142
- Some ( ref fs) if i < fs. len ( ) => {
1140
+ Some ( fs) if i < fs. len ( ) => {
1143
1141
let ety = fs[ i] . expect_ty ( ) ;
1144
1142
self . check_expr_coercable_to_type ( & e, ety, None ) ;
1145
1143
ety
@@ -1328,7 +1326,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1328
1326
for field in fields {
1329
1327
self . check_expr ( & field. expr ) ;
1330
1328
}
1331
- if let Some ( ref base) = * base_expr {
1329
+ if let Some ( base) = * base_expr {
1332
1330
self . check_expr ( & base) ;
1333
1331
}
1334
1332
}
@@ -1488,7 +1486,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1488
1486
} ,
1489
1487
_ => {
1490
1488
// prevent all specified fields from being suggested
1491
- let skip_fields = skip_fields. iter ( ) . map ( |ref x| x. ident . name ) ;
1489
+ let skip_fields = skip_fields. iter ( ) . map ( |x| x. ident . name ) ;
1492
1490
if let Some ( field_name) =
1493
1491
Self :: suggest_field_name ( variant, field. ident . name , skip_fields. collect ( ) )
1494
1492
{
@@ -1617,7 +1615,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1617
1615
private_candidate = Some ( ( base_def. did , field_ty) ) ;
1618
1616
}
1619
1617
}
1620
- ty:: Tuple ( ref tys) => {
1618
+ ty:: Tuple ( tys) => {
1621
1619
let fstr = field. as_str ( ) ;
1622
1620
if let Ok ( index) = fstr. parse :: < usize > ( ) {
1623
1621
if fstr == index. to_string ( ) {
0 commit comments