diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2020-12-09 13:38:33 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-09 13:38:33 -0800 |
| commit | 9ced8dc0f5995e534988a79d7e7d8a2a555ef76f (patch) | |
| tree | 9da7e97e0feb3ae901fdacea6dbe865fa9a40452 | |
| parent | 666d1a8951093a5cc6e3e83bdc2cff9d7cd83045 (diff) | |
| parent | 7654b12112664f4e21e519c0c0d7d0aff1f70221 (diff) | |
| download | rust-9ced8dc0f5995e534988a79d7e7d8a2a555ef76f.tar.gz rust-9ced8dc0f5995e534988a79d7e7d8a2a555ef76f.zip | |
Rollup merge of #79826 - LingMan:match_if, r=lcnr
Simplify visit_{foreign,trait}_item
Using an `if` seems like a better semantic fit and saves a few lines.
Noticed while looking at https://github.com/rust-lang/rust/pull/79752, but that's already merged.
r? `@lcnr,` cc `@cjgillot`
`@rustbot` modify labels +C-cleanup +T-compiler
| -rw-r--r-- | compiler/rustc_passes/src/dead.rs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index bbd6b9b505f..00152878d6d 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -423,15 +423,11 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { } fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) { - match trait_item.kind { - hir::TraitItemKind::Const(_, Some(_)) - | hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)) => { - if has_allow_dead_code_or_lang_attr(self.tcx, trait_item.hir_id, &trait_item.attrs) - { - self.worklist.push(trait_item.hir_id); - } - } - _ => {} + use hir::TraitItemKind::{Const, Fn}; + if matches!(trait_item.kind, Const(_, Some(_)) | Fn(_, hir::TraitFn::Provided(_))) + && has_allow_dead_code_or_lang_attr(self.tcx, trait_item.hir_id, &trait_item.attrs) + { + self.worklist.push(trait_item.hir_id); } } @@ -440,17 +436,11 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { } fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) { - match foreign_item.kind { - hir::ForeignItemKind::Static(..) | hir::ForeignItemKind::Fn(..) => { - if has_allow_dead_code_or_lang_attr( - self.tcx, - foreign_item.hir_id, - &foreign_item.attrs, - ) { - self.worklist.push(foreign_item.hir_id); - } - } - _ => {} + use hir::ForeignItemKind::{Fn, Static}; + if matches!(foreign_item.kind, Static(..) | Fn(..)) + && has_allow_dead_code_or_lang_attr(self.tcx, foreign_item.hir_id, &foreign_item.attrs) + { + self.worklist.push(foreign_item.hir_id); } } } |
