Skip to content

Commit 170f068

Browse files
Don't render const keyword on stable
1 parent 748d354 commit 170f068

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait {
207207
fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
208208
let sig = cx.tcx.fn_sig(did);
209209

210-
let constness = if cx.tcx.is_const_fn(did) {
210+
let constness = if cx.tcx.is_min_const_fn(did) {
211211
hir::Constness::Const
212212
} else {
213213
hir::Constness::NotConst

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
20092009
ty::TraitContainer(_) => self.defaultness.has_value()
20102010
};
20112011
if provided {
2012-
let constness = if cx.tcx.is_const_fn(self.def_id) {
2012+
let constness = if cx.tcx.is_min_const_fn(self.def_id) {
20132013
hir::Constness::Const
20142014
} else {
20152015
hir::Constness::NotConst

src/test/rustdoc/const-display.rs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2018 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_name = "foo"]
12+
13+
#![unstable(feature = "humans",
14+
reason = "who ever let humans program computers, we're apparently really bad at it",
15+
issue = "0")]
16+
17+
#![feature(rustc_const_unstable, const_fn, foo, foo2)]
18+
#![feature(min_const_unsafe_fn)]
19+
#![feature(staged_api)]
20+
21+
// @has 'foo/fn.foo.html' '//pre' 'pub const unsafe fn foo() -> u32'
22+
#[stable(feature = "rust1", since = "1.0.0")]
23+
#[rustc_const_unstable(feature="foo")]
24+
pub const unsafe fn foo() -> u32 { 42 }
25+
26+
// @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32'
27+
#[unstable(feature = "humans", issue="0")]
28+
pub const fn foo2() -> u32 { 42 }
29+
30+
// @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32'
31+
#[stable(feature = "rust1", since = "1.0.0")]
32+
pub const fn bar2() -> u32 { 42 }
33+
34+
// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32'
35+
#[unstable(feature = "foo2", issue="0")]
36+
pub const unsafe fn foo2_gated() -> u32 { 42 }
37+
38+
// @has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32'
39+
#[stable(feature = "rust1", since = "1.0.0")]
40+
pub const unsafe fn bar2_gated() -> u32 { 42 }
41+
42+
// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32'
43+
pub const unsafe fn bar_not_gated() -> u32 { 42 }

0 commit comments

Comments
 (0)