Rename Pat.node to Pat.kind

This commit is contained in:
varkor 2019-09-26 16:18:31 +01:00
parent 95f6d72a60
commit 8bd0382134
52 changed files with 135 additions and 135 deletions

View File

@ -696,7 +696,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
visitor.visit_id(pattern.hir_id);
match pattern.node {
match pattern.kind {
PatKind::TupleStruct(ref qpath, ref children, _) => {
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
walk_list!(visitor, visit_pat, children);

View File

@ -425,7 +425,7 @@ fn with_hir_id_owner<F, T>(&mut self, owner: Option<NodeId>, f: F) -> T
impl<'tcx, 'interner> Visitor<'tcx> for MiscCollector<'tcx, 'interner> {
fn visit_pat(&mut self, p: &'tcx Pat) {
if let PatKind::Paren(..) | PatKind::Rest = p.node {
if let PatKind::Paren(..) | PatKind::Rest = p.kind {
// Doesn't generate a HIR node
} else if let Some(owner) = self.hir_id_owner {
self.lctx.lower_node_id_with_owner(p.id, owner);
@ -2095,7 +2095,7 @@ fn lower_mutability(&mut self, m: Mutability) -> hir::Mutability {
fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> hir::HirVec<Ident> {
decl.inputs
.iter()
.map(|param| match param.pat.node {
.map(|param| match param.pat.kind {
PatKind::Ident(_, ident, _) => ident,
_ => Ident::new(kw::Invalid, param.pat.span),
})
@ -2172,7 +2172,7 @@ fn lower_fn_decl(
implicit_self: decl.inputs.get(0).map_or(
hir::ImplicitSelfKind::None,
|arg| {
let is_mutable_pat = match arg.pat.node {
let is_mutable_pat = match arg.pat.kind {
PatKind::Ident(BindingMode::ByValue(mt), _, _) |
PatKind::Ident(BindingMode::ByRef(mt), _, _) =>
mt == Mutability::Mutable,
@ -2688,7 +2688,7 @@ fn lower_block_expr(&mut self, b: &Block) -> hir::Expr {
}
fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
let node = match p.node {
let node = match p.kind {
PatKind::Wild => hir::PatKind::Wild,
PatKind::Ident(ref binding_mode, ident, ref sub) => {
let lower_sub = |this: &mut Self| sub.as_ref().map(|x| this.lower_pat(x));
@ -2805,7 +2805,7 @@ fn lower_pat_slice(&mut self, pats: &[AstP<Pat>]) -> hir::PatKind {
let mut iter = pats.iter();
while let Some(pat) = iter.next() {
// Interpret the first `((ref mut?)? x @)? ..` pattern as a subslice pattern.
match pat.node {
match pat.kind {
PatKind::Rest => {
prev_rest_span = Some(pat.span);
slice = Some(self.pat_wild_with_node_id_of(pat));
@ -2827,7 +2827,7 @@ fn lower_pat_slice(&mut self, pats: &[AstP<Pat>]) -> hir::PatKind {
while let Some(pat) = iter.next() {
// There was a previous subslice pattern; make sure we don't allow more.
let rest_span = match pat.node {
let rest_span = match pat.kind {
PatKind::Rest => Some(pat.span),
PatKind::Ident(.., Some(ref sub)) if sub.is_rest() => {
// The `HirValidator` is merciless; add a `_` pattern to avoid ICEs.
@ -2884,10 +2884,10 @@ fn pat_wild_with_node_id_of(&mut self, p: &Pat) -> P<hir::Pat> {
}
/// Construct a `Pat` with the `HirId` of `p.id` lowered.
fn pat_with_node_id_of(&mut self, p: &Pat, node: hir::PatKind) -> P<hir::Pat> {
fn pat_with_node_id_of(&mut self, p: &Pat, kind: hir::PatKind) -> P<hir::Pat> {
P(hir::Pat {
hir_id: self.lower_node_id(p.id),
node,
kind,
span: p.span,
})
}
@ -3112,7 +3112,7 @@ fn pat_ident_binding_mode(
(
P(hir::Pat {
hir_id,
node: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
kind: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
span,
}),
hir_id
@ -3123,10 +3123,10 @@ fn pat_wild(&mut self, span: Span) -> P<hir::Pat> {
self.pat(span, hir::PatKind::Wild)
}
fn pat(&mut self, span: Span, pat: hir::PatKind) -> P<hir::Pat> {
fn pat(&mut self, span: Span, kind: hir::PatKind) -> P<hir::Pat> {
P(hir::Pat {
hir_id: self.next_id(),
node: pat,
kind,
span,
})
}

View File

@ -1133,7 +1133,7 @@ fn lower_maybe_async_body(
// Check if this is a binding pattern, if so, we can optimize and avoid adding a
// `let <pat> = __argN;` statement. In this case, we do not rename the parameter.
let (ident, is_simple_parameter) = match parameter.pat.node {
let (ident, is_simple_parameter) = match parameter.pat.kind {
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, _) =>
(ident, true),
_ => {

View File

@ -427,7 +427,7 @@ fn visit_impl_item(&mut self, ii: &'hir ImplItem) {
}
fn visit_pat(&mut self, pat: &'hir Pat) {
let node = if let PatKind::Binding(..) = pat.node {
let node = if let PatKind::Binding(..) = pat.kind {
Node::Binding(pat)
} else {
Node::Pat(pat)

View File

@ -257,7 +257,7 @@ fn visit_impl_item(&mut self, ii: &'a ImplItem) {
}
fn visit_pat(&mut self, pat: &'a Pat) {
match pat.node {
match pat.kind {
PatKind::Mac(..) => return self.visit_macro_invoc(pat.id),
_ => visit::walk_pat(self, pat),
}

View File

@ -948,7 +948,7 @@ pub fn name(&self, id: HirId) -> Name {
Node::Field(f) => f.ident.name,
Node::Lifetime(lt) => lt.name.ident().name,
Node::GenericParam(param) => param.name.ident().name,
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
Node::Binding(&Pat { kind: PatKind::Binding(_, _, l, _), .. }) => l.name,
Node::Ctor(..) => self.name(self.get_parent_item(id)),
_ => bug!("no name for {}", self.node_to_string(id))
}

View File

@ -869,7 +869,7 @@ pub struct Block {
pub struct Pat {
#[stable_hasher(ignore)]
pub hir_id: HirId,
pub node: PatKind,
pub kind: PatKind,
pub span: Span,
}
@ -888,7 +888,7 @@ fn walk_short_(&self, it: &mut impl FnMut(&Pat) -> bool) -> bool {
}
use PatKind::*;
match &self.node {
match &self.kind {
Wild | Lit(_) | Range(..) | Binding(.., None) | Path(_) => true,
Box(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_short_(it),
Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
@ -919,7 +919,7 @@ fn walk_(&self, it: &mut impl FnMut(&Pat) -> bool) {
}
use PatKind::*;
match &self.node {
match &self.kind {
Wild | Lit(_) | Range(..) | Binding(.., None) | Path(_) => {},
Box(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_(it),
Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
@ -1295,7 +1295,7 @@ impl Arm {
// HACK(or_patterns; Centril | dlrobertson): Remove this and
// correctly handle each case in which this method is used.
pub fn top_pats_hack(&self) -> &[P<Pat>] {
match &self.pat.node {
match &self.pat.kind {
PatKind::Or(pats) => pats,
_ => std::slice::from_ref(&self.pat),
}

View File

@ -45,7 +45,7 @@ fn enumerate_and_adjust(self, expected_len: usize, gap_pos: Option<usize>)
impl hir::Pat {
pub fn is_refutable(&self) -> bool {
match self.node {
match self.kind {
PatKind::Lit(_) |
PatKind::Range(..) |
PatKind::Path(hir::QPath::Resolved(Some(..), _)) |
@ -68,7 +68,7 @@ pub fn is_refutable(&self) -> bool {
/// `match foo() { Some(a) => (), None => () }`
pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident)) {
self.walk(|p| {
if let PatKind::Binding(binding_mode, _, ident, _) = p.node {
if let PatKind::Binding(binding_mode, _, ident, _) = p.kind {
f(binding_mode, p.hir_id, p.span, ident);
}
true
@ -83,7 +83,7 @@ pub fn each_binding_or_first(
&self,
f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident),
) {
self.walk(|p| match &p.node {
self.walk(|p| match &p.kind {
PatKind::Or(ps) => {
ps[0].each_binding_or_first(f);
false
@ -99,7 +99,7 @@ pub fn each_binding_or_first(
/// Checks if the pattern contains any patterns that bind something to
/// an ident, e.g., `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
pub fn contains_bindings(&self) -> bool {
self.satisfies(|p| match p.node {
self.satisfies(|p| match p.kind {
PatKind::Binding(..) => true,
_ => false,
})
@ -108,7 +108,7 @@ pub fn contains_bindings(&self) -> bool {
/// Checks if the pattern contains any patterns that bind something to
/// an ident or wildcard, e.g., `foo`, or `Foo(_)`, `foo @ Bar(..)`,
pub fn contains_bindings_or_wild(&self) -> bool {
self.satisfies(|p| match p.node {
self.satisfies(|p| match p.kind {
PatKind::Binding(..) | PatKind::Wild => true,
_ => false,
})
@ -129,7 +129,7 @@ fn satisfies(&self, pred: impl Fn(&Self) -> bool) -> bool {
}
pub fn simple_ident(&self) -> Option<ast::Ident> {
match self.node {
match self.kind {
PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) |
PatKind::Binding(hir::BindingAnnotation::Mutable, _, ident, None) => Some(ident),
_ => None,
@ -139,7 +139,7 @@ pub fn simple_ident(&self) -> Option<ast::Ident> {
/// Returns variants that are necessary to exist for the pattern to match.
pub fn necessary_variants(&self) -> Vec<DefId> {
let mut variants = vec![];
self.walk(|p| match &p.node {
self.walk(|p| match &p.kind {
PatKind::Or(_) => false,
PatKind::Path(hir::QPath::Resolved(_, path)) |
PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..) |

View File

@ -1617,7 +1617,7 @@ pub fn print_pat(&mut self, pat: &hir::Pat) {
self.ann.pre(self, AnnNode::Pat(pat));
// Pat isn't normalized, but the beauty of it
// is that it doesn't matter
match pat.node {
match pat.kind {
PatKind::Wild => self.s.word("_"),
PatKind::Binding(binding_mode, _, ident, ref sub) => {
match binding_mode {
@ -1710,7 +1710,7 @@ pub fn print_pat(&mut self, pat: &hir::Pat) {
self.pclose();
}
PatKind::Box(ref inner) => {
let is_range_inner = match inner.node {
let is_range_inner = match inner.kind {
PatKind::Range(..) => true,
_ => false,
};
@ -1724,7 +1724,7 @@ pub fn print_pat(&mut self, pat: &hir::Pat) {
}
}
PatKind::Ref(ref inner, mutbl) => {
let is_range_inner = match inner.node {
let is_range_inner = match inner.kind {
PatKind::Range(..) => true,
_ => false,
};
@ -1757,7 +1757,7 @@ pub fn print_pat(&mut self, pat: &hir::Pat) {
if !before.is_empty() {
self.word_space(",");
}
if let PatKind::Wild = p.node {
if let PatKind::Wild = p.kind {
// Print nothing.
} else {
self.print_pat(&p);

View File

@ -47,7 +47,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
}
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
if let hir::PatKind::Binding(_, hir_id, ..) = pat.node {
if let hir::PatKind::Binding(_, hir_id, ..) = pat.kind {
self.locals.insert(hir_id);
}
intravisit::walk_pat(self, pat);

View File

@ -133,7 +133,7 @@ fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, res: Res, pats: &[hir::
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
};
for pat in pats {
if let PatKind::Wild = pat.pat.node {
if let PatKind::Wild = pat.pat.kind {
continue;
}
let index = self.tcx.field_index(pat.hir_id, self.tables);
@ -269,7 +269,7 @@ fn visit_arm(&mut self, arm: &'tcx hir::Arm) {
}
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
match pat.node {
match pat.kind {
PatKind::Struct(ref path, ref fields, _) => {
let res = self.tables.qpath_res(path, pat.hir_id);
self.handle_field_pattern_match(pat, res, fields);

View File

@ -812,7 +812,7 @@ fn determine_pat_move_mode(&mut self,
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr, pat);
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| {
if let PatKind::Binding(..) = pat.node {
if let PatKind::Binding(..) = pat.kind {
let bm = *self.mc.tables.pat_binding_modes()
.get(pat.hir_id)
.expect("missing binding mode");
@ -839,7 +839,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, match_mode: Mat
let tcx = self.tcx();
let ExprUseVisitor { ref mc, ref mut delegate, param_env } = *self;
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |cmt_pat, pat| {
if let PatKind::Binding(_, canonical_id, ..) = pat.node {
if let PatKind::Binding(_, canonical_id, ..) = pat.kind {
debug!(
"walk_pat: binding cmt_pat={:?} pat={:?} match_mode={:?}",
cmt_pat,
@ -885,7 +885,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, match_mode: Mat
// to the above loop's visit of than the bindings that form
// the leaves of the pattern tree structure.
return_if_err!(mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| {
let qpath = match pat.node {
let qpath = match pat.kind {
PatKind::Path(ref qpath) |
PatKind::TupleStruct(ref qpath, ..) |
PatKind::Struct(ref qpath, ..) => qpath,

View File

@ -372,7 +372,7 @@ fn visit_fn<'tcx>(
let body = ir.tcx.hir().body(body_id);
for param in &body.params {
let is_shorthand = match param.pat.node {
let is_shorthand = match param.pat.kind {
crate::hir::PatKind::Struct(..) => true,
_ => false,
};
@ -412,7 +412,7 @@ fn add_from_pat(ir: &mut IrMaps<'_>, pat: &P<hir::Pat>) {
pats.push_back(pat);
while let Some(pat) = pats.pop_front() {
use crate::hir::PatKind::*;
match &pat.node {
match &pat.kind {
Binding(.., inner_pat) => {
pats.extend(inner_pat.iter());
}

View File

@ -271,7 +271,7 @@ fn from_local(
id: hir::HirId,
) -> MutabilityCategory {
let ret = match tcx.hir().get(id) {
Node::Binding(p) => match p.node {
Node::Binding(p) => match p.kind {
PatKind::Binding(..) => {
let bm = *tables.pat_binding_modes()
.get(p.hir_id)
@ -486,7 +486,7 @@ fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
// This code detects whether we are looking at a `ref x`,
// and if so, figures out what the type *being borrowed* is.
let ret_ty = match pat.node {
let ret_ty = match pat.kind {
PatKind::Binding(..) => {
let bm = *self.tables
.pat_binding_modes()
@ -1212,7 +1212,7 @@ fn cat_pattern_<F>(&self, mut cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F) -> McR
// that (where the `ref` on `x` is implied).
op(cmt.clone(), pat);
match pat.node {
match pat.kind {
PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => {
let res = self.tables.qpath_res(qpath, pat.hir_id);
let (cmt, expected_len) = match res {

View File

@ -850,7 +850,7 @@ fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir
visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node });
// If this is a binding then record the lifetime of that binding.
if let PatKind::Binding(..) = pat.node {
if let PatKind::Binding(..) = pat.kind {
record_var_lifetime(visitor, pat.hir_id.local_id, pat.span);
}
@ -1198,7 +1198,7 @@ fn is_binding_pat(pat: &hir::Pat) -> bool {
// In the former case (the implicit ref version), the temporary is created by the
// & expression, and its lifetime would be extended to the end of the block (due
// to a different rule, not the below code).
match pat.node {
match pat.kind {
PatKind::Binding(hir::BindingAnnotation::Ref, ..) |
PatKind::Binding(hir::BindingAnnotation::RefMut, ..) => true,

View File

@ -1010,7 +1010,7 @@ fn suggest_fn_call(
"{}({})",
ident,
body.params.iter()
.map(|arg| match &arg.pat.node {
.map(|arg| match &arg.pat.kind {
hir::PatKind::Binding(_, _, ident, None)
if ident.name != kw::SelfLower => ident.to_string(),
_ => "_".to_string(),
@ -1141,7 +1141,7 @@ pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec<ArgKind>) {
self.tcx.hir().body(id).params.iter()
.map(|arg| {
if let hir::Pat {
node: hir::PatKind::Tuple(ref args, _),
kind: hir::PatKind::Tuple(ref args, _),
span,
..
} = *arg.pat {

View File

@ -114,7 +114,7 @@ fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
}
fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
match pat.node {
match pat.kind {
PatKind::Binding(.., None) |
PatKind::Path(_) |
PatKind::Lit(..) |

View File

@ -159,7 +159,7 @@ fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) {
if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.node {
if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.kind {
let variant = cx.tables.pat_ty(pat).ty_adt_def()
.expect("struct pattern type is not an ADT")
.variant_of_res(cx.tables.qpath_res(qpath, pat.hir_id));
@ -173,7 +173,7 @@ fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) {
// (Issue #49588)
continue;
}
if let PatKind::Binding(_, _, ident, None) = fieldpat.pat.node {
if let PatKind::Binding(_, _, ident, None) = fieldpat.pat.kind {
if cx.tcx.find_field_index(ident, &variant) ==
Some(cx.tcx.field_index(fieldpat.hir_id, cx.tables)) {
let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS,
@ -614,7 +614,7 @@ fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::TraitItem) {
match it.node {
ast::TraitItemKind::Method(ref sig, _) => {
for arg in sig.decl.inputs.iter() {
match arg.pat.node {
match arg.pat.kind {
ast::PatKind::Ident(_, ident, None) => {
if ident.name == kw::Invalid {
let ty_snip = cx
@ -1321,7 +1321,7 @@ fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat) {
/// If `pat` is a `...` pattern, return the start and end of the range, as well as the span
/// corresponding to the ellipsis.
fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(&P<Expr>, &P<Expr>, Span)> {
match &pat.node {
match &pat.kind {
PatKind::Range(a, b, Spanned { span, node: RangeEnd::Included(DotDotDot), .. }) => {
Some((a, b, *span))
}
@ -1329,7 +1329,7 @@ fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(&P<Expr>, &P<Expr>, Span)> {
}
}
let (parenthesise, endpoints) = match &pat.node {
let (parenthesise, endpoints) = match &pat.kind {
PatKind::Ref(subpat, _) => (true, matches_ellipsis_pat(&subpat)),
_ => (false, matches_ellipsis_pat(pat)),
};

View File

@ -341,7 +341,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem)
}
fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) {
if let &PatKind::Binding(_, _, ident, _) = &p.node {
if let &PatKind::Binding(_, _, ident, _) = &p.kind {
self.check_snake_case(cx, "variable", &ident);
}
}
@ -412,7 +412,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, ii: &hir::ImplItem) {
fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) {
// Lint for constants that look like binding identifiers (#7526)
if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.node {
if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.kind {
if let Res::Def(DefKind::Const, _) = path.res {
if path.segments.len() == 1 {
NonUpperCaseGlobals::check_upper_case(

View File

@ -416,8 +416,8 @@ fn check_unused_parens_pat(
) {
use ast::{PatKind, BindingMode::ByValue, Mutability::Mutable};
if let PatKind::Paren(inner) = &value.node {
match inner.node {
if let PatKind::Paren(inner) = &value.kind {
match inner.kind {
// The lint visitor will visit each subpattern of `p`. We do not want to lint
// any range pattern no matter where it occurs in the pattern. For something like
// `&(a..=b)`, there is a recursive `check_pat` on `a` and `b`, but we will assume
@ -566,7 +566,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
fn check_pat(&mut self, cx: &EarlyContext<'_>, p: &ast::Pat) {
use ast::{PatKind::*, Mutability};
match &p.node {
match &p.kind {
// Do not lint on `(..)` as that will result in the other arms being useless.
Paren(_)
// The other cases do not contain sub-patterns.

View File

@ -1047,7 +1047,7 @@ fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId)
self.tcx.dep_graph.with_ignore(|| {
let body = self.tcx.hir().body(body_id);
self.lazy(body.params.iter().map(|arg| {
match arg.pat.node {
match arg.pat.kind {
PatKind::Binding(_, _, ident, _) => ident.name,
_ => kw::Invalid,
}

View File

@ -338,7 +338,7 @@ pub(super) fn report_mutability_error(
_,
upvar_ident,
_,
) = pat.node
) = pat.kind
{
err.span_suggestion(
upvar_ident.span,

View File

@ -559,7 +559,7 @@ fn construct_fn<'a, 'tcx, A>(
};
let mut mutability = Mutability::Not;
if let Some(Node::Binding(pat)) = tcx_hir.find(var_hir_id) {
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
debuginfo.debug_name = ident.name;
if let Some(&bm) = hir.tables.pat_binding_modes().get(pat.hir_id) {
if bm == ty::BindByValue(hir::MutMutable) {

View File

@ -270,7 +270,7 @@ fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
"refutable pattern in {}: {} not covered",
origin, joined_patterns
);
err.span_label(pat.span, match &pat.node {
err.span_label(pat.span, match &pat.kind {
PatKind::Path(hir::QPath::Resolved(None, path))
if path.segments.len() == 1 && path.segments[0].args.is_none() => {
format!("interpreted as {} {} pattern, not new variable",
@ -286,7 +286,7 @@ fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pat) {
pat.walk(|p| {
if let PatKind::Binding(_, _, ident, None) = p.node {
if let PatKind::Binding(_, _, ident, None) = p.kind {
if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) {
if bm != ty::BindByValue(hir::MutImmutable) {
// Nothing to check.
@ -321,7 +321,7 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa
/// Checks for common cases of "catchall" patterns that may not be intended as such.
fn pat_is_catchall(pat: &Pat) -> bool {
match pat.node {
match pat.kind {
PatKind::Binding(.., None) => true,
PatKind::Binding(.., Some(ref s)) => pat_is_catchall(s),
PatKind::Ref(ref s, _) => pat_is_catchall(s),
@ -568,7 +568,7 @@ fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: boo
};
pat.walk(|p| {
if let PatKind::Binding(.., sub) = &p.node {
if let PatKind::Binding(.., sub) = &p.kind {
if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) {
if let ty::BindByValue(..) = bm {
let pat_ty = cx.tables.node_type(p.hir_id);
@ -618,7 +618,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
}
fn visit_pat(&mut self, pat: &Pat) {
match pat.node {
match pat.kind {
PatKind::Binding(.., ref subpat) => {
if !self.bindings_allowed {
struct_span_err!(self.cx.tcx.sess, pat.span, E0303,

View File

@ -449,7 +449,7 @@ fn lower_range_expr(
fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {
let mut ty = self.tables.node_type(pat.hir_id);
let kind = match pat.node {
let kind = match pat.kind {
PatKind::Wild => PatternKind::Wild,
PatKind::Lit(ref value) => self.lower_lit(value),

View File

@ -200,7 +200,7 @@ fn aggregate_field_path_elem(
if let Some((&var_hir_id, _)) = upvars.get_index(field) {
let node = self.ecx.tcx.hir().get(var_hir_id);
if let hir::Node::Binding(pat) = node {
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
name = Some(ident.name);
}
}

View File

@ -231,7 +231,7 @@ fn invalid_visibility(&self, vis: &Visibility, note: Option<&str>) {
fn check_decl_no_pat<ReportFn: Fn(Span, bool)>(&self, decl: &FnDecl, report_err: ReportFn) {
for arg in &decl.inputs {
match arg.pat.node {
match arg.pat.kind {
PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), _, None) |
PatKind::Wild => {}
PatKind::Ident(BindingMode::ByValue(Mutability::Mutable), _, None) =>
@ -786,7 +786,7 @@ fn visit_generic_param(&mut self, param: &'a GenericParam) {
}
fn visit_pat(&mut self, pat: &'a Pat) {
match pat.node {
match pat.kind {
PatKind::Lit(ref expr) => {
self.check_expr_within_pat(expr, false);
}

View File

@ -1062,7 +1062,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
}
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
match pat.node {
match pat.kind {
PatKind::Struct(ref qpath, ref fields, _) => {
let res = self.tables.qpath_res(qpath, pat.hir_id);
let adt = self.tables.pat_ty(pat).ty_adt_def().unwrap();

View File

@ -1134,7 +1134,7 @@ fn $visit(&mut self, node: &'b $ty) {
impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item, node);
method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr, kind);
method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, node);
method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, kind);
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty, node);
fn visit_item(&mut self, item: &'b Item) {

View File

@ -1146,7 +1146,7 @@ fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap {
let mut binding_map = FxHashMap::default();
pat.walk(&mut |pat| {
match pat.node {
match pat.kind {
PatKind::Ident(binding_mode, ident, ref sub_pat)
if sub_pat.is_some() || self.is_base_res_local(pat.id) =>
{
@ -1246,7 +1246,7 @@ fn check_consistent_bindings(&mut self, pats: &[P<Pat>]) -> Vec<BindingMap> {
/// Check the consistency of the outermost or-patterns.
fn check_consistent_bindings_top(&mut self, pat: &Pat) {
pat.walk(&mut |pat| match pat.node {
pat.walk(&mut |pat| match pat.kind {
PatKind::Or(ref ps) => {
self.check_consistent_bindings(ps);
false
@ -1308,8 +1308,8 @@ fn resolve_pattern_inner(
) {
// Visit all direct subpatterns of this pattern.
pat.walk(&mut |pat| {
debug!("resolve_pattern pat={:?} node={:?}", pat, pat.node);
match pat.node {
debug!("resolve_pattern pat={:?} node={:?}", pat, pat.kind);
match pat.kind {
PatKind::Ident(bmode, ident, ref sub) => {
// First try to resolve the identifier as some existing entity,
// then fall back to a fresh binding.

View File

@ -864,7 +864,7 @@ fn process_method_call(
}
fn process_pat(&mut self, p: &'l ast::Pat) {
match p.node {
match p.kind {
PatKind::Struct(ref _path, ref fields, _) => {
// FIXME do something with _path?
let hir_id = self.tcx.hir().node_to_hir_id(p.id);

View File

@ -640,15 +640,15 @@ pub fn get_path_res(&self, id: NodeId) -> Res {
..
}) |
Node::Pat(&hir::Pat {
node: hir::PatKind::Path(ref qpath),
kind: hir::PatKind::Path(ref qpath),
..
}) |
Node::Pat(&hir::Pat {
node: hir::PatKind::Struct(ref qpath, ..),
kind: hir::PatKind::Struct(ref qpath, ..),
..
}) |
Node::Pat(&hir::Pat {
node: hir::PatKind::TupleStruct(ref qpath, ..),
kind: hir::PatKind::TupleStruct(ref qpath, ..),
..
}) |
Node::Ty(&hir::Ty {
@ -659,7 +659,7 @@ pub fn get_path_res(&self, id: NodeId) -> Res {
}
Node::Binding(&hir::Pat {
node: hir::PatKind::Binding(_, canonical_id, ..),
kind: hir::PatKind::Binding(_, canonical_id, ..),
..
}) => Res::Local(canonical_id),
@ -965,7 +965,7 @@ fn new() -> PathCollector<'l> {
impl<'l> Visitor<'l> for PathCollector<'l> {
fn visit_pat(&mut self, p: &'l ast::Pat) {
match p.node {
match p.kind {
PatKind::Struct(ref path, ..) => {
self.collected_paths.push((p.id, path));
}

View File

@ -167,7 +167,7 @@ fn visit_pat(&mut self, pat: &'tcx Pat) {
self.expr_count += 1;
if let PatKind::Binding(..) = pat.node {
if let PatKind::Binding(..) = pat.kind {
let scope = self.region_scope_tree.var_scope(pat.hir_id.local_id);
let ty = self.fcx.tables.borrow().pat_ty(pat);
self.record(ty, Some(scope), None, pat.span);

View File

@ -1032,7 +1032,7 @@ fn visit_local(&mut self, local: &'tcx hir::Local) {
// Add pattern bindings.
fn visit_pat(&mut self, p: &'tcx hir::Pat) {
if let PatKind::Binding(_, _, ident, _) = p.node {
if let PatKind::Binding(_, _, ident, _) = p.kind {
let var_ty = self.assign(p.span, p.hir_id, None);
if !self.fcx.tcx.features().unsized_locals {
@ -4205,7 +4205,7 @@ fn suggest_fn_call(
})) => {
let body = hir.body(*body_id);
sugg_call = body.params.iter()
.map(|param| match &param.pat.node {
.map(|param| match &param.pat.kind {
hir::PatKind::Binding(_, _, ident, None)
if ident.name != kw::SelfLower => ident.to_string(),
_ => "_".to_string(),
@ -4223,7 +4223,7 @@ fn suggest_fn_call(
msg = "call this closure";
let body = hir.body(*body_id);
sugg_call = body.params.iter()
.map(|param| match &param.pat.node {
.map(|param| match &param.pat.kind {
hir::PatKind::Binding(_, _, ident, None)
if ident.name != kw::SelfLower => ident.to_string(),
_ => "_".to_string(),

View File

@ -59,14 +59,14 @@ fn check_pat(
) {
debug!("check_pat(pat={:?},expected={:?},def_bm={:?})", pat, expected, def_bm);
let path_resolution = match &pat.node {
let path_resolution = match &pat.kind {
PatKind::Path(qpath) => Some(self.resolve_ty_and_res_ufcs(qpath, pat.hir_id, pat.span)),
_ => None,
};
let is_nrp = self.is_non_ref_pat(pat, path_resolution.map(|(res, ..)| res));
let (expected, def_bm) = self.calc_default_binding_mode(pat, expected, def_bm, is_nrp);
let ty = match &pat.node {
let ty = match &pat.kind {
PatKind::Wild => expected,
PatKind::Lit(lt) => self.check_pat_lit(pat.span, lt, expected, discrim_span),
PatKind::Range(begin, end, _) => {
@ -193,7 +193,7 @@ fn calc_default_binding_mode(
// ```
//
// See issue #46688.
let def_bm = match pat.node {
let def_bm = match pat.kind {
PatKind::Ref(..) => ty::BindByValue(hir::MutImmutable),
_ => def_bm,
};
@ -204,7 +204,7 @@ fn calc_default_binding_mode(
/// Is the pattern a "non reference pattern"?
/// When the pattern is a path pattern, `opt_path_res` must be `Some(res)`.
fn is_non_ref_pat(&self, pat: &'tcx Pat, opt_path_res: Option<Res>) -> bool {
match pat.node {
match pat.kind {
PatKind::Struct(..) |
PatKind::TupleStruct(..) |
PatKind::Tuple(..) |
@ -472,7 +472,7 @@ fn borrow_pat_suggestion(
expected: Ty<'tcx>,
) {
let tcx = self.tcx;
if let PatKind::Binding(..) = inner.node {
if let PatKind::Binding(..) = inner.kind {
let binding_parent_id = tcx.hir().get_parent_node(pat.hir_id);
let binding_parent = tcx.hir().get(binding_parent_id);
debug!("inner {:?} pat {:?} parent {:?}", inner, pat, binding_parent);
@ -505,7 +505,7 @@ fn borrow_pat_suggestion(
}
pub fn check_dereferencable(&self, span: Span, expected: Ty<'tcx>, inner: &Pat) -> bool {
if let PatKind::Binding(..) = inner.node {
if let PatKind::Binding(..) = inner.kind {
if let Some(mt) = self.shallow_resolve(expected).builtin_deref(true) {
if let ty::Dynamic(..) = mt.ty.kind {
// This is "x = SomeTrait" being reduced from
@ -617,7 +617,7 @@ fn check_pat_tuple_struct(
res.descr(),
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
let mut err = struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg);
match (res, &pat.node) {
match (res, &pat.kind) {
(Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::Method, _), _) => {
err.span_label(pat.span, "`fn` calls are not allowed in patterns");
err.help("for more information, visit \

View File

@ -1097,7 +1097,7 @@ fn link_pattern(&self, discr_cmt: mc::cmt<'tcx>, root_pat: &hir::Pat) {
ignore_err!(self.with_mc(|mc| {
mc.cat_pattern(discr_cmt, root_pat, |sub_cmt, sub_pat| {
// `ref x` pattern
if let PatKind::Binding(..) = sub_pat.node {
if let PatKind::Binding(..) = sub_pat.kind {
if let Some(&bm) = mc.tables.pat_binding_modes().get(sub_pat.hir_id) {
if let ty::BindByReference(mutbl) = bm {
self.link_region_from_node_type(

View File

@ -270,7 +270,7 @@ fn visit_block(&mut self, b: &'tcx hir::Block) {
}
fn visit_pat(&mut self, p: &'tcx hir::Pat) {
match p.node {
match p.kind {
hir::PatKind::Binding(..) => {
if let Some(&bm) = self.fcx.tables.borrow().pat_binding_modes().get(p.hir_id) {
self.tables.pat_binding_modes_mut().insert(p.hir_id, bm);

View File

@ -4182,7 +4182,7 @@ fn name_from_pat(p: &hir::Pat) -> String {
use rustc::hir::*;
debug!("trying to get a name from pattern: {:?}", p);
match p.node {
match p.kind {
PatKind::Wild => "_".to_string(),
PatKind::Binding(_, _, ident, _) => ident.to_string(),
PatKind::TupleStruct(ref p, ..) | PatKind::Path(ref p) => qpath_to_string(p),

View File

@ -511,7 +511,7 @@ pub struct Block {
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Pat {
pub id: NodeId,
pub node: PatKind,
pub kind: PatKind,
pub span: Span,
}
@ -525,7 +525,7 @@ impl Pat {
/// Attempt reparsing the pattern as a type.
/// This is intended for use by diagnostics.
pub(super) fn to_ty(&self) -> Option<P<Ty>> {
let node = match &self.node {
let node = match &self.kind {
// In a type expression `_` is an inference variable.
PatKind::Wild => TyKind::Infer,
// An IDENT pattern with no binding mode would be valid as path to a type. E.g. `u32`.
@ -569,7 +569,7 @@ pub fn walk(&self, it: &mut impl FnMut(&Pat) -> bool) {
return;
}
match &self.node {
match &self.kind {
PatKind::Ident(_, _, Some(p)) => p.walk(it),
PatKind::Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk(it)),
PatKind::TupleStruct(_, s)
@ -591,7 +591,7 @@ pub fn walk(&self, it: &mut impl FnMut(&Pat) -> bool) {
/// Is this a `..` pattern?
pub fn is_rest(&self) -> bool {
match self.node {
match self.kind {
PatKind::Rest => true,
_ => false,
}
@ -1821,7 +1821,7 @@ pub enum SelfKind {
impl Param {
pub fn to_self(&self) -> Option<ExplicitSelf> {
if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.node {
if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.kind {
if ident.name == kw::SelfLower {
return match self.ty.node {
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
@ -1839,7 +1839,7 @@ pub fn to_self(&self) -> Option<ExplicitSelf> {
}
pub fn is_self(&self) -> bool {
if let PatKind::Ident(_, ident, _) = self.pat.node {
if let PatKind::Ident(_, ident, _) = self.pat.kind {
ident.name == kw::SelfLower
} else {
false
@ -1857,7 +1857,7 @@ pub fn from_self(attrs: ThinVec<Attribute>, eself: ExplicitSelf, eself_ident: Id
attrs,
pat: P(Pat {
id: DUMMY_NODE_ID,
node: PatKind::Ident(BindingMode::ByValue(mutbl), eself_ident, None),
kind: PatKind::Ident(BindingMode::ByValue(mutbl), eself_ident, None),
span,
}),
span,

View File

@ -298,7 +298,7 @@ pub fn configure_expr(&mut self, expr: &mut P<ast::Expr>) {
}
pub fn configure_pat(&mut self, pat: &mut P<ast::Pat>) {
if let ast::PatKind::Struct(_path, fields, _etc) = &mut pat.node {
if let ast::PatKind::Struct(_path, fields, _etc) = &mut pat.kind {
fields.flat_map_in_place(|field| self.configure(field));
}
}

View File

@ -511,7 +511,7 @@ fn make_pat(self: Box<Self>) -> Option<P<ast::Pat>> {
return Some(P(ast::Pat {
id: ast::DUMMY_NODE_ID,
span: e.span,
node: PatKind::Lit(e),
kind: PatKind::Lit(e),
}));
}
}
@ -559,7 +559,7 @@ pub fn raw_expr(sp: Span, is_error: bool) -> P<ast::Expr> {
pub fn raw_pat(sp: Span) -> ast::Pat {
ast::Pat {
id: ast::DUMMY_NODE_ID,
node: PatKind::Wild,
kind: PatKind::Wild,
span: sp,
}
}

View File

@ -411,8 +411,8 @@ pub fn expr_try(&self, sp: Span, head: P<ast::Expr>) -> P<ast::Expr> {
}
pub fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat> {
P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span })
pub fn pat(&self, span: Span, kind: PatKind) -> P<ast::Pat> {
P(ast::Pat { id: ast::DUMMY_NODE_ID, kind, span })
}
pub fn pat_wild(&self, span: Span) -> P<ast::Pat> {
self.pat(span, PatKind::Wild)

View File

@ -1172,13 +1172,13 @@ fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
self.cfg.configure_pat(pat);
match pat.node {
match pat.kind {
PatKind::Mac(_) => {}
_ => return noop_visit_pat(pat, self),
}
visit_clobber(pat, |mut pat| {
match mem::replace(&mut pat.node, PatKind::Wild) {
match mem::replace(&mut pat.kind, PatKind::Wild) {
PatKind::Mac(mac) =>
self.collect_bang(mac, pat.span, AstFragmentKind::Pat).make_pat(),
_ => unreachable!(),

View File

@ -39,7 +39,7 @@ fn mac_placeholder() -> ast::Mac {
});
let pat = P(ast::Pat {
id,
node: ast::PatKind::Mac(mac_placeholder()),
kind: ast::PatKind::Mac(mac_placeholder()),
span,
});
@ -68,7 +68,7 @@ fn mac_placeholder() -> ast::Mac {
node: ast::ForeignItemKind::Macro(mac_placeholder()),
}]),
AstFragmentKind::Pat => AstFragment::Pat(P(ast::Pat {
id, span, node: ast::PatKind::Mac(mac_placeholder()),
id, span, kind: ast::PatKind::Mac(mac_placeholder()),
})),
AstFragmentKind::Ty => AstFragment::Ty(P(ast::Ty {
id, span, node: ast::TyKind::Mac(mac_placeholder()),
@ -311,7 +311,7 @@ fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
}
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
match pat.node {
match pat.kind {
ast::PatKind::Mac(_) => *pat = self.remove(pat.id).make_pat(),
_ => noop_visit_pat(pat, self),
}

View File

@ -487,11 +487,11 @@ fn visit_arm(&mut self, arm: &'a ast::Arm) {
}
fn visit_pat(&mut self, pattern: &'a ast::Pat) {
match &pattern.node {
match &pattern.kind {
PatKind::Slice(pats) => {
for pat in &*pats {
let span = pat.span;
let inner_pat = match &pat.node {
let inner_pat = match &pat.kind {
PatKind::Ident(.., Some(pat)) => pat,
_ => pat,
};

View File

@ -1055,9 +1055,9 @@ pub fn noop_flat_map_foreign_item<T: MutVisitor>(mut item: ForeignItem, visitor:
}
pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
let Pat { id, node, span } = pat.deref_mut();
let Pat { id, kind, span } = pat.deref_mut();
vis.visit_id(id);
match node {
match kind {
PatKind::Wild | PatKind::Rest => {}
PatKind::Ident(_binding_mode, ident, sub) => {
vis.visit_ident(ident);

View File

@ -21,7 +21,7 @@
crate fn dummy_arg(ident: Ident) -> Param {
let pat = P(Pat {
id: ast::DUMMY_NODE_ID,
node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None),
kind: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None),
span: ident.span,
});
let ty = Ty {
@ -148,7 +148,7 @@ fn to_ty(&self) -> Option<P<Ty>> {
fn recovered(qself: Option<QSelf>, path: ast::Path) -> Self {
Self {
span: path.span,
node: PatKind::Path(qself, path),
kind: PatKind::Path(qself, path),
id: ast::DUMMY_NODE_ID,
}
}
@ -978,7 +978,7 @@ fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question:
.emit();
// Unwrap `(pat)` into `pat` to avoid the `unused_parens` lint.
pat.and_then(|pat| match pat.node {
pat.and_then(|pat| match pat.kind {
PatKind::Paren(pat) => pat,
_ => P(pat),
})
@ -1237,7 +1237,7 @@ fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question:
Applicability::HasPlaceholders,
);
return Some(ident);
} else if let PatKind::Ident(_, ident, _) = pat.node {
} else if let PatKind::Ident(_, ident, _) = pat.kind {
if require_name && (
is_trait_item ||
self.token == token::Comma ||
@ -1283,7 +1283,7 @@ fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question:
// Pretend the pattern is `_`, to avoid duplicate errors from AST validation.
let pat = P(Pat {
node: PatKind::Wild,
kind: PatKind::Wild,
span: pat.span,
id: ast::DUMMY_NODE_ID
});
@ -1360,7 +1360,7 @@ fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question:
let mut seen_inputs = FxHashSet::default();
for input in fn_inputs.iter_mut() {
let opt_ident = if let (PatKind::Ident(_, ident, _), TyKind::Err) = (
&input.pat.node, &input.ty.node,
&input.pat.kind, &input.ty.node,
) {
Some(*ident)
} else {
@ -1368,7 +1368,7 @@ fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question:
};
if let Some(ident) = opt_ident {
if seen_inputs.contains(&ident) {
input.pat.node = PatKind::Wild;
input.pat.kind = PatKind::Wild;
}
seen_inputs.insert(ident);
}

View File

@ -66,7 +66,7 @@ pub(super) fn parse_fn_param_pat(&mut self) -> PResult<'a, P<Pat>> {
self.recover_leading_vert("not allowed in a parameter pattern");
let pat = self.parse_pat_with_or(PARAM_EXPECTED, GateOr::No, RecoverComma::No)?;
if let PatKind::Or(..) = &pat.node {
if let PatKind::Or(..) = &pat.kind {
self.ban_illegal_fn_param_or_pat(&pat);
}
@ -324,7 +324,7 @@ fn parse_pat_with_range_pat(
/// Ban a range pattern if it has an ambiguous interpretation.
fn ban_pat_range_if_ambiguous(&self, pat: &Pat) -> PResult<'a, ()> {
match pat.node {
match pat.kind {
PatKind::Range(
.., Spanned { node: RangeEnd::Included(RangeSyntax::DotDotDot), .. }
) => return Ok(()),
@ -399,12 +399,12 @@ fn parse_pat_ident_mut(&mut self) -> PResult<'a, PatKind> {
// Unwrap; If we don't have `mut $ident`, error.
let pat = pat.into_inner();
match &pat.node {
match &pat.kind {
PatKind::Ident(..) => {}
_ => self.ban_mut_general_pat(mut_span, &pat, changed_any_binding),
}
Ok(pat.node)
Ok(pat.kind)
}
/// Recover on `mut ref? ident @ pat` and suggest
@ -430,7 +430,7 @@ fn make_all_value_bindings_mutable(pat: &mut P<Pat>) -> bool {
impl MutVisitor for AddMut {
fn visit_pat(&mut self, pat: &mut P<Pat>) {
if let PatKind::Ident(BindingMode::ByValue(ref mut m @ Mutability::Immutable), ..)
= pat.node
= pat.kind
{
*m = Mutability::Mutable;
self.0 = true;
@ -890,7 +890,7 @@ pub(super) fn mk_pat_ident(&self, span: Span, bm: BindingMode, ident: Ident) ->
self.mk_pat(span, PatKind::Ident(bm, ident, None))
}
fn mk_pat(&self, span: Span, node: PatKind) -> P<Pat> {
P(Pat { node, span, id: ast::DUMMY_NODE_ID })
fn mk_pat(&self, span: Span, kind: PatKind) -> P<Pat> {
P(Pat { kind, span, id: ast::DUMMY_NODE_ID })
}
}

View File

@ -171,7 +171,7 @@ struct PatIdentVisitor {
}
impl<'a> crate::visit::Visitor<'a> for PatIdentVisitor {
fn visit_pat(&mut self, p: &'a ast::Pat) {
match p.node {
match p.kind {
PatKind::Ident(_ , ref ident, _) => {
self.spans.push(ident.span.clone());
}

View File

@ -2353,7 +2353,7 @@ fn print_qpath(&mut self,
self.ann.pre(self, AnnNode::Pat(pat));
/* Pat isn't normalized, but the beauty of it
is that it doesn't matter */
match pat.node {
match pat.kind {
PatKind::Wild => self.s.word("_"),
PatKind::Ident(binding_mode, ident, ref sub) => {
match binding_mode {
@ -2766,7 +2766,7 @@ fn print_explicit_self(&mut self, explicit_self: &ast::ExplicitSelf) {
if let Some(eself) = input.to_self() {
self.print_explicit_self(&eself);
} else {
let invalid = if let PatKind::Ident(_, ident, _) = input.pat.node {
let invalid = if let PatKind::Ident(_, ident, _) = input.pat.kind {
ident.name == kw::Invalid
} else {
false

View File

@ -443,7 +443,7 @@ pub fn walk_assoc_ty_constraint<'a, V: Visitor<'a>>(visitor: &mut V,
}
pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
match pattern.node {
match pattern.kind {
PatKind::TupleStruct(ref path, ref elems) => {
visitor.visit_path(path, pattern.id);
walk_list!(visitor, visit_pat, elems);

View File

@ -154,7 +154,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
19 => {
let pat = P(Pat {
id: DUMMY_NODE_ID,
node: PatKind::Wild,
kind: PatKind::Wild,
span: DUMMY_SP,
});
iter_exprs(depth - 1, &mut |e| g(ExprKind::Let(pat.clone(), e)))