diff options
| author | bors <bors@rust-lang.org> | 2019-12-01 00:39:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-01 00:39:18 +0000 |
| commit | 135ccbaca86ed4b9c0efaf0cd31442eae57ffad7 (patch) | |
| tree | f5d91a593d425871fff9e1b68ac2e9f982d6c8e1 /src/libcore/unicode/unicode.py | |
| parent | d8bdb3fdcbd88eb16e1a6669236122c41ed2aed3 (diff) | |
| parent | b772b5b19d769e7062b032e6e73f6466b26d78bd (diff) | |
| download | rust-135ccbaca86ed4b9c0efaf0cd31442eae57ffad7.tar.gz rust-135ccbaca86ed4b9c0efaf0cd31442eae57ffad7.zip | |
Auto merge of #66908 - Centril:rollup-26givp6, r=Centril
Rollup of 9 pull requests Successful merges: - #66612 (Initial implementation of or-pattern usefulness checking) - #66705 (Atomic as_mut_ptr) - #66759 (impl TrustedLen for vec::Drain) - #66858 (Use LLVMAddAnalysisPasses instead of Rust's wrapper) - #66870 (SimplifyArmIdentity only for locals with the same type) - #66883 (rustc_typeck: gate AnonConst's generics on feature(const_generics).) - #66889 (Make python-generated source files compatible with rustfmt) - #66894 (Remove unneeded prelude imports in libcore tests) - #66895 (Feature gating *declarations* => new crate `rustc_feature`) Failed merges: - #66905 (rustc_plugin: Remove some remaining plugin features) r? @ghost
Diffstat (limited to 'src/libcore/unicode/unicode.py')
| -rwxr-xr-x | src/libcore/unicode/unicode.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/libcore/unicode/unicode.py b/src/libcore/unicode/unicode.py index 89894f7932d..97df92a56da 100755 --- a/src/libcore/unicode/unicode.py +++ b/src/libcore/unicode/unicode.py @@ -81,8 +81,8 @@ PREAMBLE = """\ #![allow(missing_docs, non_upper_case_globals, non_snake_case, clippy::unreadable_literal)] -use crate::unicode::version::UnicodeVersion; use crate::unicode::bool_trie::{{BoolTrie, SmallBoolTrie}}; +use crate::unicode::version::UnicodeVersion; """.format(year=datetime.datetime.now().year) # Mapping taken from Table 12 from: @@ -555,6 +555,8 @@ def generate_table( if is_pub: pub_string = "pub " + yield "\n" + yield " #[rustfmt::skip]\n" yield " %sconst %s: %s = &[\n" % (pub_string, name, decl_type) data = [] @@ -568,7 +570,7 @@ def generate_table( for table_line in generate_table_lines("".join(data).split(","), 8): yield table_line - yield "\n ];\n\n" + yield "\n ];\n" def compute_trie(raw_data, chunk_size): @@ -634,6 +636,9 @@ def generate_bool_trie(name, codepoint_ranges, is_pub=False): pub_string = "" if is_pub: pub_string = "pub " + + yield "\n" + yield " #[rustfmt::skip]\n" yield " %sconst %s: &super::BoolTrie = &super::BoolTrie {\n" % (pub_string, name) yield " r1: [\n" data = ("0x%016x" % chunk for chunk in chunks[:0x800 // chunk_size]) @@ -678,7 +683,7 @@ def generate_bool_trie(name, codepoint_ranges, is_pub=False): yield fragment yield "\n ],\n" - yield " };\n\n" + yield " };\n" def generate_small_bool_trie(name, codepoint_ranges, is_pub=False): @@ -700,6 +705,8 @@ def generate_small_bool_trie(name, codepoint_ranges, is_pub=False): if is_pub: pub_string = "pub " + yield "\n" + yield " #[rustfmt::skip]\n" yield (" %sconst %s: &super::SmallBoolTrie = &super::SmallBoolTrie {\n" % (pub_string, name)) @@ -717,7 +724,7 @@ def generate_small_bool_trie(name, codepoint_ranges, is_pub=False): yield fragment yield "\n ],\n" - yield " };\n\n" + yield " };\n" def generate_property_module(mod, grouped_categories, category_subset): @@ -726,7 +733,7 @@ def generate_property_module(mod, grouped_categories, category_subset): Generate Rust code for module defining properties. """ - yield "pub(crate) mod %s {\n" % mod + yield "pub(crate) mod %s {" % mod for cat in sorted(category_subset): if cat in ("Cc", "White_Space"): generator = generate_small_bool_trie("%s_table" % cat, grouped_categories[cat]) @@ -736,9 +743,10 @@ def generate_property_module(mod, grouped_categories, category_subset): for fragment in generator: yield fragment + yield "\n" yield " pub fn %s(c: char) -> bool {\n" % cat yield " %s_table.lookup(c)\n" % cat - yield " }\n\n" + yield " }\n" yield "}\n\n" @@ -753,21 +761,21 @@ def generate_conversions_module(unicode_data): yield """ pub fn to_lower(c: char) -> [char; 3] { match bsearch_case_table(c, to_lowercase_table) { - None => [c, '\\0', '\\0'], + None => [c, '\\0', '\\0'], Some(index) => to_lowercase_table[index].1, } } pub fn to_upper(c: char) -> [char; 3] { match bsearch_case_table(c, to_uppercase_table) { - None => [c, '\\0', '\\0'], + None => [c, '\\0', '\\0'], Some(index) => to_uppercase_table[index].1, } } fn bsearch_case_table(c: char, table: &[(char, [char; 3])]) -> Option<usize> { table.binary_search_by(|&(key, _)| key.cmp(&c)).ok() - }\n\n""" + }\n""" decl_type = "&[(char, [char; 3])]" format_conversion = lambda x: "({},[{},{},{}])".format(*( @@ -827,13 +835,9 @@ def main(): /// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of /// `char` and `str` methods are based on. #[unstable(feature = "unicode_version", issue = "49726")] - pub const UNICODE_VERSION: UnicodeVersion = UnicodeVersion {{ - major: {version.major}, - minor: {version.minor}, - micro: {version.micro}, - _priv: (), - }}; - """).format(version=unicode_version) + pub const UNICODE_VERSION: UnicodeVersion = + UnicodeVersion {{ major: {v.major}, minor: {v.minor}, micro: {v.micro}, _priv: () }}; + """).format(v=unicode_version) buf.write(unicode_version_notice) get_path = lambda f: get_unicode_file_path(unicode_version, f) |
