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 char conversion functions unstably const #89258

Merged
merged 1 commit into from
Nov 19, 2021

Conversation

est31
Copy link
Member

@est31 est31 commented Sep 25, 2021

The char conversion functions like char::from_u32 do trivial computations and can easily be converted into const fns. Only smaller tricks are needed to avoid non-const standard library functions like Result::ok or bool::then_some.

Tracking issue: #89259

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(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 25, 2021
@rust-log-analyzer

This comment has been minimized.

@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Oct 2, 2021

I admit that I feel a little "meh" about small const-ifications that also need to change the bodies of functions to make them amenable to const-ifying (or even extracting them into helper functions for sharing). It seems like there is no particularly pressing need to do so, and const-fn evaluation is progressing gradually to the point where that becomes less necessary to do.

That said, this PR seems OK to me in isolation (and seems to match current policy...).

r? @yaahc for libs-api approval

@bors
Copy link
Contributor

bors commented Oct 11, 2021

☔ The latest upstream changes (presumably #89767) made this pull request unmergeable. Please resolve the merge conflicts.

@apiraino apiraino added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Oct 14, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 31, 2021
@est31
Copy link
Member Author

est31 commented Nov 18, 2021

@Mark-Simulacrum does this need libs-api approval? @oli-obk has recently r+'d a very similar PR #90607 without libs-api approval.

@Mark-Simulacrum
Copy link
Member

I think current policy is const eval OR libs-api, but am not confident on that.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 18, 2021

wg-const-eval may unstably add const to functions without querying libs-api

@oli-obk
Copy link
Contributor

oli-obk commented Nov 18, 2021

r? @oli-obk
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 18, 2021

📌 Commit 7272b6f has been approved by oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned yaahc Nov 18, 2021
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 18, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 18, 2021
Make char conversion functions unstably const

The char conversion functions like `char::from_u32` do trivial computations and can easily be converted into const fns. Only smaller tricks are needed to avoid non-const standard library functions like `Result::ok` or `bool::then_some`.

Tracking issue: rust-lang#89259
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 19, 2021
Rollup of 8 pull requests

Successful merges:

 - rust-lang#89258 (Make char conversion functions unstably const)
 - rust-lang#90578 (add const generics test)
 - rust-lang#90633 (Refactor single variant `Candidate` enum into a struct)
 - rust-lang#90800 (bootstap: create .cargo/config only if not present)
 - rust-lang#90942 (windows: Return the "Not Found" error when a path is empty)
 - rust-lang#90947 (Move some tests to more reasonable directories - 9.5)
 - rust-lang#90961 (Suggest removal of arguments for unit variant, not replacement)
 - rust-lang#90990 (Arenas cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7432588 into rust-lang:master Nov 19, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.