]> git.lizzy.rs Git - rust.git/commitdiff
Remove static and const initialization from documentation
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 25 Aug 2018 19:19:38 +0000 (21:19 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Sun, 26 Aug 2018 10:08:30 +0000 (12:08 +0200)
src/librustdoc/html/render.rs
src/test/rustdoc/escape-rust-expr.rs
src/test/rustdoc/issue-33302.rs

index 8d672ffd7bb27c10ca470e1b04b2c8e56cc38d3e..d61855011d36b153e5bf8be2f3b44f9e3b35ad4b 100644 (file)
@@ -2579,27 +2579,15 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
     stability
 }
 
-struct Initializer<'a>(&'a str);
-
-impl<'a> fmt::Display for Initializer<'a> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let Initializer(s) = *self;
-        if s.is_empty() { return Ok(()); }
-        write!(f, "<code> = </code>")?;
-        write!(f, "<code>{}</code>", Escape(s))
-    }
-}
-
 fn item_constant(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
                  c: &clean::Constant) -> fmt::Result {
     write!(w, "<pre class='rust const'>")?;
     render_attributes(w, it)?;
     write!(w, "{vis}const \
-               {name}: {typ}{init}</pre>",
+               {name}: {typ}</pre>",
            vis = VisSpace(&it.visibility),
            name = it.name.as_ref().unwrap(),
-           typ = c.type_,
-           init = Initializer(&c.expr))?;
+           typ = c.type_)?;
     document(w, cx, it)
 }
 
@@ -2608,12 +2596,11 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
     write!(w, "<pre class='rust static'>")?;
     render_attributes(w, it)?;
     write!(w, "{vis}static {mutability}\
-               {name}: {typ}{init}</pre>",
+               {name}: {typ}</pre>",
            vis = VisSpace(&it.visibility),
            mutability = MutableSpace(s.mutability),
            name = it.name.as_ref().unwrap(),
-           typ = s.type_,
-           init = Initializer(&s.expr))?;
+           typ = s.type_)?;
     document(w, cx, it)
 }
 
index 7f9a2bf175a5f96c7a23daf497665244f16b055e..4594eb95ea18e2abc23202a596b016dde16afbaf 100644 (file)
@@ -11,5 +11,5 @@
 // Test that we HTML-escape Rust expressions, where HTML special chars
 // can occur, and we know it's definitely not markup.
 
-// @has escape_rust_expr/constant.CONST_S.html '//pre[@class="rust const"]' '"<script>"'
+// @!has escape_rust_expr/constant.CONST_S.html '//pre[@class="rust const"]' '"<script>"'
 pub const CONST_S: &'static str = "<script>";
index dba8732d893a113367be334a3c4f1890354cea2f..538de228424ae11fb9a28aaca34130c70420b5ea 100644 (file)
@@ -17,10 +17,10 @@ macro_rules! make {
         pub struct S;
 
         // @has issue_33302/constant.CST.html \
-        //        '//pre[@class="rust const"]' 'pub const CST: i32 = 4 * 4'
+        //        '//pre[@class="rust const"]' 'pub const CST: i32'
         pub const CST: i32 = ($n * $n);
         // @has issue_33302/static.ST.html \
-        //        '//pre[@class="rust static"]' 'pub static ST: i32 = 4 * 4'
+        //        '//pre[@class="rust static"]' 'pub static ST: i32'
         pub static ST: i32 = ($n * $n);
 
         pub trait T<X> {