-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't render const keyword on stable #55327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
aa87cea
to
a680180
Compare
src/librustdoc/html/render.rs
Outdated
@@ -2672,9 +2672,14 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, | |||
|
|||
fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, | |||
f: &clean::Function) -> fmt::Result { | |||
// FIXME: to be removed when "const" keyword is stabilised. | |||
let vis_constness = match UnstableFeatures::from_environment().is_nightly_build() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way we could move this check earlier in the process and store the result in the Cache
or something? That way we wouldn't have to keep poking the environment variables over and over.
The Context
already has the codes
field, which can be used as a stand-in for "can i do nightly things", but that won't help the other spot where you put this check, since it doesn't receive a &Context
.
Uhm... const fns are stable on nightly already... at least some of them. This should be in the current beta, too. to figure out whether a const fn from the libstd is available on stable you can call |
Oh nice! That'll make things simpler! |
@oli-obk: So we might have a "little" problem with using |
not quite. This check will stay around for libstd for quite a while, because it's very hard to know which const fns are stable and which are not. How are you figuring out any details that are not in the syntax tree without a Side note: You can "cheat" depending on what you mean by "stage". This is the trick that ty::tls::with(|tcx| tcx.is_min_const_fn(def_id)) |
src/librustdoc/html/render.rs
Outdated
@@ -2672,9 +2672,14 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, | |||
|
|||
fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you strip the constness during the generation of clean::Function
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of tricking that way yes.
a680180
to
5343eb5
Compare
@oli-obk Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only work for methods, free const functions aren't touched at all by this PR
src/librustdoc/clean/mod.rs
Outdated
@@ -2002,7 +2002,8 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem { | |||
ty::TraitContainer(_) => self.defaultness.has_value() | |||
}; | |||
if provided { | |||
let constness = if cx.tcx.is_const_fn(self.def_id) { | |||
let constness = if cx.tcx.is_const_fn(self.def_id) && | |||
cx.tcx.is_min_const_fn(self.def_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the is_const_fn
call, just the is_min_const_fn
suffices.
5343eb5
to
5238d04
Compare
Updated. |
What about
Also, is it possible to test this somehow? |
Yes but that also means that when it'll be stabilized, a rustdoc test will break. If that sounds fine to you then I'll add one. |
I think the important test is whether #![unstable(feature = "humans",
reason = "who ever let humans program computers,
we're apparently really bad at it",
issue = "0")]
#![feature(rustc_const_unstable, const_fn, foo, foo2)]
#![feature(min_const_unsafe_fn)]
#![feature(staged_api)]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature="foo")]
const unsafe fn foo() -> u32 { 42 }
#[unstable(feature = "rust1", issue="0")]
const fn foo2() -> u32 { 42 }
#[stable(feature = "rust1", since = "1.0.0")]
const fn bar2() -> u32 { 42 }
#[unstable(feature = "foo2", issue="0")]
const unsafe fn foo2_gated() -> u32 { 42 }
#[stable(feature = "rust1", since = "1.0.0")]
const unsafe fn bar2_gated() -> u32 { 42 } |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@GuillaumeGomez I think this'll need some updates as const fn has now stabilized; I've changed the status to waiting-on-author |
A check @oli-obk proposed and suggested to add isn't working as expected. I need to speak with him about it. |
Pinging from triage. @GuillaumeGomez any updates on this? |
I didn't speak with him yet. |
Ping from triage! This PR hasn't made progress in a while, so I'm closing it per our guidelines. Thanks for your contributions and please feel free to re-open in the future. |
Don't render const keyword on stable Fixes rust-lang#55246. Continuation of rust-lang#55327. r? @oli-obk
Fixes #55246.
r? @QuietMisdreavus