Upgrade thiserror-impl to 1.0.40

This project was upgraded with external_updater.
Usage: tools/external_updater/updater.sh update rust/crates/thiserror-impl
For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md

Test: TreeHugger
Bug: 276463929
Change-Id: If342f5da42f46f83e97593fd806bc77bd079223e
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 9f6267f..cfd0f22 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
 {
   "git": {
-    "sha1": "74bfe75eb25ba9d39b0ae5b570d611855cbc5086"
+    "sha1": "3cec8c487953298acd00c61ef9a81d0461517974"
   },
   "path_in_vcs": "impl"
 }
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 367ebe3..b62d6fa 100644
--- a/Android.bp
+++ b/Android.bp
@@ -43,7 +43,7 @@
     name: "libthiserror_impl",
     crate_name: "thiserror_impl",
     cargo_env_compat: true,
-    cargo_pkg_version: "1.0.38",
+    cargo_pkg_version: "1.0.40",
     srcs: ["src/lib.rs"],
     edition: "2018",
     rustlibs: [
diff --git a/Cargo.toml b/Cargo.toml
index ca2a0b4..bf61470 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,9 +11,9 @@
 
 [package]
 edition = "2018"
-rust-version = "1.31"
+rust-version = "1.56"
 name = "thiserror-impl"
-version = "1.0.38"
+version = "1.0.40"
 authors = ["David Tolnay <dtolnay@gmail.com>"]
 description = "Implementation detail of the `thiserror` crate"
 license = "MIT OR Apache-2.0"
@@ -32,4 +32,4 @@
 version = "1.0"
 
 [dependencies.syn]
-version = "1.0.45"
+version = "2.0"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index dee506a..422a303 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,12 +1,12 @@
 [package]
 name = "thiserror-impl"
-version = "1.0.38"
+version = "1.0.40"
 authors = ["David Tolnay <dtolnay@gmail.com>"]
 description = "Implementation detail of the `thiserror` crate"
 edition = "2018"
 license = "MIT OR Apache-2.0"
 repository = "https://github.com/dtolnay/thiserror"
-rust-version = "1.31"
+rust-version = "1.56"
 
 [lib]
 proc-macro = true
@@ -14,7 +14,7 @@
 [dependencies]
 proc-macro2 = "1.0"
 quote = "1.0"
-syn = "1.0.45"
+syn = "2.0"
 
 [package.metadata.docs.rs]
 targets = ["x86_64-unknown-linux-gnu"]
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
index 16fe87b..1b5ec8b 100644
--- a/LICENSE-APACHE
+++ b/LICENSE-APACHE
@@ -174,28 +174,3 @@
    of your accepting any such warranty or additional liability.
 
 END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
-   To apply the Apache License to your work, attach the following
-   boilerplate notice, with the fields enclosed by brackets "[]"
-   replaced with your own identifying information. (Don't include
-   the brackets!)  The text should be enclosed in the appropriate
-   comment syntax for the file format. We also recommend that a
-   file or class name and description of purpose be included on the
-   same "printed page" as the copyright notice for easier
-   identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-	http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/METADATA b/METADATA
index 075ed9f..c3accff 100644
--- a/METADATA
+++ b/METADATA
@@ -11,13 +11,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/thiserror-impl/thiserror-impl-1.0.38.crate"
+    value: "https://static.crates.io/crates/thiserror-impl/thiserror-impl-1.0.40.crate"
   }
-  version: "1.0.38"
+  version: "1.0.40"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2022
-    month: 12
-    day: 19
+    year: 2023
+    month: 3
+    day: 23
   }
 }
diff --git a/src/attr.rs b/src/attr.rs
index 9963fd6..0b1b89d 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -2,9 +2,9 @@
 use quote::{format_ident, quote, ToTokens};
 use std::collections::BTreeSet as Set;
 use std::iter::FromIterator;
-use syn::parse::{Nothing, ParseStream};
+use syn::parse::ParseStream;
 use syn::{
-    braced, bracketed, parenthesized, token, Attribute, Error, Ident, Index, LitInt, LitStr,
+    braced, bracketed, parenthesized, token, Attribute, Error, Ident, Index, LitInt, LitStr, Meta,
     Result, Token,
 };
 
@@ -54,24 +54,27 @@
     };
 
     for attr in input {
-        if attr.path.is_ident("error") {
+        if attr.path().is_ident("error") {
             parse_error_attribute(&mut attrs, attr)?;
-        } else if attr.path.is_ident("source") {
+        } else if attr.path().is_ident("source") {
             require_empty_attribute(attr)?;
             if attrs.source.is_some() {
                 return Err(Error::new_spanned(attr, "duplicate #[source] attribute"));
             }
             attrs.source = Some(attr);
-        } else if attr.path.is_ident("backtrace") {
+        } else if attr.path().is_ident("backtrace") {
             require_empty_attribute(attr)?;
             if attrs.backtrace.is_some() {
                 return Err(Error::new_spanned(attr, "duplicate #[backtrace] attribute"));
             }
             attrs.backtrace = Some(attr);
-        } else if attr.path.is_ident("from") {
-            if !attr.tokens.is_empty() {
-                // Assume this is meant for derive_more crate or something.
-                continue;
+        } else if attr.path().is_ident("from") {
+            match attr.meta {
+                Meta::Path(_) => {}
+                Meta::List(_) | Meta::NameValue(_) => {
+                    // Assume this is meant for derive_more crate or something.
+                    continue;
+                }
             }
             if attrs.from.is_some() {
                 return Err(Error::new_spanned(attr, "duplicate #[from] attribute"));
@@ -166,21 +169,21 @@
             let delimiter = parenthesized!(content in input);
             let nested = parse_token_expr(&content, true)?;
             let mut group = Group::new(Delimiter::Parenthesis, nested);
-            group.set_span(delimiter.span);
+            group.set_span(delimiter.span.join());
             TokenTree::Group(group)
         } else if input.peek(token::Brace) {
             let content;
             let delimiter = braced!(content in input);
             let nested = parse_token_expr(&content, true)?;
             let mut group = Group::new(Delimiter::Brace, nested);
-            group.set_span(delimiter.span);
+            group.set_span(delimiter.span.join());
             TokenTree::Group(group)
         } else if input.peek(token::Bracket) {
             let content;
             let delimiter = bracketed!(content in input);
             let nested = parse_token_expr(&content, true)?;
             let mut group = Group::new(Delimiter::Bracket, nested);
-            group.set_span(delimiter.span);
+            group.set_span(delimiter.span.join());
             TokenTree::Group(group)
         } else {
             input.parse()?
@@ -191,8 +194,15 @@
 }
 
 fn require_empty_attribute(attr: &Attribute) -> Result<()> {
-    syn::parse2::<Nothing>(attr.tokens.clone())?;
-    Ok(())
+    let error_span = match &attr.meta {
+        Meta::Path(_) => return Ok(()),
+        Meta::List(meta) => meta.delimiter.span().open(),
+        Meta::NameValue(meta) => meta.eq_token.span,
+    };
+    Err(Error::new(
+        error_span,
+        "unexpected token in thiserror attribute",
+    ))
 }
 
 impl ToTokens for Display<'_> {
diff --git a/src/expand.rs b/src/expand.rs
index 4352209..ef8eaf3 100644
--- a/src/expand.rs
+++ b/src/expand.rs
@@ -528,15 +528,14 @@
 
 fn spanned_error_trait(input: &DeriveInput) -> TokenStream {
     let vis_span = match &input.vis {
-        Visibility::Public(vis) => Some(vis.pub_token.span()),
-        Visibility::Crate(vis) => Some(vis.crate_token.span()),
-        Visibility::Restricted(vis) => Some(vis.pub_token.span()),
+        Visibility::Public(vis) => Some(vis.span),
+        Visibility::Restricted(vis) => Some(vis.pub_token.span),
         Visibility::Inherited => None,
     };
     let data_span = match &input.data {
-        Data::Struct(data) => data.struct_token.span(),
-        Data::Enum(data) => data.enum_token.span(),
-        Data::Union(data) => data.union_token.span(),
+        Data::Struct(data) => data.struct_token.span,
+        Data::Enum(data) => data.enum_token.span,
+        Data::Union(data) => data.union_token.span,
     };
     let first_span = vis_span.unwrap_or(data_span);
     let last_span = input.ident.span();