1
Fork 0

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 /// Similar to VisSpace, but used for mutability
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct MutableSpace(pub clean::Mutability); 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. /// Wrapper struct for emitting type parameter bounds.
pub struct GenericBounds<'a>(pub &'a [clean::GenericBound]); pub struct GenericBounds<'a>(pub &'a [clean::GenericBound]);
/// Wrapper struct for emitting a comma-separated list of items /// 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::Never => primitive_link(f, PrimitiveType::Never, "!"),
clean::CVarArgs => primitive_link(f, PrimitiveType::CVarArgs, "..."), clean::CVarArgs => primitive_link(f, PrimitiveType::CVarArgs, "..."),
clean::RawPointer(m, ref t) => { clean::RawPointer(m, ref t) => {
let m = match m {
clean::Immutable => "const",
clean::Mutable => "mut",
};
match **t { match **t {
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => { clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
if f.alternate() { if f.alternate() {
primitive_link(f, clean::PrimitiveType::RawPointer, primitive_link(f, clean::PrimitiveType::RawPointer,
&format!("*{}{:#}", RawMutableSpace(m), t)) &format!("*{} {:#}", m, t))
} else { } else {
primitive_link(f, clean::PrimitiveType::RawPointer, primitive_link(f, clean::PrimitiveType::RawPointer,
&format!("*{}{}", RawMutableSpace(m), t)) &format!("*{} {}", m, t))
} }
} }
_ => { _ => {
primitive_link(f, clean::PrimitiveType::RawPointer, primitive_link(f, clean::PrimitiveType::RawPointer, &format!("*{} ", m))?;
&format!("*{}", RawMutableSpace(m)))?;
fmt::Display::fmt(t, f) 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 { impl fmt::Display for AbiSpace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let quot = if f.alternate() { "\"" } else { "&quot;" }; let quot = if f.alternate() { "\"" } else { "&quot;" };