Skip to content
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_unicode_case_lookup #132948

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,12 @@ impl char {
/// In a const context:
///
/// ```
/// #![feature(const_unicode_case_lookup)]
/// const CAPITAL_DELTA_IS_LOWERCASE: bool = 'Δ'.is_lowercase();
/// assert!(!CAPITAL_DELTA_IS_LOWERCASE);
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")]
#[rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0")]
#[rustc_const_stable(feature = "const_unicode_case_lookup", since = "CURRENT_RUSTC_VERSION")]

same for the others

#[inline]
pub const fn is_lowercase(self) -> bool {
match self {
Expand Down Expand Up @@ -817,13 +816,12 @@ impl char {
/// In a const context:
///
/// ```
/// #![feature(const_unicode_case_lookup)]
/// const CAPITAL_DELTA_IS_UPPERCASE: bool = 'Δ'.is_uppercase();
/// assert!(CAPITAL_DELTA_IS_UPPERCASE);
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")]
#[rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0")]
#[inline]
pub const fn is_uppercase(self) -> bool {
match self {
Expand Down
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
#![feature(const_type_name)]
#![feature(const_typed_swap)]
#![feature(const_ub_checks)]
#![feature(const_unicode_case_lookup)]
#![feature(core_intrinsics)]
#![feature(coverage_attribute)]
#![feature(do_not_recommend)]
Expand Down
3 changes: 3 additions & 0 deletions library/core/src/unicode/unicode_data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
///! This file is generated by `./x run src/tools/unicode-table-generator`; do not edit manually!

#[inline(always)]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0"))]
const fn bitset_search<
const N: usize,
const CHUNK_SIZE: usize,
Expand Down Expand Up @@ -423,6 +424,7 @@ pub mod lowercase {
(5, 187), (6, 78), (7, 132),
];

#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0"))]
pub const fn lookup(c: char) -> bool {
super::bitset_search(
c as u32,
Expand Down Expand Up @@ -547,6 +549,7 @@ pub mod uppercase {
(2, 146), (2, 20), (3, 146), (3, 140), (3, 134), (4, 178), (4, 171),
];

#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0"))]
pub const fn lookup(c: char) -> bool {
super::bitset_search(
c as u32,
Expand Down
1 change: 1 addition & 0 deletions src/tools/unicode-table-generator/src/range_search.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[inline(always)]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0"))]
const fn bitset_search<
const N: usize,
const CHUNK_SIZE: usize,
Expand Down
4 changes: 4 additions & 0 deletions src/tools/unicode-table-generator/src/raw_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ impl RawEmitter {

self.blank_line();

writeln!(
&mut self.file,
r#"#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_unicode_case_lookup", since = "1.84.0"))]"#
).unwrap();
writeln!(&mut self.file, "pub const fn lookup(c: char) -> bool {{").unwrap();
if first_code_point > 0x7f {
writeln!(&mut self.file, " (c as u32) >= {first_code_point:#04x} &&").unwrap();
Expand Down
Loading