Remove static and const initialization from documentation
This commit is contained in:
parent
a00706a3b9
commit
86141797db
3 changed files with 7 additions and 20 deletions
|
@ -2579,27 +2579,15 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
|
||||||
stability
|
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,
|
fn item_constant(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
c: &clean::Constant) -> fmt::Result {
|
c: &clean::Constant) -> fmt::Result {
|
||||||
write!(w, "<pre class='rust const'>")?;
|
write!(w, "<pre class='rust const'>")?;
|
||||||
render_attributes(w, it)?;
|
render_attributes(w, it)?;
|
||||||
write!(w, "{vis}const \
|
write!(w, "{vis}const \
|
||||||
{name}: {typ}{init}</pre>",
|
{name}: {typ}</pre>",
|
||||||
vis = VisSpace(&it.visibility),
|
vis = VisSpace(&it.visibility),
|
||||||
name = it.name.as_ref().unwrap(),
|
name = it.name.as_ref().unwrap(),
|
||||||
typ = c.type_,
|
typ = c.type_)?;
|
||||||
init = Initializer(&c.expr))?;
|
|
||||||
document(w, cx, it)
|
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'>")?;
|
write!(w, "<pre class='rust static'>")?;
|
||||||
render_attributes(w, it)?;
|
render_attributes(w, it)?;
|
||||||
write!(w, "{vis}static {mutability}\
|
write!(w, "{vis}static {mutability}\
|
||||||
{name}: {typ}{init}</pre>",
|
{name}: {typ}</pre>",
|
||||||
vis = VisSpace(&it.visibility),
|
vis = VisSpace(&it.visibility),
|
||||||
mutability = MutableSpace(s.mutability),
|
mutability = MutableSpace(s.mutability),
|
||||||
name = it.name.as_ref().unwrap(),
|
name = it.name.as_ref().unwrap(),
|
||||||
typ = s.type_,
|
typ = s.type_)?;
|
||||||
init = Initializer(&s.expr))?;
|
|
||||||
document(w, cx, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,5 +11,5 @@
|
||||||
// Test that we HTML-escape Rust expressions, where HTML special chars
|
// Test that we HTML-escape Rust expressions, where HTML special chars
|
||||||
// can occur, and we know it's definitely not markup.
|
// 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>";
|
pub const CONST_S: &'static str = "<script>";
|
||||||
|
|
|
@ -17,10 +17,10 @@ macro_rules! make {
|
||||||
pub struct S;
|
pub struct S;
|
||||||
|
|
||||||
// @has issue_33302/constant.CST.html \
|
// @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);
|
pub const CST: i32 = ($n * $n);
|
||||||
// @has issue_33302/static.ST.html \
|
// @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 static ST: i32 = ($n * $n);
|
||||||
|
|
||||||
pub trait T<X> {
|
pub trait T<X> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue