Add Crate and Restricted variants to ast::Visibility

This commit is contained in:
Jeffrey Seyfried
2016-03-31 19:10:38 +00:00
parent bc355244df
commit 432eb8a094
6 changed files with 40 additions and 8 deletions

View File

@@ -435,6 +435,8 @@ pub fn mac_to_string(arg: &ast::Mac) -> String {
pub fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
match *vis {
ast::Visibility::Public => format!("pub {}", s),
ast::Visibility::Crate => format!("pub(crate) {}", s),
ast::Visibility::Restricted { ref path, .. } => format!("pub({}) {}", path, s),
ast::Visibility::Inherited => s.to_string()
}
}
@@ -1384,6 +1386,9 @@ impl<'a> State<'a> {
pub fn print_visibility(&mut self, vis: &ast::Visibility) -> io::Result<()> {
match *vis {
ast::Visibility::Public => self.word_nbsp("pub"),
ast::Visibility::Crate => self.word_nbsp("pub(crate)"),
ast::Visibility::Restricted { ref path, .. } =>
self.word_nbsp(&format!("pub({})", path)),
ast::Visibility::Inherited => Ok(())
}
}