1
Fork 0

Stringify non-shorthand visibility correctly

This commit is contained in:
Jacob Pratt 2022-08-09 23:31:45 -04:00
parent 34a6cae28e
commit be5672ecb2
No known key found for this signature in database
GPG key ID: B80E19E4662B5AA4
6 changed files with 18 additions and 9 deletions

View file

@ -412,9 +412,9 @@ impl<'a> State<'a> {
pub(crate) fn print_visibility(&mut self, vis: &ast::Visibility) {
match vis.kind {
ast::VisibilityKind::Public => self.word_nbsp("pub"),
ast::VisibilityKind::Restricted { ref path, .. } => {
ast::VisibilityKind::Restricted { ref path, id: _, shorthand } => {
let path = Self::to_string(|s| s.print_path(path, false, 0));
if path == "crate" || path == "self" || path == "super" {
if shorthand && (path == "crate" || path == "self" || path == "super") {
self.word_nbsp(format!("pub({})", path))
} else {
self.word_nbsp(format!("pub(in {})", path))