Skip to content

Commit

Permalink
Gather deprecation information during cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Aug 10, 2019
1 parent 11735b6 commit 4beb751
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 56 deletions.
32 changes: 16 additions & 16 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ impl Clean<Item> for doctree::Module<'_> {
source: whence.clean(cx),
visibility: self.vis.clean(cx),
stability: cx.stability(self.hid).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.hid).clean(cx),
def_id: cx.tcx.hir().local_def_id_from_node_id(self.id),
inner: ModuleItem(Module {
is_crate: self.is_crate,
Expand Down Expand Up @@ -1941,7 +1941,7 @@ impl Clean<Item> for doctree::Function<'_> {
source: self.whence.clean(cx),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
def_id: did,
inner: FunctionItem(Function {
decl,
Expand Down Expand Up @@ -2141,7 +2141,7 @@ impl Clean<Item> for doctree::Trait<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: TraitItem(Trait {
auto: self.is_auto.clean(cx),
unsafety: self.unsafety,
Expand Down Expand Up @@ -2171,7 +2171,7 @@ impl Clean<Item> for doctree::TraitAlias<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: TraitAliasItem(TraitAlias {
generics: self.generics.clean(cx),
bounds: self.bounds.clean(cx),
Expand Down Expand Up @@ -3245,7 +3245,7 @@ impl Clean<Item> for doctree::Struct<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: StructItem(Struct {
struct_type: self.struct_type,
generics: self.generics.clean(cx),
Expand All @@ -3265,7 +3265,7 @@ impl Clean<Item> for doctree::Union<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: UnionItem(Union {
struct_type: self.struct_type,
generics: self.generics.clean(cx),
Expand Down Expand Up @@ -3312,7 +3312,7 @@ impl Clean<Item> for doctree::Enum<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: EnumItem(Enum {
variants: self.variants.iter().map(|v| v.clean(cx)).collect(),
generics: self.generics.clean(cx),
Expand All @@ -3335,7 +3335,7 @@ impl Clean<Item> for doctree::Variant<'_> {
source: self.whence.clean(cx),
visibility: None,
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
def_id: cx.tcx.hir().local_def_id(self.id),
inner: VariantItem(Variant {
kind: self.def.clean(cx),
Expand Down Expand Up @@ -3640,7 +3640,7 @@ impl Clean<Item> for doctree::Typedef<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: TypedefItem(Typedef {
type_: self.ty.clean(cx),
generics: self.gen.clean(cx),
Expand All @@ -3664,7 +3664,7 @@ impl Clean<Item> for doctree::OpaqueTy<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: OpaqueTyItem(OpaqueTy {
bounds: self.opaque_ty.bounds.clean(cx),
generics: self.opaque_ty.generics.clean(cx),
Expand Down Expand Up @@ -3715,7 +3715,7 @@ impl Clean<Item> for doctree::Static<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: StaticItem(Static {
type_: self.type_.clean(cx),
mutability: self.mutability.clean(cx),
Expand All @@ -3740,7 +3740,7 @@ impl Clean<Item> for doctree::Constant<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: ConstantItem(Constant {
type_: self.type_.clean(cx),
expr: print_const_expr(cx, self.expr),
Expand Down Expand Up @@ -3827,7 +3827,7 @@ impl Clean<Vec<Item>> for doctree::Impl<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner: ImplItem(Impl {
unsafety: self.unsafety,
generics: self.generics.clean(cx),
Expand Down Expand Up @@ -4066,7 +4066,7 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
inner,
}
}
Expand Down Expand Up @@ -4249,7 +4249,7 @@ impl Clean<Item> for doctree::Macro<'_> {
source: self.whence.clean(cx),
visibility: Some(Public),
stability: cx.stability(self.hid).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.hid).clean(cx),
def_id: self.def_id,
inner: MacroItem(Macro {
source: format!("macro_rules! {} {{\n{}}}",
Expand Down Expand Up @@ -4277,7 +4277,7 @@ impl Clean<Item> for doctree::ProcMacro<'_> {
source: self.whence.clean(cx),
visibility: Some(Public),
stability: cx.stability(self.id).clean(cx),
deprecation: self.depr.clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
def_id: cx.tcx.hir().local_def_id(self.id),
inner: ProcMacroItem(ProcMacro {
kind: self.kind,
Expand Down
5 changes: 5 additions & 0 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ impl<'tcx> DocContext<'tcx> {
self.tcx.hir().opt_local_def_id(id)
.and_then(|def_id| self.tcx.lookup_stability(def_id)).cloned()
}

pub fn deprecation(&self, id: HirId) -> Option<attr::Deprecation> {
self.tcx.hir().opt_local_def_id(id)
.and_then(|def_id| self.tcx.lookup_deprecation(def_id))
}
}

pub trait DocAccessLevels {
Expand Down
18 changes: 0 additions & 18 deletions src/librustdoc/doctree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub use self::StructType::*;

use syntax::ast;
use syntax::ast::{Name, NodeId};
use syntax::attr;
use syntax::ext::base::MacroKind;
use syntax_pos::{self, Span};

Expand Down Expand Up @@ -32,7 +31,6 @@ pub struct Module<'hir> {
pub constants: Vec<Constant<'hir>>,
pub traits: Vec<Trait<'hir>>,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub impls: Vec<Impl<'hir>>,
pub foreigns: Vec<ForeignItem<'hir>>,
pub macros: Vec<Macro<'hir>>,
Expand All @@ -52,7 +50,6 @@ impl Module<'hir> {
id: ast::CRATE_NODE_ID,
hid: hir::CRATE_HIR_ID,
vis,
depr: None,
where_outer: syntax_pos::DUMMY_SP,
where_inner: syntax_pos::DUMMY_SP,
attrs,
Expand Down Expand Up @@ -90,7 +87,6 @@ pub enum StructType {

pub struct Struct<'hir> {
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub id: hir::HirId,
pub struct_type: StructType,
pub name: Name,
Expand All @@ -102,7 +98,6 @@ pub struct Struct<'hir> {

pub struct Union<'hir> {
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub id: hir::HirId,
pub struct_type: StructType,
pub name: Name,
Expand All @@ -114,7 +109,6 @@ pub struct Union<'hir> {

pub struct Enum<'hir> {
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub variants: Vec<Variant<'hir>>,
pub generics: &'hir hir::Generics,
pub attrs: &'hir hir::HirVec<ast::Attribute>,
Expand All @@ -128,7 +122,6 @@ pub struct Variant<'hir> {
pub id: hir::HirId,
pub attrs: &'hir hir::HirVec<ast::Attribute>,
pub def: &'hir hir::VariantData,
pub depr: Option<attr::Deprecation>,
pub whence: Span,
}

Expand All @@ -138,7 +131,6 @@ pub struct Function<'hir> {
pub id: hir::HirId,
pub name: Name,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub header: hir::FnHeader,
pub whence: Span,
pub generics: &'hir hir::Generics,
Expand All @@ -153,7 +145,6 @@ pub struct Typedef<'hir> {
pub attrs: &'hir hir::HirVec<ast::Attribute>,
pub whence: Span,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
}

pub struct OpaqueTy<'hir> {
Expand All @@ -163,7 +154,6 @@ pub struct OpaqueTy<'hir> {
pub attrs: &'hir hir::HirVec<ast::Attribute>,
pub whence: Span,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
}

#[derive(Debug)]
Expand All @@ -174,7 +164,6 @@ pub struct Static<'hir> {
pub name: Name,
pub attrs: &'hir hir::HirVec<ast::Attribute>,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub id: hir::HirId,
pub whence: Span,
}
Expand All @@ -185,7 +174,6 @@ pub struct Constant<'hir> {
pub name: Name,
pub attrs: &'hir hir::HirVec<ast::Attribute>,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub id: hir::HirId,
pub whence: Span,
}
Expand All @@ -201,7 +189,6 @@ pub struct Trait<'hir> {
pub id: hir::HirId,
pub whence: Span,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
}

pub struct TraitAlias<'hir> {
Expand All @@ -212,7 +199,6 @@ pub struct TraitAlias<'hir> {
pub id: hir::HirId,
pub whence: Span,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
}

#[derive(Debug)]
Expand All @@ -227,13 +213,11 @@ pub struct Impl<'hir> {
pub attrs: &'hir hir::HirVec<ast::Attribute>,
pub whence: Span,
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub id: hir::HirId,
}

pub struct ForeignItem<'hir> {
pub vis: &'hir hir::Visibility,
pub depr: Option<attr::Deprecation>,
pub id: hir::HirId,
pub name: Name,
pub kind: &'hir hir::ForeignItemKind,
Expand All @@ -250,7 +234,6 @@ pub struct Macro<'hir> {
pub attrs: &'hir hir::HirVec<ast::Attribute>,
pub whence: Span,
pub matchers: hir::HirVec<Span>,
pub depr: Option<attr::Deprecation>,
pub imported_from: Option<Name>,
}

Expand Down Expand Up @@ -280,7 +263,6 @@ pub struct ProcMacro<'hir> {
pub helpers: Vec<Name>,
pub attrs: &'hir hir::HirVec<ast::Attribute>,
pub whence: Span,
pub depr: Option<attr::Deprecation>,
}

pub fn struct_type_from_def(vdata: &hir::VariantData) -> StructType {
Expand Down
Loading

0 comments on commit 4beb751

Please sign in to comment.