-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Stabilize const char convert #102470
Stabilize const char convert #102470
Conversation
It relies on the Option::unwrap function which is not const-stable (yet).
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @scottmcm (rust-highfive has picked a reviewer for you, use r? to override) |
r? rust-lang/libs-api |
There's no group for libs-api, so I (got ddg to) flip a coin, and it came up |
Seems reasonable to me! @rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
r? @joshtriplett it's ready for approval now that the FCP has passed :) |
Could not assign reviewer from: |
@bors r+ rollup |
…, r=joshtriplett Stabilize const char convert Split out `const_char_from_u32_unchecked` from `const_char_convert` and stabilize the rest, i.e. stabilize the following functions: ```Rust impl char { pub const fn from_u32(self, i: u32) -> Option<char>; pub const fn from_digit(self, num: u32, radix: u32) -> Option<char>; pub const fn to_digit(self, radix: u32) -> Option<u32>; } // Available through core::char and std::char mod char { pub const fn from_u32(i: u32) -> Option<char>; pub const fn from_digit(num: u32, radix: u32) -> Option<char>; } ``` And put the following under the `from_u32_unchecked` const stability gate as it needs `Option::unwrap` which isn't const-stable (yet): ```Rust impl char { pub const unsafe fn from_u32_unchecked(i: u32) -> char; } // Available through core::char and std::char mod char { pub const unsafe fn from_u32_unchecked(i: u32) -> char; } ``` cc the tracking issue rust-lang#89259 (which I'd like to keep open for `const_char_from_u32_unchecked`).
…, r=joshtriplett Stabilize const char convert Split out `const_char_from_u32_unchecked` from `const_char_convert` and stabilize the rest, i.e. stabilize the following functions: ```Rust impl char { pub const fn from_u32(self, i: u32) -> Option<char>; pub const fn from_digit(self, num: u32, radix: u32) -> Option<char>; pub const fn to_digit(self, radix: u32) -> Option<u32>; } // Available through core::char and std::char mod char { pub const fn from_u32(i: u32) -> Option<char>; pub const fn from_digit(num: u32, radix: u32) -> Option<char>; } ``` And put the following under the `from_u32_unchecked` const stability gate as it needs `Option::unwrap` which isn't const-stable (yet): ```Rust impl char { pub const unsafe fn from_u32_unchecked(i: u32) -> char; } // Available through core::char and std::char mod char { pub const unsafe fn from_u32_unchecked(i: u32) -> char; } ``` cc the tracking issue rust-lang#89259 (which I'd like to keep open for `const_char_from_u32_unchecked`).
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#101967 (Move `unix_socket_abstract` feature API to `SocketAddrExt`.) - rust-lang#102470 (Stabilize const char convert) - rust-lang#104223 (Recover from function pointer types with generic parameter list) - rust-lang#104229 (Don't print full paths in overlap errors) - rust-lang#104294 (Don't ICE with inline const errors during MIR build) - rust-lang#104332 (Fixed some `_i32` notation in `maybe_uninit`’s doc) - rust-lang#104349 (fix some typos in comments) - rust-lang#104350 (Fix x finding Python on Windows) - rust-lang#104356 (interpret: make check_mplace public) - rust-lang#104364 (rustdoc: Resolve doc links in external traits having local impls) - rust-lang#104378 (Bump chalk to v0.87) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Const stabilize mem::discriminant Tracking issue: rust-lang#69821. This PR is a rebase of rust-lang#103893 to resolve conflicts in library/core/src/lib.rs (against rust-lang#102470 and rust-lang#110393).
Const stabilize mem::discriminant Tracking issue: rust-lang#69821. This PR is a rebase of rust-lang#103893 to resolve conflicts in library/core/src/lib.rs (against rust-lang#102470 and rust-lang#110393).
Stabilize const unchecked conversion from u32 to char Closes rust-lang#89259. The functions in this PR were left out of the initial set of `feature(const_char_convert)` stabilizations in rust-lang#102470, but have since been unblocked by rust-lang#118979. If `unsafe { from_u32_unchecked(u) }` is called in const with a value for which `from_u32(u)` returns None, we get the following compile error. ```rust fn main() { let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; } ``` ```console error[E0080]: it is undefined behavior to use this value --> src/main.rs:2:19 | 2 | let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x0000d800, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 d8 00 00 │ .... } note: erroneous constant encountered --> src/main.rs:2:13 | 2 | let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
Stabilize const unchecked conversion from u32 to char Closes rust-lang/rust#89259. The functions in this PR were left out of the initial set of `feature(const_char_convert)` stabilizations in rust-lang/rust#102470, but have since been unblocked by rust-lang/rust#118979. If `unsafe { from_u32_unchecked(u) }` is called in const with a value for which `from_u32(u)` returns None, we get the following compile error. ```rust fn main() { let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; } ``` ```console error[E0080]: it is undefined behavior to use this value --> src/main.rs:2:19 | 2 | let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x0000d800, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 d8 00 00 │ .... } note: erroneous constant encountered --> src/main.rs:2:13 | 2 | let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
Stabilize const unchecked conversion from u32 to char Closes rust-lang/rust#89259. The functions in this PR were left out of the initial set of `feature(const_char_convert)` stabilizations in rust-lang/rust#102470, but have since been unblocked by rust-lang/rust#118979. If `unsafe { from_u32_unchecked(u) }` is called in const with a value for which `from_u32(u)` returns None, we get the following compile error. ```rust fn main() { let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; } ``` ```console error[E0080]: it is undefined behavior to use this value --> src/main.rs:2:19 | 2 | let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x0000d800, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 d8 00 00 │ .... } note: erroneous constant encountered --> src/main.rs:2:13 | 2 | let _ = const { unsafe { char::from_u32_unchecked(0xd800) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
Split out
const_char_from_u32_unchecked
fromconst_char_convert
and stabilize the rest, i.e. stabilize the following functions:And put the following under the
from_u32_unchecked
const stability gate as it needsOption::unwrap
which isn't const-stable (yet):cc the tracking issue #89259 (which I'd like to keep open for
const_char_from_u32_unchecked
).