Skip to content

Commit a779e3b

Browse files
committed
fix missed switch pointed out in review plus a few others
1 parent 232ffa0 commit a779e3b

File tree

2 files changed

+33
-52
lines changed

2 files changed

+33
-52
lines changed

src/librustc/lint/builtin.rs

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,14 +1173,12 @@ impl LintPass for NonShorthandFieldPatterns {
11731173
.filter(|fieldpat| !fieldpat.node.is_shorthand)
11741174
.filter(|fieldpat| def_map.get(&fieldpat.node.pat.id)
11751175
== 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() {
11791178
cx.span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span,
11801179
format!("the `{}:` in this pattern is redundant and can \
11811180
be removed", ident.node.as_str()).as_slice())
1182-
},
1183-
_ => {},
1181+
}
11841182
}
11851183
}
11861184
}
@@ -1198,15 +1196,12 @@ impl LintPass for UnusedUnsafe {
11981196
}
11991197

12001198
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
1201-
match e.node {
1199+
if let ast::ExprBlock(ref blk) = e.node {
12021200
// 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) {
12061203
cx.span_lint(UNUSED_UNSAFE, blk.span, "unnecessary `unsafe` block");
1207-
}
12081204
}
1209-
_ => ()
12101205
}
12111206
}
12121207
}
@@ -1222,12 +1217,11 @@ impl LintPass for UnsafeBlocks {
12221217
}
12231218

12241219
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
1225-
match e.node {
1220+
if let ast::ExprBlock(ref blk) = e.node {
12261221
// 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) {
12281223
cx.span_lint(UNSAFE_BLOCKS, blk.span, "usage of an `unsafe` block");
12291224
}
1230-
_ => ()
12311225
}
12321226
}
12331227
}
@@ -1246,17 +1240,13 @@ impl UnusedMut {
12461240
for p in pats.iter() {
12471241
pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| {
12481242
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); },
12561248
}
12571249
}
1258-
_ => {
1259-
}
12601250
}
12611251
});
12621252
}
@@ -1379,9 +1369,10 @@ impl MissingDoc {
13791369
// Only check publicly-visible items, using the result from the privacy pass.
13801370
// It's an option so the crate root can also use this function (it doesn't
13811371
// 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+
}
13851376
}
13861377

13871378
let has_doc = attrs.iter().any(|a| {
@@ -1465,15 +1456,14 @@ impl LintPass for MissingDoc {
14651456
}
14661457

14671458
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 {
14701461
let cur_struct_def = *self.struct_def_stack.last()
14711462
.expect("empty struct_def_stack");
14721463
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")
14751466
}
1476-
_ => {}
14771467
}
14781468
}
14791469

@@ -1639,12 +1629,9 @@ impl LintPass for Stability {
16391629
match item.node {
16401630
ast::ItemTrait(_, _, ref supertraits, _) => {
16411631
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);
16481635
}
16491636
}
16501637
}

src/librustc/metadata/decoder.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -521,21 +521,15 @@ fn each_child_of_item_or_crate(intr: Rc<IdentInterner>,
521521
let impl_item_def_id = item_def_id(impl_item_def_id_doc,
522522
cdata);
523523
if let Some(impl_method_doc) = maybe_find_item(impl_item_def_id.node, items) {
524-
match item_family(impl_method_doc) {
525-
StaticMethod => {
526-
// Hand off the static method
527-
// to the callback.
528-
let static_method_name =
529-
item_name(&*intr, impl_method_doc);
530-
let static_method_def_like =
531-
item_to_def_like(impl_method_doc,
532-
impl_item_def_id,
533-
cdata.cnum);
534-
callback(static_method_def_like,
535-
static_method_name,
536-
item_visibility(impl_method_doc));
537-
}
538-
_ => {}
524+
if let StaticMethod = item_family(impl_method_doc) {
525+
// Hand off the static method to the callback.
526+
let static_method_name = item_name(&*intr, impl_method_doc);
527+
let static_method_def_like = item_to_def_like(impl_method_doc,
528+
impl_item_def_id,
529+
cdata.cnum);
530+
callback(static_method_def_like,
531+
static_method_name,
532+
item_visibility(impl_method_doc));
539533
}
540534
}
541535
true

0 commit comments

Comments
 (0)