Now also displays portability tags.

This commit is contained in:
Tor Hovland 2021-04-14 20:49:08 +02:00
parent 1e2ab998c3
commit fca088ae23
5 changed files with 36 additions and 14 deletions

View File

@ -477,6 +477,7 @@ fn build_module(
}],
},
did: None,
attrs: None,
},
true,
)),

View File

@ -2081,6 +2081,7 @@ impl Import {
crate struct ImportSource {
crate path: Path,
crate did: Option<DefId>,
crate attrs: Option<Attributes>,
}
#[derive(Clone, Debug)]

View File

@ -468,10 +468,10 @@ fn print_const_with_custom_print_scalar(tcx: TyCtxt<'_>, ct: &'tcx ty::Const<'tc
}
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

View File

@ -282,9 +282,14 @@ fn cmp(
}
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)

View File

@ -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'
pub use io::Writer;
// @has - '//span' 'sync'
pub use tag::Portability;
}
// @has foo/mod3/index.html
pub mod mod3 {
// @has - '//code' 'pub use tag::Unstable;'
// @!has - '//span' 'Deprecated'
// @!has - '//span' 'sync'
pub use tag::Unstable;
}