Skip to content

Commit

Permalink
Auto merge of #33654 - petrochenkov:hirident, r=nrc
Browse files Browse the repository at this point in the history
Remove hir::Ident

Now when name resolution is done on AST, `hir::Ident` is no longer necessary.
See #30145 for more details.

r? @nrc
  • Loading branch information
bors committed May 18, 2016
2 parents 75e23e1 + 02a1eef commit 310d899
Show file tree
Hide file tree
Showing 32 changed files with 160 additions and 239 deletions.
4 changes: 2 additions & 2 deletions src/librustc/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
}

hir::ExprBreak(label) => {
let loop_scope = self.find_scope(expr, label.map(|l| l.node.name));
let loop_scope = self.find_scope(expr, label.map(|l| l.node));
let b = self.add_ast_node(expr.id, &[pred]);
self.add_exiting_edge(expr, b,
loop_scope, loop_scope.break_index);
self.add_unreachable_node()
}

hir::ExprAgain(label) => {
let loop_scope = self.find_scope(expr, label.map(|l| l.node.name));
let loop_scope = self.find_scope(expr, label.map(|l| l.node));
let a = self.add_ast_node(expr.id, &[pred]);
self.add_exiting_edge(expr, a,
loop_scope, loop_scope.continue_index);
Expand Down
30 changes: 11 additions & 19 deletions src/librustc/hir/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ pub trait Folder : Sized {
noop_fold_name(n, self)
}

fn fold_ident(&mut self, i: Ident) -> Ident {
noop_fold_ident(i, self)
}

fn fold_usize(&mut self, i: usize) -> usize {
noop_fold_usize(i, self)
}
Expand Down Expand Up @@ -407,20 +403,16 @@ pub fn noop_fold_name<T: Folder>(n: Name, _: &mut T) -> Name {
n
}

pub fn noop_fold_ident<T: Folder>(i: Ident, _: &mut T) -> Ident {
i
}

pub fn noop_fold_usize<T: Folder>(i: usize, _: &mut T) -> usize {
i
}

pub fn noop_fold_path<T: Folder>(Path { global, segments, span }: Path, fld: &mut T) -> Path {
Path {
global: global,
segments: segments.move_map(|PathSegment { identifier, parameters }| {
segments: segments.move_map(|PathSegment { name, parameters }| {
PathSegment {
identifier: fld.fold_ident(identifier),
name: fld.fold_name(name),
parameters: fld.fold_path_parameters(parameters),
}
}),
Expand Down Expand Up @@ -926,7 +918,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
PatKind::Ident(binding_mode,
Spanned {
span: folder.new_span(pth1.span),
node: folder.fold_ident(pth1.node),
node: folder.fold_name(pth1.node),
},
sub.map(|x| folder.fold_pat(x)))
}
Expand Down Expand Up @@ -1014,14 +1006,14 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
folder.fold_block(tr),
fl.map(|x| folder.fold_expr(x)))
}
ExprWhile(cond, body, opt_ident) => {
ExprWhile(cond, body, opt_name) => {
ExprWhile(folder.fold_expr(cond),
folder.fold_block(body),
opt_ident.map(|i| folder.fold_ident(i)))
opt_name.map(|i| folder.fold_name(i)))
}
ExprLoop(body, opt_ident) => {
ExprLoop(body, opt_name) => {
ExprLoop(folder.fold_block(body),
opt_ident.map(|i| folder.fold_ident(i)))
opt_name.map(|i| folder.fold_name(i)))
}
ExprMatch(expr, arms, source) => {
ExprMatch(folder.fold_expr(expr),
Expand Down Expand Up @@ -1061,11 +1053,11 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
});
ExprPath(qself, folder.fold_path(path))
}
ExprBreak(opt_ident) => ExprBreak(opt_ident.map(|label| {
respan(folder.new_span(label.span), folder.fold_ident(label.node))
ExprBreak(opt_name) => ExprBreak(opt_name.map(|label| {
respan(folder.new_span(label.span), folder.fold_name(label.node))
})),
ExprAgain(opt_ident) => ExprAgain(opt_ident.map(|label| {
respan(folder.new_span(label.span), folder.fold_ident(label.node))
ExprAgain(opt_name) => ExprAgain(opt_name.map(|label| {
respan(folder.new_span(label.span), folder.fold_name(label.node))
})),
ExprRet(e) => ExprRet(e.map(|x| folder.fold_expr(x))),
ExprInlineAsm(asm, outputs, inputs) => {
Expand Down
31 changes: 9 additions & 22 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ pub trait Visitor<'v> : Sized {
fn visit_name(&mut self, _span: Span, _name: Name) {
// Nothing to do.
}
fn visit_ident(&mut self, span: Span, ident: Ident) {
walk_ident(self, span, ident);
}
fn visit_mod(&mut self, m: &'v Mod, _s: Span, _n: NodeId) {
walk_mod(self, m)
}
Expand Down Expand Up @@ -211,16 +208,6 @@ pub fn walk_opt_name<'v, V: Visitor<'v>>(visitor: &mut V, span: Span, opt_name:
}
}

pub fn walk_opt_ident<'v, V: Visitor<'v>>(visitor: &mut V, span: Span, opt_ident: Option<Ident>) {
for ident in opt_ident {
visitor.visit_ident(span, ident);
}
}

pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, span: Span, ident: Ident) {
visitor.visit_name(span, ident.name);
}

/// Walks the contents of a crate. See also `Crate::visit_all_items`.
pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate) {
visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID);
Expand Down Expand Up @@ -439,7 +426,7 @@ pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_path_segment<'v, V: Visitor<'v>>(visitor: &mut V,
path_span: Span,
segment: &'v PathSegment) {
visitor.visit_ident(path_span, segment.identifier);
visitor.visit_name(path_span, segment.name);
visitor.visit_path_parameters(path_span, &segment.parameters);
}

Expand Down Expand Up @@ -495,7 +482,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
visitor.visit_pat(subpattern)
}
PatKind::Ident(_, ref pth1, ref optional_subpattern) => {
visitor.visit_ident(pth1.span, pth1.node);
visitor.visit_name(pth1.span, pth1.node);
walk_list!(visitor, visit_pat, optional_subpattern);
}
PatKind::Lit(ref expression) => visitor.visit_expr(expression),
Expand Down Expand Up @@ -750,14 +737,14 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
visitor.visit_block(if_block);
walk_list!(visitor, visit_expr, optional_else);
}
ExprWhile(ref subexpression, ref block, opt_ident) => {
ExprWhile(ref subexpression, ref block, opt_name) => {
visitor.visit_expr(subexpression);
visitor.visit_block(block);
walk_opt_ident(visitor, expression.span, opt_ident)
walk_opt_name(visitor, expression.span, opt_name)
}
ExprLoop(ref block, opt_ident) => {
ExprLoop(ref block, opt_name) => {
visitor.visit_block(block);
walk_opt_ident(visitor, expression.span, opt_ident)
walk_opt_name(visitor, expression.span, opt_name)
}
ExprMatch(ref subexpression, ref arms, _) => {
visitor.visit_expr(subexpression);
Expand Down Expand Up @@ -796,9 +783,9 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
}
visitor.visit_path(path, expression.id)
}
ExprBreak(ref opt_sp_ident) | ExprAgain(ref opt_sp_ident) => {
for sp_ident in opt_sp_ident {
visitor.visit_ident(sp_ident.span, sp_ident.node);
ExprBreak(ref opt_sp_name) | ExprAgain(ref opt_sp_name) => {
for sp_name in opt_sp_name {
visitor.visit_name(sp_name.span, sp_name.node);
}
}
ExprRet(ref optional_expression) => {
Expand Down
Loading

0 comments on commit 310d899

Please sign in to comment.