about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTor Hovland <tor.hovland@bekk.no>2021-04-14 20:49:08 +0200
committerTor Hovland <tor.hovland@bekk.no>2021-04-18 10:46:06 +0200
commitfca088ae23cd2f3ea261e1d0c04e799a2918bb6f (patch)
tree426d2e5666b5b53be372ec71bb79d34dc4b11edd /src
parent1e2ab998c378e3c9b532e811a8f93b6a65711f92 (diff)
downloadrust-fca088ae23cd2f3ea261e1d0c04e799a2918bb6f.tar.gz
rust-fca088ae23cd2f3ea261e1d0c04e799a2918bb6f.zip
Now also displays portability tags.
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/inline.rs1
-rw-r--r--src/librustdoc/clean/types.rs1
-rw-r--r--src/librustdoc/clean/utils.rs8
-rw-r--r--src/librustdoc/html/render/print_item.rs11
-rw-r--r--src/test/rustdoc/issue-83832.rs29
5 files changed, 36 insertions, 14 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 277ec91f15e..598d6da390a 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -477,6 +477,7 @@ fn build_module(
                                 }],
                             },
                             did: None,
+                            attrs: None,
                         },
                         true,
                     )),
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 2b25c6a26bc..75c541a50ed 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -2081,6 +2081,7 @@ crate enum ImportKind {
 crate struct ImportSource {
     crate path: Path,
     crate did: Option<DefId>,
+    crate attrs: Option<Attributes>,
 }
 
 #[derive(Clone, Debug)]
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
index c2a971d6375..898a5b0df5d 100644
--- a/src/librustdoc/clean/utils.rs
+++ b/src/librustdoc/clean/utils.rs
@@ -468,10 +468,10 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
 }
 
 crate fn resolve_use_source(cx: &mut DocContext<'_>, path: Path) -> ImportSource {
-    ImportSource {
-        did: if path.res.opt_def_id().is_none() { None } else { Some(register_res(cx, path.res)) },
-        path,
-    }
+    let did = if path.res.opt_def_id().is_none() { None } else { Some(register_res(cx, path.res)) };
+    let attrs = did.map(|did| cx.tcx.get_attrs(did).clean(cx));
+
+    ImportSource { did, path, attrs }
 }
 
 crate fn enter_impl_trait<F, R>(cx: &mut DocContext<'_>, f: F) -> R
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index c37a21d1ade..045ff5b4b89 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -282,9 +282,14 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
             }
 
             clean::ImportItem(ref import) => {
-                let (stab, stab_tags) = if let Some(def_id) = import.source.did {
-                    // Just need an item with the correct def_id
-                    let import_item = clean::Item { def_id, ..myitem.clone() };
+                let (stab, stab_tags) = if let (Some(def_id), Some(attrs)) =
+                    (import.source.did, import.source.attrs.clone())
+                {
+                    let attrs = Box::new(attrs);
+
+                    // Just need an item with the correct def_id and attrs
+                    let import_item = clean::Item { def_id, attrs, ..myitem.clone() };
+
                     let stab = import_item.stability_class(cx.tcx());
                     let stab_tags = Some(extra_info_tags(&import_item, item, cx.tcx()));
                     (stab, stab_tags)
diff --git a/src/test/rustdoc/issue-83832.rs b/src/test/rustdoc/issue-83832.rs
index 93dff7c6ce6..a00401fbe09 100644
--- a/src/test/rustdoc/issue-83832.rs
+++ b/src/test/rustdoc/issue-83832.rs
@@ -1,21 +1,36 @@
 #![crate_name = "foo"]
+#![feature(doc_cfg)]
 
-pub mod io {
+pub mod tag {
     #[deprecated(since = "0.1.8", note = "Use bar() instead")]
-    pub trait Reader {}
-    pub trait Writer {}
+    pub trait Deprecated {}
+
+    #[doc(cfg(feature = "sync"))]
+    pub trait Portability {}
+
+    pub trait Unstable {}
 }
 
 // @has foo/mod1/index.html
 pub mod mod1 {
-    // @has - '//code' 'pub use io::Reader;'
+    // @has - '//code' 'pub use tag::Deprecated;'
     // @has - '//span' 'Deprecated'
-    pub use io::Reader;
+    // @!has - '//span' 'sync'
+    pub use tag::Deprecated;
 }
 
 // @has foo/mod2/index.html
 pub mod mod2 {
-    // @has - '//code' 'pub use io::Writer;'
+    // @has - '//code' 'pub use tag::Portability;'
+    // @!has - '//span' 'Deprecated'
+    // @has - '//span' 'sync'
+    pub use tag::Portability;
+}
+
+// @has foo/mod3/index.html
+pub mod mod3 {
+    // @has - '//code' 'pub use tag::Unstable;'
     // @!has - '//span' 'Deprecated'
-    pub use io::Writer;
+    // @!has - '//span' 'sync'
+    pub use tag::Unstable;
 }