Eliminate PatKind::Path
This commit is contained in:
parent
ccc9ba5c30
commit
f47ad71059
39 changed files with 273 additions and 174 deletions
|
@ -1437,7 +1437,7 @@ impl<'hir> Pat<'hir> {
|
|||
|
||||
use PatKind::*;
|
||||
match self.kind {
|
||||
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => true,
|
||||
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
|
||||
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_short_(it),
|
||||
Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
|
||||
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
|
||||
|
@ -1464,7 +1464,7 @@ impl<'hir> Pat<'hir> {
|
|||
|
||||
use PatKind::*;
|
||||
match self.kind {
|
||||
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => {}
|
||||
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
|
||||
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
|
||||
Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
|
||||
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
|
||||
|
@ -1618,9 +1618,6 @@ pub enum PatKind<'hir> {
|
|||
/// A never pattern `!`.
|
||||
Never,
|
||||
|
||||
/// A path pattern for a unit struct/variant or a (maybe-associated) constant.
|
||||
Path(QPath<'hir>),
|
||||
|
||||
/// A tuple pattern (e.g., `(a, b)`).
|
||||
/// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
|
||||
/// `0 <= position <= subpats.len()`
|
||||
|
|
|
@ -709,9 +709,6 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) -> V:
|
|||
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
|
||||
walk_list!(visitor, visit_pat, children);
|
||||
}
|
||||
PatKind::Path(ref qpath) => {
|
||||
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
|
||||
}
|
||||
PatKind::Struct(ref qpath, fields, _) => {
|
||||
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
|
||||
walk_list!(visitor, visit_pat_field, fields);
|
||||
|
|
|
@ -105,7 +105,10 @@ impl hir::Pat<'_> {
|
|||
let mut variants = vec![];
|
||||
self.walk(|p| match &p.kind {
|
||||
PatKind::Or(_) => false,
|
||||
PatKind::Path(hir::QPath::Resolved(_, path))
|
||||
PatKind::Expr(hir::PatExpr {
|
||||
kind: hir::PatExprKind::Path(hir::QPath::Resolved(_, path)),
|
||||
..
|
||||
})
|
||||
| PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..)
|
||||
| PatKind::Struct(hir::QPath::Resolved(_, path), ..) => {
|
||||
if let Res::Def(DefKind::Variant | DefKind::Ctor(CtorOf::Variant, ..), id) =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue