diff options
author | Haibo Huang <hhb@google.com> | 2020-05-04 15:37:15 -0700 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2020-05-04 15:37:15 -0700 |
commit | 1e2fc31cecafc5fd4e9d3432e183e57c90ff4acc (patch) | |
tree | 6f930e1c8e73aca418b420ef67ed577f107d6084 | |
parent | eeaf47fc4dddcea4f6b4e0d4e3247f11c477e284 (diff) | |
download | paste-impl-1e2fc31cecafc5fd4e9d3432e183e57c90ff4acc.tar.gz |
Upgrade rust/crates/paste-impl to 0.1.12
Test: None
Change-Id: I87248828f21a1a97d4d6cd35dd2652ed6ce66506
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Cargo.toml.orig | 5 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | src/lib.rs | 29 |
5 files changed, 28 insertions, 18 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 652f708..326754d 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "a3c7d4f0d396480243fd40b777bd3708e87ea80c" + "sha1": "ff47f2f0bbba62fcb2f892f5c488265b3bd7156f" } } @@ -13,7 +13,7 @@ [package] edition = "2018" name = "paste-impl" -version = "0.1.11" +version = "0.1.12" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Implementation detail of the `paste` crate" license = "MIT OR Apache-2.0" @@ -34,5 +34,3 @@ version = "1.0" [dependencies.syn] version = "1.0" -[badges.travis-ci] -repository = "dtolnay/paste" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index a11873f..057e084 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "paste-impl" -version = "0.1.11" +version = "0.1.12" authors = ["David Tolnay <dtolnay@gmail.com>"] edition = "2018" license = "MIT OR Apache-2.0" @@ -10,9 +10,6 @@ repository = "https://github.com/dtolnay/paste" [lib] proc-macro = true -[badges] -travis-ci = { repository = "dtolnay/paste" } - [dependencies] proc-macro-hack = "0.5" proc-macro2 = "1.0" @@ -9,11 +9,11 @@ third_party { type: GIT value: "https://github.com/dtolnay/paste" } - version: "0.1.11" + version: "0.1.12" license_type: NOTICE last_upgrade_date { year: 2020 - month: 4 - day: 27 + month: 5 + day: 4 } } @@ -51,7 +51,7 @@ impl Parse for PasteInput { let segments = parse_bracket_as_segments.parse2(content)?; let pasted = paste_segments(span, &segments)?; pasted.to_tokens(&mut expanded); - } else if delimiter == Delimiter::None && is_single_ident(&content) { + } else if is_none_delimited_single_ident_or_lifetime(delimiter, &content) { content.to_tokens(&mut expanded); } else { let nested = PasteInput::parse.parse2(content)?; @@ -72,15 +72,30 @@ fn is_paste_operation(input: &TokenStream) -> bool { parse_bracket_as_segments.parse2(input).is_ok() } -fn is_single_ident(input: &TokenStream) -> bool { - let mut has_ident = false; +// https://github.com/dtolnay/paste/issues/26 +fn is_none_delimited_single_ident_or_lifetime(delimiter: Delimiter, input: &TokenStream) -> bool { + if delimiter != Delimiter::None { + return false; + } + + #[derive(PartialEq)] + enum State { + Init, + Ident, + Apostrophe, + Lifetime, + } + + let mut state = State::Init; for tt in input.clone() { - match tt { - TokenTree::Ident(_) if !has_ident => has_ident = true, + state = match (state, &tt) { + (State::Init, TokenTree::Ident(_)) => State::Ident, + (State::Init, TokenTree::Punct(punct)) if punct.as_char() == '\'' => State::Apostrophe, + (State::Apostrophe, TokenTree::Ident(_)) => State::Lifetime, _ => return false, - } + }; } - has_ident + state == State::Ident || state == State::Lifetime } enum Segment { |