Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 632eb11

Browse files
authoredMar 18, 2017
Rollup merge of rust-lang#40564 - GuillaumeGomez:rustdoc-const, r=frewsxcv
Fix const not displayed in rustdoc Fixes rust-lang#40331. r? @rust-lang/docs
2 parents 89c7d45 + 9b89274 commit 632eb11

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed
 

‎src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
13881388
decl: decl,
13891389
abi: sig.abi(),
13901390

1391-
// trait methods canot (currently, at least) be const
1391+
// trait methods cannot (currently, at least) be const
13921392
constness: hir::Constness::NotConst,
13931393
})
13941394
} else {

‎src/librustdoc/html/render.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ use rustc::middle::privacy::AccessLevels;
6060
use rustc::middle::stability;
6161
use rustc::hir;
6262
use rustc::util::nodemap::{FxHashMap, FxHashSet};
63+
use rustc::session::config::nightly_options::is_nightly_build;
6364
use rustc_data_structures::flock;
6465

6566
use clean::{self, AttributesExt, GetDefId, SelfTy, Mutability};
@@ -2316,9 +2317,10 @@ fn render_assoc_item(w: &mut fmt::Formatter,
23162317
}
23172318
};
23182319
// FIXME(#24111): remove when `const_fn` is stabilized
2319-
let vis_constness = match UnstableFeatures::from_environment() {
2320-
UnstableFeatures::Allow => constness,
2321-
_ => hir::Constness::NotConst
2320+
let vis_constness = if is_nightly_build() {
2321+
constness
2322+
} else {
2323+
hir::Constness::NotConst
23222324
};
23232325
let prefix = format!("{}{}{:#}fn {}{:#}",
23242326
ConstnessSpace(vis_constness),

‎src/test/rustdoc/const.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type="lib"]
12+
13+
#![feature(const_fn)]
14+
15+
pub struct Foo;
16+
17+
impl Foo {
18+
// @has const/struct.Foo.html '//*[@id="new.v"]//code' 'const unsafe fn new'
19+
pub const unsafe fn new() -> Foo {
20+
Foo
21+
}
22+
}

0 commit comments

Comments
 (0)
Please sign in to comment.