Skip to content

Commit 06411c4

Browse files
committed
update print_visibility for new pub(restricted) syntax
1 parent d53e413 commit 06411c4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/libsyntax/print/pprust.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,7 @@ pub fn mac_to_string(arg: &ast::Mac) -> String {
432432
}
433433

434434
pub fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
435-
match *vis {
436-
ast::Visibility::Public => format!("pub {}", s),
437-
ast::Visibility::Crate(_) => format!("pub(crate) {}", s),
438-
ast::Visibility::Restricted { ref path, .. } =>
439-
format!("pub({}) {}", to_string(|s| s.print_path(path, false, 0, true)), s),
440-
ast::Visibility::Inherited => s.to_string()
441-
}
435+
format!("{}{}", to_string(|s| s.print_visibility(vis)), s)
442436
}
443437

444438
fn needs_parentheses(expr: &ast::Expr) -> bool {
@@ -1473,7 +1467,11 @@ impl<'a> State<'a> {
14731467
ast::Visibility::Crate(_) => self.word_nbsp("pub(crate)"),
14741468
ast::Visibility::Restricted { ref path, .. } => {
14751469
let path = to_string(|s| s.print_path(path, false, 0, true));
1476-
self.word_nbsp(&format!("pub({})", path))
1470+
if path == "self" || path == "super" {
1471+
self.word_nbsp(&format!("pub({})", path))
1472+
} else {
1473+
self.word_nbsp(&format!("pub(in {})", path))
1474+
}
14771475
}
14781476
ast::Visibility::Inherited => Ok(())
14791477
}

0 commit comments

Comments
 (0)