Skip to content

Commit 3f33f0c

Browse files
committed
Don't duplicate handling of Visibility::Crate
Instead, represent it as just another `Restricted` path.
1 parent 85fca6d commit 3f33f0c

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/librustdoc/clean/mod.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,10 @@ impl Clean<Visibility> for hir::Visibility<'_> {
17531753
match self.node {
17541754
hir::VisibilityKind::Public => Visibility::Public,
17551755
hir::VisibilityKind::Inherited => Visibility::Inherited,
1756-
hir::VisibilityKind::Crate(_) => Visibility::Crate,
1756+
hir::VisibilityKind::Crate(_) => {
1757+
let krate = DefId::local(CRATE_DEF_INDEX);
1758+
Visibility::Restricted(krate, cx.tcx.def_path(krate))
1759+
}
17571760
hir::VisibilityKind::Restricted { ref path, .. } => {
17581761
let path = path.clean(cx);
17591762
let did = register_res(cx, path.res);
@@ -1767,14 +1770,10 @@ impl Clean<Visibility> for ty::Visibility {
17671770
fn clean(&self, cx: &DocContext<'_>) -> Visibility {
17681771
match *self {
17691772
ty::Visibility::Public => Visibility::Public,
1773+
ty::Visibility::Invisible => Visibility::Inherited,
17701774
ty::Visibility::Restricted(module) => {
1771-
if module.is_top_level_module() {
1772-
Visibility::Crate
1773-
} else {
1774-
Visibility::Restricted(module, cx.tcx.def_path(module))
1775-
}
1775+
Visibility::Restricted(module, cx.tcx.def_path(module))
17761776
}
1777-
ty::Visibility::Invisible => Visibility::Inherited,
17781777
}
17791778
}
17801779
}

src/librustdoc/clean/types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,6 @@ impl From<hir::PrimTy> for PrimitiveType {
15291529
pub enum Visibility {
15301530
Public,
15311531
Inherited,
1532-
Crate,
15331532
Restricted(DefId, rustc_hir::definitions::DefPath),
15341533
}
15351534

src/librustdoc/html/format.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,6 @@ impl clean::Visibility {
10941094
display_fn(move |f| match *self {
10951095
clean::Public => f.write_str("pub "),
10961096
clean::Inherited => Ok(()),
1097-
clean::Visibility::Crate => write!(f, "pub(crate) "),
10981097
// If this is `pub(crate)`, `path` will be empty.
10991098
clean::Visibility::Restricted(did, _) if did.index == CRATE_DEF_INDEX => {
11001099
write!(f, "pub(crate) ")

0 commit comments

Comments
 (0)