diff options
author | Joel Galenson <jgalenson@google.com> | 2021-10-12 15:49:59 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-12 15:49:59 +0000 |
commit | b8046b511ea4f26fdf204769540d40e1e326cda9 (patch) | |
tree | 63531f0d324940802cc647f6fee983b0ae77096b | |
parent | 4bf336ce60720c03ab425d1729f268b1fd60bd67 (diff) | |
parent | 6f824469adde1ebaedc2937fd4c55722d39437a4 (diff) | |
download | unicode-bidi-b8046b511ea4f26fdf204769540d40e1e326cda9.tar.gz |
Merge "Upgrade rust/crates/unicode-bidi to 0.3.6" am: acd4023a46 am: ba1c2fd608 am: ba2216899e am: 6f824469ad
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/unicode-bidi/+/1833388
Change-Id: Id845547b807d028aefdf7862147c6967a62fffad
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 27 | ||||
-rw-r--r-- | Cargo.toml | 10 | ||||
-rw-r--r-- | Cargo.toml.orig | 15 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | src/char_data/mod.rs | 4 | ||||
-rw-r--r-- | src/deprecated.rs | 2 | ||||
-rw-r--r-- | src/explicit.rs | 7 | ||||
-rw-r--r-- | src/implicit.rs | 9 | ||||
-rw-r--r-- | src/level.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 24 | ||||
-rw-r--r-- | src/prepare.rs | 15 |
12 files changed, 82 insertions, 45 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 3daa8eb..54bfe61 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "1fd2a2d8dd267f857ef18f29c8945b76c42ee19e" + "sha1": "2c89f8f02566cfaeb1266706b259c6c7c3aae8dd" } } @@ -42,11 +42,13 @@ rust_library { name: "libunicode_bidi", host_supported: true, crate_name: "unicode_bidi", + cargo_env_compat: true, + cargo_pkg_version: "0.3.6", srcs: ["src/lib.rs"], edition: "2018", - features: ["default"], - rustlibs: [ - "libmatches", + features: [ + "default", + "std", ], apex_available: [ "//apex_available:platform", @@ -56,22 +58,26 @@ rust_library { } rust_defaults { - name: "unicode-bidi_defaults", + name: "unicode-bidi_test_defaults", crate_name: "unicode_bidi", srcs: ["src/lib.rs"], + cargo_env_compat: true, + cargo_pkg_version: "0.3.6", test_suites: ["general-tests"], auto_gen_config: true, edition: "2018", - features: ["default"], + features: [ + "default", + "std", + ], rustlibs: [ - "libmatches", "libserde_test", ], } rust_test_host { name: "unicode-bidi_host_test_src_lib", - defaults: ["unicode-bidi_defaults"], + defaults: ["unicode-bidi_test_defaults"], test_options: { unit_test: true, }, @@ -79,10 +85,5 @@ rust_test_host { rust_test { name: "unicode-bidi_device_test_src_lib", - defaults: ["unicode-bidi_defaults"], + defaults: ["unicode-bidi_test_defaults"], } - -// dependent_library ["feature_list"] -// matches-0.1.8 -// serde-1.0.126 "default,std" -// serde_test-1.0.126 @@ -13,13 +13,14 @@ [package] edition = "2018" name = "unicode-bidi" -version = "0.3.5" +version = "0.3.6" authors = ["The Servo Project Developers"] exclude = ["benches/**", "data/**", "examples/**", "tests/**", "tools/**"] description = "Implementation of the Unicode Bidirectional Algorithm" documentation = "https://docs.rs/unicode-bidi/" readme = "README.md" keywords = ["rtl", "unicode", "text", "layout", "bidi"] +categories = ["no-std", "encoding", "text-processing"] license = "MIT / Apache-2.0" repository = "https://github.com/servo/unicode-bidi" @@ -33,20 +34,19 @@ optional = true version = "0.4" optional = true -[dependencies.matches] -version = "0.1" - [dependencies.serde] version = ">=0.8, <2.0" features = ["derive"] optional = true +default-features = false [dev-dependencies.serde_test] version = ">=0.8, <2.0" [features] bench_it = [] -default = [] +default = ["std"] flame_it = ["flame", "flamer"] +std = [] unstable = [] with_serde = ["serde"] [badges.appveyor] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 650aa3e..912ded6 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "unicode-bidi" -version = "0.3.5" +version = "0.3.6" authors = ["The Servo Project Developers"] license = "MIT / Apache-2.0" description = "Implementation of the Unicode Bidirectional Algorithm" @@ -9,6 +9,11 @@ documentation = "https://docs.rs/unicode-bidi/" keywords = ["rtl", "unicode", "text", "layout", "bidi"] readme="README.md" edition = "2018" +categories = [ + "no-std", + "encoding", + "text-processing", +] # No data is shipped; benches, examples and tests also depend on data. exclude = [ @@ -29,14 +34,16 @@ name = "unicode_bidi" [dependencies] flame = { version = "0.2", optional = true } flamer = { version = "0.4", optional = true } -matches = "0.1" -serde = { version = ">=0.8, <2.0", optional = true, features = ["derive"] } +serde = { version = ">=0.8, <2.0", default-features = false, optional = true, features = ["derive"] } [dev-dependencies] serde_test = ">=0.8, <2.0" [features] -default = [] +# Note: We don't actually use the `std` feature for anything other than making +# doctests work. But it may come in handy in the future. +default = ["std"] +std = [] unstable = [] # travis-cargo needs it bench_it = [] flame_it = ["flame", "flamer"] @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.5.crate" + value: "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.6.crate" } - version: "0.3.5" + version: "0.3.6" license_type: NOTICE last_upgrade_date { year: 2021 - month: 5 - day: 19 + month: 9 + day: 22 } } diff --git a/src/char_data/mod.rs b/src/char_data/mod.rs index da85c84..c91bfad 100644 --- a/src/char_data/mod.rs +++ b/src/char_data/mod.rs @@ -13,8 +13,8 @@ mod tables; pub use self::tables::{BidiClass, UNICODE_VERSION}; -use std::cmp::Ordering::{Equal, Less, Greater}; -use std::char; +use core::cmp::Ordering::{Equal, Less, Greater}; +use core::char; use self::tables::bidi_class_table; use crate::BidiClass::*; diff --git a/src/deprecated.rs b/src/deprecated.rs index 8bd206b..491436a 100644 --- a/src/deprecated.rs +++ b/src/deprecated.rs @@ -9,6 +9,8 @@ //! This module holds deprecated assets only. +use alloc::vec::Vec; + use super::*; /// Find the level runs within a line and return them in visual order. diff --git a/src/explicit.rs b/src/explicit.rs index 95de505..ec39dee 100644 --- a/src/explicit.rs +++ b/src/explicit.rs @@ -11,7 +11,7 @@ //! //! <http://www.unicode.org/reports/tr9/#Explicit_Levels_and_Directions> -use matches::matches; +use alloc::vec::Vec; use super::char_data::{BidiClass::{self, *}, is_rtl}; use super::level::Level; @@ -46,7 +46,10 @@ pub fn compute( let last_level = stack.last().level; // X5a-X5c: Isolate initiators get the level of the last entry on the stack. - let is_isolate = matches!(original_classes[i], RLI | LRI | FSI); + let is_isolate = match original_classes[i] { + RLI | LRI | FSI => true, + _ => false, + }; if is_isolate { levels[i] = last_level; match stack.last().status { diff --git a/src/implicit.rs b/src/implicit.rs index 7e43294..2bb3581 100644 --- a/src/implicit.rs +++ b/src/implicit.rs @@ -9,8 +9,8 @@ //! 3.3.4 - 3.3.6. Resolve implicit levels and types. -use std::cmp::max; -use matches::matches; +use core::cmp::max; +use alloc::vec::Vec; use super::char_data::BidiClass::{self, *}; use super::prepare::{IsolatingRunSequence, LevelRun, not_removed_by_x9, removed_by_x9}; @@ -223,5 +223,8 @@ pub fn resolve_levels(original_classes: &[BidiClass], levels: &mut [Level]) -> L /// <http://www.unicode.org/reports/tr9/#NI> #[allow(non_snake_case)] fn is_NI(class: BidiClass) -> bool { - matches!(class, B | S | WS | ON | FSI | LRI | RLI | PDI) + match class { + B | S | WS | ON | FSI | LRI | RLI | PDI => true, + _ => false, + } } diff --git a/src/level.rs b/src/level.rs index bc74205..c1adf1f 100644 --- a/src/level.rs +++ b/src/level.rs @@ -13,7 +13,9 @@ //! //! <http://www.unicode.org/reports/tr9/#BD2> -use std::convert::{From, Into}; +use alloc::vec::Vec; +use core::convert::{From, Into}; +use alloc::string::{String, ToString}; use super::char_data::BidiClass; @@ -53,10 +53,24 @@ //! ]); //! ``` //! +//! # Features +//! +//! - `std`: Enabled by default, but can be disabled to make `unicode_bidi` +//! `#![no_std]` + `alloc` compatible. +//! - `serde`: Adds [`serde::Serialize`] and [`serde::Deserialize`] +//! implementations to relevant types. +//! //! [tr9]: <http://www.unicode.org/reports/tr9/> #![forbid(unsafe_code)] +#![no_std] +// We need to link to std to make doc tests work on older Rust versions +#![cfg(feature = "std")] +extern crate std; +#[macro_use] +extern crate alloc; + pub mod deprecated; pub mod format_chars; pub mod level; @@ -70,10 +84,12 @@ pub use crate::char_data::{BidiClass, bidi_class, UNICODE_VERSION}; pub use crate::level::{Level, LTR_LEVEL, RTL_LEVEL}; pub use crate::prepare::LevelRun; -use std::borrow::Cow; -use std::cmp::{max, min}; -use std::iter::repeat; -use std::ops::Range; +use alloc::borrow::Cow; +use alloc::vec::Vec; +use alloc::string::String; +use core::cmp::{max, min}; +use core::iter::repeat; +use core::ops::Range; use crate::BidiClass::*; use crate::format_chars as chars; diff --git a/src/prepare.rs b/src/prepare.rs index ccb8c0f..752087b 100644 --- a/src/prepare.rs +++ b/src/prepare.rs @@ -11,9 +11,9 @@ //! //! <http://www.unicode.org/reports/tr9/#Preparations_for_Implicit_Processing> -use std::cmp::max; -use std::ops::Range; -use matches::matches; +use core::cmp::max; +use core::ops::Range; +use alloc::vec::Vec; use super::BidiClass::{self, *}; use super::level::Level; @@ -73,7 +73,7 @@ pub fn isolating_run_sequences( sequence.push(run); - if matches!(end_class, RLI | LRI | FSI) { + if let RLI | LRI | FSI = end_class { // Resume this sequence after the isolate. stack.push(sequence); } else { @@ -113,7 +113,7 @@ pub fn isolating_run_sequences( }; // Get the level of the next non-removed char after the runs. - let succ_level = if matches!(original_classes[end_of_seq - 1], RLI | LRI | FSI) { + let succ_level = if let RLI | LRI | FSI = original_classes[end_of_seq - 1] { para_level } else { match original_classes[end_of_seq..].iter().position( @@ -163,7 +163,10 @@ fn level_runs(levels: &[Level], original_classes: &[BidiClass]) -> Vec<LevelRun> /// /// <http://www.unicode.org/reports/tr9/#X9> pub fn removed_by_x9(class: BidiClass) -> bool { - matches!(class, RLE | LRE | RLO | LRO | PDF | BN) + match class { + RLE | LRE | RLO | LRO | PDF | BN => true, + _ => false, + } } // For use as a predicate for `position` / `rposition` |