diff options
| author | Alex Burka <alex@alexburka.com> | 2017-04-02 04:46:33 +0000 |
|---|---|---|
| committer | Alex Burka <alex@alexburka.com> | 2017-04-15 19:06:19 +0000 |
| commit | 06411c47694916aaf22ef30b6b8877d7659b2002 (patch) | |
| tree | 396ca0db76d8a07af7d0b0c0ea6cb4f929d84bcd | |
| parent | d53e413e04e438fd0dc1a8b1a8dcb07a0774092a (diff) | |
| download | rust-06411c47694916aaf22ef30b6b8877d7659b2002.tar.gz rust-06411c47694916aaf22ef30b6b8877d7659b2002.zip | |
update print_visibility for new pub(restricted) syntax
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 2494af2c161..be1d26f8fe4 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -432,13 +432,7 @@ 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({}) {}", to_string(|s| s.print_path(path, false, 0, true)), s), - ast::Visibility::Inherited => s.to_string() - } + format!("{}{}", to_string(|s| s.print_visibility(vis)), s) } fn needs_parentheses(expr: &ast::Expr) -> bool { @@ -1473,7 +1467,11 @@ impl<'a> State<'a> { ast::Visibility::Crate(_) => self.word_nbsp("pub(crate)"), ast::Visibility::Restricted { ref path, .. } => { let path = to_string(|s| s.print_path(path, false, 0, true)); - self.word_nbsp(&format!("pub({})", path)) + if path == "self" || path == "super" { + self.word_nbsp(&format!("pub({})", path)) + } else { + self.word_nbsp(&format!("pub(in {})", path)) + } } ast::Visibility::Inherited => Ok(()) } |
