Implement PrintWithSpace trait on hir::Mutability
This commit is contained in:
parent
5a0d747eef
commit
0d7a49d356
3 changed files with 13 additions and 13 deletions
|
@ -472,7 +472,7 @@ fn build_const(cx: &DocContext<'_>, did: DefId) -> clean::Constant {
|
||||||
fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static {
|
fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static {
|
||||||
clean::Static {
|
clean::Static {
|
||||||
type_: cx.tcx.type_of(did).clean(cx),
|
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
|
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::Never => primitive_link(f, PrimitiveType::Never, "!"),
|
||||||
clean::RawPointer(m, ref t) => {
|
clean::RawPointer(m, ref t) => {
|
||||||
let m = match m {
|
let m = match m {
|
||||||
clean::Immutable => "const",
|
hir::Mutability::Mut => "mut",
|
||||||
clean::Mutable => "mut",
|
hir::Mutability::Not => "const",
|
||||||
};
|
};
|
||||||
match **t {
|
match **t {
|
||||||
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
|
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 {
|
impl clean::Import {
|
||||||
crate fn print(&self) -> impl fmt::Display + '_ {
|
crate fn print(&self) -> impl fmt::Display + '_ {
|
||||||
display_fn(move |f| {
|
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 {
|
crate fn print_abi_with_space(abi: Abi) -> impl fmt::Display {
|
||||||
display_fn(move |f| {
|
display_fn(move |f| {
|
||||||
let quot = if f.alternate() { "\"" } else { """ };
|
let quot = if f.alternate() { "\"" } else { """ };
|
||||||
|
|
|
@ -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 {
|
let (by_mut_ref, by_box, by_value) = match self_ty {
|
||||||
SelfTy::SelfBorrowed(_, mutability) |
|
SelfTy::SelfBorrowed(_, mutability) |
|
||||||
SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
|
SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
|
||||||
(mutability == Mutability::Mutable, false, false)
|
(mutability == Mutability::Mut, false, false)
|
||||||
},
|
},
|
||||||
SelfTy::SelfExplicit(clean::ResolvedPath { did, .. }) => {
|
SelfTy::SelfExplicit(clean::ResolvedPath { did, .. }) => {
|
||||||
(false, Some(did) == cache().owned_box_did, false)
|
(false, Some(did) == cache().owned_box_did, false)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue