use matches!() macro in more places
This commit is contained in:
parent
c34c015fe2
commit
d12a358673
34 changed files with 138 additions and 270 deletions
|
@ -23,18 +23,18 @@ use rustc_span::symbol::{sym, Symbol};
|
|||
// function, then we should explore its block to check for codes that
|
||||
// may need to be marked as live.
|
||||
fn should_explore(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
|
||||
match tcx.hir().find(hir_id) {
|
||||
matches!(
|
||||
tcx.hir().find(hir_id),
|
||||
Some(
|
||||
Node::Item(..)
|
||||
| Node::ImplItem(..)
|
||||
| Node::ForeignItem(..)
|
||||
| Node::TraitItem(..)
|
||||
| Node::Variant(..)
|
||||
| Node::AnonConst(..)
|
||||
| Node::Pat(..),
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
| Node::ImplItem(..)
|
||||
| Node::ForeignItem(..)
|
||||
| Node::TraitItem(..)
|
||||
| Node::Variant(..)
|
||||
| Node::AnonConst(..)
|
||||
| Node::Pat(..),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
struct MarkSymbolVisitor<'tcx> {
|
||||
|
@ -500,16 +500,16 @@ struct DeadVisitor<'tcx> {
|
|||
|
||||
impl DeadVisitor<'tcx> {
|
||||
fn should_warn_about_item(&mut self, item: &hir::Item<'_>) -> bool {
|
||||
let should_warn = match item.kind {
|
||||
let should_warn = matches!(
|
||||
item.kind,
|
||||
hir::ItemKind::Static(..)
|
||||
| hir::ItemKind::Const(..)
|
||||
| hir::ItemKind::Fn(..)
|
||||
| hir::ItemKind::TyAlias(..)
|
||||
| hir::ItemKind::Enum(..)
|
||||
| hir::ItemKind::Struct(..)
|
||||
| hir::ItemKind::Union(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
| hir::ItemKind::Const(..)
|
||||
| hir::ItemKind::Fn(..)
|
||||
| hir::ItemKind::TyAlias(..)
|
||||
| hir::ItemKind::Enum(..)
|
||||
| hir::ItemKind::Struct(..)
|
||||
| hir::ItemKind::Union(..)
|
||||
);
|
||||
should_warn && !self.symbol_is_live(item.hir_id)
|
||||
}
|
||||
|
||||
|
|
|
@ -367,10 +367,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
|
||||
let is_shorthand = match param.pat.kind {
|
||||
rustc_hir::PatKind::Struct(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
let is_shorthand = matches!(param.pat.kind, rustc_hir::PatKind::Struct(..));
|
||||
param.pat.each_binding(|_bm, hir_id, _x, ident| {
|
||||
let var = if is_shorthand {
|
||||
Local(LocalInfo { id: hir_id, name: ident.name, is_shorthand: true })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue