From d59372b7aad364a287f21cfbcf12e85d8be97fc7 Mon Sep 17 00:00:00 2001 From: Brandon W Maister Date: Mon, 1 Feb 2016 13:05:37 -0500 Subject: [PATCH] Decide to hide constness only in fn/method renders ConstnessSpace has no knowledge of the type of item it's modifying, so hide the constness a level up. --- src/librustdoc/html/format.rs | 3 --- src/librustdoc/html/render.rs | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 68909b958ba..9d5189cfd0b 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -657,9 +657,6 @@ impl fmt::Display for UnsafetySpace { impl fmt::Display for ConstnessSpace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { - return Ok(()); - } match self.get() { hir::Constness::Const => write!(f, "const "), hir::Constness::NotConst => Ok(()) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 850045382e1..dfbe08a0e42 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -54,10 +54,12 @@ use externalfiles::ExternalHtml; use serialize::json::{self, ToJson}; use syntax::{abi, ast}; +use syntax::feature_gate::UnstableFeatures; use rustc::middle::cstore::LOCAL_CRATE; use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId}; use rustc::middle::privacy::AccessLevels; use rustc::middle::stability; +use rustc::session::config::get_unstable_features_setting; use rustc_front::hir; use clean::{self, SelfTy}; @@ -1897,10 +1899,14 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, f: &clean::Function) -> fmt::Result { + let vis_constness = match get_unstable_features_setting() { + UnstableFeatures::Allow => f.constness, + _ => hir::Constness::NotConst + }; try!(write!(w, "
{vis}{constness}{unsafety}{abi}fn \
                     {name}{generics}{decl}{where_clause}
", vis = VisSpace(it.visibility), - constness = ConstnessSpace(f.constness), + constness = ConstnessSpace(vis_constness), unsafety = UnsafetySpace(f.unsafety), abi = AbiSpace(f.abi), name = it.name.as_ref().unwrap(), @@ -2122,9 +2128,13 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item, href(did).map(|p| format!("{}{}", p.0, anchor)).unwrap_or(anchor) } }; + let vis_constness = match get_unstable_features_setting() { + UnstableFeatures::Allow => constness, + _ => hir::Constness::NotConst + }; write!(w, "{}{}{}fn {name}\ {generics}{decl}{where_clause}", - ConstnessSpace(constness), + ConstnessSpace(vis_constness), UnsafetySpace(unsafety), match abi { Abi::Rust => String::new(),