pub struct RustdocVisitor<'a, 'tcx: 'a> {
pub module: Module,
- pub attrs: Vec<ast::Attribute>,
+ pub attrs: hir::HirVec<ast::Attribute>,
pub cx: &'a core::DocContext<'a, 'tcx>,
pub analysis: Option<&'a core::CrateAnalysis>,
view_item_stack: HashSet<ast::NodeId>,
stack.insert(ast::CRATE_NODE_ID);
RustdocVisitor {
module: Module::new(None),
- attrs: Vec::new(),
+ attrs: hir::HirVec::new(),
cx: cx,
analysis: analysis,
view_item_stack: stack,
fn stability(&self, id: ast::NodeId) -> Option<attr::Stability> {
self.cx.tcx_opt().and_then(|tcx| {
self.cx.map.opt_local_def_id(id)
- .and_then(|def_id| stability::lookup(tcx, def_id))
+ .and_then(|def_id| stability::lookup_stability(tcx, def_id))
.cloned()
})
}
+ fn deprecation(&self, id: ast::NodeId) -> Option<attr::Deprecation> {
+ self.cx.tcx_opt().and_then(|tcx| {
+ self.cx.map.opt_local_def_id(id)
+ .and_then(|def_id| stability::lookup_deprecation(tcx, def_id))
+ })
+ }
+
pub fn visit(&mut self, krate: &hir::Crate) {
self.attrs = krate.attrs.clone();
name: name,
vis: item.vis,
stab: self.stability(item.id),
+ depr: self.deprecation(item.id),
attrs: item.attrs.clone(),
generics: generics.clone(),
fields: sd.fields().iter().cloned().collect(),
name: v.node.name,
attrs: v.node.attrs.clone(),
stab: self.stability(v.node.data.id()),
+ depr: self.deprecation(v.node.data.id()),
def: v.node.data.clone(),
whence: v.span,
}).collect(),
vis: it.vis,
stab: self.stability(it.id),
+ depr: self.deprecation(it.id),
generics: params.clone(),
attrs: it.attrs.clone(),
id: it.id,
id: item.id,
vis: item.vis,
stab: self.stability(item.id),
+ depr: self.deprecation(item.id),
attrs: item.attrs.clone(),
decl: fd.clone(),
name: name,
}
}
- pub fn visit_mod_contents(&mut self, span: Span, attrs: Vec<ast::Attribute> ,
+ pub fn visit_mod_contents(&mut self, span: Span, attrs: hir::HirVec<ast::Attribute>,
vis: hir::Visibility, id: ast::NodeId,
m: &hir::Mod,
name: Option<ast::Name>) -> Module {
om.attrs = attrs;
om.vis = vis;
om.stab = self.stability(id);
+ om.depr = self.deprecation(id);
om.id = id;
for i in &m.item_ids {
let item = self.cx.map.expect_item(i.id);
let mine = paths.into_iter().filter(|path| {
!self.resolve_id(path.node.id(), None, false, om,
please_inline)
- }).collect::<Vec<hir::PathListItem>>();
+ }).collect::<hir::HirVec<hir::PathListItem>>();
if mine.is_empty() {
None
whence: item.span,
vis: item.vis,
stab: self.stability(item.id),
+ depr: self.deprecation(item.id),
};
om.typedefs.push(t);
},
whence: item.span,
vis: item.vis,
stab: self.stability(item.id),
+ depr: self.deprecation(item.id),
};
om.statics.push(s);
},
whence: item.span,
vis: item.vis,
stab: self.stability(item.id),
+ depr: self.deprecation(item.id),
};
om.constants.push(s);
},
whence: item.span,
vis: item.vis,
stab: self.stability(item.id),
+ depr: self.deprecation(item.id),
};
om.traits.push(t);
},
whence: item.span,
vis: item.vis,
stab: self.stability(item.id),
+ depr: self.deprecation(item.id),
};
// Don't duplicate impls when inlining glob imports, we'll pick
// them up regardless of where they're located.
// convert each exported_macro into a doc item
fn visit_macro(&self, def: &hir::MacroDef) -> Macro {
+ // Extract the spans of all matchers. They represent the "interface" of the macro.
+ let matchers = def.body.chunks(4).map(|arm| arm[0].get_span()).collect();
+
Macro {
id: def.id,
attrs: def.attrs.clone(),
name: def.name,
whence: def.span,
+ matchers: matchers,
stab: self.stability(def.id),
+ depr: self.deprecation(def.id),
imported_from: def.imported_from,
}
}