diff options
author | Stephen Hines <srhines@google.com> | 2021-10-05 04:01:09 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-05 04:01:09 +0000 |
commit | c2db27cb5d03f5230ed7a20edb7ccc0b20628b15 (patch) | |
tree | b0cb732cb0c2c548b98c132b869c0cef62c5b60c | |
parent | 3b6ea3576eb8a2666ff3326b6518318c281d05be (diff) | |
parent | 100dd8f647fb59290587b8fab8449641a0b42ba6 (diff) | |
download | proc-macro2-c2db27cb5d03f5230ed7a20edb7ccc0b20628b15.tar.gz |
Merge "Upgrade rust/crates/proc-macro2 to 1.0.29" am: 8129d0cb0c am: f2619ed659 am: 9c9387fa41 am: 22688df941 am: 100dd8f647
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/proc-macro2/+/1833322
Change-Id: Ifa2dd9016303e80297591420adc2528b6f3b1ee8
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 16 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | build.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/wrapper.rs | 25 |
8 files changed, 38 insertions, 23 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 0b4ad97..b4a0dce 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "93c4df24e2d5ef9ddff484a7086f2e0018a13507" + "sha1": "4fc89676e7bdef2ba68e8a1383d07df0bb7bbeb0" } } @@ -1,4 +1,4 @@ -// This file is generated by cargo2android.py --run --dependencies --tests --host-first-multilib --features=default,span-locations. +// This file is generated by cargo2android.py --run --tests --host-first-multilib --features=default,span-locations. // Do not modify this file as changes will be overridden on upgrade. package { @@ -40,6 +40,8 @@ license { rust_library_host { name: "libproc_macro2", crate_name: "proc_macro2", + cargo_env_compat: true, + cargo_pkg_version: "1.0.29", srcs: ["src/lib.rs"], edition: "2018", features: [ @@ -50,6 +52,7 @@ rust_library_host { cfgs: [ "hygiene", "lexerror_display", + "literal_from_str", "proc_macro_span", "span_locations", "use_proc_macro", @@ -64,6 +67,8 @@ rust_library_host { rust_test_host { name: "proc-macro2_host_test_src_lib", crate_name: "proc_macro2", + cargo_env_compat: true, + cargo_pkg_version: "1.0.29", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, @@ -79,6 +84,7 @@ rust_test_host { cfgs: [ "hygiene", "lexerror_display", + "literal_from_str", "proc_macro_span", "span_locations", "use_proc_macro", @@ -93,6 +99,8 @@ rust_test_host { rust_defaults { name: "proc-macro2_test_defaults", crate_name: "proc_macro2", + cargo_env_compat: true, + cargo_pkg_version: "1.0.29", test_suites: ["general-tests"], auto_gen_config: true, edition: "2018", @@ -104,6 +112,7 @@ rust_defaults { cfgs: [ "hygiene", "lexerror_display", + "literal_from_str", "proc_macro_span", "span_locations", "use_proc_macro", @@ -160,8 +169,3 @@ rust_test_host { unit_test: true, }, } - -// dependent_library ["feature_list"] -// proc-macro2-1.0.28 -// quote-1.0.9 -// unicode-xid-0.2.2 "default" @@ -12,7 +12,7 @@ [package] edition = "2018" name = "proc-macro2" -version = "1.0.28" +version = "1.0.29" authors = ["Alex Crichton <alex@alexcrichton.com>", "David Tolnay <dtolnay@gmail.com>"] description = "A substitute implementation of the compiler's `proc_macro` API to decouple\ntoken-based libraries from the procedural macro use case.\n" documentation = "https://docs.rs/proc-macro2" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 254063e..543dca5 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "proc-macro2" -version = "1.0.28" # remember to update html_root_url +version = "1.0.29" # remember to update html_root_url authors = ["Alex Crichton <alex@alexcrichton.com>", "David Tolnay <dtolnay@gmail.com>"] license = "MIT OR Apache-2.0" readme = "README.md" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/proc-macro2/proc-macro2-1.0.28.crate" + value: "https://static.crates.io/crates/proc-macro2/proc-macro2-1.0.29.crate" } - version: "1.0.28" + version: "1.0.29" license_type: NOTICE last_upgrade_date { year: 2021 - month: 8 - day: 9 + month: 9 + day: 22 } } @@ -78,6 +78,10 @@ fn main() { println!("cargo:rustc-cfg=hygiene"); } + if version.minor >= 54 { + println!("cargo:rustc-cfg=literal_from_str"); + } + let target = env::var("TARGET").unwrap(); if !enable_use_proc_macro(&target) { return; @@ -78,7 +78,7 @@ //! a different thread. // Proc-macro2 types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.28")] +#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.29")] #![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))] #![cfg_attr(super_unstable, feature(proc_macro_raw_ident, proc_macro_def_site))] #![cfg_attr(doc_cfg, feature(doc_cfg))] diff --git a/src/wrapper.rs b/src/wrapper.rs index 2829dd7..dc93873 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -921,18 +921,25 @@ impl FromStr for Literal { fn from_str(repr: &str) -> Result<Self, Self::Err> { if inside_proc_macro() { - // TODO: use libproc_macro's FromStr impl once it is available in - // rustc. https://github.com/rust-lang/rust/pull/84717 - let tokens = proc_macro_parse(repr)?; - let mut iter = tokens.into_iter(); - if let (Some(proc_macro::TokenTree::Literal(literal)), None) = - (iter.next(), iter.next()) + #[cfg(literal_from_str)] { - if literal.to_string().len() == repr.len() { - return Ok(Literal::Compiler(literal)); + proc_macro::Literal::from_str(repr) + .map(Literal::Compiler) + .map_err(LexError::Compiler) + } + #[cfg(not(literal_from_str))] + { + let tokens = proc_macro_parse(repr)?; + let mut iter = tokens.into_iter(); + if let (Some(proc_macro::TokenTree::Literal(literal)), None) = + (iter.next(), iter.next()) + { + if literal.to_string().len() == repr.len() { + return Ok(Literal::Compiler(literal)); + } } + Err(LexError::call_site()) } - Err(LexError::call_site()) } else { let literal = fallback::Literal::from_str(repr)?; Ok(Literal::Fallback(literal)) |