Skip to content

Commit 9b697d0

Browse files
committed
Merge crate and restricted visibilities
1 parent 0d27f70 commit 9b697d0

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Diff for: src/items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ pub(crate) fn format_struct_struct(
13611361

13621362
fn get_bytepos_after_visibility(vis: &ast::Visibility, default_span: Span) -> BytePos {
13631363
match vis.kind {
1364-
ast::VisibilityKind::Crate | ast::VisibilityKind::Restricted { .. } => vis.span.hi(),
1364+
ast::VisibilityKind::Restricted { .. } => vis.span.hi(),
13651365
_ => default_span.lo(),
13661366
}
13671367
}

Diff for: src/utils.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ pub(crate) fn is_same_visibility(a: &Visibility, b: &Visibility) -> bool {
4444
VisibilityKind::Restricted { path: q, .. },
4545
) => pprust::path_to_string(p) == pprust::path_to_string(q),
4646
(VisibilityKind::Public, VisibilityKind::Public)
47-
| (VisibilityKind::Inherited, VisibilityKind::Inherited)
48-
| (
49-
VisibilityKind::Crate,
50-
VisibilityKind::Crate,
51-
) => true,
47+
| (VisibilityKind::Inherited, VisibilityKind::Inherited) => true,
5248
_ => false,
5349
}
5450
}
@@ -61,7 +57,6 @@ pub(crate) fn format_visibility(
6157
match vis.kind {
6258
VisibilityKind::Public => Cow::from("pub "),
6359
VisibilityKind::Inherited => Cow::from(""),
64-
VisibilityKind::Crate => Cow::from("pub(crate) "),
6560
VisibilityKind::Restricted { ref path, .. } => {
6661
let Path { ref segments, .. } = **path;
6762
let mut segments_iter = segments.iter().map(|seg| rewrite_ident(context, seg.ident));
@@ -70,7 +65,7 @@ pub(crate) fn format_visibility(
7065
.next()
7166
.expect("Non-global path in pub(restricted)?");
7267
}
73-
let is_keyword = |s: &str| s == "self" || s == "super";
68+
let is_keyword = |s: &str| s == "crate" || s == "self" || s == "super";
7469
let path = segments_iter.collect::<Vec<_>>().join("::");
7570
let in_str = if is_keyword(&path) { "" } else { "in " };
7671

0 commit comments

Comments
 (0)