]> git.lizzy.rs Git - rust.git/commitdiff
Set constness correctly
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 18 Dec 2018 21:24:20 +0000 (22:24 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 19 Dec 2018 08:57:29 +0000 (09:57 +0100)
src/librustdoc/clean/mod.rs
src/test/rustdoc/const-display.rs

index f08b594a8e49009bfdd70919952abec2dc6b7a13..44ea3d1ac2d13a5757c71a3108d6dd5906ab43cb 100644 (file)
@@ -1674,6 +1674,12 @@ fn clean(&self, cx: &DocContext) -> Item {
             (self.generics.clean(cx), (&self.decl, self.body).clean(cx))
         });
 
+        let did = cx.tcx.hir().local_def_id(self.id);
+        let constness = if cx.tcx.is_min_const_fn(did) {
+            hir::Constness::Const
+        } else {
+            hir::Constness::NotConst
+        };
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -1681,11 +1687,11 @@ fn clean(&self, cx: &DocContext) -> Item {
             visibility: self.vis.clean(cx),
             stability: self.stab.clean(cx),
             deprecation: self.depr.clean(cx),
-            def_id: cx.tcx.hir().local_def_id(self.id),
+            def_id: did,
             inner: FunctionItem(Function {
                 decl,
                 generics,
-                header: self.header,
+                header: hir::FnHeader { constness, ..self.header },
             }),
         }
     }
index 0b72719091380e3910392657a881135e6f90dffc..8ac0d07ceefe45283570f8da012915acd2221380 100644 (file)
 #![feature(min_const_unsafe_fn)]
 #![feature(staged_api)]
 
-// @has 'foo/fn.foo.html' '//pre' 'pub const unsafe fn foo() -> u32'
+// @has 'foo/fn.foo.html' '//pre' 'pub unsafe fn foo() -> u32'
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_unstable(feature="foo")]
 pub const unsafe fn foo() -> u32 { 42 }
 
-// @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32'
+// @has 'foo/fn.foo2.html' '//pre' 'pub fn foo2() -> u32'
 #[unstable(feature = "humans", issue="0")]
 pub const fn foo2() -> u32 { 42 }
 
@@ -31,7 +31,7 @@ pub const fn foo2() -> u32 { 42 }
 #[stable(feature = "rust1", since = "1.0.0")]
 pub const fn bar2() -> u32 { 42 }
 
-// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32'
+// @has 'foo/fn.foo2_gated.html' '//pre' 'pub unsafe fn foo2_gated() -> u32'
 #[unstable(feature = "foo2", issue="0")]
 pub const unsafe fn foo2_gated() -> u32 { 42 }
 
@@ -39,5 +39,5 @@ pub const fn bar2() -> u32 { 42 }
 #[stable(feature = "rust1", since = "1.0.0")]
 pub const unsafe fn bar2_gated() -> u32 { 42 }
 
-// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32'
+// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub unsafe fn bar_not_gated() -> u32'
 pub const unsafe fn bar_not_gated() -> u32 { 42 }