Rollup merge of #131463 - bjoernager:const-char-encode-utf8, r=RalfJung · qinheping/verify-rust-std@eb8ff20 (original) (raw)

Original file line number Diff line number Diff line change
@@ -674,8 +674,9 @@ impl char {
674 674 /// 'ß'.encode_utf8(&mut b);
675 675 /// ```
676 676 #[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")]
678 678 #[inline]
679 +#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
679 680 pub const fn encode_utf8(self, dst: &mut [u8]) -> &mut str {
680 681 // SAFETY: `char` is not a surrogate, so this is valid UTF-8.
681 682 unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) }
@@ -1770,9 +1771,11 @@ const fn len_utf16(code: u32) -> usize {
1770 1771 /// Panics if the buffer is not large enough.
1771 1772 /// A buffer of length four is large enough to encode any `char`.
1772 1773 #[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")]
1774 1775 #[doc(hidden)]
1775 1776 #[inline]
1777 +#[rustc_allow_const_fn_unstable(const_eval_select)]
1778 +#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
1776 1779 pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] {
1777 1780 const fn panic_at_const(_code: u32, _len: usize, _dst_len: usize) {
1778 1781 // Note that we cannot format in constant expressions.