Skip to content

Commit 67a9784

Browse files
committedDec 12, 2015
Support #[deprecated] in rustdoc
1 parent 105bd15 commit 67a9784

File tree

7 files changed

+121
-4
lines changed

7 files changed

+121
-4
lines changed
 

‎src/librustdoc/clean/inline.rs

+5
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt,
121121
inner: inner,
122122
visibility: Some(hir::Public),
123123
stability: stability::lookup_stability(tcx, did).clean(cx),
124+
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
124125
def_id: did,
125126
});
126127
Some(ret)
@@ -304,6 +305,7 @@ pub fn build_impl(cx: &DocContext,
304305
attrs: attrs,
305306
visibility: Some(hir::Inherited),
306307
stability: stability::lookup_stability(tcx, did).clean(cx),
308+
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
307309
def_id: did,
308310
});
309311
}
@@ -334,6 +336,7 @@ pub fn build_impl(cx: &DocContext,
334336
attrs: vec![],
335337
visibility: None,
336338
stability: stability::lookup_stability(tcx, did).clean(cx),
339+
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
337340
def_id: did
338341
})
339342
}
@@ -382,6 +385,7 @@ pub fn build_impl(cx: &DocContext,
382385
attrs: vec![],
383386
visibility: None,
384387
stability: stability::lookup_stability(tcx, did).clean(cx),
388+
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
385389
def_id: did
386390
})
387391
}
@@ -415,6 +419,7 @@ pub fn build_impl(cx: &DocContext,
415419
attrs: attrs,
416420
visibility: Some(hir::Inherited),
417421
stability: stability::lookup_stability(tcx, did).clean(cx),
422+
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
418423
def_id: did,
419424
});
420425

‎src/librustdoc/clean/mod.rs

+45
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ fn get_stability(cx: &DocContext, def_id: DefId) -> Option<Stability> {
6565
cx.tcx_opt().and_then(|tcx| stability::lookup_stability(tcx, def_id)).clean(cx)
6666
}
6767

68+
fn get_deprecation(cx: &DocContext, def_id: DefId) -> Option<Deprecation> {
69+
cx.tcx_opt().and_then(|tcx| stability::lookup_deprecation(tcx, def_id)).clean(cx)
70+
}
71+
6872
pub trait Clean<T> {
6973
fn clean(&self, cx: &DocContext) -> T;
7074
}
@@ -188,6 +192,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
188192
attrs: child.attrs.clone(),
189193
visibility: Some(hir::Public),
190194
stability: None,
195+
deprecation: None,
191196
def_id: DefId::local(prim.to_def_index()),
192197
inner: PrimitiveItem(prim),
193198
});
@@ -254,6 +259,7 @@ pub struct Item {
254259
pub visibility: Option<Visibility>,
255260
pub def_id: DefId,
256261
pub stability: Option<Stability>,
262+
pub deprecation: Option<Deprecation>,
257263
}
258264

259265
impl Item {
@@ -417,6 +423,7 @@ impl Clean<Item> for doctree::Module {
417423
source: whence.clean(cx),
418424
visibility: self.vis.clean(cx),
419425
stability: self.stab.clean(cx),
426+
deprecation: self.depr.clean(cx),
420427
def_id: cx.map.local_def_id(self.id),
421428
inner: ModuleItem(Module {
422429
is_crate: self.is_crate,
@@ -1078,6 +1085,7 @@ impl Clean<Item> for doctree::Function {
10781085
source: self.whence.clean(cx),
10791086
visibility: self.vis.clean(cx),
10801087
stability: self.stab.clean(cx),
1088+
deprecation: self.depr.clean(cx),
10811089
def_id: cx.map.local_def_id(self.id),
10821090
inner: FunctionItem(Function {
10831091
decl: self.decl.clean(cx),
@@ -1204,6 +1212,7 @@ impl Clean<Item> for doctree::Trait {
12041212
def_id: cx.map.local_def_id(self.id),
12051213
visibility: self.vis.clean(cx),
12061214
stability: self.stab.clean(cx),
1215+
deprecation: self.depr.clean(cx),
12071216
inner: TraitItem(Trait {
12081217
unsafety: self.unsafety,
12091218
items: self.items.clean(cx),
@@ -1254,6 +1263,7 @@ impl Clean<Item> for hir::TraitItem {
12541263
def_id: cx.map.local_def_id(self.id),
12551264
visibility: None,
12561265
stability: get_stability(cx, cx.map.local_def_id(self.id)),
1266+
deprecation: get_deprecation(cx, cx.map.local_def_id(self.id)),
12571267
inner: inner
12581268
}
12591269
}
@@ -1287,6 +1297,7 @@ impl Clean<Item> for hir::ImplItem {
12871297
def_id: cx.map.local_def_id(self.id),
12881298
visibility: self.vis.clean(cx),
12891299
stability: get_stability(cx, cx.map.local_def_id(self.id)),
1300+
deprecation: get_deprecation(cx, cx.map.local_def_id(self.id)),
12901301
inner: inner
12911302
}
12921303
}
@@ -1357,6 +1368,7 @@ impl<'tcx> Clean<Item> for ty::Method<'tcx> {
13571368
name: Some(self.name.clean(cx)),
13581369
visibility: Some(hir::Inherited),
13591370
stability: get_stability(cx, self.def_id),
1371+
deprecation: get_deprecation(cx, self.def_id),
13601372
def_id: self.def_id,
13611373
attrs: inline::load_attrs(cx, cx.tcx(), self.def_id),
13621374
source: Span::empty(),
@@ -1715,6 +1727,7 @@ impl Clean<Item> for hir::StructField {
17151727
source: self.span.clean(cx),
17161728
visibility: Some(vis),
17171729
stability: get_stability(cx, cx.map.local_def_id(self.node.id)),
1730+
deprecation: get_deprecation(cx, cx.map.local_def_id(self.node.id)),
17181731
def_id: cx.map.local_def_id(self.node.id),
17191732
inner: StructFieldItem(TypedStructField(self.node.ty.clean(cx))),
17201733
}
@@ -1740,6 +1753,7 @@ impl<'tcx> Clean<Item> for ty::FieldDefData<'tcx, 'static> {
17401753
source: Span::empty(),
17411754
visibility: Some(self.vis),
17421755
stability: get_stability(cx, self.did),
1756+
deprecation: get_deprecation(cx, self.did),
17431757
def_id: self.did,
17441758
inner: StructFieldItem(TypedStructField(self.unsubst_ty().clean(cx))),
17451759
}
@@ -1771,6 +1785,7 @@ impl Clean<Item> for doctree::Struct {
17711785
def_id: cx.map.local_def_id(self.id),
17721786
visibility: self.vis.clean(cx),
17731787
stability: self.stab.clean(cx),
1788+
deprecation: self.depr.clean(cx),
17741789
inner: StructItem(Struct {
17751790
struct_type: self.struct_type,
17761791
generics: self.generics.clean(cx),
@@ -1817,6 +1832,7 @@ impl Clean<Item> for doctree::Enum {
18171832
def_id: cx.map.local_def_id(self.id),
18181833
visibility: self.vis.clean(cx),
18191834
stability: self.stab.clean(cx),
1835+
deprecation: self.depr.clean(cx),
18201836
inner: EnumItem(Enum {
18211837
variants: self.variants.clean(cx),
18221838
generics: self.generics.clean(cx),
@@ -1839,6 +1855,7 @@ impl Clean<Item> for doctree::Variant {
18391855
source: self.whence.clean(cx),
18401856
visibility: None,
18411857
stability: self.stab.clean(cx),
1858+
deprecation: self.depr.clean(cx),
18421859
def_id: cx.map.local_def_id(self.def.id()),
18431860
inner: VariantItem(Variant {
18441861
kind: struct_def_to_variant_kind(&self.def, cx),
@@ -1876,6 +1893,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
18761893
// at the needed information here.
18771894
def_id: self.did,
18781895
stability: get_stability(cx, self.did),
1896+
deprecation: get_deprecation(cx, self.did),
18791897
inner: StructFieldItem(
18801898
TypedStructField(field.unsubst_ty().clean(cx))
18811899
)
@@ -1892,6 +1910,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
18921910
def_id: self.did,
18931911
inner: VariantItem(Variant { kind: kind }),
18941912
stability: get_stability(cx, self.did),
1913+
deprecation: get_deprecation(cx, self.did),
18951914
}
18961915
}
18971916
}
@@ -2067,6 +2086,7 @@ impl Clean<Item> for doctree::Typedef {
20672086
def_id: cx.map.local_def_id(self.id.clone()),
20682087
visibility: self.vis.clean(cx),
20692088
stability: self.stab.clean(cx),
2089+
deprecation: self.depr.clean(cx),
20702090
inner: TypedefItem(Typedef {
20712091
type_: self.ty.clean(cx),
20722092
generics: self.gen.clean(cx),
@@ -2118,6 +2138,7 @@ impl Clean<Item> for doctree::Static {
21182138
def_id: cx.map.local_def_id(self.id),
21192139
visibility: self.vis.clean(cx),
21202140
stability: self.stab.clean(cx),
2141+
deprecation: self.depr.clean(cx),
21212142
inner: StaticItem(Static {
21222143
type_: self.type_.clean(cx),
21232144
mutability: self.mutability.clean(cx),
@@ -2142,6 +2163,7 @@ impl Clean<Item> for doctree::Constant {
21422163
def_id: cx.map.local_def_id(self.id),
21432164
visibility: self.vis.clean(cx),
21442165
stability: self.stab.clean(cx),
2166+
deprecation: self.depr.clean(cx),
21452167
inner: ConstantItem(Constant {
21462168
type_: self.type_.clean(cx),
21472169
expr: self.expr.span.to_src(cx),
@@ -2216,6 +2238,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
22162238
def_id: cx.map.local_def_id(self.id),
22172239
visibility: self.vis.clean(cx),
22182240
stability: self.stab.clean(cx),
2241+
deprecation: self.depr.clean(cx),
22192242
inner: ImplItem(Impl {
22202243
unsafety: self.unsafety,
22212244
generics: self.generics.clean(cx),
@@ -2298,6 +2321,7 @@ impl Clean<Item> for doctree::DefaultImpl {
22982321
def_id: cx.map.local_def_id(self.id),
22992322
visibility: Some(hir::Public),
23002323
stability: None,
2324+
deprecation: None,
23012325
inner: DefaultImplItem(DefaultImpl {
23022326
unsafety: self.unsafety,
23032327
trait_: self.trait_.clean(cx),
@@ -2315,6 +2339,7 @@ impl Clean<Item> for doctree::ExternCrate {
23152339
def_id: cx.map.local_def_id(0),
23162340
visibility: self.vis.clean(cx),
23172341
stability: None,
2342+
deprecation: None,
23182343
inner: ExternCrateItem(self.name.clean(cx), self.path.clone())
23192344
}
23202345
}
@@ -2380,6 +2405,7 @@ impl Clean<Vec<Item>> for doctree::Import {
23802405
def_id: cx.map.local_def_id(0),
23812406
visibility: self.vis.clean(cx),
23822407
stability: None,
2408+
deprecation: None,
23832409
inner: ImportItem(inner)
23842410
});
23852411
ret
@@ -2466,6 +2492,7 @@ impl Clean<Item> for hir::ForeignItem {
24662492
def_id: cx.map.local_def_id(self.id),
24672493
visibility: self.vis.clean(cx),
24682494
stability: get_stability(cx, cx.map.local_def_id(self.id)),
2495+
deprecation: get_deprecation(cx, cx.map.local_def_id(self.id)),
24692496
inner: inner,
24702497
}
24712498
}
@@ -2659,6 +2686,7 @@ impl Clean<Item> for doctree::Macro {
26592686
source: self.whence.clean(cx),
26602687
visibility: hir::Public.clean(cx),
26612688
stability: self.stab.clean(cx),
2689+
deprecation: self.depr.clean(cx),
26622690
def_id: cx.map.local_def_id(self.id),
26632691
inner: MacroItem(Macro {
26642692
source: format!("macro_rules! {} {{\n{}}}",
@@ -2680,6 +2708,12 @@ pub struct Stability {
26802708
pub issue: Option<u32>
26812709
}
26822710

2711+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
2712+
pub struct Deprecation {
2713+
pub since: String,
2714+
pub note: String,
2715+
}
2716+
26832717
impl Clean<Stability> for attr::Stability {
26842718
fn clean(&self, _: &DocContext) -> Stability {
26852719
Stability {
@@ -2716,6 +2750,15 @@ impl<'a> Clean<Stability> for &'a attr::Stability {
27162750
}
27172751
}
27182752

2753+
impl Clean<Deprecation> for attr::Deprecation {
2754+
fn clean(&self, _: &DocContext) -> Deprecation {
2755+
Deprecation {
2756+
since: self.since.as_ref().map_or("".to_string(), |s| s.to_string()),
2757+
note: self.note.as_ref().map_or("".to_string(), |s| s.to_string()),
2758+
}
2759+
}
2760+
}
2761+
27192762
impl<'tcx> Clean<Item> for ty::AssociatedConst<'tcx> {
27202763
fn clean(&self, cx: &DocContext) -> Item {
27212764
Item {
@@ -2726,6 +2769,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedConst<'tcx> {
27262769
visibility: None,
27272770
def_id: self.def_id,
27282771
stability: None,
2772+
deprecation: None,
27292773
}
27302774
}
27312775
}
@@ -2783,6 +2827,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedType<'tcx> {
27832827
visibility: self.vis.clean(cx),
27842828
def_id: self.def_id,
27852829
stability: stability::lookup_stability(cx.tcx(), self.def_id).clean(cx),
2830+
deprecation: stability::lookup_deprecation(cx.tcx(), self.def_id).clean(cx),
27862831
}
27872832
}
27882833
}

‎src/librustdoc/doctree.rs

+12
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub struct Module {
4040
pub traits: Vec<Trait>,
4141
pub vis: hir::Visibility,
4242
pub stab: Option<attr::Stability>,
43+
pub depr: Option<attr::Deprecation>,
4344
pub impls: Vec<Impl>,
4445
pub def_traits: Vec<DefaultImpl>,
4546
pub foreigns: Vec<hir::ForeignMod>,
@@ -54,6 +55,7 @@ impl Module {
5455
id: 0,
5556
vis: hir::Inherited,
5657
stab: None,
58+
depr: None,
5759
where_outer: syntax::codemap::DUMMY_SP,
5860
where_inner: syntax::codemap::DUMMY_SP,
5961
attrs : Vec::new(),
@@ -96,6 +98,7 @@ pub enum TypeBound {
9698
pub struct Struct {
9799
pub vis: hir::Visibility,
98100
pub stab: Option<attr::Stability>,
101+
pub depr: Option<attr::Deprecation>,
99102
pub id: NodeId,
100103
pub struct_type: StructType,
101104
pub name: Name,
@@ -108,6 +111,7 @@ pub struct Struct {
108111
pub struct Enum {
109112
pub vis: hir::Visibility,
110113
pub stab: Option<attr::Stability>,
114+
pub depr: Option<attr::Deprecation>,
111115
pub variants: Vec<Variant>,
112116
pub generics: hir::Generics,
113117
pub attrs: Vec<ast::Attribute>,
@@ -121,6 +125,7 @@ pub struct Variant {
121125
pub attrs: Vec<ast::Attribute>,
122126
pub def: hir::VariantData,
123127
pub stab: Option<attr::Stability>,
128+
pub depr: Option<attr::Deprecation>,
124129
pub whence: Span,
125130
}
126131

@@ -131,6 +136,7 @@ pub struct Function {
131136
pub name: Name,
132137
pub vis: hir::Visibility,
133138
pub stab: Option<attr::Stability>,
139+
pub depr: Option<attr::Deprecation>,
134140
pub unsafety: hir::Unsafety,
135141
pub constness: hir::Constness,
136142
pub whence: Span,
@@ -147,6 +153,7 @@ pub struct Typedef {
147153
pub whence: Span,
148154
pub vis: hir::Visibility,
149155
pub stab: Option<attr::Stability>,
156+
pub depr: Option<attr::Deprecation>,
150157
}
151158

152159
#[derive(Debug)]
@@ -158,6 +165,7 @@ pub struct Static {
158165
pub attrs: Vec<ast::Attribute>,
159166
pub vis: hir::Visibility,
160167
pub stab: Option<attr::Stability>,
168+
pub depr: Option<attr::Deprecation>,
161169
pub id: ast::NodeId,
162170
pub whence: Span,
163171
}
@@ -169,6 +177,7 @@ pub struct Constant {
169177
pub attrs: Vec<ast::Attribute>,
170178
pub vis: hir::Visibility,
171179
pub stab: Option<attr::Stability>,
180+
pub depr: Option<attr::Deprecation>,
172181
pub id: ast::NodeId,
173182
pub whence: Span,
174183
}
@@ -184,6 +193,7 @@ pub struct Trait {
184193
pub whence: Span,
185194
pub vis: hir::Visibility,
186195
pub stab: Option<attr::Stability>,
196+
pub depr: Option<attr::Deprecation>,
187197
}
188198

189199
pub struct Impl {
@@ -197,6 +207,7 @@ pub struct Impl {
197207
pub whence: Span,
198208
pub vis: hir::Visibility,
199209
pub stab: Option<attr::Stability>,
210+
pub depr: Option<attr::Deprecation>,
200211
pub id: ast::NodeId,
201212
}
202213

@@ -215,6 +226,7 @@ pub struct Macro {
215226
pub whence: Span,
216227
pub matchers: Vec<Span>,
217228
pub stab: Option<attr::Stability>,
229+
pub depr: Option<attr::Deprecation>,
218230
pub imported_from: Option<Name>,
219231
}
220232

‎src/librustdoc/fold.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub trait DocFolder : Sized {
1919

2020
/// don't override!
2121
fn fold_item_recur(&mut self, item: Item) -> Option<Item> {
22-
let Item { attrs, name, source, visibility, def_id, inner, stability } = item;
22+
let Item { attrs, name, source, visibility, def_id, inner, stability, deprecation } = item;
2323
let inner = inner;
2424
let inner = match inner {
2525
StructItem(mut i) => {
@@ -66,7 +66,8 @@ pub trait DocFolder : Sized {
6666
};
6767

6868
Some(Item { attrs: attrs, name: name, source: source, inner: inner,
69-
visibility: visibility, stability: stability, def_id: def_id })
69+
visibility: visibility, stability: stability, deprecation: deprecation,
70+
def_id: def_id })
7071
}
7172

7273
fn fold_mod(&mut self, m: Module) -> Module {

‎src/librustdoc/html/render.rs

+22-2
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
18011801
}
18021802

18031803
fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Option<String> {
1804-
item.stability.as_ref().and_then(|stab| {
1804+
let mut result = item.stability.as_ref().and_then(|stab| {
18051805
let reason = if show_reason && !stab.reason.is_empty() {
18061806
format!(": {}", stab.reason)
18071807
} else {
@@ -1836,7 +1836,27 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Optio
18361836
};
18371837
Some(format!("<em class='stab {}'>{}</em>",
18381838
item.stability_class(), text))
1839-
})
1839+
});
1840+
1841+
if result.is_none() {
1842+
result = item.deprecation.as_ref().and_then(|depr| {
1843+
let note = if show_reason && !depr.note.is_empty() {
1844+
format!(": {}", depr.note)
1845+
} else {
1846+
String::new()
1847+
};
1848+
let since = if show_reason && !depr.since.is_empty() {
1849+
format!(" since {}", Escape(&depr.since))
1850+
} else {
1851+
String::new()
1852+
};
1853+
1854+
let text = format!("Deprecated{}{}", since, Markdown(&note));
1855+
Some(format!("<em class='stab deprecated'>{}</em>", text))
1856+
});
1857+
}
1858+
1859+
result
18401860
}
18411861

18421862
struct Initializer<'a>(&'a str);

‎src/librustdoc/visit_ast.rs

+18
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
6969
})
7070
}
7171

72+
fn deprecation(&self, id: ast::NodeId) -> Option<attr::Deprecation> {
73+
self.cx.tcx_opt().and_then(|tcx| {
74+
self.cx.map.opt_local_def_id(id)
75+
.and_then(|def_id| stability::lookup_deprecation(tcx, def_id))
76+
})
77+
}
78+
7279
pub fn visit(&mut self, krate: &hir::Crate) {
7380
self.attrs = krate.attrs.clone();
7481

@@ -95,6 +102,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
95102
name: name,
96103
vis: item.vis,
97104
stab: self.stability(item.id),
105+
depr: self.deprecation(item.id),
98106
attrs: item.attrs.clone(),
99107
generics: generics.clone(),
100108
fields: sd.fields().iter().cloned().collect(),
@@ -112,11 +120,13 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
112120
name: v.node.name,
113121
attrs: v.node.attrs.clone(),
114122
stab: self.stability(v.node.data.id()),
123+
depr: self.deprecation(v.node.data.id()),
115124
def: v.node.data.clone(),
116125
whence: v.span,
117126
}).collect(),
118127
vis: it.vis,
119128
stab: self.stability(it.id),
129+
depr: self.deprecation(it.id),
120130
generics: params.clone(),
121131
attrs: it.attrs.clone(),
122132
id: it.id,
@@ -135,6 +145,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
135145
id: item.id,
136146
vis: item.vis,
137147
stab: self.stability(item.id),
148+
depr: self.deprecation(item.id),
138149
attrs: item.attrs.clone(),
139150
decl: fd.clone(),
140151
name: name,
@@ -156,6 +167,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
156167
om.attrs = attrs;
157168
om.vis = vis;
158169
om.stab = self.stability(id);
170+
om.depr = self.deprecation(id);
159171
om.id = id;
160172
for i in &m.item_ids {
161173
let item = self.cx.map.expect_item(i.id);
@@ -314,6 +326,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
314326
whence: item.span,
315327
vis: item.vis,
316328
stab: self.stability(item.id),
329+
depr: self.deprecation(item.id),
317330
};
318331
om.typedefs.push(t);
319332
},
@@ -328,6 +341,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
328341
whence: item.span,
329342
vis: item.vis,
330343
stab: self.stability(item.id),
344+
depr: self.deprecation(item.id),
331345
};
332346
om.statics.push(s);
333347
},
@@ -341,6 +355,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
341355
whence: item.span,
342356
vis: item.vis,
343357
stab: self.stability(item.id),
358+
depr: self.deprecation(item.id),
344359
};
345360
om.constants.push(s);
346361
},
@@ -356,6 +371,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
356371
whence: item.span,
357372
vis: item.vis,
358373
stab: self.stability(item.id),
374+
depr: self.deprecation(item.id),
359375
};
360376
om.traits.push(t);
361377
},
@@ -372,6 +388,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
372388
whence: item.span,
373389
vis: item.vis,
374390
stab: self.stability(item.id),
391+
depr: self.deprecation(item.id),
375392
};
376393
// Don't duplicate impls when inlining glob imports, we'll pick
377394
// them up regardless of where they're located.
@@ -410,6 +427,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
410427
whence: def.span,
411428
matchers: matchers,
412429
stab: self.stability(def.id),
430+
depr: self.deprecation(def.id),
413431
imported_from: def.imported_from,
414432
}
415433
}

‎src/test/rustdoc/deprecated.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(deprecated)]
12+
13+
// @has deprecated/struct.S.html '//*[@class="stab deprecated"]' \
14+
// 'Deprecated since 1.0.0: text'
15+
#[deprecated(since = "1.0.0", note = "text")]
16+
pub struct S;

0 commit comments

Comments
 (0)
Please sign in to comment.