From 30109aca3144d129cd8d15cb86326e6732fef94a Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Wed, 4 Nov 2020 17:00:26 -0800 Subject: Upgrade rust/crates/thiserror-impl to 1.0.22 Test: make Change-Id: Ie03da9360a51da84cbc9f5629e9043206348b5c8 --- .cargo_vcs_info.json | 2 +- Cargo.toml | 4 ++-- Cargo.toml.orig | 4 ++-- METADATA | 8 ++++---- src/fmt.rs | 19 ++++++++++++++----- 5 files changed, 23 insertions(+), 14 deletions(-) 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 "] description = "Implementation detail of the `thiserror` crate" license = "MIT OR Apache-2.0" @@ -30,4 +30,4 @@ version = "1.0" 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 "] edition = "2018" license = "MIT OR Apache-2.0" @@ -13,7 +13,7 @@ proc-macro = true [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 @@ third_party { } 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 @@ impl Display<'_> { 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 @@ impl Display<'_> { 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 @@ fn explicit_named_args(input: ParseStream) -> Result> { while !input.is_empty() { if input.peek(Token![,]) && input.peek2(Ident::peek_any) && input.peek3(Token![=]) { input.parse::()?; - let ident: Ident = input.parse()?; + let ident = input.call(Ident::parse_any)?; input.parse::()?; named_args.insert(ident); } else { @@ -123,8 +127,13 @@ fn take_int(read: &mut &str) -> String { 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 @@ fn take_ident(read: &mut &str) -> String { } } } - ident + Ident::parse_any.parse_str(&ident).unwrap() } -- cgit v1.2.3