Skip to content

Commit 1ebfc8c

Browse files
joboetKmeakin
authored andcommitted
Rename N to Numeric
Workaround for issue #148387
1 parent 5012450 commit 1ebfc8c

5 files changed

Lines changed: 17 additions & 12 deletions

File tree

library/core/src/unicode/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub use unicode_data::conversions;
1212
pub(crate) use unicode_data::alphabetic::lookup as Alphabetic;
1313
pub(crate) use unicode_data::grapheme_extend::lookup as Grapheme_Extend;
1414
pub(crate) use unicode_data::lowercase::lookup as Lowercase;
15-
pub(crate) use unicode_data::n::lookup as N;
15+
pub(crate) use unicode_data::numeric::lookup as N;
1616
pub(crate) use unicode_data::uppercase::lookup as Uppercase;
1717
pub(crate) use unicode_data::white_space::lookup as White_Space;
1818

library/core/src/unicode/unicode_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Cased : 401 bytes, 4580 codepoints in 156 ranges (U+0000AA - U+01F18A) using skiplist
55
// Grapheme_Extend : 899 bytes, 2232 codepoints in 383 ranges (U+000300 - U+0E01F0) using skiplist
66
// Lowercase : 943 bytes, 2569 codepoints in 676 ranges (U+0000AA - U+01E944) using bitset
7-
// N : 463 bytes, 1914 codepoints in 145 ranges (U+0000B2 - U+01FBFA) using skiplist
7+
// Numeric : 463 bytes, 1914 codepoints in 145 ranges (U+0000B2 - U+01FBFA) using skiplist
88
// Uppercase : 799 bytes, 1980 codepoints in 659 ranges (U+0000C0 - U+01F18A) using bitset
99
// White_Space : 256 bytes, 19 codepoints in 8 ranges (U+000085 - U+003001) using cascading
1010
// to_lower : 11708 bytes
@@ -539,7 +539,7 @@ pub mod lowercase {
539539
}
540540
}
541541

542-
pub mod n {
542+
pub mod numeric {
543543
use super::ShortOffsetRunHeader;
544544

545545
static SHORT_OFFSET_RUNS: [ShortOffsetRunHeader; 43] = [

library/coretests/tests/unicode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ fn lowercase() {
7373

7474
#[test]
7575
#[cfg_attr(miri, ignore)] // Miri is too slow
76-
fn n() {
77-
test_boolean_property(test_data::N, unicode_data::n::lookup);
76+
fn numeric() {
77+
test_boolean_property(test_data::NUMERIC, unicode_data::numeric::lookup);
7878
}
7979

8080
#[test]

library/coretests/tests/unicode/test_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ pub(super) static LOWERCASE: &[RangeInclusive<char>; 676] = &[
777777
];
778778

779779
#[rustfmt::skip]
780-
pub(super) static N: &[RangeInclusive<char>; 145] = &[
780+
pub(super) static NUMERIC: &[RangeInclusive<char>; 145] = &[
781781
'\u{b2}'..='\u{b3}', '\u{b9}'..='\u{b9}', '\u{bc}'..='\u{be}', '\u{660}'..='\u{669}',
782782
'\u{6f0}'..='\u{6f9}', '\u{7c0}'..='\u{7c9}', '\u{966}'..='\u{96f}', '\u{9e6}'..='\u{9ef}',
783783
'\u{9f4}'..='\u{9f9}', '\u{a66}'..='\u{a6f}', '\u{ae6}'..='\u{aef}', '\u{b66}'..='\u{b6f}',

src/tools/unicode-table-generator/src/main.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static PROPERTIES: &[&str] = &[
9393
"Case_Ignorable",
9494
"Grapheme_Extend",
9595
"White_Space",
96-
"N",
96+
"Numeric",
9797
];
9898

9999
struct UnicodeData {
@@ -148,10 +148,13 @@ fn load_data() -> UnicodeData {
148148
for row in ucd_parse::UnicodeDataExpander::new(
149149
ucd_parse::parse::<_, ucd_parse::UnicodeData>(&UNICODE_DIRECTORY).unwrap(),
150150
) {
151-
let general_category = if ["Nd", "Nl", "No"].contains(&row.general_category.as_str()) {
152-
"N"
153-
} else {
154-
row.general_category.as_str()
151+
// FIXME: this used to map `Nd`, `Nl` and `No` to `N`, but the generated
152+
// `unicode_data` is `pub`, so the module names can show up in
153+
// recommendations (see issue #148387). While that's a rustc issue, we
154+
// choose a better name for the `N` property to avoid bad diagnostics.
155+
let general_category = match row.general_category.as_str() {
156+
"Nd" | "Nl" | "No" => "Numeric",
157+
category => category,
155158
};
156159
if let Some(name) = PROPERTIES.iter().find(|prop| **prop == general_category) {
157160
properties
@@ -241,7 +244,9 @@ fn main() {
241244
emit_codepoints(&mut emitter, ranges);
242245
}
243246

244-
modules.push((property.to_lowercase().to_string(), emitter.file));
247+
let module_name = property.to_lowercase();
248+
249+
modules.push((module_name, emitter.file));
245250
writeln!(
246251
table_file,
247252
"// {:16}: {:5} bytes, {:6} codepoints in {:3} ranges (U+{:06X} - U+{:06X}) using {}",

0 commit comments

Comments
 (0)