mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rollup merge of #131496 - bjoernager:const-make-ascii, r=dtolnay
Stabilise `const_make_ascii`. Closes: #130698 This PR stabilises the `const_make_ascii` feature gate (i.e. marking the `make_ascii_uppercase` and `make_ascii_lowercase` methods in `char`, `u8`, `[u8]`, and `str` as const).
This commit is contained in:
commit
9716a42389
@ -1282,8 +1282,9 @@ impl char {
|
||||
///
|
||||
/// [`to_ascii_uppercase()`]: #method.to_ascii_uppercase
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_unstable(feature = "const_make_ascii", issue = "130698")]
|
||||
#[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn make_ascii_uppercase(&mut self) {
|
||||
*self = self.to_ascii_uppercase();
|
||||
}
|
||||
@ -1308,8 +1309,9 @@ impl char {
|
||||
///
|
||||
/// [`to_ascii_lowercase()`]: #method.to_ascii_lowercase
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_unstable(feature = "const_make_ascii", issue = "130698")]
|
||||
#[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn make_ascii_lowercase(&mut self) {
|
||||
*self = self.to_ascii_lowercase();
|
||||
}
|
||||
|
@ -125,7 +125,6 @@
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_index_range_slice_index)]
|
||||
#![feature(const_likely)]
|
||||
#![feature(const_make_ascii)]
|
||||
#![feature(const_nonnull_new)]
|
||||
#![feature(const_num_midpoint)]
|
||||
#![feature(const_option_ext)]
|
||||
|
@ -624,8 +624,9 @@ impl u8 {
|
||||
///
|
||||
/// [`to_ascii_uppercase`]: Self::to_ascii_uppercase
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_unstable(feature = "const_make_ascii", issue = "130698")]
|
||||
#[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn make_ascii_uppercase(&mut self) {
|
||||
*self = self.to_ascii_uppercase();
|
||||
}
|
||||
@ -650,8 +651,9 @@ impl u8 {
|
||||
///
|
||||
/// [`to_ascii_lowercase`]: Self::to_ascii_lowercase
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_unstable(feature = "const_make_ascii", issue = "130698")]
|
||||
#[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn make_ascii_lowercase(&mut self) {
|
||||
*self = self.to_ascii_lowercase();
|
||||
}
|
||||
|
@ -67,8 +67,9 @@ impl [u8] {
|
||||
///
|
||||
/// [`to_ascii_uppercase`]: #method.to_ascii_uppercase
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_unstable(feature = "const_make_ascii", issue = "130698")]
|
||||
#[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn make_ascii_uppercase(&mut self) {
|
||||
// FIXME(const-hack): We would like to simply iterate using `for` loops but this isn't currently allowed in constant expressions.
|
||||
let mut i = 0;
|
||||
@ -89,8 +90,9 @@ impl [u8] {
|
||||
///
|
||||
/// [`to_ascii_lowercase`]: #method.to_ascii_lowercase
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_unstable(feature = "const_make_ascii", issue = "130698")]
|
||||
#[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn make_ascii_lowercase(&mut self) {
|
||||
// FIXME(const-hack): We would like to simply iterate using `for` loops but this isn't currently allowed in constant expressions.
|
||||
let mut i = 0;
|
||||
|
@ -2475,8 +2475,9 @@ impl str {
|
||||
/// assert_eq!("GRüßE, JüRGEN ❤", s);
|
||||
/// ```
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_unstable(feature = "const_make_ascii", issue = "130698")]
|
||||
#[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn make_ascii_uppercase(&mut self) {
|
||||
// SAFETY: changing ASCII letters only does not invalidate UTF-8.
|
||||
let me = unsafe { self.as_bytes_mut() };
|
||||
@ -2503,8 +2504,9 @@ impl str {
|
||||
/// assert_eq!("grÜße, jÜrgen ❤", s);
|
||||
/// ```
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[rustc_const_unstable(feature = "const_make_ascii", issue = "130698")]
|
||||
#[rustc_const_stable(feature = "const_make_ascii", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn make_ascii_lowercase(&mut self) {
|
||||
// SAFETY: changing ASCII letters only does not invalidate UTF-8.
|
||||
let me = unsafe { self.as_bytes_mut() };
|
||||
|
Loading…
Reference in New Issue
Block a user