aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-06-02 21:56:24 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-02 21:56:24 +0000
commit62de5e50c9199bed18111720a0429e879c28445a (patch)
treef9a3e5de38f28a167d25149bc9567b53eed03afe
parent881e7257163fac96f0d5f574cba879747ea14f87 (diff)
parent333e704e79600f1711d319333302a45026bc1f12 (diff)
downloadsyn-aosp-emu-30-release.tar.gz
Upgrade rust/crates/syn to 1.0.30 am: 333e704e79aosp-emu-30-release
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/syn/+/1322358 Change-Id: I2e55a96ab28cecf15de6a530f774990cc36e8bbf
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Cargo.toml2
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA6
-rw-r--r--src/attr.rs4
-rw-r--r--src/buffer.rs8
-rw-r--r--src/expr.rs6
-rw-r--r--src/gen/fold.rs1
-rw-r--r--src/lib.rs2
-rw-r--r--src/ty.rs2
-rw-r--r--tests/test_expr.rs22
-rw-r--r--tests/test_lit.rs19
12 files changed, 61 insertions, 15 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 9e297260..0808224b 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "b30011c1ffc5bf6eb9a020d2599cd9268880ecc9"
+ "sha1": "89658fc242ee17041a4e2dd74b455f8d89d5de31"
}
}
diff --git a/Cargo.toml b/Cargo.toml
index 52058086..7d8c8a9b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "syn"
-version = "1.0.29"
+version = "1.0.30"
authors = ["David Tolnay <dtolnay@gmail.com>"]
include = ["/benches/**", "/build.rs", "/Cargo.toml", "/LICENSE-APACHE", "/LICENSE-MIT", "/README.md", "/src/**", "/tests/**"]
description = "Parser for Rust source code"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 17443519..55d82eda 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "syn"
-version = "1.0.29" # don't forget to update html_root_url and syn.json
+version = "1.0.30" # don't forget to update html_root_url and syn.json
authors = ["David Tolnay <dtolnay@gmail.com>"]
license = "MIT OR Apache-2.0"
description = "Parser for Rust source code"
diff --git a/METADATA b/METADATA
index 810405d6..0b51e9ef 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@ third_party {
type: GIT
value: "https://github.com/dtolnay/syn"
}
- version: "1.0.29"
+ version: "1.0.30"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 5
- day: 29
+ month: 6
+ day: 2
}
}
diff --git a/src/attr.rs b/src/attr.rs
index 2a51c380..d8a9d877 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -505,7 +505,7 @@ where
fn is_outer(attr: &&Attribute) -> bool {
match attr.style {
AttrStyle::Outer => true,
- _ => false,
+ AttrStyle::Inner(_) => false,
}
}
self.into_iter().filter(is_outer)
@@ -515,7 +515,7 @@ where
fn is_inner(attr: &&Attribute) -> bool {
match attr.style {
AttrStyle::Inner(_) => true,
- _ => false,
+ AttrStyle::Outer => false,
}
}
self.into_iter().filter(is_inner)
diff --git a/src/buffer.rs b/src/buffer.rs
index 73255d6e..00aaa7de 100644
--- a/src/buffer.rs
+++ b/src/buffer.rs
@@ -201,13 +201,13 @@ impl<'a> Cursor<'a> {
Cursor::create(self.ptr.offset(1), self.scope)
}
- /// If the cursor is looking at a `None`-delimited group, move it to look at
- /// the first token inside instead. If the group is empty, this will move
+ /// While the cursor is looking at a `None`-delimited group, move it to look
+ /// at the first token inside instead. If the group is empty, this will move
/// the cursor past the `None`-delimited group.
///
/// WARNING: This mutates its argument.
fn ignore_none(&mut self) {
- if let Entry::Group(group, buf) = self.entry() {
+ while let Entry::Group(group, buf) = self.entry() {
if group.delimiter() == Delimiter::None {
// NOTE: We call `Cursor::create` here to make sure that
// situations where we should immediately exit the span after
@@ -215,6 +215,8 @@ impl<'a> Cursor<'a> {
unsafe {
*self = Cursor::create(&buf.data[0], self.scope);
}
+ } else {
+ break;
}
}
}
diff --git a/src/expr.rs b/src/expr.rs
index 6f14cbc3..d98cc612 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1691,7 +1691,11 @@ pub(crate) mod parsing {
// interactions, as they are fully contained.
#[cfg(feature = "full")]
fn atom_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
- if input.peek(token::Group) && !input.peek2(Token![::]) && !input.peek2(Token![!]) {
+ if input.peek(token::Group)
+ && !input.peek2(Token![::])
+ && !input.peek2(Token![!])
+ && !input.peek2(token::Brace)
+ {
input.call(expr_group).map(Expr::Group)
} else if input.peek(Lit) {
input.parse().map(Expr::Lit)
diff --git a/src/gen/fold.rs b/src/gen/fold.rs
index b472d142..ec1bcfda 100644
--- a/src/gen/fold.rs
+++ b/src/gen/fold.rs
@@ -2,6 +2,7 @@
// It is not intended for manual editing.
#![allow(unreachable_code, unused_variables)]
+#![allow(clippy::match_wildcard_for_single_variants)]
#[cfg(any(feature = "full", feature = "derive"))]
use crate::gen::helper::fold::*;
#[cfg(any(feature = "full", feature = "derive"))]
diff --git a/src/lib.rs b/src/lib.rs
index c84d4f9f..33926fdf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -250,7 +250,7 @@
//! dynamic library libproc_macro from rustc toolchain.
// Syn types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/syn/1.0.29")]
+#![doc(html_root_url = "https://docs.rs/syn/1.0.30")]
#![deny(clippy::all, clippy::pedantic)]
// Ignored clippy lints.
#![allow(
diff --git a/src/ty.rs b/src/ty.rs
index 8383bec4..ed263e67 100644
--- a/src/ty.rs
+++ b/src/ty.rs
@@ -529,7 +529,7 @@ pub mod parsing {
..trait_bound
})
}
- other => other,
+ other @ TypeParamBound::Lifetime(_) => other,
}
}
_ => break,
diff --git a/tests/test_expr.rs b/tests/test_expr.rs
index 481ee3d5..85d09d3c 100644
--- a/tests/test_expr.rs
+++ b/tests/test_expr.rs
@@ -142,3 +142,25 @@ fn test_macro_variable_macro() {
}
"###);
}
+
+#[test]
+fn test_macro_variable_struct() {
+ // mimics the token stream corresponding to `$struct {}`
+ let tokens = TokenStream::from_iter(vec![
+ TokenTree::Group(Group::new(Delimiter::None, quote! { S })),
+ TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
+ ]);
+
+ snapshot!(tokens as Expr, @r###"
+ Expr::Struct {
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "S",
+ arguments: None,
+ },
+ ],
+ },
+ }
+ "###);
+}
diff --git a/tests/test_lit.rs b/tests/test_lit.rs
index 4435aadb..0bd170c3 100644
--- a/tests/test_lit.rs
+++ b/tests/test_lit.rs
@@ -1,5 +1,9 @@
-use proc_macro2::{Span, TokenStream, TokenTree};
+#[macro_use]
+mod macros;
+
+use proc_macro2::{Delimiter, Group, Literal, Span, TokenStream, TokenTree};
use quote::ToTokens;
+use std::iter::FromIterator;
use std::str::FromStr;
use syn::{Lit, LitFloat, LitInt};
@@ -229,3 +233,16 @@ fn suffix() {
assert_eq!(get_suffix("1.0f32"), "f32");
assert_eq!(get_suffix("1.0_f32"), "f32");
}
+
+#[test]
+fn test_deep_group_empty() {
+ let tokens = TokenStream::from_iter(vec![TokenTree::Group(Group::new(
+ Delimiter::None,
+ TokenStream::from_iter(vec![TokenTree::Group(Group::new(
+ Delimiter::None,
+ TokenStream::from_iter(vec![TokenTree::Literal(Literal::string("hi"))]),
+ ))]),
+ ))]);
+
+ snapshot!(tokens as Lit, @r#""hi""# );
+}