diff options
| author | bors <bors@rust-lang.org> | 2022-09-04 18:10:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-04 18:10:04 +0000 |
| commit | 0ebd3ab63aa08337bb4e4600358679262ce8d242 (patch) | |
| tree | 0dfaee0b3b84f3594c86d2d25958f0b44c8accc6 /src/tools | |
| parent | a2cdcb3fea2baae5d20eabaa412e0d2f5b98c318 (diff) | |
| parent | cea11f50dc9e6e28d74e0e08e24641147c7c7fb8 (diff) | |
| download | rust-0ebd3ab63aa08337bb4e4600358679262ce8d242.tar.gz rust-0ebd3ab63aa08337bb4e4600358679262ce8d242.zip | |
Auto merge of #101411 - matthiaskrgr:rollup-uj24yb5, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #101322 (Fix internal doc link) - #101385 (updated description of File struct in std::fs) - #101388 (Don't delay invalid LHS bug unless it will be covered by an error in `check_overloaded_binop`) - #101394 (Forbid mixing `System` with direct sytem allocator calls) - #101397 (rustdoc: remove redundant mobile-sized `.source nav:not(.sidebar).sub`) - #101401 (Make `char::is_lowercase` and `char::is_uppercase` const) - #101407 (Remove duplicated test (superseeded by search-form-elements.goml)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/unicode-table-generator/src/range_search.rs | 15 | ||||
| -rw-r--r-- | src/tools/unicode-table-generator/src/raw_emitter.rs | 15 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/tools/unicode-table-generator/src/range_search.rs b/src/tools/unicode-table-generator/src/range_search.rs index 39b47ce703f..3a5b869f72f 100644 --- a/src/tools/unicode-table-generator/src/range_search.rs +++ b/src/tools/unicode-table-generator/src/range_search.rs @@ -1,5 +1,6 @@ +#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")] #[inline(always)] -fn bitset_search< +const fn bitset_search< const N: usize, const CHUNK_SIZE: usize, const N1: usize, @@ -15,14 +16,18 @@ fn bitset_search< let bucket_idx = (needle / 64) as usize; let chunk_map_idx = bucket_idx / CHUNK_SIZE; let chunk_piece = bucket_idx % CHUNK_SIZE; - let chunk_idx = if let Some(&v) = chunk_idx_map.get(chunk_map_idx) { - v + // FIXME: const-hack: Revert to `slice::get` after `const_slice_index` + // feature stabilizes. + let chunk_idx = if chunk_map_idx < chunk_idx_map.len() { + chunk_idx_map[chunk_map_idx] } else { return false; }; let idx = bitset_chunk_idx[chunk_idx as usize][chunk_piece] as usize; - let word = if let Some(word) = bitset_canonical.get(idx) { - *word + // FIXME: const-hack: Revert to `slice::get` after `const_slice_index` + // feature stabilizes. + let word = if idx < bitset_canonical.len() { + bitset_canonical[idx] } else { let (real_idx, mapping) = bitset_canonicalized[idx - bitset_canonical.len()]; let mut word = bitset_canonical[real_idx as usize]; diff --git a/src/tools/unicode-table-generator/src/raw_emitter.rs b/src/tools/unicode-table-generator/src/raw_emitter.rs index 13eed7b1099..890ff986c2b 100644 --- a/src/tools/unicode-table-generator/src/raw_emitter.rs +++ b/src/tools/unicode-table-generator/src/raw_emitter.rs @@ -76,7 +76,7 @@ impl RawEmitter { writeln!( &mut self.file, - "static BITSET_CANONICAL: [u64; {}] = [{}];", + "const BITSET_CANONICAL: &'static [u64; {}] = &[{}];", canonicalized.canonical_words.len(), fmt_list(canonicalized.canonical_words.iter().map(|v| Bits(*v))), ) @@ -84,7 +84,7 @@ impl RawEmitter { self.bytes_used += 8 * canonicalized.canonical_words.len(); writeln!( &mut self.file, - "static BITSET_MAPPING: [(u8, u8); {}] = [{}];", + "const BITSET_MAPPING: &'static [(u8, u8); {}] = &[{}];", canonicalized.canonicalized_words.len(), fmt_list(&canonicalized.canonicalized_words), ) @@ -96,7 +96,12 @@ impl RawEmitter { self.blank_line(); - writeln!(&mut self.file, "pub fn lookup(c: char) -> bool {{").unwrap(); + writeln!( + &mut self.file, + r#"#[rustc_const_unstable(feature = "const_unicode_case_lookup", issue = "101400")]"# + ) + .unwrap(); + writeln!(&mut self.file, "pub const fn lookup(c: char) -> bool {{").unwrap(); writeln!(&mut self.file, " super::bitset_search(",).unwrap(); writeln!(&mut self.file, " c as u32,").unwrap(); writeln!(&mut self.file, " &BITSET_CHUNKS_MAP,").unwrap(); @@ -130,7 +135,7 @@ impl RawEmitter { writeln!( &mut self.file, - "static BITSET_CHUNKS_MAP: [u8; {}] = [{}];", + "const BITSET_CHUNKS_MAP: &'static [u8; {}] = &[{}];", chunk_indices.len(), fmt_list(&chunk_indices), ) @@ -138,7 +143,7 @@ impl RawEmitter { self.bytes_used += chunk_indices.len(); writeln!( &mut self.file, - "static BITSET_INDEX_CHUNKS: [[u8; {}]; {}] = [{}];", + "const BITSET_INDEX_CHUNKS: &'static [[u8; {}]; {}] = &[{}];", chunk_length, chunks.len(), fmt_list(chunks.iter()), |
