Skip to content

Commit 14adc9b

Browse files
committed
Rename ast::Pat_ and its variants
1 parent 5801991 commit 14adc9b

File tree

16 files changed

+145
-145
lines changed

16 files changed

+145
-145
lines changed

src/librustc_front/lowering.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -913,26 +913,26 @@ pub fn lower_pat(lctx: &LoweringContext, p: &Pat) -> P<hir::Pat> {
913913
P(hir::Pat {
914914
id: p.id,
915915
node: match p.node {
916-
PatWild => hir::PatWild,
917-
PatIdent(ref binding_mode, pth1, ref sub) => {
916+
PatKind::Wild => hir::PatWild,
917+
PatKind::Ident(ref binding_mode, pth1, ref sub) => {
918918
hir::PatIdent(lower_binding_mode(lctx, binding_mode),
919919
respan(pth1.span, lower_ident(lctx, pth1.node)),
920920
sub.as_ref().map(|x| lower_pat(lctx, x)))
921921
}
922-
PatLit(ref e) => hir::PatLit(lower_expr(lctx, e)),
923-
PatEnum(ref pth, ref pats) => {
922+
PatKind::Lit(ref e) => hir::PatLit(lower_expr(lctx, e)),
923+
PatKind::Enum(ref pth, ref pats) => {
924924
hir::PatEnum(lower_path(lctx, pth),
925925
pats.as_ref()
926926
.map(|pats| pats.iter().map(|x| lower_pat(lctx, x)).collect()))
927927
}
928-
PatQPath(ref qself, ref pth) => {
928+
PatKind::QPath(ref qself, ref pth) => {
929929
let qself = hir::QSelf {
930930
ty: lower_ty(lctx, &qself.ty),
931931
position: qself.position,
932932
};
933933
hir::PatQPath(qself, lower_path(lctx, pth))
934934
}
935-
PatStruct(ref pth, ref fields, etc) => {
935+
PatKind::Struct(ref pth, ref fields, etc) => {
936936
let pth = lower_path(lctx, pth);
937937
let fs = fields.iter()
938938
.map(|f| {
@@ -948,20 +948,22 @@ pub fn lower_pat(lctx: &LoweringContext, p: &Pat) -> P<hir::Pat> {
948948
.collect();
949949
hir::PatStruct(pth, fs, etc)
950950
}
951-
PatTup(ref elts) => hir::PatTup(elts.iter().map(|x| lower_pat(lctx, x)).collect()),
952-
PatBox(ref inner) => hir::PatBox(lower_pat(lctx, inner)),
953-
PatRegion(ref inner, mutbl) => {
951+
PatKind::Tup(ref elts) => {
952+
hir::PatTup(elts.iter().map(|x| lower_pat(lctx, x)).collect())
953+
}
954+
PatKind::Box(ref inner) => hir::PatBox(lower_pat(lctx, inner)),
955+
PatKind::Ref(ref inner, mutbl) => {
954956
hir::PatRegion(lower_pat(lctx, inner), lower_mutability(lctx, mutbl))
955957
}
956-
PatRange(ref e1, ref e2) => {
958+
PatKind::Range(ref e1, ref e2) => {
957959
hir::PatRange(lower_expr(lctx, e1), lower_expr(lctx, e2))
958960
}
959-
PatVec(ref before, ref slice, ref after) => {
961+
PatKind::Vec(ref before, ref slice, ref after) => {
960962
hir::PatVec(before.iter().map(|x| lower_pat(lctx, x)).collect(),
961963
slice.as_ref().map(|x| lower_pat(lctx, x)),
962964
after.iter().map(|x| lower_pat(lctx, x)).collect())
963965
}
964-
PatMac(_) => panic!("Shouldn't exist here"),
966+
PatKind::Mac(_) => panic!("Shouldn't exist here"),
965967
},
966968
span: p.span,
967969
})

src/librustc_passes/const_fn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
use rustc::session::{Session, CompileResult};
1515

16-
use syntax::ast;
16+
use syntax::ast::{self, PatKind};
1717
use syntax::visit::{self, Visitor, FnKind};
1818
use syntax::codemap::Span;
1919

@@ -104,8 +104,8 @@ impl<'a, 'v> Visitor<'v> for CheckConstFn<'a> {
104104
// Ensure the arguments are simple, not mutable/by-ref or patterns.
105105
for arg in &fd.inputs {
106106
match arg.pat.node {
107-
ast::PatWild => {}
108-
ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {}
107+
PatKind::Wild => {}
108+
PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {}
109109
_ => {
110110
span_err!(self.sess, arg.pat.span, E0022,
111111
"arguments of constant functions can only \

src/librustc_trans/save/dump_csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use std::fs::File;
4040
use std::hash::*;
4141
use std::collections::HashSet;
4242

43-
use syntax::ast::{self, NodeId};
43+
use syntax::ast::{self, NodeId, PatKind};
4444
use syntax::codemap::*;
4545
use syntax::parse::token::{self, keywords};
4646
use syntax::visit::{self, Visitor};
@@ -780,7 +780,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
780780

781781
fn process_pat(&mut self, p: &ast::Pat) {
782782
match p.node {
783-
ast::PatStruct(ref path, ref fields, _) => {
783+
PatKind::Struct(ref path, ref fields, _) => {
784784
visit::walk_path(self, path);
785785
let adt = self.tcx.node_id_to_type(p.id).ty_adt_def().unwrap();
786786
let def = self.tcx.def_map.borrow()[&p.id].full_def();

src/librustc_trans/save/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_front::{hir, lowering};
2121
use rustc::front::map::NodeItem;
2222
use rustc::session::config::CrateType::CrateTypeExecutable;
2323

24-
use syntax::ast::{self, NodeId};
24+
use syntax::ast::{self, NodeId, PatKind};
2525
use syntax::ast_util;
2626
use syntax::codemap::*;
2727
use syntax::parse::token::{self, keywords};
@@ -758,16 +758,16 @@ impl PathCollector {
758758
impl<'v> Visitor<'v> for PathCollector {
759759
fn visit_pat(&mut self, p: &ast::Pat) {
760760
match p.node {
761-
ast::PatStruct(ref path, _, _) => {
761+
PatKind::Struct(ref path, _, _) => {
762762
self.collected_paths.push((p.id, path.clone(),
763763
ast::Mutability::Mutable, recorder::TypeRef));
764764
}
765-
ast::PatEnum(ref path, _) |
766-
ast::PatQPath(_, ref path) => {
765+
PatKind::Enum(ref path, _) |
766+
PatKind::QPath(_, ref path) => {
767767
self.collected_paths.push((p.id, path.clone(),
768768
ast::Mutability::Mutable, recorder::VarRef));
769769
}
770-
ast::PatIdent(bm, ref path1, _) => {
770+
PatKind::Ident(bm, ref path1, _) => {
771771
debug!("PathCollector, visit ident in pat {}: {:?} {:?}",
772772
path1.node,
773773
p.span,

src/libsyntax/ast.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// The Rust abstract syntax tree.
1212

13-
pub use self::Pat_::*;
1413
pub use self::StructFieldKind::*;
1514
pub use self::TyParamBound::*;
1615
pub use self::UnsafeSource::*;
@@ -521,7 +520,7 @@ pub struct Block {
521520
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
522521
pub struct Pat {
523522
pub id: NodeId,
524-
pub node: Pat_,
523+
pub node: PatKind,
525524
pub span: Span,
526525
}
527526

@@ -552,47 +551,47 @@ pub enum BindingMode {
552551
}
553552

554553
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
555-
pub enum Pat_ {
554+
pub enum PatKind {
556555
/// Represents a wildcard pattern (`_`)
557-
PatWild,
556+
Wild,
558557

559-
/// A PatIdent may either be a new bound variable,
558+
/// A PatKind::Ident may either be a new bound variable,
560559
/// or a nullary enum (in which case the third field
561560
/// is None).
562561
///
563562
/// In the nullary enum case, the parser can't determine
564563
/// which it is. The resolver determines this, and
565564
/// records this pattern's NodeId in an auxiliary
566565
/// set (of "PatIdents that refer to nullary enums")
567-
PatIdent(BindingMode, SpannedIdent, Option<P<Pat>>),
566+
Ident(BindingMode, SpannedIdent, Option<P<Pat>>),
568567

569568
/// "None" means a `Variant(..)` pattern where we don't bind the fields to names.
570-
PatEnum(Path, Option<Vec<P<Pat>>>),
569+
Enum(Path, Option<Vec<P<Pat>>>),
571570

572571
/// An associated const named using the qualified path `<T>::CONST` or
573572
/// `<T as Trait>::CONST`. Associated consts from inherent impls can be
574573
/// referred to as simply `T::CONST`, in which case they will end up as
575-
/// PatEnum, and the resolver will have to sort that out.
576-
PatQPath(QSelf, Path),
574+
/// PatKind::Enum, and the resolver will have to sort that out.
575+
QPath(QSelf, Path),
577576

578577
/// Destructuring of a struct, e.g. `Foo {x, y, ..}`
579578
/// The `bool` is `true` in the presence of a `..`
580-
PatStruct(Path, Vec<Spanned<FieldPat>>, bool),
579+
Struct(Path, Vec<Spanned<FieldPat>>, bool),
581580
/// A tuple pattern `(a, b)`
582-
PatTup(Vec<P<Pat>>),
581+
Tup(Vec<P<Pat>>),
583582
/// A `box` pattern
584-
PatBox(P<Pat>),
583+
Box(P<Pat>),
585584
/// A reference pattern, e.g. `&mut (a, b)`
586-
PatRegion(P<Pat>, Mutability),
585+
Ref(P<Pat>, Mutability),
587586
/// A literal
588-
PatLit(P<Expr>),
587+
Lit(P<Expr>),
589588
/// A range pattern, e.g. `1...2`
590-
PatRange(P<Expr>, P<Expr>),
589+
Range(P<Expr>, P<Expr>),
591590
/// `[a, b, ..i, y, z]` is represented as:
592-
/// `PatVec(box [a, b], Some(i), box [y, z])`
593-
PatVec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
591+
/// `PatKind::Vec(box [a, b], Some(i), box [y, z])`
592+
Vec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
594593
/// A macro pattern; pre-expansion
595-
PatMac(Mac),
594+
Mac(Mac),
596595
}
597596

598597
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
@@ -1609,7 +1608,7 @@ impl Arg {
16091608
}),
16101609
pat: P(Pat {
16111610
id: DUMMY_NODE_ID,
1612-
node: PatIdent(BindingMode::ByValue(mutability), path, None),
1611+
node: PatKind::Ident(BindingMode::ByValue(mutability), path, None),
16131612
span: span
16141613
}),
16151614
id: DUMMY_NODE_ID

src/libsyntax/ast_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P<Pat> {
6969
let spanned = codemap::Spanned{ span: s, node: i };
7070
P(Pat {
7171
id: id,
72-
node: PatIdent(BindingMode::ByValue(Mutability::Immutable), spanned, None),
72+
node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), spanned, None),
7373
span: s
7474
})
7575
}
@@ -348,7 +348,7 @@ pub fn compute_id_range_for_fn_body(fk: FnKind,
348348
/// and false otherwise.
349349
pub fn pat_is_ident(pat: P<ast::Pat>) -> bool {
350350
match pat.node {
351-
ast::PatIdent(..) => true,
351+
PatKind::Ident(..) => true,
352352
_ => false,
353353
}
354354
}

src/libsyntax/ext/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
pub use self::SyntaxExtension::*;
1212

1313
use ast;
14-
use ast::Name;
14+
use ast::{Name, PatKind};
1515
use codemap;
1616
use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION};
1717
use errors::DiagnosticBuilder;
@@ -307,7 +307,7 @@ impl MacResult for MacEager {
307307
return Some(P(ast::Pat {
308308
id: ast::DUMMY_NODE_ID,
309309
span: e.span,
310-
node: ast::PatLit(e),
310+
node: PatKind::Lit(e),
311311
}));
312312
}
313313
}
@@ -359,7 +359,7 @@ impl DummyResult {
359359
pub fn raw_pat(sp: Span) -> ast::Pat {
360360
ast::Pat {
361361
id: ast::DUMMY_NODE_ID,
362-
node: ast::PatWild,
362+
node: PatKind::Wild,
363363
span: sp,
364364
}
365365
}

src/libsyntax/ext/build.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use abi::Abi;
12-
use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp};
12+
use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind};
1313
use attr;
1414
use codemap::{Span, respan, Spanned, DUMMY_SP, Pos};
1515
use ext::base::ExtCtxt;
@@ -166,7 +166,7 @@ pub trait AstBuilder {
166166
fn expr_err(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
167167
fn expr_try(&self, span: Span, head: P<ast::Expr>) -> P<ast::Expr>;
168168

169-
fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat>;
169+
fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat>;
170170
fn pat_wild(&self, span: Span) -> P<ast::Pat>;
171171
fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat>;
172172
fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat>;
@@ -805,14 +805,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
805805
}
806806

807807

808-
fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat> {
808+
fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat> {
809809
P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span: span })
810810
}
811811
fn pat_wild(&self, span: Span) -> P<ast::Pat> {
812-
self.pat(span, ast::PatWild)
812+
self.pat(span, PatKind::Wild)
813813
}
814814
fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat> {
815-
self.pat(span, ast::PatLit(expr))
815+
self.pat(span, PatKind::Lit(expr))
816816
}
817817
fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> {
818818
let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Immutable);
@@ -823,20 +823,20 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
823823
span: Span,
824824
ident: ast::Ident,
825825
bm: ast::BindingMode) -> P<ast::Pat> {
826-
let pat = ast::PatIdent(bm, Spanned{span: span, node: ident}, None);
826+
let pat = PatKind::Ident(bm, Spanned{span: span, node: ident}, None);
827827
self.pat(span, pat)
828828
}
829829
fn pat_enum(&self, span: Span, path: ast::Path, subpats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
830-
let pat = ast::PatEnum(path, Some(subpats));
830+
let pat = PatKind::Enum(path, Some(subpats));
831831
self.pat(span, pat)
832832
}
833833
fn pat_struct(&self, span: Span,
834834
path: ast::Path, field_pats: Vec<Spanned<ast::FieldPat>>) -> P<ast::Pat> {
835-
let pat = ast::PatStruct(path, field_pats, false);
835+
let pat = PatKind::Struct(path, field_pats, false);
836836
self.pat(span, pat)
837837
}
838838
fn pat_tuple(&self, span: Span, pats: Vec<P<ast::Pat>>) -> P<ast::Pat> {
839-
self.pat(span, ast::PatTup(pats))
839+
self.pat(span, PatKind::Tup(pats))
840840
}
841841

842842
fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {

0 commit comments

Comments
 (0)