Skip to content

Commit 4beb751

Browse files
Gather deprecation information during cleaning
1 parent 11735b6 commit 4beb751

File tree

4 files changed

+21
-56
lines changed

4 files changed

+21
-56
lines changed

src/librustdoc/clean/mod.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ impl Clean<Item> for doctree::Module<'_> {
655655
source: whence.clean(cx),
656656
visibility: self.vis.clean(cx),
657657
stability: cx.stability(self.hid).clean(cx),
658-
deprecation: self.depr.clean(cx),
658+
deprecation: cx.deprecation(self.hid).clean(cx),
659659
def_id: cx.tcx.hir().local_def_id_from_node_id(self.id),
660660
inner: ModuleItem(Module {
661661
is_crate: self.is_crate,
@@ -1941,7 +1941,7 @@ impl Clean<Item> for doctree::Function<'_> {
19411941
source: self.whence.clean(cx),
19421942
visibility: self.vis.clean(cx),
19431943
stability: cx.stability(self.id).clean(cx),
1944-
deprecation: self.depr.clean(cx),
1944+
deprecation: cx.deprecation(self.id).clean(cx),
19451945
def_id: did,
19461946
inner: FunctionItem(Function {
19471947
decl,
@@ -2141,7 +2141,7 @@ impl Clean<Item> for doctree::Trait<'_> {
21412141
def_id: cx.tcx.hir().local_def_id(self.id),
21422142
visibility: self.vis.clean(cx),
21432143
stability: cx.stability(self.id).clean(cx),
2144-
deprecation: self.depr.clean(cx),
2144+
deprecation: cx.deprecation(self.id).clean(cx),
21452145
inner: TraitItem(Trait {
21462146
auto: self.is_auto.clean(cx),
21472147
unsafety: self.unsafety,
@@ -2171,7 +2171,7 @@ impl Clean<Item> for doctree::TraitAlias<'_> {
21712171
def_id: cx.tcx.hir().local_def_id(self.id),
21722172
visibility: self.vis.clean(cx),
21732173
stability: cx.stability(self.id).clean(cx),
2174-
deprecation: self.depr.clean(cx),
2174+
deprecation: cx.deprecation(self.id).clean(cx),
21752175
inner: TraitAliasItem(TraitAlias {
21762176
generics: self.generics.clean(cx),
21772177
bounds: self.bounds.clean(cx),
@@ -3245,7 +3245,7 @@ impl Clean<Item> for doctree::Struct<'_> {
32453245
def_id: cx.tcx.hir().local_def_id(self.id),
32463246
visibility: self.vis.clean(cx),
32473247
stability: cx.stability(self.id).clean(cx),
3248-
deprecation: self.depr.clean(cx),
3248+
deprecation: cx.deprecation(self.id).clean(cx),
32493249
inner: StructItem(Struct {
32503250
struct_type: self.struct_type,
32513251
generics: self.generics.clean(cx),
@@ -3265,7 +3265,7 @@ impl Clean<Item> for doctree::Union<'_> {
32653265
def_id: cx.tcx.hir().local_def_id(self.id),
32663266
visibility: self.vis.clean(cx),
32673267
stability: cx.stability(self.id).clean(cx),
3268-
deprecation: self.depr.clean(cx),
3268+
deprecation: cx.deprecation(self.id).clean(cx),
32693269
inner: UnionItem(Union {
32703270
struct_type: self.struct_type,
32713271
generics: self.generics.clean(cx),
@@ -3312,7 +3312,7 @@ impl Clean<Item> for doctree::Enum<'_> {
33123312
def_id: cx.tcx.hir().local_def_id(self.id),
33133313
visibility: self.vis.clean(cx),
33143314
stability: cx.stability(self.id).clean(cx),
3315-
deprecation: self.depr.clean(cx),
3315+
deprecation: cx.deprecation(self.id).clean(cx),
33163316
inner: EnumItem(Enum {
33173317
variants: self.variants.iter().map(|v| v.clean(cx)).collect(),
33183318
generics: self.generics.clean(cx),
@@ -3335,7 +3335,7 @@ impl Clean<Item> for doctree::Variant<'_> {
33353335
source: self.whence.clean(cx),
33363336
visibility: None,
33373337
stability: cx.stability(self.id).clean(cx),
3338-
deprecation: self.depr.clean(cx),
3338+
deprecation: cx.deprecation(self.id).clean(cx),
33393339
def_id: cx.tcx.hir().local_def_id(self.id),
33403340
inner: VariantItem(Variant {
33413341
kind: self.def.clean(cx),
@@ -3640,7 +3640,7 @@ impl Clean<Item> for doctree::Typedef<'_> {
36403640
def_id: cx.tcx.hir().local_def_id(self.id),
36413641
visibility: self.vis.clean(cx),
36423642
stability: cx.stability(self.id).clean(cx),
3643-
deprecation: self.depr.clean(cx),
3643+
deprecation: cx.deprecation(self.id).clean(cx),
36443644
inner: TypedefItem(Typedef {
36453645
type_: self.ty.clean(cx),
36463646
generics: self.gen.clean(cx),
@@ -3664,7 +3664,7 @@ impl Clean<Item> for doctree::OpaqueTy<'_> {
36643664
def_id: cx.tcx.hir().local_def_id(self.id),
36653665
visibility: self.vis.clean(cx),
36663666
stability: cx.stability(self.id).clean(cx),
3667-
deprecation: self.depr.clean(cx),
3667+
deprecation: cx.deprecation(self.id).clean(cx),
36683668
inner: OpaqueTyItem(OpaqueTy {
36693669
bounds: self.opaque_ty.bounds.clean(cx),
36703670
generics: self.opaque_ty.generics.clean(cx),
@@ -3715,7 +3715,7 @@ impl Clean<Item> for doctree::Static<'_> {
37153715
def_id: cx.tcx.hir().local_def_id(self.id),
37163716
visibility: self.vis.clean(cx),
37173717
stability: cx.stability(self.id).clean(cx),
3718-
deprecation: self.depr.clean(cx),
3718+
deprecation: cx.deprecation(self.id).clean(cx),
37193719
inner: StaticItem(Static {
37203720
type_: self.type_.clean(cx),
37213721
mutability: self.mutability.clean(cx),
@@ -3740,7 +3740,7 @@ impl Clean<Item> for doctree::Constant<'_> {
37403740
def_id: cx.tcx.hir().local_def_id(self.id),
37413741
visibility: self.vis.clean(cx),
37423742
stability: cx.stability(self.id).clean(cx),
3743-
deprecation: self.depr.clean(cx),
3743+
deprecation: cx.deprecation(self.id).clean(cx),
37443744
inner: ConstantItem(Constant {
37453745
type_: self.type_.clean(cx),
37463746
expr: print_const_expr(cx, self.expr),
@@ -3827,7 +3827,7 @@ impl Clean<Vec<Item>> for doctree::Impl<'_> {
38273827
def_id: cx.tcx.hir().local_def_id(self.id),
38283828
visibility: self.vis.clean(cx),
38293829
stability: cx.stability(self.id).clean(cx),
3830-
deprecation: self.depr.clean(cx),
3830+
deprecation: cx.deprecation(self.id).clean(cx),
38313831
inner: ImplItem(Impl {
38323832
unsafety: self.unsafety,
38333833
generics: self.generics.clean(cx),
@@ -4066,7 +4066,7 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
40664066
def_id: cx.tcx.hir().local_def_id(self.id),
40674067
visibility: self.vis.clean(cx),
40684068
stability: cx.stability(self.id).clean(cx),
4069-
deprecation: self.depr.clean(cx),
4069+
deprecation: cx.deprecation(self.id).clean(cx),
40704070
inner,
40714071
}
40724072
}
@@ -4249,7 +4249,7 @@ impl Clean<Item> for doctree::Macro<'_> {
42494249
source: self.whence.clean(cx),
42504250
visibility: Some(Public),
42514251
stability: cx.stability(self.hid).clean(cx),
4252-
deprecation: self.depr.clean(cx),
4252+
deprecation: cx.deprecation(self.hid).clean(cx),
42534253
def_id: self.def_id,
42544254
inner: MacroItem(Macro {
42554255
source: format!("macro_rules! {} {{\n{}}}",
@@ -4277,7 +4277,7 @@ impl Clean<Item> for doctree::ProcMacro<'_> {
42774277
source: self.whence.clean(cx),
42784278
visibility: Some(Public),
42794279
stability: cx.stability(self.id).clean(cx),
4280-
deprecation: self.depr.clean(cx),
4280+
deprecation: cx.deprecation(self.id).clean(cx),
42814281
def_id: cx.tcx.hir().local_def_id(self.id),
42824282
inner: ProcMacroItem(ProcMacro {
42834283
kind: self.kind,

src/librustdoc/core.rs

+5
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ impl<'tcx> DocContext<'tcx> {
171171
self.tcx.hir().opt_local_def_id(id)
172172
.and_then(|def_id| self.tcx.lookup_stability(def_id)).cloned()
173173
}
174+
175+
pub fn deprecation(&self, id: HirId) -> Option<attr::Deprecation> {
176+
self.tcx.hir().opt_local_def_id(id)
177+
.and_then(|def_id| self.tcx.lookup_deprecation(def_id))
178+
}
174179
}
175180

176181
pub trait DocAccessLevels {

src/librustdoc/doctree.rs

-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub use self::StructType::*;
44

55
use syntax::ast;
66
use syntax::ast::{Name, NodeId};
7-
use syntax::attr;
87
use syntax::ext::base::MacroKind;
98
use syntax_pos::{self, Span};
109

@@ -32,7 +31,6 @@ pub struct Module<'hir> {
3231
pub constants: Vec<Constant<'hir>>,
3332
pub traits: Vec<Trait<'hir>>,
3433
pub vis: &'hir hir::Visibility,
35-
pub depr: Option<attr::Deprecation>,
3634
pub impls: Vec<Impl<'hir>>,
3735
pub foreigns: Vec<ForeignItem<'hir>>,
3836
pub macros: Vec<Macro<'hir>>,
@@ -52,7 +50,6 @@ impl Module<'hir> {
5250
id: ast::CRATE_NODE_ID,
5351
hid: hir::CRATE_HIR_ID,
5452
vis,
55-
depr: None,
5653
where_outer: syntax_pos::DUMMY_SP,
5754
where_inner: syntax_pos::DUMMY_SP,
5855
attrs,
@@ -90,7 +87,6 @@ pub enum StructType {
9087

9188
pub struct Struct<'hir> {
9289
pub vis: &'hir hir::Visibility,
93-
pub depr: Option<attr::Deprecation>,
9490
pub id: hir::HirId,
9591
pub struct_type: StructType,
9692
pub name: Name,
@@ -102,7 +98,6 @@ pub struct Struct<'hir> {
10298

10399
pub struct Union<'hir> {
104100
pub vis: &'hir hir::Visibility,
105-
pub depr: Option<attr::Deprecation>,
106101
pub id: hir::HirId,
107102
pub struct_type: StructType,
108103
pub name: Name,
@@ -114,7 +109,6 @@ pub struct Union<'hir> {
114109

115110
pub struct Enum<'hir> {
116111
pub vis: &'hir hir::Visibility,
117-
pub depr: Option<attr::Deprecation>,
118112
pub variants: Vec<Variant<'hir>>,
119113
pub generics: &'hir hir::Generics,
120114
pub attrs: &'hir hir::HirVec<ast::Attribute>,
@@ -128,7 +122,6 @@ pub struct Variant<'hir> {
128122
pub id: hir::HirId,
129123
pub attrs: &'hir hir::HirVec<ast::Attribute>,
130124
pub def: &'hir hir::VariantData,
131-
pub depr: Option<attr::Deprecation>,
132125
pub whence: Span,
133126
}
134127

@@ -138,7 +131,6 @@ pub struct Function<'hir> {
138131
pub id: hir::HirId,
139132
pub name: Name,
140133
pub vis: &'hir hir::Visibility,
141-
pub depr: Option<attr::Deprecation>,
142134
pub header: hir::FnHeader,
143135
pub whence: Span,
144136
pub generics: &'hir hir::Generics,
@@ -153,7 +145,6 @@ pub struct Typedef<'hir> {
153145
pub attrs: &'hir hir::HirVec<ast::Attribute>,
154146
pub whence: Span,
155147
pub vis: &'hir hir::Visibility,
156-
pub depr: Option<attr::Deprecation>,
157148
}
158149

159150
pub struct OpaqueTy<'hir> {
@@ -163,7 +154,6 @@ pub struct OpaqueTy<'hir> {
163154
pub attrs: &'hir hir::HirVec<ast::Attribute>,
164155
pub whence: Span,
165156
pub vis: &'hir hir::Visibility,
166-
pub depr: Option<attr::Deprecation>,
167157
}
168158

169159
#[derive(Debug)]
@@ -174,7 +164,6 @@ pub struct Static<'hir> {
174164
pub name: Name,
175165
pub attrs: &'hir hir::HirVec<ast::Attribute>,
176166
pub vis: &'hir hir::Visibility,
177-
pub depr: Option<attr::Deprecation>,
178167
pub id: hir::HirId,
179168
pub whence: Span,
180169
}
@@ -185,7 +174,6 @@ pub struct Constant<'hir> {
185174
pub name: Name,
186175
pub attrs: &'hir hir::HirVec<ast::Attribute>,
187176
pub vis: &'hir hir::Visibility,
188-
pub depr: Option<attr::Deprecation>,
189177
pub id: hir::HirId,
190178
pub whence: Span,
191179
}
@@ -201,7 +189,6 @@ pub struct Trait<'hir> {
201189
pub id: hir::HirId,
202190
pub whence: Span,
203191
pub vis: &'hir hir::Visibility,
204-
pub depr: Option<attr::Deprecation>,
205192
}
206193

207194
pub struct TraitAlias<'hir> {
@@ -212,7 +199,6 @@ pub struct TraitAlias<'hir> {
212199
pub id: hir::HirId,
213200
pub whence: Span,
214201
pub vis: &'hir hir::Visibility,
215-
pub depr: Option<attr::Deprecation>,
216202
}
217203

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

234219
pub struct ForeignItem<'hir> {
235220
pub vis: &'hir hir::Visibility,
236-
pub depr: Option<attr::Deprecation>,
237221
pub id: hir::HirId,
238222
pub name: Name,
239223
pub kind: &'hir hir::ForeignItemKind,
@@ -250,7 +234,6 @@ pub struct Macro<'hir> {
250234
pub attrs: &'hir hir::HirVec<ast::Attribute>,
251235
pub whence: Span,
252236
pub matchers: hir::HirVec<Span>,
253-
pub depr: Option<attr::Deprecation>,
254237
pub imported_from: Option<Name>,
255238
}
256239

@@ -280,7 +263,6 @@ pub struct ProcMacro<'hir> {
280263
pub helpers: Vec<Name>,
281264
pub attrs: &'hir hir::HirVec<ast::Attribute>,
282265
pub whence: Span,
283-
pub depr: Option<attr::Deprecation>,
284266
}
285267

286268
pub fn struct_type_from_def(vdata: &hir::VariantData) -> StructType {

0 commit comments

Comments
 (0)