Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring: Rename hir::Pat_ and its variants #31685

Merged
merged 2 commits into from
Feb 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/front/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {

fn visit_pat(&mut self, pat: &'ast Pat) {
let maybe_binding = match pat.node {
PatIdent(_, id, _) => Some(id.node),
PatKind::Ident(_, id, _) => Some(id.node),
_ => None
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ impl<'ast> Map<'ast> {
NodeVariant(v) => PathName(v.node.name),
NodeLifetime(lt) => PathName(lt.name),
NodeTyParam(tp) => PathName(tp.name),
NodeLocal(&Pat { node: PatIdent(_,l,_), .. }) => {
NodeLocal(&Pat { node: PatKind::Ident(_,l,_), .. }) => {
PathName(l.node.name)
},
_ => panic!("no path elem for {:?}", node)
Expand Down
29 changes: 15 additions & 14 deletions src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use middle::ty;
use syntax::ast;
use syntax::ptr::P;

use rustc_front::hir;
use rustc_front::hir::{self, PatKind};

struct CFGBuilder<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>,
Expand Down Expand Up @@ -99,35 +99,36 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {

fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
match pat.node {
hir::PatIdent(_, _, None) |
hir::PatEnum(_, None) |
hir::PatQPath(..) |
hir::PatLit(..) |
hir::PatRange(..) |
hir::PatWild => {
PatKind::Ident(_, _, None) |
PatKind::TupleStruct(_, None) |
PatKind::Path(..) |
PatKind::QPath(..) |
PatKind::Lit(..) |
PatKind::Range(..) |
PatKind::Wild => {
self.add_ast_node(pat.id, &[pred])
}

hir::PatBox(ref subpat) |
hir::PatRegion(ref subpat, _) |
hir::PatIdent(_, _, Some(ref subpat)) => {
PatKind::Box(ref subpat) |
PatKind::Ref(ref subpat, _) |
PatKind::Ident(_, _, Some(ref subpat)) => {
let subpat_exit = self.pat(&subpat, pred);
self.add_ast_node(pat.id, &[subpat_exit])
}

hir::PatEnum(_, Some(ref subpats)) |
hir::PatTup(ref subpats) => {
PatKind::TupleStruct(_, Some(ref subpats)) |
PatKind::Tup(ref subpats) => {
let pats_exit = self.pats_all(subpats.iter(), pred);
self.add_ast_node(pat.id, &[pats_exit])
}

hir::PatStruct(_, ref subpats, _) => {
PatKind::Struct(_, ref subpats, _) => {
let pats_exit =
self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
self.add_ast_node(pat.id, &[pats_exit])
}

hir::PatVec(ref pre, ref vec, ref post) => {
PatKind::Vec(ref pre, ref vec, ref post) => {
let pre_exit = self.pats_all(pre.iter(), pred);
let vec_exit = self.pats_all(vec.iter(), pre_exit);
let post_exit = self.pats_all(post.iter(), vec_exit);
Expand Down
Loading