Rollup merge of #131641 - RalfJung:unicode-bitset-static, r=dtolnay
switch unicode-data bitsets back to 'static' Back in https://github.com/rust-lang/rust/pull/101401, these were changed to `const` to make some functions `const fn`. However, `@dtolnay` was [not happy](https://github.com/rust-lang/rust/issues/101400#issuecomment-1742500968) about this. Meanwhile, `const fn` can access immutable statics like these, so we can change this back. Part of https://github.com/rust-lang/rust/issues/101400.
This commit is contained in:
commit
84dd8cdb22
@ -178,6 +178,7 @@
|
|||||||
// tidy-alphabetical-start
|
// tidy-alphabetical-start
|
||||||
#![cfg_attr(bootstrap, feature(const_mut_refs))]
|
#![cfg_attr(bootstrap, feature(const_mut_refs))]
|
||||||
#![cfg_attr(bootstrap, feature(const_refs_to_cell))]
|
#![cfg_attr(bootstrap, feature(const_refs_to_cell))]
|
||||||
|
#![cfg_attr(bootstrap, feature(const_refs_to_static))]
|
||||||
#![feature(abi_unadjusted)]
|
#![feature(abi_unadjusted)]
|
||||||
#![feature(adt_const_params)]
|
#![feature(adt_const_params)]
|
||||||
#![feature(allow_internal_unsafe)]
|
#![feature(allow_internal_unsafe)]
|
||||||
|
@ -331,14 +331,14 @@ fn lookup_slow(c: char) -> bool {
|
|||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub mod lowercase {
|
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,
|
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, 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, 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,
|
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,
|
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, 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, 0, 61, 0, 0],
|
||||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 14, 56, 0],
|
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 14, 56, 0],
|
||||||
@ -360,7 +360,7 @@ pub mod lowercase {
|
|||||||
[16, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
[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],
|
[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,
|
0b0000000000000000000000000000000000000000000000000000000000000000,
|
||||||
0b1111111111111111110000000000000000000000000011111111111111111111,
|
0b1111111111111111110000000000000000000000000011111111111111111111,
|
||||||
0b1010101010101010101010101010101010101010101010101010100000000010,
|
0b1010101010101010101010101010101010101010101010101010100000000010,
|
||||||
@ -418,7 +418,7 @@ pub mod lowercase {
|
|||||||
0b1110011001010001001011010010101001001110001001000011000100101001,
|
0b1110011001010001001011010010101001001110001001000011000100101001,
|
||||||
0b1110101111000000000000000000000000001111111111111111111111111100,
|
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),
|
(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),
|
(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),
|
(5, 187), (6, 78), (7, 132),
|
||||||
@ -471,14 +471,14 @@ pub fn lookup(c: char) -> bool {
|
|||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub mod uppercase {
|
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,
|
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, 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, 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, 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,
|
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, 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, 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],
|
[44, 44, 40, 44, 44, 44, 44, 44, 17, 17, 63, 17, 43, 29, 24, 23],
|
||||||
@ -497,7 +497,7 @@ pub mod uppercase {
|
|||||||
[58, 19, 2, 18, 10, 48, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44],
|
[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],
|
[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,
|
0b0000011111111111111111111111111000000000000000000000000000000000,
|
||||||
0b0000000000111111111111111111111111111111111111111111111111111111,
|
0b0000000000111111111111111111111111111111111111111111111111111111,
|
||||||
0b0101010101010101010101010101010101010101010101010101010000000001,
|
0b0101010101010101010101010101010101010101010101010101010000000001,
|
||||||
@ -543,7 +543,7 @@ pub mod uppercase {
|
|||||||
0b1111011111111111000000000000000000000000000000000000000000000000,
|
0b1111011111111111000000000000000000000000000000000000000000000000,
|
||||||
0b1111111100000000111111110000000000111111000000001111111100000000,
|
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, 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),
|
(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),
|
(2, 146), (2, 20), (3, 146), (3, 140), (3, 134), (4, 178), (4, 171),
|
||||||
|
@ -77,7 +77,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut self.file,
|
&mut self.file,
|
||||||
"const BITSET_CANONICAL: &'static [u64; {}] = &[{}];",
|
"static BITSET_CANONICAL: [u64; {}] = [{}];",
|
||||||
canonicalized.canonical_words.len(),
|
canonicalized.canonical_words.len(),
|
||||||
fmt_list(canonicalized.canonical_words.iter().map(|v| Bits(*v))),
|
fmt_list(canonicalized.canonical_words.iter().map(|v| Bits(*v))),
|
||||||
)
|
)
|
||||||
@ -85,7 +85,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|||||||
self.bytes_used += 8 * canonicalized.canonical_words.len();
|
self.bytes_used += 8 * canonicalized.canonical_words.len();
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut self.file,
|
&mut self.file,
|
||||||
"const BITSET_MAPPING: &'static [(u8, u8); {}] = &[{}];",
|
"static BITSET_MAPPING: [(u8, u8); {}] = [{}];",
|
||||||
canonicalized.canonicalized_words.len(),
|
canonicalized.canonicalized_words.len(),
|
||||||
fmt_list(&canonicalized.canonicalized_words),
|
fmt_list(&canonicalized.canonicalized_words),
|
||||||
)
|
)
|
||||||
@ -139,7 +139,7 @@ fn emit_chunk_map(&mut self, zero_at: u8, compressed_words: &[u8], chunk_length:
|
|||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut self.file,
|
&mut self.file,
|
||||||
"const BITSET_CHUNKS_MAP: &'static [u8; {}] = &[{}];",
|
"static BITSET_CHUNKS_MAP: [u8; {}] = [{}];",
|
||||||
chunk_indices.len(),
|
chunk_indices.len(),
|
||||||
fmt_list(&chunk_indices),
|
fmt_list(&chunk_indices),
|
||||||
)
|
)
|
||||||
@ -147,7 +147,7 @@ fn emit_chunk_map(&mut self, zero_at: u8, compressed_words: &[u8], chunk_length:
|
|||||||
self.bytes_used += chunk_indices.len();
|
self.bytes_used += chunk_indices.len();
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut self.file,
|
&mut self.file,
|
||||||
"const BITSET_INDEX_CHUNKS: &'static [[u8; {}]; {}] = &[{}];",
|
"static BITSET_INDEX_CHUNKS: [[u8; {}]; {}] = [{}];",
|
||||||
chunk_length,
|
chunk_length,
|
||||||
chunks.len(),
|
chunks.len(),
|
||||||
fmt_list(chunks.iter()),
|
fmt_list(chunks.iter()),
|
||||||
|
Loading…
Reference in New Issue
Block a user