Skip to content

Commit 0d7a49d

Browse files
Implement PrintWithSpace trait on hir::Mutability
1 parent 5a0d747 commit 0d7a49d

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn build_const(cx: &DocContext<'_>, did: DefId) -> clean::Constant {
472472
fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static {
473473
clean::Static {
474474
type_: cx.tcx.type_of(did).clean(cx),
475-
mutability: if mutable { Mutability::Mutable } else { Mutability::Immutable },
475+
mutability: if mutable { Mutability::Mut } else { Mutability::Not },
476476
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
477477
}
478478
}

src/librustdoc/html/format.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) ->
670670
clean::Never => primitive_link(f, PrimitiveType::Never, "!"),
671671
clean::RawPointer(m, ref t) => {
672672
let m = match m {
673-
clean::Immutable => "const",
674-
clean::Mutable => "mut",
673+
hir::Mutability::Mut => "mut",
674+
hir::Mutability::Not => "const",
675675
};
676676
match **t {
677677
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
@@ -1082,6 +1082,15 @@ impl PrintWithSpace for hir::IsAsync {
10821082
}
10831083
}
10841084

1085+
impl PrintWithSpace for hir::Mutability {
1086+
fn print_with_space(&self) -> &str {
1087+
match self {
1088+
hir::Mutability::Not => "",
1089+
hir::Mutability::Mut => "mut ",
1090+
}
1091+
}
1092+
}
1093+
10851094
impl clean::Import {
10861095
crate fn print(&self) -> impl fmt::Display + '_ {
10871096
display_fn(move |f| {
@@ -1151,15 +1160,6 @@ impl clean::TypeBinding {
11511160
}
11521161
}
11531162

1154-
impl clean::Mutability {
1155-
crate fn print_with_space(&self) -> &str {
1156-
match self {
1157-
clean::Immutable => "",
1158-
clean::Mutable => "mut ",
1159-
}
1160-
}
1161-
}
1162-
11631163
crate fn print_abi_with_space(abi: Abi) -> impl fmt::Display {
11641164
display_fn(move |f| {
11651165
let quot = if f.alternate() { "\"" } else { "&quot;" };

src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3298,7 +3298,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
32983298
let (by_mut_ref, by_box, by_value) = match self_ty {
32993299
SelfTy::SelfBorrowed(_, mutability) |
33003300
SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
3301-
(mutability == Mutability::Mutable, false, false)
3301+
(mutability == Mutability::Mut, false, false)
33023302
},
33033303
SelfTy::SelfExplicit(clean::ResolvedPath { did, .. }) => {
33043304
(false, Some(did) == cache().owned_box_did, false)

0 commit comments

Comments
 (0)