summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-03-19 10:18:15 -0400
committerGitHub <noreply@github.com>2017-03-19 10:18:15 -0400
commita04c7de2cfd6f740ae2558d4ea723256dee8cb5a (patch)
treeb4c50f3915d0dd042d76359dc24ade9e00a60ea6 /src
parent8287d0de0ee24dda2b64de0758e8fd7719ab5b58 (diff)
parent9b892745ad1da5ce9fc374da10f0f06174f13e48 (diff)
downloadrust-a04c7de2cfd6f740ae2558d4ea723256dee8cb5a.tar.gz
Rollup merge of #40564 - GuillaumeGomez:rustdoc-const, r=frewsxcv
Fix const not displayed in rustdoc Fixes #40331. r? @rust-lang/docs
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs2
-rw-r--r--src/librustdoc/html/render.rs8
-rw-r--r--src/test/rustdoc/const.rs22
3 files changed, 28 insertions, 4 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 660fa647882..eff848be2b8 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -1387,7 +1387,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
decl: decl,
abi: sig.abi(),
- // trait methods canot (currently, at least) be const
+ // trait methods cannot (currently, at least) be const
constness: hir::Constness::NotConst,
})
} else {
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index a9da8edc379..7b60d497932 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -60,6 +60,7 @@ use rustc::middle::privacy::AccessLevels;
use rustc::middle::stability;
use rustc::hir;
use rustc::util::nodemap::{FxHashMap, FxHashSet};
+use rustc::session::config::nightly_options::is_nightly_build;
use rustc_data_structures::flock;
use clean::{self, AttributesExt, GetDefId, SelfTy, Mutability};
@@ -2316,9 +2317,10 @@ fn render_assoc_item(w: &mut fmt::Formatter,
}
};
// FIXME(#24111): remove when `const_fn` is stabilized
- let vis_constness = match UnstableFeatures::from_environment() {
- UnstableFeatures::Allow => constness,
- _ => hir::Constness::NotConst
+ let vis_constness = if is_nightly_build() {
+ constness
+ } else {
+ hir::Constness::NotConst
};
let prefix = format!("{}{}{:#}fn {}{:#}",
ConstnessSpace(vis_constness),
diff --git a/src/test/rustdoc/const.rs b/src/test/rustdoc/const.rs
new file mode 100644
index 00000000000..380feb941d6
--- /dev/null
+++ b/src/test/rustdoc/const.rs
@@ -0,0 +1,22 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![crate_type="lib"]
+
+#![feature(const_fn)]
+
+pub struct Foo;
+
+impl Foo {
+ // @has const/struct.Foo.html '//*[@id="new.v"]//code' 'const unsafe fn new'
+ pub const unsafe fn new() -> Foo {
+ Foo
+ }
+}