Skip to content
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

Fix rendering of const keyword for functions #44254

Merged
merged 1 commit into from
Sep 15, 2017

Conversation

GuillaumeGomez
Copy link
Member

@QuietMisdreavus
Copy link
Member

So there's something weird i noticed when digging into this. I saw that you took out the import for UnstableFeatures, even though i remember associated fns still using some kind of check.

It turns out, associated fns use a different check altogether:

    // FIXME(#24111): remove when `const_fn` is stabilized
    let vis_constness = if is_nightly_build() {
        constness
    } else {
        hir::Constness::NotConst
    };

However, this doesn't stop constness from showing up in the stable std docs. I'm starting to think the check here to make sure we don't print constness on stable builds is superfluous. We try to compile the crate anyway; if it builds, we're on a nightly build (or a bootstrap build), by definition. If we can't hide constness from the stable std docs, then we should just leave it in and treat it like the way we treat other unstable things in the stable docs: give people a chance to look into it and shape it.

cc @rust-lang/docs Pulling in the rest of the team here; what do y'all think about this idea?

@arielb1 arielb1 added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 5, 2017
@GuillaumeGomez
Copy link
Member Author

Any news in here?

@steveklabnik
Copy link
Member

I'm starting to think the check here to make sure we don't print constness on stable builds is superfluous.

👍 from me; we also had previously printed const ness on stable builds.

@QuietMisdreavus
Copy link
Member

We talked about this on IRC, and are generally in favor of printing constness all the time. To this end, i'd like it if you took out the check for bare functions, right here so it doesn't even try to mask it (this is the check that doesn't work and always prints it).

@QuietMisdreavus
Copy link
Member

travis failure:

[00:32:53] error: unused import: `rustc::session::config::nightly_options::is_nightly_build`
[00:32:53]   --> /checkout/src/librustdoc/html/render.rs:62:5
[00:32:53]    |
[00:32:53] 62 | use rustc::session::config::nightly_options::is_nightly_build;
[00:32:53]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:32:53]    |

@GuillaumeGomez
Copy link
Member Author

What failure? :p

/// foo
pub const fn bar() -> usize {
2
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding something to this test to make sure we're rendering "const" on associated functions too? Something like this is what i have in mind:

// @has foo/struct.Foo.html
// @has - '//*[@class="method"]' 'pub const fn new()'
pub struct Foo(usize);

impl Foo {
    pub const fn new() -> Foo { Foo(0) }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@QuietMisdreavus
Copy link
Member

r=me pending travis

@QuietMisdreavus
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 12, 2017

📌 Commit 742ff5a has been approved by QuietMisdreavus

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 13, 2017
…=QuietMisdreavus

Fix rendering of const keyword for functions

Fixes rust-lang#44187.

r? @QuietMisdreavus
@rust-lang rust-lang deleted a comment from bors Sep 13, 2017
@rust-lang rust-lang deleted a comment from bors Sep 13, 2017
@rust-lang rust-lang deleted a comment from bors Sep 13, 2017
@rust-lang rust-lang deleted a comment from bors Sep 13, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Sep 14, 2017
…=QuietMisdreavus

Fix rendering of const keyword for functions

Fixes rust-lang#44187.

r? @QuietMisdreavus
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Sep 15, 2017
…=QuietMisdreavus

Fix rendering of const keyword for functions

Fixes rust-lang#44187.

r? @QuietMisdreavus
bors added a commit that referenced this pull request Sep 15, 2017
@bors bors merged commit 742ff5a into rust-lang:master Sep 15, 2017
@GuillaumeGomez GuillaumeGomez deleted the const-fix-rustdoc branch September 15, 2017 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants