Skip to content

Commit 1948ddf

Browse files
committed
De-mode std::unicode. Part of #3583.
1 parent 37ff152 commit 1948ddf

File tree

2 files changed

+143
-147
lines changed

2 files changed

+143
-147
lines changed

src/libstd/std.rc

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ mod cmp;
124124
mod base64;
125125

126126
#[cfg(unicode)]
127-
#[legacy_exports]
128127
mod unicode;
129128

130129

src/libstd/unicode.rs

+143-146
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,155 @@
11
#[forbid(deprecated_mode)];
22

3-
mod icu {
4-
#[legacy_exports];
5-
type UBool = u8;
6-
type UProperty = int;
7-
type UChar32 = char;
8-
9-
const TRUE : u8 = 1u8;
10-
const FALSE : u8 = 1u8;
11-
12-
const UCHAR_ALPHABETIC : UProperty = 0;
13-
const UCHAR_BINARY_START : UProperty = 0; // = UCHAR_ALPHABETIC
14-
const UCHAR_ASCII_HEX_DIGIT : UProperty = 1;
15-
const UCHAR_BIDI_CONTROL : UProperty = 2;
16-
17-
const UCHAR_BIDI_MIRRORED : UProperty = 3;
18-
const UCHAR_DASH : UProperty = 4;
19-
const UCHAR_DEFAULT_IGNORABLE_CODE_POINT : UProperty = 5;
20-
const UCHAR_DEPRECATED : UProperty = 6;
21-
22-
const UCHAR_DIACRITIC : UProperty = 7;
23-
const UCHAR_EXTENDER : UProperty = 8;
24-
const UCHAR_FULL_COMPOSITION_EXCLUSION : UProperty = 9;
25-
const UCHAR_GRAPHEME_BASE : UProperty = 10;
26-
27-
const UCHAR_GRAPHEME_EXTEND : UProperty = 11;
28-
const UCHAR_GRAPHEME_LINK : UProperty = 12;
29-
const UCHAR_HEX_DIGIT : UProperty = 13;
30-
const UCHAR_HYPHEN : UProperty = 14;
31-
32-
const UCHAR_ID_CONTINUE : UProperty = 15;
33-
const UCHAR_ID_START : UProperty = 16;
34-
const UCHAR_IDEOGRAPHIC : UProperty = 17;
35-
const UCHAR_IDS_BINARY_OPERATOR : UProperty = 18;
36-
37-
const UCHAR_IDS_TRINARY_OPERATOR : UProperty = 19;
38-
const UCHAR_JOIN_CONTROL : UProperty = 20;
39-
const UCHAR_LOGICAL_ORDER_EXCEPTION : UProperty = 21;
40-
const UCHAR_LOWERCASE : UProperty = 22;
41-
42-
const UCHAR_MATH : UProperty = 23;
43-
const UCHAR_NONCHARACTER_CODE_POINT : UProperty = 24;
44-
const UCHAR_QUOTATION_MARK : UProperty = 25;
45-
const UCHAR_RADICAL : UProperty = 26;
46-
47-
const UCHAR_SOFT_DOTTED : UProperty = 27;
48-
const UCHAR_TERMINAL_PUNCTUATION : UProperty = 28;
49-
const UCHAR_UNIFIED_IDEOGRAPH : UProperty = 29;
50-
const UCHAR_UPPERCASE : UProperty = 30;
51-
52-
const UCHAR_WHITE_SPACE : UProperty = 31;
53-
const UCHAR_XID_CONTINUE : UProperty = 32;
54-
const UCHAR_XID_START : UProperty = 33;
55-
const UCHAR_CASE_SENSITIVE : UProperty = 34;
56-
57-
const UCHAR_S_TERM : UProperty = 35;
58-
const UCHAR_VARIATION_SELECTOR : UProperty = 36;
59-
const UCHAR_NFD_INERT : UProperty = 37;
60-
const UCHAR_NFKD_INERT : UProperty = 38;
61-
62-
const UCHAR_NFC_INERT : UProperty = 39;
63-
const UCHAR_NFKC_INERT : UProperty = 40;
64-
const UCHAR_SEGMENT_STARTER : UProperty = 41;
65-
const UCHAR_PATTERN_SYNTAX : UProperty = 42;
66-
67-
const UCHAR_PATTERN_WHITE_SPACE : UProperty = 43;
68-
const UCHAR_POSIX_ALNUM : UProperty = 44;
69-
const UCHAR_POSIX_BLANK : UProperty = 45;
70-
const UCHAR_POSIX_GRAPH : UProperty = 46;
71-
72-
const UCHAR_POSIX_PRINT : UProperty = 47;
73-
const UCHAR_POSIX_XDIGIT : UProperty = 48;
74-
const UCHAR_CASED : UProperty = 49;
75-
const UCHAR_CASE_IGNORABLE : UProperty = 50;
76-
77-
const UCHAR_CHANGES_WHEN_LOWERCASED : UProperty = 51;
78-
const UCHAR_CHANGES_WHEN_UPPERCASED : UProperty = 52;
79-
const UCHAR_CHANGES_WHEN_TITLECASED : UProperty = 53;
80-
const UCHAR_CHANGES_WHEN_CASEFOLDED : UProperty = 54;
81-
82-
const UCHAR_CHANGES_WHEN_CASEMAPPED : UProperty = 55;
83-
const UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED : UProperty = 56;
84-
const UCHAR_BINARY_LIMIT : UProperty = 57;
85-
const UCHAR_BIDI_CLASS : UProperty = 0x1000;
86-
87-
const UCHAR_INT_START : UProperty = 0x1000; // UCHAR_BIDI_CLASS
88-
const UCHAR_BLOCK : UProperty = 0x1001;
89-
const UCHAR_CANONICAL_COMBINING_CLASS : UProperty = 0x1002;
90-
const UCHAR_DECOMPOSITION_TYPE : UProperty = 0x1003;
91-
92-
const UCHAR_EAST_ASIAN_WIDTH : UProperty = 0x1004;
93-
const UCHAR_GENERAL_CATEGORY : UProperty = 0x1005;
94-
const UCHAR_JOINING_GROUP : UProperty = 0x1006;
95-
const UCHAR_JOINING_TYPE : UProperty = 0x1007;
96-
97-
const UCHAR_LINE_BREAK : UProperty = 0x1008;
98-
const UCHAR_NUMERIC_TYPE : UProperty = 0x1009;
99-
const UCHAR_SCRIPT : UProperty = 0x100A;
100-
const UCHAR_HANGUL_SYLLABLE_TYPE : UProperty = 0x100B;
101-
102-
const UCHAR_NFD_QUICK_CHECK : UProperty = 0x100C;
103-
const UCHAR_NFKD_QUICK_CHECK : UProperty = 0x100D;
104-
const UCHAR_NFC_QUICK_CHECK : UProperty = 0x100E;
105-
const UCHAR_NFKC_QUICK_CHECK : UProperty = 0x100F;
106-
107-
const UCHAR_LEAD_CANONICAL_COMBINING_CLASS : UProperty = 0x1010;
108-
const UCHAR_TRAIL_CANONICAL_COMBINING_CLASS : UProperty = 0x1011;
109-
const UCHAR_GRAPHEME_CLUSTER_BREAK : UProperty = 0x1012;
110-
const UCHAR_SENTENCE_BREAK : UProperty = 0x1013;
111-
112-
const UCHAR_WORD_BREAK : UProperty = 0x1014;
113-
const UCHAR_INT_LIMIT : UProperty = 0x1015;
114-
115-
const UCHAR_GENERAL_CATEGORY_MASK : UProperty = 0x2000;
116-
const UCHAR_MASK_START : UProperty = 0x2000;
3+
pub mod icu {
4+
pub type UBool = u8;
5+
pub type UProperty = int;
6+
pub type UChar32 = char;
7+
8+
pub const TRUE : u8 = 1u8;
9+
pub const FALSE : u8 = 1u8;
10+
11+
pub const UCHAR_ALPHABETIC : UProperty = 0;
12+
pub const UCHAR_BINARY_START : UProperty = 0; // = UCHAR_ALPHABETIC
13+
pub const UCHAR_ASCII_HEX_DIGIT : UProperty = 1;
14+
pub const UCHAR_BIDI_CONTROL : UProperty = 2;
15+
16+
pub const UCHAR_BIDI_MIRRORED : UProperty = 3;
17+
pub const UCHAR_DASH : UProperty = 4;
18+
pub const UCHAR_DEFAULT_IGNORABLE_CODE_POINT : UProperty = 5;
19+
pub const UCHAR_DEPRECATED : UProperty = 6;
20+
21+
pub const UCHAR_DIACRITIC : UProperty = 7;
22+
pub const UCHAR_EXTENDER : UProperty = 8;
23+
pub const UCHAR_FULL_COMPOSITION_EXCLUSION : UProperty = 9;
24+
pub const UCHAR_GRAPHEME_BASE : UProperty = 10;
25+
26+
pub const UCHAR_GRAPHEME_EXTEND : UProperty = 11;
27+
pub const UCHAR_GRAPHEME_LINK : UProperty = 12;
28+
pub const UCHAR_HEX_DIGIT : UProperty = 13;
29+
pub const UCHAR_HYPHEN : UProperty = 14;
30+
31+
pub const UCHAR_ID_CONTINUE : UProperty = 15;
32+
pub const UCHAR_ID_START : UProperty = 16;
33+
pub const UCHAR_IDEOGRAPHIC : UProperty = 17;
34+
pub const UCHAR_IDS_BINARY_OPERATOR : UProperty = 18;
35+
36+
pub const UCHAR_IDS_TRINARY_OPERATOR : UProperty = 19;
37+
pub const UCHAR_JOIN_CONTROL : UProperty = 20;
38+
pub const UCHAR_LOGICAL_ORDER_EXCEPTION : UProperty = 21;
39+
pub const UCHAR_LOWERCASE : UProperty = 22;
40+
41+
pub const UCHAR_MATH : UProperty = 23;
42+
pub const UCHAR_NONCHARACTER_CODE_POINT : UProperty = 24;
43+
pub const UCHAR_QUOTATION_MARK : UProperty = 25;
44+
pub const UCHAR_RADICAL : UProperty = 26;
45+
46+
pub const UCHAR_SOFT_DOTTED : UProperty = 27;
47+
pub const UCHAR_TERMINAL_PUNCTUATION : UProperty = 28;
48+
pub const UCHAR_UNIFIED_IDEOGRAPH : UProperty = 29;
49+
pub const UCHAR_UPPERCASE : UProperty = 30;
50+
51+
pub const UCHAR_WHITE_SPACE : UProperty = 31;
52+
pub const UCHAR_XID_CONTINUE : UProperty = 32;
53+
pub const UCHAR_XID_START : UProperty = 33;
54+
pub const UCHAR_CASE_SENSITIVE : UProperty = 34;
55+
56+
pub const UCHAR_S_TERM : UProperty = 35;
57+
pub const UCHAR_VARIATION_SELECTOR : UProperty = 36;
58+
pub const UCHAR_NFD_INERT : UProperty = 37;
59+
pub const UCHAR_NFKD_INERT : UProperty = 38;
60+
61+
pub const UCHAR_NFC_INERT : UProperty = 39;
62+
pub const UCHAR_NFKC_INERT : UProperty = 40;
63+
pub const UCHAR_SEGMENT_STARTER : UProperty = 41;
64+
pub const UCHAR_PATTERN_SYNTAX : UProperty = 42;
65+
66+
pub const UCHAR_PATTERN_WHITE_SPACE : UProperty = 43;
67+
pub const UCHAR_POSIX_ALNUM : UProperty = 44;
68+
pub const UCHAR_POSIX_BLANK : UProperty = 45;
69+
pub const UCHAR_POSIX_GRAPH : UProperty = 46;
70+
71+
pub const UCHAR_POSIX_PRINT : UProperty = 47;
72+
pub const UCHAR_POSIX_XDIGIT : UProperty = 48;
73+
pub const UCHAR_CASED : UProperty = 49;
74+
pub const UCHAR_CASE_IGNORABLE : UProperty = 50;
75+
76+
pub const UCHAR_CHANGES_WHEN_LOWERCASED : UProperty = 51;
77+
pub const UCHAR_CHANGES_WHEN_UPPERCASED : UProperty = 52;
78+
pub const UCHAR_CHANGES_WHEN_TITLECASED : UProperty = 53;
79+
pub const UCHAR_CHANGES_WHEN_CASEFOLDED : UProperty = 54;
80+
81+
pub const UCHAR_CHANGES_WHEN_CASEMAPPED : UProperty = 55;
82+
pub const UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED : UProperty = 56;
83+
pub const UCHAR_BINARY_LIMIT : UProperty = 57;
84+
pub const UCHAR_BIDI_CLASS : UProperty = 0x1000;
85+
86+
pub const UCHAR_INT_START : UProperty = 0x1000; // UCHAR_BIDI_CLASS
87+
pub const UCHAR_BLOCK : UProperty = 0x1001;
88+
pub const UCHAR_CANONICAL_COMBINING_CLASS : UProperty = 0x1002;
89+
pub const UCHAR_DECOMPOSITION_TYPE : UProperty = 0x1003;
90+
91+
pub const UCHAR_EAST_ASIAN_WIDTH : UProperty = 0x1004;
92+
pub const UCHAR_GENERAL_CATEGORY : UProperty = 0x1005;
93+
pub const UCHAR_JOINING_GROUP : UProperty = 0x1006;
94+
pub const UCHAR_JOINING_TYPE : UProperty = 0x1007;
95+
96+
pub const UCHAR_LINE_BREAK : UProperty = 0x1008;
97+
pub const UCHAR_NUMERIC_TYPE : UProperty = 0x1009;
98+
pub const UCHAR_SCRIPT : UProperty = 0x100A;
99+
pub const UCHAR_HANGUL_SYLLABLE_TYPE : UProperty = 0x100B;
100+
101+
pub const UCHAR_NFD_QUICK_CHECK : UProperty = 0x100C;
102+
pub const UCHAR_NFKD_QUICK_CHECK : UProperty = 0x100D;
103+
pub const UCHAR_NFC_QUICK_CHECK : UProperty = 0x100E;
104+
pub const UCHAR_NFKC_QUICK_CHECK : UProperty = 0x100F;
105+
106+
pub const UCHAR_LEAD_CANONICAL_COMBINING_CLASS : UProperty = 0x1010;
107+
pub const UCHAR_TRAIL_CANONICAL_COMBINING_CLASS : UProperty = 0x1011;
108+
pub const UCHAR_GRAPHEME_CLUSTER_BREAK : UProperty = 0x1012;
109+
pub const UCHAR_SENTENCE_BREAK : UProperty = 0x1013;
110+
111+
pub const UCHAR_WORD_BREAK : UProperty = 0x1014;
112+
pub const UCHAR_INT_LIMIT : UProperty = 0x1015;
113+
114+
pub const UCHAR_GENERAL_CATEGORY_MASK : UProperty = 0x2000;
115+
pub const UCHAR_MASK_START : UProperty = 0x2000;
117116
// = UCHAR_GENERAL_CATEGORY_MASK
118-
const UCHAR_MASK_LIMIT : UProperty = 0x2001;
117+
pub const UCHAR_MASK_LIMIT : UProperty = 0x2001;
119118

120-
const UCHAR_NUMERIC_VALUE : UProperty = 0x3000;
121-
const UCHAR_DOUBLE_START : UProperty = 0x3000;
119+
pub const UCHAR_NUMERIC_VALUE : UProperty = 0x3000;
120+
pub const UCHAR_DOUBLE_START : UProperty = 0x3000;
122121
// = UCHAR_NUMERIC_VALUE
123-
const UCHAR_DOUBLE_LIMIT : UProperty = 0x3001;
122+
pub const UCHAR_DOUBLE_LIMIT : UProperty = 0x3001;
124123

125-
const UCHAR_AGE : UProperty = 0x4000;
126-
const UCHAR_STRING_START : UProperty = 0x4000; // = UCHAR_AGE
127-
const UCHAR_BIDI_MIRRORING_GLYPH : UProperty = 0x4001;
128-
const UCHAR_CASE_FOLDING : UProperty = 0x4002;
124+
pub const UCHAR_AGE : UProperty = 0x4000;
125+
pub const UCHAR_STRING_START : UProperty = 0x4000; // = UCHAR_AGE
126+
pub const UCHAR_BIDI_MIRRORING_GLYPH : UProperty = 0x4001;
127+
pub const UCHAR_CASE_FOLDING : UProperty = 0x4002;
129128

130-
const UCHAR_ISO_COMMENT : UProperty = 0x4003;
131-
const UCHAR_LOWERCASE_MAPPING : UProperty = 0x4004;
132-
const UCHAR_NAME : UProperty = 0x4005;
133-
const UCHAR_SIMPLE_CASE_FOLDING : UProperty = 0x4006;
129+
pub const UCHAR_ISO_COMMENT : UProperty = 0x4003;
130+
pub const UCHAR_LOWERCASE_MAPPING : UProperty = 0x4004;
131+
pub const UCHAR_NAME : UProperty = 0x4005;
132+
pub const UCHAR_SIMPLE_CASE_FOLDING : UProperty = 0x4006;
134133

135-
const UCHAR_SIMPLE_LOWERCASE_MAPPING : UProperty = 0x4007;
136-
const UCHAR_SIMPLE_TITLECASE_MAPPING : UProperty = 0x4008;
137-
const UCHAR_SIMPLE_UPPERCASE_MAPPING : UProperty = 0x4009;
138-
const UCHAR_TITLECASE_MAPPING : UProperty = 0x400A;
134+
pub const UCHAR_SIMPLE_LOWERCASE_MAPPING : UProperty = 0x4007;
135+
pub const UCHAR_SIMPLE_TITLECASE_MAPPING : UProperty = 0x4008;
136+
pub const UCHAR_SIMPLE_UPPERCASE_MAPPING : UProperty = 0x4009;
137+
pub const UCHAR_TITLECASE_MAPPING : UProperty = 0x400A;
139138

140-
const UCHAR_UNICODE_1_NAME : UProperty = 0x400B;
141-
const UCHAR_UPPERCASE_MAPPING : UProperty = 0x400C;
142-
const UCHAR_STRING_LIMIT : UProperty = 0x400D;
139+
pub const UCHAR_UNICODE_1_NAME : UProperty = 0x400B;
140+
pub const UCHAR_UPPERCASE_MAPPING : UProperty = 0x400C;
141+
pub const UCHAR_STRING_LIMIT : UProperty = 0x400D;
143142

144-
const UCHAR_SCRIPT_EXTENSIONS : UProperty = 0x7000;
145-
const UCHAR_OTHER_PROPERTY_START : UProperty = 0x7000;
143+
pub const UCHAR_SCRIPT_EXTENSIONS : UProperty = 0x7000;
144+
pub const UCHAR_OTHER_PROPERTY_START : UProperty = 0x7000;
146145
// = UCHAR_SCRIPT_EXTENSIONS;
147-
const UCHAR_OTHER_PROPERTY_LIMIT : UProperty = 0x7001;
146+
pub const UCHAR_OTHER_PROPERTY_LIMIT : UProperty = 0x7001;
148147

149-
const UCHAR_INVALID_CODE : UProperty = -1;
148+
pub const UCHAR_INVALID_CODE : UProperty = -1;
150149

151150
#[link_name = "icuuc"]
152151
#[abi = "cdecl"]
153-
extern mod libicu {
154-
#[legacy_exports];
152+
pub extern mod libicu {
155153
pure fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
156154
pure fn u_isdigit(c: UChar32) -> UBool;
157155
pure fn u_islower(c: UChar32) -> UBool;
@@ -162,12 +160,12 @@ mod icu {
162160
}
163161
}
164162

165-
pure fn is_XID_start(c: char) -> bool {
163+
pub pure fn is_XID_start(c: char) -> bool {
166164
return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START)
167165
== icu::TRUE;
168166
}
169167

170-
pure fn is_XID_continue(c: char) -> bool {
168+
pub pure fn is_XID_continue(c: char) -> bool {
171169
return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START)
172170
== icu::TRUE;
173171
}
@@ -177,7 +175,7 @@ Function: is_digit
177175
178176
Returns true if a character is a digit.
179177
*/
180-
pure fn is_digit(c: char) -> bool {
178+
pub pure fn is_digit(c: char) -> bool {
181179
return icu::libicu::u_isdigit(c) == icu::TRUE;
182180
}
183181

@@ -186,7 +184,7 @@ Function: is_lower
186184
187185
Returns true if a character is a lowercase letter.
188186
*/
189-
pure fn is_lower(c: char) -> bool {
187+
pub pure fn is_lower(c: char) -> bool {
190188
return icu::libicu::u_islower(c) == icu::TRUE;
191189
}
192190

@@ -195,7 +193,7 @@ Function: is_space
195193
196194
Returns true if a character is space.
197195
*/
198-
pure fn is_space(c: char) -> bool {
196+
pub pure fn is_space(c: char) -> bool {
199197
return icu::libicu::u_isspace(c) == icu::TRUE;
200198
}
201199

@@ -204,13 +202,12 @@ Function: is_upper
204202
205203
Returns true if a character is an uppercase letter.
206204
*/
207-
pure fn is_upper(c: char) -> bool {
205+
pub pure fn is_upper(c: char) -> bool {
208206
return icu::libicu::u_isupper(c) == icu::TRUE;
209207
}
210208

211209
#[cfg(test)]
212210
mod tests {
213-
#[legacy_exports];
214211

215212
#[test]
216213
fn test_is_digit() {

0 commit comments

Comments
 (0)