Upgrade rust/crates/paste-impl to 0.1.12
Test: None
Change-Id: I87248828f21a1a97d4d6cd35dd2652ed6ce66506
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 @@
[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 @@
[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 @@
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 @@
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 @@
parse_bracket_as_segments.parse2(input).is_ok()
}
-fn is_single_ident(input: &TokenStream) -> bool {
- let mut has_ident = false;
- for tt in input.clone() {
- match tt {
- TokenTree::Ident(_) if !has_ident => has_ident = true,
- _ => return 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;
}
- has_ident
+
+ #[derive(PartialEq)]
+ enum State {
+ Init,
+ Ident,
+ Apostrophe,
+ Lifetime,
+ }
+
+ let mut state = State::Init;
+ for tt in input.clone() {
+ 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,
+ };
+ }
+ state == State::Ident || state == State::Lifetime
}
enum Segment {