]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #15605 : blake2-ppc/rust/rustdoc-const-t, r=alexcrichton
authorbors <bors@rust-lang.org>
Sat, 12 Jul 2014 14:36:35 +0000 (14:36 +0000)
committerbors <bors@rust-lang.org>
Sat, 12 Jul 2014 14:36:35 +0000 (14:36 +0000)
Update the formatting of raw immutable pointers to print *const T.

src/librustdoc/html/format.rs

index 84c0f0b97a18643cb0babe748982fbeeae255fab..e2ff80b9fd928f029eded07f085d5f71ff5962f1 100644 (file)
@@ -38,6 +38,8 @@
 pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
 /// Similar to VisSpace, but used for mutability
 pub struct MutableSpace(pub clean::Mutability);
+/// Similar to VisSpace, but used for mutability
+pub struct RawMutableSpace(pub clean::Mutability);
 /// Wrapper struct for properly emitting the stability level.
 pub struct Stability<'a>(pub &'a Option<clean::Stability>);
 /// Wrapper struct for emitting the stability level concisely.
@@ -442,7 +444,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             clean::Unique(ref t) => write!(f, "Box<{}>", **t),
             clean::Managed(ref t) => write!(f, "Gc<{}>", **t),
             clean::RawPointer(m, ref t) => {
-                write!(f, "*{}{}", MutableSpace(m), **t)
+                write!(f, "*{}{}", RawMutableSpace(m), **t)
             }
             clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
                 let lt = match *l {
@@ -602,6 +604,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+impl fmt::Show 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<'a> fmt::Show for Stability<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Stability(stab) = *self;