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

Make unwrap_or unstably const #76330

Closed
wants to merge 1 commit into from

Conversation

pickfire
Copy link
Contributor

@pickfire pickfire commented Sep 4, 2020

No description provided.

@rust-highfive
Copy link
Collaborator

r? @KodrAus

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2020
@jyn514 jyn514 added A-const-fn T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Sep 4, 2020
@jyn514 jyn514 changed the title Const unwrap_or Make unwrap_or unstably const Sep 4, 2020
@pickfire
Copy link
Contributor Author

pickfire commented Sep 5, 2020

@estebank Looks like the error message for const pub fn isn't as good.

error: expected identifier, found keyword `pub`
   --> library/core/src/option.rs:391:11
    |
391 |     const pub fn unwrap_or(self, default: T) -> T {
    |           ^^^ expected identifier, found keyword

error: expected one of `:`, `;`, or `=`, found keyword `fn`
   --> library/core/src/option.rs:391:15
    |
160 | impl<T> Option<T> {
    |                   - while parsing this item list starting here
...
391 |     const pub fn unwrap_or(self, default: T) -> T {
    |               ^^ expected one of `:`, `;`, or `=`
...
940 | }
    | - the item list ends here

error: expected identifier, found keyword `pub`
   --> library/core/src/result.rs:801:11
    |
801 |     const pub fn unwrap_or(self, default: T) -> T {
    |           ^^^ expected identifier, found keyword

error: expected one of `:`, `;`, or `=`, found keyword `fn`
   --> library/core/src/result.rs:801:15
    |
257 | impl<T, E> Result<T, E> {
    |                         - while parsing this item list starting here
...
801 |     const pub fn unwrap_or(self, default: T) -> T {
    |               ^^ expected one of `:`, `;`, or `=`
...
829 | }
    | - the item list ends here

@pickfire
Copy link
Contributor Author

pickfire commented Sep 5, 2020

const fn cannot evaluate destructors

@pickfire pickfire closed this Sep 5, 2020
@pickfire pickfire deleted the const_unwrap_or branch September 5, 2020 01:15
@TheButlah TheButlah mentioned this pull request Sep 14, 2020
@RalfJung RalfJung added the A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants