Skip to content

Commit 93042f2

Browse files
committed
Rollup merge of rust-lang#31329 - quodlibetor:no-const-doc-in-stable, r=alexcrichton
Fixes rust-lang#31098 AFAICT this is the only place where rustdoc explicitly checks if we are on stable before emitting content, so I can't tell if this is the sane way to handle this, or if anything else should be done to make sure that nobody forgets to remove this check when `const` is stabilized.
2 parents ae96e51 + d59372b commit 93042f2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/librustdoc/html/render.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ use externalfiles::ExternalHtml;
5454

5555
use serialize::json::{self, ToJson};
5656
use syntax::{abi, ast};
57+
use syntax::feature_gate::UnstableFeatures;
5758
use rustc::middle::cstore::LOCAL_CRATE;
5859
use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId};
5960
use rustc::middle::privacy::AccessLevels;
6061
use rustc::middle::stability;
62+
use rustc::session::config::get_unstable_features_setting;
6163
use rustc_front::hir;
6264

6365
use clean::{self, SelfTy};
@@ -1897,10 +1899,14 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
18971899

18981900
fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
18991901
f: &clean::Function) -> fmt::Result {
1902+
let vis_constness = match get_unstable_features_setting() {
1903+
UnstableFeatures::Allow => f.constness,
1904+
_ => hir::Constness::NotConst
1905+
};
19001906
try!(write!(w, "<pre class='rust fn'>{vis}{constness}{unsafety}{abi}fn \
19011907
{name}{generics}{decl}{where_clause}</pre>",
19021908
vis = VisSpace(it.visibility),
1903-
constness = ConstnessSpace(f.constness),
1909+
constness = ConstnessSpace(vis_constness),
19041910
unsafety = UnsafetySpace(f.unsafety),
19051911
abi = AbiSpace(f.abi),
19061912
name = it.name.as_ref().unwrap(),
@@ -2122,9 +2128,13 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item,
21222128
href(did).map(|p| format!("{}{}", p.0, anchor)).unwrap_or(anchor)
21232129
}
21242130
};
2131+
let vis_constness = match get_unstable_features_setting() {
2132+
UnstableFeatures::Allow => constness,
2133+
_ => hir::Constness::NotConst
2134+
};
21252135
write!(w, "{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
21262136
{generics}{decl}{where_clause}",
2127-
ConstnessSpace(constness),
2137+
ConstnessSpace(vis_constness),
21282138
UnsafetySpace(unsafety),
21292139
match abi {
21302140
Abi::Rust => String::new(),

0 commit comments

Comments
 (0)