Pass crate attributes in visit.rs
This commit is contained in:
parent
67a0d27c65
commit
fb7ba4772c
6 changed files with 12 additions and 12 deletions
|
|
@ -1055,7 +1055,7 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
|
|||
run_lints!(self, check_ident, early_passes, sp, id);
|
||||
}
|
||||
|
||||
fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, n: ast::NodeId) {
|
||||
fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, _a: &[ast::Attribute], n: ast::NodeId) {
|
||||
run_lints!(self, check_mod, early_passes, m, s, n);
|
||||
ast_visit::walk_mod(self, m);
|
||||
run_lints!(self, check_mod_post, early_passes, m, s, n);
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
|||
|
||||
impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
|
||||
|
||||
fn visit_mod(&mut self, m: &'v ast::Mod, _s: Span, _n: NodeId) {
|
||||
fn visit_mod(&mut self, m: &'v ast::Mod, _s: Span, _a: &[ast::Attribute], _n: NodeId) {
|
||||
self.record("Mod", Id::None, m);
|
||||
ast_visit::walk_mod(self, m)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1211,7 +1211,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
|||
}
|
||||
|
||||
impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, id: NodeId) {
|
||||
fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, attrs: &[ast::Attribute], id: NodeId) {
|
||||
// Since we handle explicit modules ourselves in visit_item, this should
|
||||
// only get called for the root module of a crate.
|
||||
assert_eq!(id, ast::CRATE_NODE_ID);
|
||||
|
|
@ -1229,11 +1229,9 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll,
|
|||
filename: filename,
|
||||
items: m.items.iter().map(|i| i.id).collect(),
|
||||
visibility: Visibility::Public,
|
||||
// TODO Visitor doesn't pass us the attibutes.
|
||||
docs: String::new(),
|
||||
docs: docs_for_attrs(attrs),
|
||||
sig: None,
|
||||
// TODO Visitor doesn't pass us the attibutes.
|
||||
attributes: vec![],
|
||||
attributes: attrs.to_owned(),
|
||||
}.lower(self.tcx));
|
||||
self.nest_scope(id, |v| visit::walk_mod(v, m));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl<'ast> Visitor<'ast> for NodeCounter {
|
|||
self.count += 1;
|
||||
walk_ident(self, span, ident);
|
||||
}
|
||||
fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId) {
|
||||
fn visit_mod(&mut self, m: &Mod, _s: Span, _a: &[Attribute], _n: NodeId) {
|
||||
self.count += 1;
|
||||
walk_mod(self, m)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ pub trait Visitor<'ast>: Sized {
|
|||
fn visit_ident(&mut self, span: Span, ident: Ident) {
|
||||
walk_ident(self, span, ident);
|
||||
}
|
||||
fn visit_mod(&mut self, m: &'ast Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
|
||||
fn visit_mod(&mut self, m: &'ast Mod, _s: Span, _attrs: &[Attribute], _n: NodeId) {
|
||||
walk_mod(self, m);
|
||||
}
|
||||
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) { walk_foreign_item(self, i) }
|
||||
fn visit_global_asm(&mut self, ga: &'ast GlobalAsm) { walk_global_asm(self, ga) }
|
||||
fn visit_item(&mut self, i: &'ast Item) { walk_item(self, i) }
|
||||
|
|
@ -172,7 +174,7 @@ pub fn walk_ident<'a, V: Visitor<'a>>(visitor: &mut V, span: Span, ident: Ident)
|
|||
}
|
||||
|
||||
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) {
|
||||
visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID);
|
||||
visitor.visit_mod(&krate.module, krate.span, &krate.attrs, CRATE_NODE_ID);
|
||||
walk_list!(visitor, visit_attribute, &krate.attrs);
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +251,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
|
|||
item.id)
|
||||
}
|
||||
ItemKind::Mod(ref module) => {
|
||||
visitor.visit_mod(module, item.span, item.id)
|
||||
visitor.visit_mod(module, item.span, &item.attrs, item.id)
|
||||
}
|
||||
ItemKind::ForeignMod(ref foreign_module) => {
|
||||
walk_list!(visitor, visit_foreign_item, &foreign_module.items);
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
|||
visit::walk_item(self, item);
|
||||
}
|
||||
|
||||
fn visit_mod(&mut self, m: &'a ast::Mod, _s: Span, id: NodeId) {
|
||||
fn visit_mod(&mut self, m: &'a ast::Mod, _s: Span, _a: &[ast::Attribute], id: NodeId) {
|
||||
let mut prev_in_root = self.in_root;
|
||||
if id != ast::CRATE_NODE_ID {
|
||||
prev_in_root = mem::replace(&mut self.in_root, false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue