Skip to content

Commit 6dced80

Browse files
committed
Remove visit_name from the AST visitor.
Because the default is empty and it's never overridden. This means `walk_ident` can also be removed, because it does nothing.
1 parent ab44b5a commit 6dced80

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

compiler/rustc_ast/src/visit.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
use crate::ast::*;
1717

18-
use rustc_span::symbol::{Ident, Symbol};
18+
use rustc_span::symbol::Ident;
1919
use rustc_span::Span;
2020

2121
#[derive(Copy, Clone, Debug, PartialEq)]
@@ -109,12 +109,7 @@ pub enum LifetimeCtxt {
109109
/// to monitor future changes to `Visitor` in case a new method with a
110110
/// new default implementation gets introduced.)
111111
pub trait Visitor<'ast>: Sized {
112-
fn visit_name(&mut self, _span: Span, _name: Symbol) {
113-
// Nothing to do.
114-
}
115-
fn visit_ident(&mut self, ident: Ident) {
116-
walk_ident(self, ident);
117-
}
112+
fn visit_ident(&mut self, _ident: Ident) {}
118113
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) {
119114
walk_foreign_item(self, i)
120115
}
@@ -267,10 +262,6 @@ macro_rules! walk_list {
267262
}
268263
}
269264

270-
pub fn walk_ident<'a, V: Visitor<'a>>(visitor: &mut V, ident: Ident) {
271-
visitor.visit_name(ident.span, ident.name);
272-
}
273-
274265
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) {
275266
walk_list!(visitor, visit_item, &krate.items);
276267
walk_list!(visitor, visit_attribute, &krate.attrs);
@@ -315,11 +306,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
315306
visitor.visit_vis(&item.vis);
316307
visitor.visit_ident(item.ident);
317308
match item.kind {
318-
ItemKind::ExternCrate(orig_name) => {
319-
if let Some(orig_name) = orig_name {
320-
visitor.visit_name(item.span, orig_name);
321-
}
322-
}
309+
ItemKind::ExternCrate(_) => {}
323310
ItemKind::Use(ref use_tree) => visitor.visit_use_tree(use_tree, item.id, false),
324311
ItemKind::Static(ref typ, _, ref expr) | ItemKind::Const(_, ref typ, ref expr) => {
325312
visitor.visit_ty(typ);

compiler/rustc_ast_passes/src/node_count.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ impl NodeCounter {
1616
}
1717

1818
impl<'ast> Visitor<'ast> for NodeCounter {
19-
fn visit_ident(&mut self, ident: Ident) {
19+
fn visit_ident(&mut self, _ident: Ident) {
2020
self.count += 1;
21-
walk_ident(self, ident);
2221
}
2322
fn visit_foreign_item(&mut self, i: &ForeignItem) {
2423
self.count += 1;

0 commit comments

Comments
 (0)