Fix const not displayed in rustdoc
This commit is contained in:
parent
0aeb9c1297
commit
9b892745ad
3 changed files with 28 additions and 4 deletions
|
@ -1388,7 +1388,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
||||||
decl: decl,
|
decl: decl,
|
||||||
abi: sig.abi(),
|
abi: sig.abi(),
|
||||||
|
|
||||||
// trait methods canot (currently, at least) be const
|
// trait methods cannot (currently, at least) be const
|
||||||
constness: hir::Constness::NotConst,
|
constness: hir::Constness::NotConst,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -60,6 +60,7 @@ use rustc::middle::privacy::AccessLevels;
|
||||||
use rustc::middle::stability;
|
use rustc::middle::stability;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||||
|
use rustc::session::config::nightly_options::is_nightly_build;
|
||||||
use rustc_data_structures::flock;
|
use rustc_data_structures::flock;
|
||||||
|
|
||||||
use clean::{self, AttributesExt, GetDefId, SelfTy, Mutability};
|
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
|
// FIXME(#24111): remove when `const_fn` is stabilized
|
||||||
let vis_constness = match UnstableFeatures::from_environment() {
|
let vis_constness = if is_nightly_build() {
|
||||||
UnstableFeatures::Allow => constness,
|
constness
|
||||||
_ => hir::Constness::NotConst
|
} else {
|
||||||
|
hir::Constness::NotConst
|
||||||
};
|
};
|
||||||
let prefix = format!("{}{}{:#}fn {}{:#}",
|
let prefix = format!("{}{}{:#}fn {}{:#}",
|
||||||
ConstnessSpace(vis_constness),
|
ConstnessSpace(vis_constness),
|
||||||
|
|
22
src/test/rustdoc/const.rs
Normal file
22
src/test/rustdoc/const.rs
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue