Skip to content

Commit

Permalink
Rollup merge of rust-lang#131641 - RalfJung:unicode-bitset-static, r=…
Browse files Browse the repository at this point in the history
…dtolnay

switch unicode-data bitsets back to 'static'

Back in rust-lang#101401, these were changed to `const` to make some functions `const fn`. However, `@dtolnay` was [not happy](rust-lang#101400 (comment)) about this. Meanwhile, `const fn` can access immutable statics like these, so we can change this back.

Part of rust-lang#101400.
  • Loading branch information
matthiaskrgr authored Oct 13, 2024
2 parents 29ef664 + 90e4f10 commit 84dd8cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(const_mut_refs))]
#![cfg_attr(bootstrap, feature(const_refs_to_cell))]
#![cfg_attr(bootstrap, feature(const_refs_to_static))]
#![feature(abi_unadjusted)]
#![feature(adt_const_params)]
#![feature(allow_internal_unsafe)]
Expand Down
16 changes: 8 additions & 8 deletions library/core/src/unicode/unicode_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@ pub mod grapheme_extend {

#[rustfmt::skip]
pub mod lowercase {
const BITSET_CHUNKS_MAP: &'static [u8; 123] = &[
static BITSET_CHUNKS_MAP: [u8; 123] = [
14, 17, 0, 0, 9, 0, 0, 12, 13, 10, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 4, 1, 0, 15, 0, 8, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0,
3, 18, 0, 7,
];
const BITSET_INDEX_CHUNKS: &'static [[u8; 16]; 20] = &[
static BITSET_INDEX_CHUNKS: [[u8; 16]; 20] = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 14, 56, 0],
Expand All @@ -360,7 +360,7 @@ pub mod lowercase {
[16, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[65, 41, 55, 12, 77, 63, 18, 1, 7, 64, 76, 20, 73, 74, 4, 45],
];
const BITSET_CANONICAL: &'static [u64; 56] = &[
static BITSET_CANONICAL: [u64; 56] = [
0b0000000000000000000000000000000000000000000000000000000000000000,
0b1111111111111111110000000000000000000000000011111111111111111111,
0b1010101010101010101010101010101010101010101010101010100000000010,
Expand Down Expand Up @@ -418,7 +418,7 @@ pub mod lowercase {
0b1110011001010001001011010010101001001110001001000011000100101001,
0b1110101111000000000000000000000000001111111111111111111111111100,
];
const BITSET_MAPPING: &'static [(u8, u8); 22] = &[
static BITSET_MAPPING: [(u8, u8); 22] = [
(0, 64), (1, 188), (1, 186), (1, 183), (1, 176), (1, 109), (1, 124), (1, 126), (1, 66),
(1, 70), (1, 77), (2, 146), (2, 144), (2, 83), (3, 93), (3, 147), (3, 133), (4, 12), (4, 6),
(5, 187), (6, 78), (7, 132),
Expand Down Expand Up @@ -471,14 +471,14 @@ pub mod n {

#[rustfmt::skip]
pub mod uppercase {
const BITSET_CHUNKS_MAP: &'static [u8; 125] = &[
static BITSET_CHUNKS_MAP: [u8; 125] = [
12, 15, 6, 6, 0, 6, 6, 2, 4, 11, 6, 16, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 5, 6, 14, 6, 10, 6, 6, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 13, 6, 6,
6, 6, 9, 6, 3,
];
const BITSET_INDEX_CHUNKS: &'static [[u8; 16]; 17] = &[
static BITSET_INDEX_CHUNKS: [[u8; 16]; 17] = [
[44, 44, 5, 35, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 5, 1],
[44, 44, 5, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44],
[44, 44, 40, 44, 44, 44, 44, 44, 17, 17, 63, 17, 43, 29, 24, 23],
Expand All @@ -497,7 +497,7 @@ pub mod uppercase {
[58, 19, 2, 18, 10, 48, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44],
[58, 38, 17, 27, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44],
];
const BITSET_CANONICAL: &'static [u64; 44] = &[
static BITSET_CANONICAL: [u64; 44] = [
0b0000011111111111111111111111111000000000000000000000000000000000,
0b0000000000111111111111111111111111111111111111111111111111111111,
0b0101010101010101010101010101010101010101010101010101010000000001,
Expand Down Expand Up @@ -543,7 +543,7 @@ pub mod uppercase {
0b1111011111111111000000000000000000000000000000000000000000000000,
0b1111111100000000111111110000000000111111000000001111111100000000,
];
const BITSET_MAPPING: &'static [(u8, u8); 25] = &[
static BITSET_MAPPING: [(u8, u8); 25] = [
(0, 187), (0, 177), (0, 171), (0, 167), (0, 164), (0, 32), (0, 47), (0, 51), (0, 121),
(0, 117), (0, 109), (1, 150), (1, 148), (1, 142), (1, 134), (1, 131), (1, 64), (2, 164),
(2, 146), (2, 20), (3, 146), (3, 140), (3, 134), (4, 178), (4, 171),
Expand Down
8 changes: 4 additions & 4 deletions src/tools/unicode-table-generator/src/raw_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ impl RawEmitter {

writeln!(
&mut self.file,
"const BITSET_CANONICAL: &'static [u64; {}] = &[{}];",
"static BITSET_CANONICAL: [u64; {}] = [{}];",
canonicalized.canonical_words.len(),
fmt_list(canonicalized.canonical_words.iter().map(|v| Bits(*v))),
)
.unwrap();
self.bytes_used += 8 * canonicalized.canonical_words.len();
writeln!(
&mut self.file,
"const BITSET_MAPPING: &'static [(u8, u8); {}] = &[{}];",
"static BITSET_MAPPING: [(u8, u8); {}] = [{}];",
canonicalized.canonicalized_words.len(),
fmt_list(&canonicalized.canonicalized_words),
)
Expand Down Expand Up @@ -139,15 +139,15 @@ impl RawEmitter {

writeln!(
&mut self.file,
"const BITSET_CHUNKS_MAP: &'static [u8; {}] = &[{}];",
"static BITSET_CHUNKS_MAP: [u8; {}] = [{}];",
chunk_indices.len(),
fmt_list(&chunk_indices),
)
.unwrap();
self.bytes_used += chunk_indices.len();
writeln!(
&mut self.file,
"const BITSET_INDEX_CHUNKS: &'static [[u8; {}]; {}] = &[{}];",
"static BITSET_INDEX_CHUNKS: [[u8; {}]; {}] = [{}];",
chunk_length,
chunks.len(),
fmt_list(chunks.iter()),
Expand Down

0 comments on commit 84dd8cd

Please sign in to comment.