Skip to content

Commit c415676

Browse files
committed
Auto merge of #51609 - dscorbett:is_numeric, r=alexcrichton
Treat gc=No characters as numeric [`char::is_numeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_numeric) and [`char::is_alphanumeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric) are documented to be defined “in terms of the Unicode General Categories 'Nd', 'Nl', 'No'”, but unicode.py does not group 'No' with the other 'N' categories. These functions therefore currently return `false` for characters like ⟨¾⟩ and ⟨①⟩.
2 parents 11f812a + 5150ff0 commit c415676

File tree

4 files changed

+50
-35
lines changed

4 files changed

+50
-35
lines changed

src/libcore/char/methods.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,11 @@ impl char {
673673
/// assert!('٣'.is_alphanumeric());
674674
/// assert!('7'.is_alphanumeric());
675675
/// assert!('৬'.is_alphanumeric());
676+
/// assert!('¾'.is_alphanumeric());
677+
/// assert!('①'.is_alphanumeric());
676678
/// assert!('K'.is_alphanumeric());
677679
/// assert!('و'.is_alphanumeric());
678680
/// assert!('藏'.is_alphanumeric());
679-
/// assert!(!'¾'.is_alphanumeric());
680-
/// assert!(!'①'.is_alphanumeric());
681681
/// ```
682682
#[stable(feature = "rust1", since = "1.0.0")]
683683
#[inline]
@@ -727,11 +727,11 @@ impl char {
727727
/// assert!('٣'.is_numeric());
728728
/// assert!('7'.is_numeric());
729729
/// assert!('৬'.is_numeric());
730+
/// assert!('¾'.is_numeric());
731+
/// assert!('①'.is_numeric());
730732
/// assert!(!'K'.is_numeric());
731733
/// assert!(!'و'.is_numeric());
732734
/// assert!(!'藏'.is_numeric());
733-
/// assert!(!'¾'.is_numeric());
734-
/// assert!(!'①'.is_numeric());
735735
/// ```
736736
#[stable(feature = "rust1", since = "1.0.0")]
737737
#[inline]

src/libcore/tests/char.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ fn test_is_control() {
148148
}
149149

150150
#[test]
151-
fn test_is_digit() {
151+
fn test_is_numeric() {
152152
assert!('2'.is_numeric());
153153
assert!('7'.is_numeric());
154+
assert!('¾'.is_numeric());
154155
assert!(!'c'.is_numeric());
155156
assert!(!'i'.is_numeric());
156157
assert!(!'z'.is_numeric());

src/libcore/unicode/tables.rs

+43-29
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub mod general_category {
4040

4141
pub const N_table: &super::BoolTrie = &super::BoolTrie {
4242
r1: [
43-
0x03ff000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
43+
0x03ff000000000000, 0x0000000000000000, 0x720c000000000000, 0x0000000000000000,
4444
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
4545
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
4646
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
@@ -50,12 +50,14 @@ pub mod general_category {
5050
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00000000000003ff
5151
],
5252
r2: [
53-
0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 2, 3,
54-
0, 0, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55-
0, 5, 0, 0, 0, 3, 2, 0, 0, 0, 0, 6, 0, 2, 0, 0, 7, 0, 0, 2, 8, 0, 0, 7, 0, 0, 0, 0, 0,
56-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53+
0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 1, 0, 3, 0, 4, 0, 5, 0, 1, 0, 6, 0, 1, 0, 7, 0, 7, 8,
54+
0, 0, 0, 0, 9, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0,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 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,
8385
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,
8486
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,
85-
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,
86-
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,
87-
0, 0, 2, 0, 0, 0
87+
0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0
8888
],
8989
r3: &[
90-
0x0000000000000000, 0x0000ffc000000000, 0x0000000003ff0000, 0x000003ff00000000,
91-
0x00000000000003ff, 0x0001c00000000000, 0x000000000000ffc0, 0x0000000003ff03ff,
92-
0x03ff000000000000, 0xffffffff00000000, 0x00000000000001e7, 0x070003fe00000080,
90+
0x0000000000000000, 0x0000ffc000000000, 0x03f0ffc000000000, 0x00fcffc000000000,
91+
0x0007ffc000000000, 0x7f00ffc000000000, 0x01ffffc07f000000, 0x0000000003ff0000,
92+
0x000fffff00000000, 0x00000000000003ff, 0x1ffffe0000000000, 0x0001c00000000000,
93+
0x03ff03ff00000000, 0x000000000000ffc0, 0x0000000007ff0000, 0x0000000003ff03ff,
94+
0x03ff000000000000, 0x03f1000000000000, 0xffffffffffff0000, 0x00000000000003e7,
95+
0xffffffff00000000, 0x000000000fffffff, 0xfffffc0000000000, 0xffc0000000000000,
96+
0x00000000000fffff, 0x2000000000000000, 0x070003fe00000080, 0x00000000003c0000,
97+
0x000003ff00000000, 0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
r6: &[
125-
0x0000000000000000, 0x001fffffffffffff, 0x0000000000000402, 0x00000000003e0000,
126-
0x000003ff00000000, 0x03ff000000000000, 0x0000ffc000000000, 0xffc0000000000000,
127-
0x0000000003ff0000, 0x00000000000003ff, 0xffffffffffffffff, 0x00007fffffffffff,
128-
0xffffffffffffc000
132+
0x0000000000000000, 0x000fffffffffff80, 0x01ffffffffffffff, 0x0000000000000c00,
133+
0x0ffffffe00000000, 0x0000000f00000000, 0x0000000000000402, 0x00000000003e0000,
134+
0x000003ff00000000, 0xfe000000ff000000, 0x0000ff8000000000, 0xf800000000000000,
135+
0x000000000fc00000, 0x3000000000000000, 0xfffffffffffcffff, 0x60000000000001ff,
136+
0x00000000e0000000, 0x0000f80000000000, 0xff000000ff000000, 0x0000fe0000000000,
137+
0xfc00000000000000, 0x03ff000000000000, 0x7fffffff00000000, 0x0000007fe0000000,
138+
0x00000000001e0000, 0x0000fffffffc0000, 0xffc0000000000000, 0x001ffffe03ff0000,
139+
0x0000000003ff0000, 0x00000000000003ff, 0x0fff000000000000, 0x0007ffff00000000,
140+
0x00001fffffff0000, 0xffffffffffffffff, 0x00007fffffffffff, 0x00000003fbff0000,
141+
0x00000000007fffff, 0x000fffff00000000, 0x01ffffff00000000, 0xffffffffffffc000,
142+
0x000000000000ff80, 0xfffe000000000000, 0x001eefffffffffff, 0x0000000000001fff
129143
],
130144
};
131145

src/libcore/unicode/unicode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
'Lu': ['LC', 'L'], 'Ll': ['LC', 'L'], 'Lt': ['LC', 'L'],
5353
'Lm': ['L'], 'Lo': ['L'],
5454
'Mn': ['M'], 'Mc': ['M'], 'Me': ['M'],
55-
'Nd': ['N'], 'Nl': ['N'], 'No': ['No'],
55+
'Nd': ['N'], 'Nl': ['N'], 'No': ['N'],
5656
'Pc': ['P'], 'Pd': ['P'], 'Ps': ['P'], 'Pe': ['P'],
5757
'Pi': ['P'], 'Pf': ['P'], 'Po': ['P'],
5858
'Sm': ['S'], 'Sc': ['S'], 'Sk': ['S'], 'So': ['S'],

0 commit comments

Comments
 (0)