Skip to content
Permalink
Browse files

Implement PrintWithSpace trait on hir::Mutability

  • Loading branch information
GuillaumeGomez committed Dec 21, 2019
1 parent 5a0d747 commit 0d7a49d3563246f193e11ae63e713c0a65319f8c
Showing with 13 additions and 13 deletions.
  1. +1 −1 src/librustdoc/clean/inline.rs
  2. +11 −11 src/librustdoc/html/format.rs
  3. +1 −1 src/librustdoc/html/render.rs
@@ -472,7 +472,7 @@ fn build_const(cx: &DocContext<'_>, did: DefId) -> clean::Constant {
fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static {
clean::Static {
type_: cx.tcx.type_of(did).clean(cx),
mutability: if mutable { Mutability::Mutable } else { Mutability::Immutable },
mutability: if mutable { Mutability::Mut } else { Mutability::Not },
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
}
}
@@ -670,8 +670,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) ->
clean::Never => primitive_link(f, PrimitiveType::Never, "!"),
clean::RawPointer(m, ref t) => {
let m = match m {
clean::Immutable => "const",
clean::Mutable => "mut",
hir::Mutability::Mut => "mut",
hir::Mutability::Not => "const",
};
match **t {
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
@@ -1082,6 +1082,15 @@ impl PrintWithSpace for hir::IsAsync {
}
}

impl PrintWithSpace for hir::Mutability {
fn print_with_space(&self) -> &str {
match self {
hir::Mutability::Not => "",
hir::Mutability::Mut => "mut ",
}
}
}

impl clean::Import {
crate fn print(&self) -> impl fmt::Display + '_ {
display_fn(move |f| {
@@ -1151,15 +1160,6 @@ impl clean::TypeBinding {
}
}

impl clean::Mutability {
crate fn print_with_space(&self) -> &str {
match self {
clean::Immutable => "",
clean::Mutable => "mut ",
}
}
}

crate fn print_abi_with_space(abi: Abi) -> impl fmt::Display {
display_fn(move |f| {
let quot = if f.alternate() { "\"" } else { "&quot;" };
@@ -3298,7 +3298,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
let (by_mut_ref, by_box, by_value) = match self_ty {
SelfTy::SelfBorrowed(_, mutability) |
SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
(mutability == Mutability::Mutable, false, false)
(mutability == Mutability::Mut, false, false)
},
SelfTy::SelfExplicit(clean::ResolvedPath { did, .. }) => {
(false, Some(did) == cache().owned_box_did, false)

0 comments on commit 0d7a49d

Please sign in to comment.
You can’t perform that action at this time.