Inline RawMutableSpace

This commit is contained in:
Mark Rousskov 2019-08-12 12:57:48 -04:00
parent 3307929a84
commit dafdfee33e

View File

@ -36,9 +36,6 @@ pub struct AsyncSpace(pub hir::IsAsync);
/// Similar to VisSpace, but used for mutability
#[derive(Copy, Clone)]
pub struct MutableSpace(pub clean::Mutability);
/// Similar to VisSpace, but used for mutability
#[derive(Copy, Clone)]
pub struct RawMutableSpace(pub clean::Mutability);
/// Wrapper struct for emitting type parameter bounds.
pub struct GenericBounds<'a>(pub &'a [clean::GenericBound]);
/// Wrapper struct for emitting a comma-separated list of items
@ -604,19 +601,22 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) ->
clean::Never => primitive_link(f, PrimitiveType::Never, "!"),
clean::CVarArgs => primitive_link(f, PrimitiveType::CVarArgs, "..."),
clean::RawPointer(m, ref t) => {
let m = match m {
clean::Immutable => "const",
clean::Mutable => "mut",
};
match **t {
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
if f.alternate() {
primitive_link(f, clean::PrimitiveType::RawPointer,
&format!("*{}{:#}", RawMutableSpace(m), t))
&format!("*{} {:#}", m, t))
} else {
primitive_link(f, clean::PrimitiveType::RawPointer,
&format!("*{}{}", RawMutableSpace(m), t))
&format!("*{} {}", m, t))
}
}
_ => {
primitive_link(f, clean::PrimitiveType::RawPointer,
&format!("*{}", RawMutableSpace(m)))?;
primitive_link(f, clean::PrimitiveType::RawPointer, &format!("*{} ", m))?;
fmt::Display::fmt(t, f)
}
}
@ -1044,15 +1044,6 @@ impl fmt::Display for MutableSpace {
}
}
impl fmt::Display for RawMutableSpace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
RawMutableSpace(clean::Immutable) => write!(f, "const "),
RawMutableSpace(clean::Mutable) => write!(f, "mut "),
}
}
}
impl fmt::Display for AbiSpace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let quot = if f.alternate() { "\"" } else { "&quot;" };