Skip to content

Commit 0d1cd9b

Browse files
committed
Auto merge of #31685 - petrochenkov:patrefact2, r=eddyb
And split `PatKind::Enum` into `PatKind::TupleStruct` and `PatKind::Path`. This is the HIR part of #31581. This is also kind of a preparation for rust-lang/rfcs#1492. r? @eddyb
2 parents 82f30d2 + 06755d9 commit 0d1cd9b

File tree

35 files changed

+416
-423
lines changed

35 files changed

+416
-423
lines changed

src/librustc/front/map/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
262262

263263
fn visit_pat(&mut self, pat: &'ast Pat) {
264264
let maybe_binding = match pat.node {
265-
PatIdent(_, id, _) => Some(id.node),
265+
PatKind::Ident(_, id, _) => Some(id.node),
266266
_ => None
267267
};
268268

src/librustc/front/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ impl<'ast> Map<'ast> {
615615
NodeVariant(v) => PathName(v.node.name),
616616
NodeLifetime(lt) => PathName(lt.name),
617617
NodeTyParam(tp) => PathName(tp.name),
618-
NodeLocal(&Pat { node: PatIdent(_,l,_), .. }) => {
618+
NodeLocal(&Pat { node: PatKind::Ident(_,l,_), .. }) => {
619619
PathName(l.node.name)
620620
},
621621
_ => panic!("no path elem for {:?}", node)

src/librustc/middle/cfg/construct.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use middle::ty;
1616
use syntax::ast;
1717
use syntax::ptr::P;
1818

19-
use rustc_front::hir;
19+
use rustc_front::hir::{self, PatKind};
2020

2121
struct CFGBuilder<'a, 'tcx: 'a> {
2222
tcx: &'a ty::ctxt<'tcx>,
@@ -99,35 +99,36 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
9999

100100
fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
101101
match pat.node {
102-
hir::PatIdent(_, _, None) |
103-
hir::PatEnum(_, None) |
104-
hir::PatQPath(..) |
105-
hir::PatLit(..) |
106-
hir::PatRange(..) |
107-
hir::PatWild => {
102+
PatKind::Ident(_, _, None) |
103+
PatKind::TupleStruct(_, None) |
104+
PatKind::Path(..) |
105+
PatKind::QPath(..) |
106+
PatKind::Lit(..) |
107+
PatKind::Range(..) |
108+
PatKind::Wild => {
108109
self.add_ast_node(pat.id, &[pred])
109110
}
110111

111-
hir::PatBox(ref subpat) |
112-
hir::PatRegion(ref subpat, _) |
113-
hir::PatIdent(_, _, Some(ref subpat)) => {
112+
PatKind::Box(ref subpat) |
113+
PatKind::Ref(ref subpat, _) |
114+
PatKind::Ident(_, _, Some(ref subpat)) => {
114115
let subpat_exit = self.pat(&subpat, pred);
115116
self.add_ast_node(pat.id, &[subpat_exit])
116117
}
117118

118-
hir::PatEnum(_, Some(ref subpats)) |
119-
hir::PatTup(ref subpats) => {
119+
PatKind::TupleStruct(_, Some(ref subpats)) |
120+
PatKind::Tup(ref subpats) => {
120121
let pats_exit = self.pats_all(subpats.iter(), pred);
121122
self.add_ast_node(pat.id, &[pats_exit])
122123
}
123124

124-
hir::PatStruct(_, ref subpats, _) => {
125+
PatKind::Struct(_, ref subpats, _) => {
125126
let pats_exit =
126127
self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
127128
self.add_ast_node(pat.id, &[pats_exit])
128129
}
129130

130-
hir::PatVec(ref pre, ref vec, ref post) => {
131+
PatKind::Vec(ref pre, ref vec, ref post) => {
131132
let pre_exit = self.pats_all(pre.iter(), pred);
132133
let vec_exit = self.pats_all(vec.iter(), pre_exit);
133134
let post_exit = self.pats_all(post.iter(), vec_exit);

0 commit comments

Comments
 (0)