Skip to content

Commit fd5be42

Browse files
committed
Stabilise 'const_char_encode_utf8';
1 parent 360f7d7 commit fd5be42

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

library/core/src/char/methods.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,9 @@ impl char {
674674
/// 'ß'.encode_utf8(&mut b);
675675
/// ```
676676
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
677-
#[rustc_const_unstable(feature = "const_char_encode_utf8", issue = "130512")]
677+
#[rustc_const_stable(feature = "const_char_encode_utf8", since = "CURRENT_RUSTC_VERSION")]
678678
#[inline]
679+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
679680
pub const fn encode_utf8(self, dst: &mut [u8]) -> &mut str {
680681
// SAFETY: `char` is not a surrogate, so this is valid UTF-8.
681682
unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) }
@@ -1770,9 +1771,10 @@ const fn len_utf16(code: u32) -> usize {
17701771
/// Panics if the buffer is not large enough.
17711772
/// A buffer of length four is large enough to encode any `char`.
17721773
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
1773-
#[rustc_const_unstable(feature = "const_char_encode_utf8", issue = "130512")]
1774+
#[rustc_const_stable(feature = "const_char_encode_utf8", since = "CURRENT_RUSTC_VERSION")]
17741775
#[doc(hidden)]
17751776
#[inline]
1777+
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
17761778
pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] {
17771779
const fn panic_at_const(_code: u32, _len: usize, _dst_len: usize) {
17781780
// Note that we cannot format in constant expressions.

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
#![feature(const_bigint_helper_methods)]
120120
#![feature(const_black_box)]
121121
#![feature(const_char_encode_utf16)]
122-
#![feature(const_char_encode_utf8)]
123122
#![feature(const_eval_select)]
124123
#![feature(const_exact_div)]
125124
#![feature(const_float_classify)]

0 commit comments

Comments
 (0)