Merge "Upgrade rust/crates/thiserror-impl to 1.0.22" am: 559b51e1f4

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/thiserror-impl/+/1486921

Change-Id: Iaac8b37c8671d7d80264cbea91c66daa487adf39
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index a0bee43..660ea81 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "f757a0489b2cddfea15ab870b49f159ce1aa71cd"
+    "sha1": "09f247addaf6c5f57353f9558ba131e6619390c7"
   }
 }
diff --git a/Cargo.toml b/Cargo.toml
index b38f58a..3ae9bdc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
 [package]
 edition = "2018"
 name = "thiserror-impl"
-version = "1.0.21"
+version = "1.0.22"
 authors = ["David Tolnay <dtolnay@gmail.com>"]
 description = "Implementation detail of the `thiserror` crate"
 license = "MIT OR Apache-2.0"
@@ -30,4 +30,4 @@
 version = "1.0"
 
 [dependencies.syn]
-version = "1.0.11"
+version = "1.0.45"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index ff97c59..632bcc4 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "thiserror-impl"
-version = "1.0.21"
+version = "1.0.22"
 authors = ["David Tolnay <dtolnay@gmail.com>"]
 edition = "2018"
 license = "MIT OR Apache-2.0"
@@ -13,7 +13,7 @@
 [dependencies]
 proc-macro2 = "1.0"
 quote = "1.0"
-syn = "1.0.11"
+syn = "1.0.45"
 
 [package.metadata.docs.rs]
 targets = ["x86_64-unknown-linux-gnu"]
diff --git a/METADATA b/METADATA
index d2622e0..4eb6800 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/thiserror-impl/thiserror-impl-1.0.21.crate"
+    value: "https://static.crates.io/crates/thiserror-impl/thiserror-impl-1.0.22.crate"
   }
-  version: "1.0.21"
+  version: "1.0.22"
   license_type: NOTICE
   last_upgrade_date {
     year: 2020
-    month: 10
-    day: 26
+    month: 11
+    day: 4
   }
 }
diff --git a/src/fmt.rs b/src/fmt.rs
index ea1b518..e12e94b 100644
--- a/src/fmt.rs
+++ b/src/fmt.rs
@@ -54,8 +54,9 @@
                     member
                 }
                 'a'..='z' | 'A'..='Z' | '_' => {
-                    let ident = take_ident(&mut read);
-                    Member::Named(Ident::new(&ident, span))
+                    let mut ident = take_ident(&mut read);
+                    ident.set_span(span);
+                    Member::Named(ident)
                 }
                 _ => continue,
             };
@@ -64,6 +65,9 @@
                 Member::Named(ident) => ident.clone(),
             };
             let mut formatvar = local.clone();
+            if formatvar.to_string().starts_with("r#") {
+                formatvar = format_ident!("r_{}", formatvar);
+            }
             if formatvar.to_string().starts_with('_') {
                 // Work around leading underscore being rejected by 1.40 and
                 // older compilers. https://github.com/rust-lang/rust/pull/66847
@@ -98,7 +102,7 @@
     while !input.is_empty() {
         if input.peek(Token![,]) && input.peek2(Ident::peek_any) && input.peek3(Token![=]) {
             input.parse::<Token![,]>()?;
-            let ident: Ident = input.parse()?;
+            let ident = input.call(Ident::parse_any)?;
             input.parse::<Token![=]>()?;
             named_args.insert(ident);
         } else {
@@ -123,8 +127,13 @@
     int
 }
 
-fn take_ident(read: &mut &str) -> String {
+fn take_ident(read: &mut &str) -> Ident {
     let mut ident = String::new();
+    let raw = read.starts_with("r#");
+    if raw {
+        ident.push_str("r#");
+        *read = &read[2..];
+    }
     for (i, ch) in read.char_indices() {
         match ch {
             'a'..='z' | 'A'..='Z' | '0'..='9' | '_' => ident.push(ch),
@@ -134,5 +143,5 @@
             }
         }
     }
-    ident
+    Ident::parse_any.parse_str(&ident).unwrap()
 }