Skip to content

Commit a6943d9

Browse files
Set constness correctly
1 parent 170f068 commit a6943d9

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/librustdoc/clean/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1674,18 +1674,24 @@ impl Clean<Item> for doctree::Function {
16741674
(self.generics.clean(cx), (&self.decl, self.body).clean(cx))
16751675
});
16761676

1677+
let did = cx.tcx.hir().local_def_id(self.id);
1678+
let constness = if cx.tcx.is_min_const_fn(did) {
1679+
hir::Constness::Const
1680+
} else {
1681+
hir::Constness::NotConst
1682+
};
16771683
Item {
16781684
name: Some(self.name.clean(cx)),
16791685
attrs: self.attrs.clean(cx),
16801686
source: self.whence.clean(cx),
16811687
visibility: self.vis.clean(cx),
16821688
stability: self.stab.clean(cx),
16831689
deprecation: self.depr.clean(cx),
1684-
def_id: cx.tcx.hir().local_def_id(self.id),
1690+
def_id: did,
16851691
inner: FunctionItem(Function {
16861692
decl,
16871693
generics,
1688-
header: self.header,
1694+
header: hir::FnHeader { constness, ..self.header },
16891695
}),
16901696
}
16911697
}

src/test/rustdoc/const-display.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@
1818
#![feature(min_const_unsafe_fn)]
1919
#![feature(staged_api)]
2020

21-
// @has 'foo/fn.foo.html' '//pre' 'pub const unsafe fn foo() -> u32'
21+
// @has 'foo/fn.foo.html' '//pre' 'pub unsafe fn foo() -> u32'
2222
#[stable(feature = "rust1", since = "1.0.0")]
2323
#[rustc_const_unstable(feature="foo")]
2424
pub const unsafe fn foo() -> u32 { 42 }
2525

26-
// @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32'
26+
// @has 'foo/fn.foo2.html' '//pre' 'pub fn foo2() -> u32'
2727
#[unstable(feature = "humans", issue="0")]
2828
pub const fn foo2() -> u32 { 42 }
2929

3030
// @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32'
3131
#[stable(feature = "rust1", since = "1.0.0")]
3232
pub const fn bar2() -> u32 { 42 }
3333

34-
// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32'
34+
// @has 'foo/fn.foo2_gated.html' '//pre' 'pub unsafe fn foo2_gated() -> u32'
3535
#[unstable(feature = "foo2", issue="0")]
3636
pub const unsafe fn foo2_gated() -> u32 { 42 }
3737

3838
// @has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32'
3939
#[stable(feature = "rust1", since = "1.0.0")]
4040
pub const unsafe fn bar2_gated() -> u32 { 42 }
4141

42-
// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32'
42+
// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub unsafe fn bar_not_gated() -> u32'
4343
pub const unsafe fn bar_not_gated() -> u32 { 42 }

0 commit comments

Comments
 (0)