Upgrade rust/crates/unicode-bidi to 0.3.5 am: c62c1264e5

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/unicode-bidi/+/1713388

Change-Id: I6786e3b740c0db9a5bbafa75eebf4a294746a26a
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
new file mode 100644
index 0000000..3daa8eb
--- /dev/null
+++ b/.cargo_vcs_info.json
@@ -0,0 +1,5 @@
+{
+  "git": {
+    "sha1": "1fd2a2d8dd267f857ef18f29c8945b76c42ee19e"
+  }
+}
diff --git a/.travis.yml b/.travis.yml
index 76a90be..7949019 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,7 @@
   - nightly
   - beta
   - stable
-  - 1.17.0
+  - 1.31.0
 
 matrix:
   fast_finish: true
@@ -15,7 +15,6 @@
     - rust: nightly
 
 notifications:
-  webhooks: http://build.servo.org:54856/travis
   email:
     on_success: never
 
diff --git a/Android.bp b/Android.bp
index 135442f..0894381 100644
--- a/Android.bp
+++ b/Android.bp
@@ -40,11 +40,10 @@
 
 rust_library {
     name: "libunicode_bidi",
-    // has rustc warnings
     host_supported: true,
     crate_name: "unicode_bidi",
     srcs: ["src/lib.rs"],
-    edition: "2015",
+    edition: "2018",
     features: ["default"],
     rustlibs: [
         "libmatches",
@@ -59,11 +58,10 @@
 rust_defaults {
     name: "unicode-bidi_defaults",
     crate_name: "unicode_bidi",
-    // has rustc warnings
     srcs: ["src/lib.rs"],
     test_suites: ["general-tests"],
     auto_gen_config: true,
-    edition: "2015",
+    edition: "2018",
     features: ["default"],
     rustlibs: [
         "libmatches",
@@ -86,5 +84,5 @@
 
 // dependent_library ["feature_list"]
 //   matches-0.1.8
-//   serde-1.0.125 "default,std"
-//   serde_test-1.0.125
+//   serde-1.0.126 "default,std"
+//   serde_test-1.0.126
diff --git a/Cargo.toml b/Cargo.toml
index f12ebcd..9ad832a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@
 # When uploading crates to the registry Cargo will automatically
 # "normalize" Cargo.toml files for maximal compatibility
 # with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g. crates.io) dependencies
+# to registry (e.g., crates.io) dependencies
 #
 # If you believe there's an error in this file please file an
 # issue against the rust-lang/cargo repository. If you're
@@ -11,12 +11,14 @@
 # will likely look very different (and much more reasonable)
 
 [package]
+edition = "2018"
 name = "unicode-bidi"
-version = "0.3.4"
+version = "0.3.5"
 authors = ["The Servo Project Developers"]
 exclude = ["benches/**", "data/**", "examples/**", "tests/**", "tools/**"]
 description = "Implementation of the Unicode Bidirectional Algorithm"
-documentation = "http://doc.servo.org/unicode_bidi/"
+documentation = "https://docs.rs/unicode-bidi/"
+readme = "README.md"
 keywords = ["rtl", "unicode", "text", "layout", "bidi"]
 license = "MIT / Apache-2.0"
 repository = "https://github.com/servo/unicode-bidi"
@@ -24,26 +26,31 @@
 [lib]
 name = "unicode_bidi"
 [dependencies.flame]
-version = "0.1"
+version = "0.2"
 optional = true
 
 [dependencies.flamer]
-version = "0.1"
+version = "0.4"
 optional = true
 
+[dependencies.matches]
+version = "0.1"
+
 [dependencies.serde]
 version = ">=0.8, <2.0"
 features = ["derive"]
 optional = true
-
-[dependencies.matches]
-version = "0.1"
 [dev-dependencies.serde_test]
 version = ">=0.8, <2.0"
 
 [features]
-with_serde = ["serde"]
+bench_it = []
+default = []
 flame_it = ["flame", "flamer"]
 unstable = []
-default = []
-bench_it = []
+with_serde = ["serde"]
+[badges.appveyor]
+repository = "servo/unicode-bidi"
+
+[badges.travis-ci]
+repository = "servo/unicode-bidi"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index abfcaac..650aa3e 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,12 +1,14 @@
 [package]
 name = "unicode-bidi"
-version = "0.3.4"
+version = "0.3.5"
 authors = ["The Servo Project Developers"]
 license = "MIT / Apache-2.0"
 description = "Implementation of the Unicode Bidirectional Algorithm"
 repository = "https://github.com/servo/unicode-bidi"
-documentation = "http://doc.servo.org/unicode_bidi/"
+documentation = "https://docs.rs/unicode-bidi/"
 keywords = ["rtl", "unicode", "text", "layout", "bidi"]
+readme="README.md"
+edition = "2018"
 
 # No data is shipped; benches, examples and tests also depend on data.
 exclude = [
@@ -17,12 +19,16 @@
     "tools/**",
 ]
 
+[badges]
+travis-ci = { repository = "servo/unicode-bidi" }
+appveyor = { repository = "servo/unicode-bidi" }
+
 [lib]
 name = "unicode_bidi"
 
 [dependencies]
-flame = { version = "0.1", optional = true }
-flamer = { version = "0.1", optional = true }
+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"] }
 
diff --git a/METADATA b/METADATA
index 9db39e1..ea9ca37 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.4.crate"
+    value: "https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.5.crate"
   }
-  version: "0.3.4"
+  version: "0.3.5"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2020
-    month: 12
-    day: 15
+    year: 2021
+    month: 5
+    day: 19
   }
 }
diff --git a/README.md b/README.md
index d2888a1..f409b0a 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 of mixed right-to-left and left-to-right text.  It is written in safe Rust,
 compatible with the current stable release.
 
-[Documentation](http://doc.servo.org/unicode_bidi/)
+[Documentation](https://docs.rs/unicode-bidi/)
 
 [![Travis-CI](https://travis-ci.org/servo/unicode-bidi.svg?branch=master)](https://travis-ci.org/servo/unicode-bidi)
 [![AppVeyor](https://img.shields.io/appveyor/ci/servo/unicode-bidi/master.svg)](https://ci.appveyor.com/project/servo/unicode-bidi)
diff --git a/TEST_MAPPING b/TEST_MAPPING
index d1919fd..4fe6b66 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,8 +1,23 @@
-// Generated by cargo2android.py for tests in Android.bp
+// Generated by update_crate_tests.py for tests that depend on this crate.
 {
   "presubmit": [
     {
+      "name": "doh_unit_test"
+    },
+    {
+      "name": "quiche_device_test_src_lib"
+    },
+    {
       "name": "unicode-bidi_device_test_src_lib"
+    },
+    {
+      "name": "url_device_test_src_lib"
+    },
+    {
+      "name": "url_device_test_tests_data"
+    },
+    {
+      "name": "url_device_test_tests_unit"
     }
   ]
 }
diff --git a/src/char_data/mod.rs b/src/char_data/mod.rs
index 4899a71..da85c84 100644
--- a/src/char_data/mod.rs
+++ b/src/char_data/mod.rs
@@ -17,7 +17,7 @@
 use std::char;
 
 use self::tables::bidi_class_table;
-use BidiClass::*;
+use crate::BidiClass::*;
 
 /// Find the `BidiClass` of a single char.
 pub fn bidi_class(c: char) -> BidiClass {
diff --git a/src/deprecated.rs b/src/deprecated.rs
index 4d4b76e..8bd206b 100644
--- a/src/deprecated.rs
+++ b/src/deprecated.rs
@@ -9,9 +9,6 @@
 
 //! This module holds deprecated assets only.
 
-// Doesn't worth updating API here
-#![cfg_attr(feature="cargo-clippy", allow(needless_pass_by_value))]
-
 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 4f6f22f..95de505 100644
--- a/src/explicit.rs
+++ b/src/explicit.rs
@@ -11,16 +11,16 @@
 //!
 //! <http://www.unicode.org/reports/tr9/#Explicit_Levels_and_Directions>
 
-use super::char_data::{BidiClass, is_rtl};
-use super::level::Level;
+use matches::matches;
 
-use BidiClass::*;
+use super::char_data::{BidiClass::{self, *}, is_rtl};
+use super::level::Level;
 
 /// Compute explicit embedding levels for one paragraph of text (X1-X8).
 ///
 /// `processing_classes[i]` must contain the `BidiClass` of the char at byte index `i`,
 /// for each char in `text`.
-#[cfg_attr(feature = "flame_it", flame)]
+#[cfg_attr(feature = "flame_it", flamer::flame)]
 pub fn compute(
     text: &str,
     para_level: Level,
diff --git a/src/implicit.rs b/src/implicit.rs
index 4344ea3..7e43294 100644
--- a/src/implicit.rs
+++ b/src/implicit.rs
@@ -10,17 +10,16 @@
 //! 3.3.4 - 3.3.6. Resolve implicit levels and types.
 
 use std::cmp::max;
+use matches::matches;
 
-use super::char_data::BidiClass;
+use super::char_data::BidiClass::{self, *};
 use super::prepare::{IsolatingRunSequence, LevelRun, not_removed_by_x9, removed_by_x9};
 use super::level::Level;
 
-use BidiClass::*;
-
 /// 3.3.4 Resolving Weak Types
 ///
 /// <http://www.unicode.org/reports/tr9/#Resolving_Weak_Types>
-#[cfg_attr(feature = "flame_it", flame)]
+#[cfg_attr(feature = "flame_it", flamer::flame)]
 pub fn resolve_weak(sequence: &IsolatingRunSequence, processing_classes: &mut [BidiClass]) {
     // FIXME (#8): This function applies steps W1-W6 in a single pass.  This can produce
     // incorrect results in cases where a "later" rule changes the value of `prev_class` seen
@@ -135,7 +134,7 @@
 /// 3.3.5 Resolving Neutral Types
 ///
 /// <http://www.unicode.org/reports/tr9/#Resolving_Neutral_Types>
-#[cfg_attr(feature = "flame_it", flame)]
+#[cfg_attr(feature = "flame_it", flamer::flame)]
 pub fn resolve_neutral(
     sequence: &IsolatingRunSequence,
     levels: &[Level],
@@ -200,7 +199,7 @@
 /// Returns the maximum embedding level in the paragraph.
 ///
 /// <http://www.unicode.org/reports/tr9/#Resolving_Implicit_Levels>
-#[cfg_attr(feature = "flame_it", flame)]
+#[cfg_attr(feature = "flame_it", flamer::flame)]
 pub fn resolve_levels(original_classes: &[BidiClass], levels: &mut [Level]) -> Level {
     let mut max_level = Level::ltr();
 
diff --git a/src/level.rs b/src/level.rs
index 1c195a9..bc74205 100644
--- a/src/level.rs
+++ b/src/level.rs
@@ -28,7 +28,7 @@
 ///
 /// <http://www.unicode.org/reports/tr9/#BD2>
 #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub struct Level(u8);
 
 pub const LTR_LEVEL: Level = Level(0);
@@ -328,7 +328,8 @@
     #[test]
     fn test_into() {
         let level = Level::rtl();
-        assert_eq!(1u8, level.into());
+        let number: u8 = level.into();
+        assert_eq!(1u8, number);
     }
 
     #[test]
diff --git a/src/lib.rs b/src/lib.rs
index 5e1d3e2..ba3220b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -57,24 +57,6 @@
 
 #![forbid(unsafe_code)]
 
-#![cfg_attr(feature="flame_it", feature(plugin, custom_attribute))]
-#![cfg_attr(feature="flame_it", plugin(flamer))]
-
-
-#[macro_use]
-extern crate matches;
-
-#[cfg(feature = "serde")]
-#[macro_use]
-extern crate serde;
-
-#[cfg(all(feature = "serde", test))]
-extern crate serde_test;
-
-#[cfg(feature = "flame_it")]
-extern crate flame;
-
-
 pub mod deprecated;
 pub mod format_chars;
 pub mod level;
@@ -84,18 +66,17 @@
 mod implicit;
 mod prepare;
 
-pub use char_data::{BidiClass, bidi_class, UNICODE_VERSION};
-pub use level::{Level, LTR_LEVEL, RTL_LEVEL};
-pub use prepare::LevelRun;
+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 BidiClass::*;
-use format_chars as chars;
-
+use crate::BidiClass::*;
+use crate::format_chars as chars;
 
 /// Bidi information about a single paragraph
 #[derive(Debug, PartialEq)]
@@ -135,8 +116,8 @@
     /// Also sets the class for each First Strong Isolate initiator (FSI) to LRI or RLI if a strong
     /// character is found before the matching PDI.  If no strong character is found, the class will
     /// remain FSI, and it's up to later stages to treat these as LRI when needed.
-    #[cfg_attr(feature = "flame_it", flame)]
-    pub fn new(text: &str, default_para_level: Option<Level>) -> InitialInfo {
+    #[cfg_attr(feature = "flame_it", flamer::flame)]
+    pub fn new(text: &str, default_para_level: Option<Level>) -> InitialInfo<'_> {
         let mut original_classes = Vec::with_capacity(text.len());
 
         // The stack contains the starting byte index for each nested isolate we're inside.
@@ -261,8 +242,8 @@
     /// text that is entirely LTR.  See the `nsBidi` class from Gecko for comparison.
     ///
     /// TODO: Support auto-RTL base direction
-    #[cfg_attr(feature = "flame_it", flame)]
-    pub fn new(text: &str, default_para_level: Option<Level>) -> BidiInfo {
+    #[cfg_attr(feature = "flame_it", flamer::flame)]
+    pub fn new(text: &str, default_para_level: Option<Level>) -> BidiInfo<'_> {
         let InitialInfo {
             original_classes,
             paragraphs,
@@ -309,15 +290,15 @@
 
     /// Re-order a line based on resolved levels and return only the embedding levels, one `Level`
     /// per *byte*.
-    #[cfg_attr(feature = "flame_it", flame)]
+    #[cfg_attr(feature = "flame_it", flamer::flame)]
     pub fn reordered_levels(&self, para: &ParagraphInfo, line: Range<usize>) -> Vec<Level> {
-        let (levels, _) = self.visual_runs(para, line.clone());
+        let (levels, _) = self.visual_runs(para, line);
         levels
     }
 
     /// Re-order a line based on resolved levels and return only the embedding levels, one `Level`
     /// per *character*.
-    #[cfg_attr(feature = "flame_it", flame)]
+    #[cfg_attr(feature = "flame_it", flamer::flame)]
     pub fn reordered_levels_per_char(
         &self,
         para: &ParagraphInfo,
@@ -329,13 +310,13 @@
 
 
     /// Re-order a line based on resolved levels and return the line in display order.
-    #[cfg_attr(feature = "flame_it", flame)]
+    #[cfg_attr(feature = "flame_it", flamer::flame)]
     pub fn reorder_line(&self, para: &ParagraphInfo, line: Range<usize>) -> Cow<'text, str> {
         let (levels, runs) = self.visual_runs(para, line.clone());
 
         // If all isolating run sequences are LTR, no reordering is needed
         if runs.iter().all(|run| levels[run.start].is_ltr()) {
-            return self.text[line.clone()].into();
+            return self.text[line].into();
         }
 
         let mut result = String::with_capacity(line.len());
@@ -354,7 +335,7 @@
     /// `line` is a range of bytes indices within `levels`.
     ///
     /// <http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels>
-    #[cfg_attr(feature = "flame_it", flame)]
+    #[cfg_attr(feature = "flame_it", flamer::flame)]
     pub fn visual_runs(
         &self,
         para: &ParagraphInfo,
@@ -364,6 +345,8 @@
         assert!(line.end <= self.levels.len());
 
         let mut levels = self.levels.clone();
+        let line_classes = &self.original_classes[line.clone()];
+        let line_levels = &mut levels[line.clone()];
 
         // Reset some whitespace chars to paragraph level.
         // <http://www.unicode.org/reports/tr9/#L1>
@@ -371,7 +354,7 @@
         let mut reset_from: Option<usize> = Some(0);
         let mut reset_to: Option<usize> = None;
         for (i, c) in line_str.char_indices() {
-            match self.original_classes[i] {
+            match line_classes[i] {
                 // Ignored by X9
                 RLE | LRE | RLO | LRO | PDF | BN => {}
                 // Segment separator, Paragraph separator
@@ -393,18 +376,16 @@
                 }
             }
             if let (Some(from), Some(to)) = (reset_from, reset_to) {
-                #[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
-                for j in from..to {
-                    levels[j] = para.level;
+                for level in &mut line_levels[from..to] {
+                    *level = para.level;
                 }
                 reset_from = None;
                 reset_to = None;
             }
         }
         if let Some(from) = reset_from {
-            #[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
-            for j in from..line_str.len() {
-                levels[j] = para.level;
+            for level in &mut line_levels[from..] {
+                *level = para.level;
             }
         }
 
@@ -479,7 +460,7 @@
 ///
 /// The levels assigned to these characters are not specified by the algorithm.  This function
 /// assigns each one the level of the previous character, to avoid breaking level runs.
-#[cfg_attr(feature = "flame_it", flame)]
+#[cfg_attr(feature = "flame_it", flamer::flame)]
 fn assign_levels_to_removed_chars(para_level: Level, classes: &[BidiClass], levels: &mut [Level]) {
     for i in 0..levels.len() {
         if prepare::removed_by_x9(classes[i]) {
@@ -674,7 +655,7 @@
             }
         );
 
-        /// BidiTest:69635 (AL ET EN)
+        // BidiTest:69635 (AL ET EN)
         let bidi_info = BidiInfo::new("\u{060B}\u{20CF}\u{06F9}", None);
         assert_eq!(bidi_info.original_classes, vec![AL, AL, ET, ET, ET, EN, EN]);
     }
@@ -703,7 +684,7 @@
         assert_eq!(BidiInfo::new("אבּג\n123", None).has_rtl(), true);
     }
 
-    fn reorder_paras(text: &str) -> Vec<Cow<str>> {
+    fn reorder_paras(text: &str) -> Vec<Cow<'_, str>> {
         let bidi_info = BidiInfo::new(text, None);
         bidi_info
             .paragraphs
@@ -714,22 +695,22 @@
 
     #[test]
     fn test_reorder_line() {
-        /// Bidi_Class: L L L B L L L B L L L
+        // Bidi_Class: L L L B L L L B L L L
         assert_eq!(
             reorder_paras("abc\ndef\nghi"),
             vec!["abc\n", "def\n", "ghi"]
         );
 
-        /// Bidi_Class: L L EN B L L EN B L L EN
+        // Bidi_Class: L L EN B L L EN B L L EN
         assert_eq!(
             reorder_paras("ab1\nde2\ngh3"),
             vec!["ab1\n", "de2\n", "gh3"]
         );
 
-        /// Bidi_Class: L L L B AL AL AL
+        // Bidi_Class: L L L B AL AL AL
         assert_eq!(reorder_paras("abc\nابج"), vec!["abc\n", "جبا"]);
 
-        /// Bidi_Class: AL AL AL B L L L
+        // Bidi_Class: AL AL AL B L L L
         assert_eq!(reorder_paras("ابج\nabc"), vec!["\nجبا", "abc"]);
 
         assert_eq!(reorder_paras("1.-2"), vec!["1.-2"]);
@@ -812,7 +793,7 @@
     #[test]
     fn test_reordered_levels() {
 
-        /// BidiTest:946 (LRI PDI)
+        // BidiTest:946 (LRI PDI)
         let text = "\u{2067}\u{2069}";
         assert_eq!(
             reordered_levels_for_paras(text),
@@ -823,6 +804,13 @@
             vec![Level::vec(&[0, 0])]
         );
 
+        let text = "aa טֶ";
+        let bidi_info = BidiInfo::new(text, None);
+        assert_eq!(
+            bidi_info.reordered_levels(&bidi_info.paragraphs[0], 3..7),
+            Level::vec(&[0, 0, 0, 1, 1, 1, 1]),
+        )
+
         /* TODO
         /// BidiTest:69635 (AL ET EN)
         let text = "\u{060B}\u{20CF}\u{06F9}";
diff --git a/src/prepare.rs b/src/prepare.rs
index 7983962..ccb8c0f 100644
--- a/src/prepare.rs
+++ b/src/prepare.rs
@@ -13,12 +13,11 @@
 
 use std::cmp::max;
 use std::ops::Range;
+use matches::matches;
 
-use super::char_data::BidiClass;
+use super::BidiClass::{self, *};
 use super::level::Level;
 
-use BidiClass::*;
-
 /// A maximal substring of characters with the same embedding level.
 ///
 /// Represented as a range of byte indices.
@@ -41,7 +40,7 @@
 /// whose matching PDI is the first character of the next level run in the sequence.
 ///
 /// Note: This function does *not* return the sequences in order by their first characters.
-#[cfg_attr(feature = "flame_it", flame)]
+#[cfg_attr(feature = "flame_it", flamer::flame)]
 pub fn isolating_run_sequences(
     para_level: Level,
     original_classes: &[BidiClass],
@@ -186,7 +185,7 @@
     }
 
     // From <http://www.unicode.org/reports/tr9/#BD13>
-    #[cfg_attr(rustfmt, rustfmt_skip)]
+    #[rustfmt::skip]
     #[test]
     fn test_isolating_run_sequences() {
 
@@ -231,7 +230,7 @@
     }
 
     // From <http://www.unicode.org/reports/tr9/#X10>
-    #[cfg_attr(rustfmt, rustfmt_skip)]
+    #[rustfmt::skip]
     #[test]
     fn test_isolating_run_sequences_sos_and_eos() {