diff options
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 4 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | TEST_MAPPING | 13 | ||||
-rw-r--r-- | src/valid.rs | 41 |
7 files changed, 43 insertions, 31 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 660ea81..77f4f3f 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "09f247addaf6c5f57353f9558ba131e6619390c7" + "sha1": "d263b4b7e4f8e3ad9558256d8f6b2ac916985f7b" } } @@ -14,6 +14,6 @@ rust_proc_macro { // dependent_library ["feature_list"] // proc-macro2-1.0.24 "default,proc-macro" -// quote-1.0.7 "default,proc-macro" -// syn-1.0.48 "clone-impls,default,derive,parsing,printing,proc-macro,quote" +// quote-1.0.8 "default,proc-macro" +// syn-1.0.60 "clone-impls,default,derive,parsing,printing,proc-macro,quote" // unicode-xid-0.2.1 "default" @@ -13,7 +13,7 @@ [package] edition = "2018" name = "thiserror-impl" -version = "1.0.22" +version = "1.0.23" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Implementation detail of the `thiserror` crate" license = "MIT OR Apache-2.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 632bcc4..2acd6a4 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "thiserror-impl" -version = "1.0.22" +version = "1.0.23" authors = ["David Tolnay <dtolnay@gmail.com>"] edition = "2018" license = "MIT OR Apache-2.0" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/thiserror-impl/thiserror-impl-1.0.22.crate" + value: "https://static.crates.io/crates/thiserror-impl/thiserror-impl-1.0.23.crate" } - version: "1.0.22" + version: "1.0.23" license_type: NOTICE last_upgrade_date { - year: 2020 - month: 11 - day: 4 + year: 2021 + month: 2 + day: 9 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index 7bc6ed2..bce6738 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,12 +1,17 @@ -// Generated by cargo2android.py for tests in Android.bp +// Generated by update_crate_tests.py for tests that depend on this crate. { "presubmit": [ { - "host": true, - "name": "libsqlite3-sys_host_test_src_lib" + "name": "libsqlite3-sys_device_test_src_lib" }, { - "name": "libsqlite3-sys_device_test_src_lib" + "name": "keystore2_test" + }, + { + "name": "keystore2_selinux_test" + }, + { + "name": "keystore2_crypto_test_rust" } ] } diff --git a/src/valid.rs b/src/valid.rs index ab20423..cbd9f41 100644 --- a/src/valid.rs +++ b/src/valid.rs @@ -188,10 +188,10 @@ fn check_field_attrs(fields: &[Field]) -> Result<()> { } } if let Some(source_field) = source_field.or(from_field) { - if contains_non_static_lifetime(source_field) { + if contains_non_static_lifetime(&source_field.ty) { return Err(Error::new_spanned( - source_field.original, - "non-static lifetimes are not allowed in the source of an error", + &source_field.original.ty, + "non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static", )); } } @@ -206,21 +206,28 @@ fn same_member(one: &Field, two: &Field) -> bool { } } -fn contains_non_static_lifetime(field: &Field) -> bool { - let ty = match field.ty { - Type::Path(ty) => ty, - _ => return false, // maybe implement later if there are common other cases - }; - let bracketed = match &ty.path.segments.last().unwrap().arguments { - PathArguments::AngleBracketed(bracketed) => bracketed, - _ => return false, - }; - for arg in &bracketed.args { - if let GenericArgument::Lifetime(lifetime) = arg { - if lifetime.ident != "static" { - return true; +fn contains_non_static_lifetime(ty: &Type) -> bool { + match ty { + Type::Path(ty) => { + let bracketed = match &ty.path.segments.last().unwrap().arguments { + PathArguments::AngleBracketed(bracketed) => bracketed, + _ => return false, + }; + for arg in &bracketed.args { + match arg { + GenericArgument::Type(ty) if contains_non_static_lifetime(ty) => return true, + GenericArgument::Lifetime(lifetime) if lifetime.ident != "static" => { + return true + } + _ => {} + } } + false } + Type::Reference(ty) => ty + .lifetime + .as_ref() + .map_or(false, |lifetime| lifetime.ident != "static"), + _ => false, // maybe implement later if there are common other cases } - false } |