diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2022-05-21 14:45:14 -0400 |
|---|---|---|
| committer | Jacob Pratt <jacob@jhpratt.dev> | 2022-05-21 17:02:55 -0400 |
| commit | 9b697d0b90f2e6e021564454c5481e2b1b3c0df4 (patch) | |
| tree | d6a73030bc99c6d1fb37b5bfee80b4727ed11ad0 | |
| parent | 0d27f70743e12255804d40ff491108c8962bd7a3 (diff) | |
| download | rust-9b697d0b90f2e6e021564454c5481e2b1b3c0df4.tar.gz rust-9b697d0b90f2e6e021564454c5481e2b1b3c0df4.zip | |
Merge crate and restricted visibilities
| -rw-r--r-- | src/items.rs | 2 | ||||
| -rw-r--r-- | src/utils.rs | 9 |
2 files changed, 3 insertions, 8 deletions
diff --git a/src/items.rs b/src/items.rs index ecbd44e1976..8816d7d2f1f 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1361,7 +1361,7 @@ pub(crate) fn format_struct_struct( fn get_bytepos_after_visibility(vis: &ast::Visibility, default_span: Span) -> BytePos { match vis.kind { - ast::VisibilityKind::Crate | ast::VisibilityKind::Restricted { .. } => vis.span.hi(), + ast::VisibilityKind::Restricted { .. } => vis.span.hi(), _ => default_span.lo(), } } diff --git a/src/utils.rs b/src/utils.rs index 4a66c168bb9..58fd95c656e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -44,11 +44,7 @@ pub(crate) fn is_same_visibility(a: &Visibility, b: &Visibility) -> bool { VisibilityKind::Restricted { path: q, .. }, ) => pprust::path_to_string(p) == pprust::path_to_string(q), (VisibilityKind::Public, VisibilityKind::Public) - | (VisibilityKind::Inherited, VisibilityKind::Inherited) - | ( - VisibilityKind::Crate, - VisibilityKind::Crate, - ) => true, + | (VisibilityKind::Inherited, VisibilityKind::Inherited) => true, _ => false, } } @@ -61,7 +57,6 @@ pub(crate) fn format_visibility( match vis.kind { VisibilityKind::Public => Cow::from("pub "), VisibilityKind::Inherited => Cow::from(""), - VisibilityKind::Crate => Cow::from("pub(crate) "), VisibilityKind::Restricted { ref path, .. } => { let Path { ref segments, .. } = **path; let mut segments_iter = segments.iter().map(|seg| rewrite_ident(context, seg.ident)); @@ -70,7 +65,7 @@ pub(crate) fn format_visibility( .next() .expect("Non-global path in pub(restricted)?"); } - let is_keyword = |s: &str| s == "self" || s == "super"; + let is_keyword = |s: &str| s == "crate" || s == "self" || s == "super"; let path = segments_iter.collect::<Vec<_>>().join("::"); let in_str = if is_keyword(&path) { "" } else { "in " }; |
