rustdoc: Add support for pub(restricted)

This commit is contained in:
Oliver Middleton 2018-05-12 18:25:09 +01:00
parent fe63e479d1
commit 3daded02fa
3 changed files with 71 additions and 5 deletions

View file

@ -927,8 +927,19 @@ impl<'a> fmt::Display for Method<'a> {
impl<'a> fmt::Display for VisSpace<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self.get() {
Some(clean::Public) => write!(f, "pub "),
Some(clean::Inherited) | None => Ok(())
Some(clean::Public) => f.write_str("pub "),
Some(clean::Inherited) | None => Ok(()),
Some(clean::Visibility::Crate) => write!(f, "pub(crate) "),
Some(clean::Visibility::Restricted(did, ref path)) => {
f.write_str("pub(")?;
if path.segments.len() != 1
|| (path.segments[0].name != "self" && path.segments[0].name != "super")
{
f.write_str("in ")?;
}
resolved_path(f, did, path, true, false)?;
f.write_str(") ")
}
}
}
}