Skip to content

Commit 88f3b20

Browse files
Rollup merge of rust-lang#132153 - bjoernager:const-char-encode-utf16, r=dtolnay
Stabilise `const_char_encode_utf16`. Closes: rust-lang#130660 This PR stabilises the `const_char_encode_utf16` feature gate (i.e. support for `char::encode_utf16` in constant expressions). ~~Note that the linked tracking issue is as of this writing currently awaiting FCP until 2024-11-02.~~
2 parents 00ed73c + 764349f commit 88f3b20

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/core/src/char/methods.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ impl char {
711711
/// '𝕊'.encode_utf16(&mut b);
712712
/// ```
713713
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
714-
#[rustc_const_unstable(feature = "const_char_encode_utf16", issue = "130660")]
714+
#[rustc_const_stable(feature = "const_char_encode_utf16", since = "CURRENT_RUSTC_VERSION")]
715715
#[inline]
716716
pub const fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16] {
717717
encode_utf16_raw(self as u32, dst)
@@ -1823,9 +1823,10 @@ pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] {
18231823
/// Panics if the buffer is not large enough.
18241824
/// A buffer of length 2 is large enough to encode any `char`.
18251825
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
1826-
#[rustc_const_unstable(feature = "const_char_encode_utf16", issue = "130660")]
1826+
#[rustc_const_stable(feature = "const_char_encode_utf16", since = "CURRENT_RUSTC_VERSION")]
18271827
#[doc(hidden)]
18281828
#[inline]
1829+
#[rustc_allow_const_fn_unstable(const_eval_select)]
18291830
pub const fn encode_utf16_raw(mut code: u32, dst: &mut [u16]) -> &mut [u16] {
18301831
const fn panic_at_const(_code: u32, _len: usize, _dst_len: usize) {
18311832
// Note that we cannot format in constant expressions.

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
#![feature(const_array_into_iter_constructors)]
119119
#![feature(const_bigint_helper_methods)]
120120
#![feature(const_black_box)]
121-
#![feature(const_char_encode_utf16)]
122121
#![feature(const_eval_select)]
123122
#![feature(const_exact_div)]
124123
#![feature(const_float_methods)]

0 commit comments

Comments
 (0)