summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-05-05 00:39:10 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-05 00:39:10 +0000
commit0f5729924099e9e6df1b89bcfa892b90fcefac7f (patch)
tree6f930e1c8e73aca418b420ef67ed577f107d6084
parent8a0b75a891a43014927aebb6c4905a95a5b782f6 (diff)
parent1e2fc31cecafc5fd4e9d3432e183e57c90ff4acc (diff)
downloadpaste-impl-0f5729924099e9e6df1b89bcfa892b90fcefac7f.tar.gz
Upgrade rust/crates/paste-impl to 0.1.12 am: 1e2fc31cec
Change-Id: I3df9c35e0b695cca3e4c591daea13b7b5db12ba1
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Cargo.toml4
-rw-r--r--Cargo.toml.orig5
-rw-r--r--METADATA6
-rw-r--r--src/lib.rs29
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"
}
}
diff --git a/Cargo.toml b/Cargo.toml
index e18833f..5b7eaad 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/METADATA b/METADATA
index e62bf34..b2cbadf 100644
--- a/METADATA
+++ b/METADATA
@@ -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
}
}
diff --git a/src/lib.rs b/src/lib.rs
index b62929d..dce8bb0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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 {