@@ -1173,14 +1173,12 @@ impl LintPass for NonShorthandFieldPatterns {
1173
1173
. filter ( |fieldpat| !fieldpat. node . is_shorthand )
1174
1174
. filter ( |fieldpat| def_map. get ( & fieldpat. node . pat . id )
1175
1175
== Some ( & def:: DefLocal ( fieldpat. node . pat . id ) ) ) {
1176
- match fieldpat. node . pat . node {
1177
- ast:: PatIdent ( _, ident, None ) if ident. node . as_str ( )
1178
- == fieldpat. node . ident . as_str ( ) => {
1176
+ if let ast:: PatIdent ( _, ident, None ) = fieldpat. node . pat . node {
1177
+ if ident. node . as_str ( ) == fieldpat. node . ident . as_str ( ) {
1179
1178
cx. span_lint ( NON_SHORTHAND_FIELD_PATTERNS , fieldpat. span ,
1180
1179
format ! ( "the `{}:` in this pattern is redundant and can \
1181
1180
be removed", ident. node. as_str( ) ) . as_slice ( ) )
1182
- } ,
1183
- _ => { } ,
1181
+ }
1184
1182
}
1185
1183
}
1186
1184
}
@@ -1198,15 +1196,12 @@ impl LintPass for UnusedUnsafe {
1198
1196
}
1199
1197
1200
1198
fn check_expr ( & mut self , cx : & Context , e : & ast:: Expr ) {
1201
- match e. node {
1199
+ if let ast :: ExprBlock ( ref blk ) = e. node {
1202
1200
// Don't warn about generated blocks, that'll just pollute the output.
1203
- ast:: ExprBlock ( ref blk) => {
1204
- if blk. rules == ast:: UnsafeBlock ( ast:: UserProvided ) &&
1205
- !cx. tcx . used_unsafe . borrow ( ) . contains ( & blk. id ) {
1201
+ if blk. rules == ast:: UnsafeBlock ( ast:: UserProvided ) &&
1202
+ !cx. tcx . used_unsafe . borrow ( ) . contains ( & blk. id ) {
1206
1203
cx. span_lint ( UNUSED_UNSAFE , blk. span , "unnecessary `unsafe` block" ) ;
1207
- }
1208
1204
}
1209
- _ => ( )
1210
1205
}
1211
1206
}
1212
1207
}
@@ -1222,12 +1217,11 @@ impl LintPass for UnsafeBlocks {
1222
1217
}
1223
1218
1224
1219
fn check_expr ( & mut self , cx : & Context , e : & ast:: Expr ) {
1225
- match e. node {
1220
+ if let ast :: ExprBlock ( ref blk ) = e. node {
1226
1221
// Don't warn about generated blocks, that'll just pollute the output.
1227
- ast :: ExprBlock ( ref blk ) if blk. rules == ast:: UnsafeBlock ( ast:: UserProvided ) => {
1222
+ if blk. rules == ast:: UnsafeBlock ( ast:: UserProvided ) {
1228
1223
cx. span_lint ( UNSAFE_BLOCKS , blk. span , "usage of an `unsafe` block" ) ;
1229
1224
}
1230
- _ => ( )
1231
1225
}
1232
1226
}
1233
1227
}
@@ -1246,17 +1240,13 @@ impl UnusedMut {
1246
1240
for p in pats. iter ( ) {
1247
1241
pat_util:: pat_bindings ( & cx. tcx . def_map , & * * p, |mode, id, _, path1| {
1248
1242
let ident = path1. node ;
1249
- match mode {
1250
- ast:: BindByValue ( ast:: MutMutable ) => {
1251
- if !token:: get_ident ( ident) . get ( ) . starts_with ( "_" ) {
1252
- match mutables. entry ( ident. name . uint ( ) ) {
1253
- Vacant ( entry) => { entry. set ( vec ! [ id] ) ; } ,
1254
- Occupied ( mut entry) => { entry. get_mut ( ) . push ( id) ; } ,
1255
- }
1243
+ if let ast:: BindByValue ( ast:: MutMutable ) = mode {
1244
+ if !token:: get_ident ( ident) . get ( ) . starts_with ( "_" ) {
1245
+ match mutables. entry ( ident. name . uint ( ) ) {
1246
+ Vacant ( entry) => { entry. set ( vec ! [ id] ) ; } ,
1247
+ Occupied ( mut entry) => { entry. get_mut ( ) . push ( id) ; } ,
1256
1248
}
1257
1249
}
1258
- _ => {
1259
- }
1260
1250
}
1261
1251
} ) ;
1262
1252
}
@@ -1379,9 +1369,10 @@ impl MissingDoc {
1379
1369
// Only check publicly-visible items, using the result from the privacy pass.
1380
1370
// It's an option so the crate root can also use this function (it doesn't
1381
1371
// have a NodeId).
1382
- match id {
1383
- Some ( ref id) if !cx. exported_items . contains ( id) => return ,
1384
- _ => ( )
1372
+ if let Some ( ref id) = id {
1373
+ if !cx. exported_items . contains ( id) {
1374
+ return ;
1375
+ }
1385
1376
}
1386
1377
1387
1378
let has_doc = attrs. iter ( ) . any ( |a| {
@@ -1465,15 +1456,14 @@ impl LintPass for MissingDoc {
1465
1456
}
1466
1457
1467
1458
fn check_struct_field ( & mut self , cx : & Context , sf : & ast:: StructField ) {
1468
- match sf. node . kind {
1469
- ast :: NamedField ( _ , vis ) if vis == ast:: Public || self . in_variant => {
1459
+ if let ast :: NamedField ( _ , vis ) = sf. node . kind {
1460
+ if vis == ast:: Public || self . in_variant {
1470
1461
let cur_struct_def = * self . struct_def_stack . last ( )
1471
1462
. expect ( "empty struct_def_stack" ) ;
1472
1463
self . check_missing_docs_attrs ( cx, Some ( cur_struct_def) ,
1473
- sf. node . attrs . as_slice ( ) , sf. span ,
1474
- "a struct field" )
1464
+ sf. node . attrs . as_slice ( ) , sf. span ,
1465
+ "a struct field" )
1475
1466
}
1476
- _ => { }
1477
1467
}
1478
1468
}
1479
1469
@@ -1639,12 +1629,9 @@ impl LintPass for Stability {
1639
1629
match item. node {
1640
1630
ast:: ItemTrait ( _, _, ref supertraits, _) => {
1641
1631
for t in supertraits. iter ( ) {
1642
- match * t {
1643
- ast:: TraitTyParamBound ( ref t) => {
1644
- let id = ty:: trait_ref_to_def_id ( cx. tcx , & t. trait_ref ) ;
1645
- self . lint ( cx, id, t. trait_ref . path . span ) ;
1646
- }
1647
- _ => ( /* pass */ )
1632
+ if let ast:: TraitTyParamBound ( ref t) = * t {
1633
+ let id = ty:: trait_ref_to_def_id ( cx. tcx , & t. trait_ref ) ;
1634
+ self . lint ( cx, id, t. trait_ref . path . span ) ;
1648
1635
}
1649
1636
}
1650
1637
}
0 commit comments