Skip to content

Commit fca088a

Browse files
author
Tor Hovland
committed
Now also displays portability tags.
1 parent 1e2ab99 commit fca088a

File tree

5 files changed

+36
-14
lines changed

5 files changed

+36
-14
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ fn build_module(
477477
}],
478478
},
479479
did: None,
480+
attrs: None,
480481
},
481482
true,
482483
)),

src/librustdoc/clean/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,7 @@ crate enum ImportKind {
20812081
crate struct ImportSource {
20822082
crate path: Path,
20832083
crate did: Option<DefId>,
2084+
crate attrs: Option<Attributes>,
20842085
}
20852086

20862087
#[derive(Clone, Debug)]

src/librustdoc/clean/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,10 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
468468
}
469469

470470
crate fn resolve_use_source(cx: &mut DocContext<'_>, path: Path) -> ImportSource {
471-
ImportSource {
472-
did: if path.res.opt_def_id().is_none() { None } else { Some(register_res(cx, path.res)) },
473-
path,
474-
}
471+
let did = if path.res.opt_def_id().is_none() { None } else { Some(register_res(cx, path.res)) };
472+
let attrs = did.map(|did| cx.tcx.get_attrs(did).clean(cx));
473+
474+
ImportSource { did, path, attrs }
475475
}
476476

477477
crate fn enter_impl_trait<F, R>(cx: &mut DocContext<'_>, f: F) -> R

src/librustdoc/html/render/print_item.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,14 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
282282
}
283283

284284
clean::ImportItem(ref import) => {
285-
let (stab, stab_tags) = if let Some(def_id) = import.source.did {
286-
// Just need an item with the correct def_id
287-
let import_item = clean::Item { def_id, ..myitem.clone() };
285+
let (stab, stab_tags) = if let (Some(def_id), Some(attrs)) =
286+
(import.source.did, import.source.attrs.clone())
287+
{
288+
let attrs = Box::new(attrs);
289+
290+
// Just need an item with the correct def_id and attrs
291+
let import_item = clean::Item { def_id, attrs, ..myitem.clone() };
292+
288293
let stab = import_item.stability_class(cx.tcx());
289294
let stab_tags = Some(extra_info_tags(&import_item, item, cx.tcx()));
290295
(stab, stab_tags)

src/test/rustdoc/issue-83832.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
#![crate_name = "foo"]
2+
#![feature(doc_cfg)]
23

3-
pub mod io {
4+
pub mod tag {
45
#[deprecated(since = "0.1.8", note = "Use bar() instead")]
5-
pub trait Reader {}
6-
pub trait Writer {}
6+
pub trait Deprecated {}
7+
8+
#[doc(cfg(feature = "sync"))]
9+
pub trait Portability {}
10+
11+
pub trait Unstable {}
712
}
813

914
// @has foo/mod1/index.html
1015
pub mod mod1 {
11-
// @has - '//code' 'pub use io::Reader;'
16+
// @has - '//code' 'pub use tag::Deprecated;'
1217
// @has - '//span' 'Deprecated'
13-
pub use io::Reader;
18+
// @!has - '//span' 'sync'
19+
pub use tag::Deprecated;
1420
}
1521

1622
// @has foo/mod2/index.html
1723
pub mod mod2 {
18-
// @has - '//code' 'pub use io::Writer;'
24+
// @has - '//code' 'pub use tag::Portability;'
25+
// @!has - '//span' 'Deprecated'
26+
// @has - '//span' 'sync'
27+
pub use tag::Portability;
28+
}
29+
30+
// @has foo/mod3/index.html
31+
pub mod mod3 {
32+
// @has - '//code' 'pub use tag::Unstable;'
1933
// @!has - '//span' 'Deprecated'
20-
pub use io::Writer;
34+
// @!has - '//span' 'sync'
35+
pub use tag::Unstable;
2136
}

0 commit comments

Comments
 (0)