summaryrefslogtreecommitdiffstats
path: root/vendor/syn/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/syn/src')
-rw-r--r--vendor/syn/src/error.rs2
-rw-r--r--vendor/syn/src/expr.rs18
-rw-r--r--vendor/syn/src/gen/fold.rs6
-rw-r--r--vendor/syn/src/gen/visit.rs1
-rw-r--r--vendor/syn/src/gen/visit_mut.rs1
-rw-r--r--vendor/syn/src/generics.rs2
-rw-r--r--vendor/syn/src/ident.rs1
-rw-r--r--vendor/syn/src/item.rs304
-rw-r--r--vendor/syn/src/lib.rs5
-rw-r--r--vendor/syn/src/lit.rs17
-rw-r--r--vendor/syn/src/pat.rs6
-rw-r--r--vendor/syn/src/path.rs42
-rw-r--r--vendor/syn/src/punctuated.rs5
-rw-r--r--vendor/syn/src/spanned.rs3
-rw-r--r--vendor/syn/src/stmt.rs7
-rw-r--r--vendor/syn/src/thread.rs20
-rw-r--r--vendor/syn/src/ty.rs4
-rw-r--r--vendor/syn/src/verbatim.rs4
18 files changed, 269 insertions, 179 deletions
diff --git a/vendor/syn/src/error.rs b/vendor/syn/src/error.rs
index 93f20f42f..3fe31d5ce 100644
--- a/vendor/syn/src/error.rs
+++ b/vendor/syn/src/error.rs
@@ -385,7 +385,7 @@ impl Clone for Error {
impl Clone for ErrorMessage {
fn clone(&self) -> Self {
ErrorMessage {
- span: self.span.clone(),
+ span: self.span,
message: self.message.clone(),
}
}
diff --git a/vendor/syn/src/expr.rs b/vendor/syn/src/expr.rs
index 0f1a6953e..ae723242e 100644
--- a/vendor/syn/src/expr.rs
+++ b/vendor/syn/src/expr.rs
@@ -1377,7 +1377,7 @@ pub(crate) mod parsing {
}
let expr = Box::new(unary_expr(input, allow_struct)?);
if raw.is_some() {
- Ok(Expr::Verbatim(verbatim::between(begin, input)))
+ Ok(Expr::Verbatim(verbatim::between(&begin, input)))
} else {
Ok(Expr::Reference(ExprReference {
attrs,
@@ -1423,7 +1423,7 @@ pub(crate) mod parsing {
let mut e = trailer_helper(input, atom)?;
if let Expr::Verbatim(tokens) = &mut e {
- *tokens = verbatim::between(begin, input);
+ *tokens = verbatim::between(&begin, input);
} else {
let inner_attrs = e.replace_attrs(Vec::new());
attrs.extend(inner_attrs);
@@ -1663,7 +1663,7 @@ pub(crate) mod parsing {
}
Ok(expr)
} else {
- Err(input.error("expected expression"))
+ Err(input.error("expected an expression"))
}
}
@@ -1691,6 +1691,16 @@ pub(crate) mod parsing {
} else if input.is_empty() {
Err(input.error("expected an expression"))
} else {
+ if input.peek(token::Brace) {
+ let scan = input.fork();
+ let content;
+ braced!(content in scan);
+ if content.parse::<Expr>().is_ok() && content.is_empty() {
+ let expr_block = verbatim::between(input, &scan);
+ input.advance_to(&scan);
+ return Ok(Expr::Verbatim(expr_block));
+ }
+ }
Err(input.error("unsupported expression; enable syn's features=[\"full\"]"))
}
}
@@ -1707,7 +1717,7 @@ pub(crate) mod parsing {
parenthesized!(args in input);
args.parse::<TokenStream>()?;
- Ok(Expr::Verbatim(verbatim::between(begin, input)))
+ Ok(Expr::Verbatim(verbatim::between(&begin, input)))
}
fn path_or_macro_or_struct(
diff --git a/vendor/syn/src/gen/fold.rs b/vendor/syn/src/gen/fold.rs
index 624c15b17..8ea6c75fc 100644
--- a/vendor/syn/src/gen/fold.rs
+++ b/vendor/syn/src/gen/fold.rs
@@ -2,7 +2,11 @@
// It is not intended for manual editing.
#![allow(unreachable_code, unused_variables)]
-#![allow(clippy::match_wildcard_for_single_variants, clippy::needless_match)]
+#![allow(
+ clippy::match_wildcard_for_single_variants,
+ clippy::needless_match,
+ clippy::needless_pass_by_ref_mut,
+)]
#[cfg(any(feature = "full", feature = "derive"))]
use crate::gen::helper::fold::*;
use crate::*;
diff --git a/vendor/syn/src/gen/visit.rs b/vendor/syn/src/gen/visit.rs
index 9eaa24f05..fe81fb63c 100644
--- a/vendor/syn/src/gen/visit.rs
+++ b/vendor/syn/src/gen/visit.rs
@@ -2,6 +2,7 @@
// It is not intended for manual editing.
#![allow(unused_variables)]
+#![allow(clippy::needless_pass_by_ref_mut)]
#[cfg(any(feature = "full", feature = "derive"))]
use crate::punctuated::Punctuated;
use crate::*;
diff --git a/vendor/syn/src/gen/visit_mut.rs b/vendor/syn/src/gen/visit_mut.rs
index 83bd1ccf8..9e7d16ff6 100644
--- a/vendor/syn/src/gen/visit_mut.rs
+++ b/vendor/syn/src/gen/visit_mut.rs
@@ -2,6 +2,7 @@
// It is not intended for manual editing.
#![allow(unused_variables)]
+#![allow(clippy::needless_pass_by_ref_mut)]
#[cfg(any(feature = "full", feature = "derive"))]
use crate::punctuated::Punctuated;
use crate::*;
diff --git a/vendor/syn/src/generics.rs b/vendor/syn/src/generics.rs
index 44a10da7d..2ad913d1d 100644
--- a/vendor/syn/src/generics.rs
+++ b/vendor/syn/src/generics.rs
@@ -771,7 +771,7 @@ pub(crate) mod parsing {
bound.paren_token = paren_token;
if is_tilde_const {
- Ok(TypeParamBound::Verbatim(verbatim::between(begin, input)))
+ Ok(TypeParamBound::Verbatim(verbatim::between(&begin, input)))
} else {
Ok(TypeParamBound::Trait(bound))
}
diff --git a/vendor/syn/src/ident.rs b/vendor/syn/src/ident.rs
index bd6f3f9f2..41eb72129 100644
--- a/vendor/syn/src/ident.rs
+++ b/vendor/syn/src/ident.rs
@@ -3,7 +3,6 @@ use crate::lookahead;
pub use proc_macro2::Ident;
-#[cfg(not(doc))] // rustdoc bug: https://github.com/rust-lang/rust/issues/105735
#[cfg(feature = "parsing")]
#[doc(hidden)]
#[allow(non_snake_case)]
diff --git a/vendor/syn/src/item.rs b/vendor/syn/src/item.rs
index 46ccd73ff..50d7e6ef6 100644
--- a/vendor/syn/src/item.rs
+++ b/vendor/syn/src/item.rs
@@ -898,96 +898,76 @@ pub(crate) mod parsing {
impl Parse for Item {
fn parse(input: ParseStream) -> Result<Self> {
let begin = input.fork();
- let mut attrs = input.call(Attribute::parse_outer)?;
- let ahead = input.fork();
- let vis: Visibility = ahead.parse()?;
+ let attrs = input.call(Attribute::parse_outer)?;
+ parse_rest_of_item(begin, attrs, input)
+ }
+ }
+ pub(crate) fn parse_rest_of_item(
+ begin: ParseBuffer,
+ mut attrs: Vec<Attribute>,
+ input: ParseStream,
+ ) -> Result<Item> {
+ let ahead = input.fork();
+ let vis: Visibility = ahead.parse()?;
+
+ let lookahead = ahead.lookahead1();
+ let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) {
+ let vis: Visibility = input.parse()?;
+ let sig: Signature = input.parse()?;
+ if input.peek(Token![;]) {
+ input.parse::<Token![;]>()?;
+ Ok(Item::Verbatim(verbatim::between(&begin, input)))
+ } else {
+ parse_rest_of_fn(input, Vec::new(), vis, sig).map(Item::Fn)
+ }
+ } else if lookahead.peek(Token![extern]) {
+ ahead.parse::<Token![extern]>()?;
let lookahead = ahead.lookahead1();
- let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) {
- let vis: Visibility = input.parse()?;
- let sig: Signature = input.parse()?;
- if input.peek(Token![;]) {
- input.parse::<Token![;]>()?;
- Ok(Item::Verbatim(verbatim::between(begin, input)))
- } else {
- parse_rest_of_fn(input, Vec::new(), vis, sig).map(Item::Fn)
- }
- } else if lookahead.peek(Token![extern]) {
- ahead.parse::<Token![extern]>()?;
+ if lookahead.peek(Token![crate]) {
+ input.parse().map(Item::ExternCrate)
+ } else if lookahead.peek(token::Brace) {
+ input.parse().map(Item::ForeignMod)
+ } else if lookahead.peek(LitStr) {
+ ahead.parse::<LitStr>()?;
let lookahead = ahead.lookahead1();
- if lookahead.peek(Token![crate]) {
- input.parse().map(Item::ExternCrate)
- } else if lookahead.peek(token::Brace) {
+ if lookahead.peek(token::Brace) {
input.parse().map(Item::ForeignMod)
- } else if lookahead.peek(LitStr) {
- ahead.parse::<LitStr>()?;
- let lookahead = ahead.lookahead1();
- if lookahead.peek(token::Brace) {
- input.parse().map(Item::ForeignMod)
- } else {
- Err(lookahead.error())
- }
} else {
Err(lookahead.error())
}
- } else if lookahead.peek(Token![use]) {
- let allow_crate_root_in_path = true;
- match parse_item_use(input, allow_crate_root_in_path)? {
- Some(item_use) => Ok(Item::Use(item_use)),
- None => Ok(Item::Verbatim(verbatim::between(begin, input))),
- }
- } else if lookahead.peek(Token![static]) {
- let vis = input.parse()?;
- let static_token = input.parse()?;
- let mutability = input.parse()?;
- let ident = input.parse()?;
- if input.peek(Token![=]) {
- input.parse::<Token![=]>()?;
- input.parse::<Expr>()?;
- input.parse::<Token![;]>()?;
- Ok(Item::Verbatim(verbatim::between(begin, input)))
- } else {
- let colon_token = input.parse()?;
- let ty = input.parse()?;
- if input.peek(Token![;]) {
- input.parse::<Token![;]>()?;
- Ok(Item::Verbatim(verbatim::between(begin, input)))
- } else {
- Ok(Item::Static(ItemStatic {
- attrs: Vec::new(),
- vis,
- static_token,
- mutability,
- ident,
- colon_token,
- ty,
- eq_token: input.parse()?,
- expr: input.parse()?,
- semi_token: input.parse()?,
- }))
- }
- }
- } else if lookahead.peek(Token![const]) {
- let vis = input.parse()?;
- let const_token: Token![const] = input.parse()?;
- let lookahead = input.lookahead1();
- let ident = if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
- input.call(Ident::parse_any)?
- } else {
- return Err(lookahead.error());
- };
+ } else {
+ Err(lookahead.error())
+ }
+ } else if lookahead.peek(Token![use]) {
+ let allow_crate_root_in_path = true;
+ match parse_item_use(input, allow_crate_root_in_path)? {
+ Some(item_use) => Ok(Item::Use(item_use)),
+ None => Ok(Item::Verbatim(verbatim::between(&begin, input))),
+ }
+ } else if lookahead.peek(Token![static]) {
+ let vis = input.parse()?;
+ let static_token = input.parse()?;
+ let mutability = input.parse()?;
+ let ident = input.parse()?;
+ if input.peek(Token![=]) {
+ input.parse::<Token![=]>()?;
+ input.parse::<Expr>()?;
+ input.parse::<Token![;]>()?;
+ Ok(Item::Verbatim(verbatim::between(&begin, input)))
+ } else {
let colon_token = input.parse()?;
let ty = input.parse()?;
if input.peek(Token![;]) {
input.parse::<Token![;]>()?;
- Ok(Item::Verbatim(verbatim::between(begin, input)))
+ Ok(Item::Verbatim(verbatim::between(&begin, input)))
} else {
- Ok(Item::Const(ItemConst {
+ Ok(Item::Static(ItemStatic {
attrs: Vec::new(),
vis,
- const_token,
+ static_token,
+ mutability,
ident,
- generics: Generics::default(),
colon_token,
ty,
eq_token: input.parse()?,
@@ -995,69 +975,97 @@ pub(crate) mod parsing {
semi_token: input.parse()?,
}))
}
- } else if lookahead.peek(Token![unsafe]) {
- ahead.parse::<Token![unsafe]>()?;
- let lookahead = ahead.lookahead1();
- if lookahead.peek(Token![trait])
- || lookahead.peek(Token![auto]) && ahead.peek2(Token![trait])
- {
- input.parse().map(Item::Trait)
- } else if lookahead.peek(Token![impl]) {
- let allow_verbatim_impl = true;
- if let Some(item) = parse_impl(input, allow_verbatim_impl)? {
- Ok(Item::Impl(item))
- } else {
- Ok(Item::Verbatim(verbatim::between(begin, input)))
- }
- } else if lookahead.peek(Token![extern]) {
- input.parse().map(Item::ForeignMod)
- } else if lookahead.peek(Token![mod]) {
- input.parse().map(Item::Mod)
- } else {
- Err(lookahead.error())
- }
- } else if lookahead.peek(Token![mod]) {
- input.parse().map(Item::Mod)
- } else if lookahead.peek(Token![type]) {
- parse_item_type(begin, input)
- } else if lookahead.peek(Token![struct]) {
- input.parse().map(Item::Struct)
- } else if lookahead.peek(Token![enum]) {
- input.parse().map(Item::Enum)
- } else if lookahead.peek(Token![union]) && ahead.peek2(Ident) {
- input.parse().map(Item::Union)
- } else if lookahead.peek(Token![trait]) {
- input.call(parse_trait_or_trait_alias)
- } else if lookahead.peek(Token![auto]) && ahead.peek2(Token![trait]) {
- input.parse().map(Item::Trait)
- } else if lookahead.peek(Token![impl])
- || lookahead.peek(Token![default]) && !ahead.peek2(Token![!])
+ }
+ } else if lookahead.peek(Token![const]) {
+ let vis = input.parse()?;
+ let const_token: Token![const] = input.parse()?;
+ let lookahead = input.lookahead1();
+ let ident = if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
+ input.call(Ident::parse_any)?
+ } else {
+ return Err(lookahead.error());
+ };
+ let colon_token = input.parse()?;
+ let ty = input.parse()?;
+ if input.peek(Token![;]) {
+ input.parse::<Token![;]>()?;
+ Ok(Item::Verbatim(verbatim::between(&begin, input)))
+ } else {
+ Ok(Item::Const(ItemConst {
+ attrs: Vec::new(),
+ vis,
+ const_token,
+ ident,
+ generics: Generics::default(),
+ colon_token,
+ ty,
+ eq_token: input.parse()?,
+ expr: input.parse()?,
+ semi_token: input.parse()?,
+ }))
+ }
+ } else if lookahead.peek(Token![unsafe]) {
+ ahead.parse::<Token![unsafe]>()?;
+ let lookahead = ahead.lookahead1();
+ if lookahead.peek(Token![trait])
+ || lookahead.peek(Token![auto]) && ahead.peek2(Token![trait])
{
+ input.parse().map(Item::Trait)
+ } else if lookahead.peek(Token![impl]) {
let allow_verbatim_impl = true;
if let Some(item) = parse_impl(input, allow_verbatim_impl)? {
Ok(Item::Impl(item))
} else {
- Ok(Item::Verbatim(verbatim::between(begin, input)))
+ Ok(Item::Verbatim(verbatim::between(&begin, input)))
}
- } else if lookahead.peek(Token![macro]) {
- input.advance_to(&ahead);
- parse_macro2(begin, vis, input)
- } else if vis.is_inherited()
- && (lookahead.peek(Ident)
- || lookahead.peek(Token![self])
- || lookahead.peek(Token![super])
- || lookahead.peek(Token![crate])
- || lookahead.peek(Token![::]))
- {
- input.parse().map(Item::Macro)
+ } else if lookahead.peek(Token![extern]) {
+ input.parse().map(Item::ForeignMod)
+ } else if lookahead.peek(Token![mod]) {
+ input.parse().map(Item::Mod)
} else {
Err(lookahead.error())
- }?;
+ }
+ } else if lookahead.peek(Token![mod]) {
+ input.parse().map(Item::Mod)
+ } else if lookahead.peek(Token![type]) {
+ parse_item_type(begin, input)
+ } else if lookahead.peek(Token![struct]) {
+ input.parse().map(Item::Struct)
+ } else if lookahead.peek(Token![enum]) {
+ input.parse().map(Item::Enum)
+ } else if lookahead.peek(Token![union]) && ahead.peek2(Ident) {
+ input.parse().map(Item::Union)
+ } else if lookahead.peek(Token![trait]) {
+ input.call(parse_trait_or_trait_alias)
+ } else if lookahead.peek(Token![auto]) && ahead.peek2(Token![trait]) {
+ input.parse().map(Item::Trait)
+ } else if lookahead.peek(Token![impl])
+ || lookahead.peek(Token![default]) && !ahead.peek2(Token![!])
+ {
+ let allow_verbatim_impl = true;
+ if let Some(item) = parse_impl(input, allow_verbatim_impl)? {
+ Ok(Item::Impl(item))
+ } else {
+ Ok(Item::Verbatim(verbatim::between(&begin, input)))
+ }
+ } else if lookahead.peek(Token![macro]) {
+ input.advance_to(&ahead);
+ parse_macro2(begin, vis, input)
+ } else if vis.is_inherited()
+ && (lookahead.peek(Ident)
+ || lookahead.peek(Token![self])
+ || lookahead.peek(Token![super])
+ || lookahead.peek(Token![crate])
+ || lookahead.peek(Token![::]))
+ {
+ input.parse().map(Item::Macro)
+ } else {
+ Err(lookahead.error())
+ }?;
- attrs.extend(item.replace_attrs(Vec::new()));
- item.replace_attrs(attrs);
- Ok(item)
- }
+ attrs.extend(item.replace_attrs(Vec::new()));
+ item.replace_attrs(attrs);
+ Ok(item)
}
struct FlexibleItemType {
@@ -1219,7 +1227,7 @@ pub(crate) mod parsing {
return Err(lookahead.error());
}
- Ok(Item::Verbatim(verbatim::between(begin, input)))
+ Ok(Item::Verbatim(verbatim::between(&begin, input)))
}
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
@@ -1340,22 +1348,28 @@ pub(crate) mod parsing {
let content;
let brace_token = braced!(content in input);
let mut items = Punctuated::new();
- let mut has_crate_root_in_path = false;
+ let mut has_any_crate_root_in_path = false;
loop {
if content.is_empty() {
break;
}
- has_crate_root_in_path |=
+ let this_tree_starts_with_crate_root =
allow_crate_root_in_path && content.parse::<Option<Token![::]>>()?.is_some();
- let tree: UseTree = content.parse()?;
- items.push_value(tree);
+ has_any_crate_root_in_path |= this_tree_starts_with_crate_root;
+ match parse_use_tree(
+ &content,
+ allow_crate_root_in_path && !this_tree_starts_with_crate_root,
+ )? {
+ Some(tree) => items.push_value(tree),
+ None => has_any_crate_root_in_path = true,
+ }
if content.is_empty() {
break;
}
let comma: Token![,] = content.parse()?;
items.push_punct(comma);
}
- if has_crate_root_in_path {
+ if has_any_crate_root_in_path {
Ok(None)
} else {
Ok(Some(UseTree::Group(UseGroup { brace_token, items })))
@@ -1753,7 +1767,7 @@ pub(crate) mod parsing {
content.call(Attribute::parse_inner)?;
content.call(Block::parse_within)?;
- Ok(ForeignItem::Verbatim(verbatim::between(begin, input)))
+ Ok(ForeignItem::Verbatim(verbatim::between(&begin, input)))
} else {
Ok(ForeignItem::Fn(ForeignItemFn {
attrs: Vec::new(),
@@ -1773,7 +1787,7 @@ pub(crate) mod parsing {
input.parse::<Token![=]>()?;
input.parse::<Expr>()?;
input.parse::<Token![;]>()?;
- Ok(ForeignItem::Verbatim(verbatim::between(begin, input)))
+ Ok(ForeignItem::Verbatim(verbatim::between(&begin, input)))
} else {
Ok(ForeignItem::Static(ForeignItemStatic {
attrs: Vec::new(),
@@ -1882,7 +1896,7 @@ pub(crate) mod parsing {
)?;
if colon_token.is_some() || ty.is_some() {
- Ok(ForeignItem::Verbatim(verbatim::between(begin, input)))
+ Ok(ForeignItem::Verbatim(verbatim::between(&begin, input)))
} else {
Ok(ForeignItem::Type(ForeignItemType {
attrs: Vec::new(),
@@ -1952,7 +1966,7 @@ pub(crate) mod parsing {
let (eq_token, ty) = match ty {
Some(ty) if colon_token.is_none() => ty,
- _ => return Ok(Item::Verbatim(verbatim::between(begin, input))),
+ _ => return Ok(Item::Verbatim(verbatim::between(&begin, input))),
};
Ok(Item::Type(ItemType {
@@ -2240,7 +2254,7 @@ pub(crate) mod parsing {
match (vis, defaultness) {
(Visibility::Inherited, None) => {}
- _ => return Ok(TraitItem::Verbatim(verbatim::between(begin, input))),
+ _ => return Ok(TraitItem::Verbatim(verbatim::between(&begin, input))),
}
let item_attrs = match &mut item {
@@ -2358,7 +2372,7 @@ pub(crate) mod parsing {
)?;
if vis.is_some() {
- Ok(TraitItem::Verbatim(verbatim::between(begin, input)))
+ Ok(TraitItem::Verbatim(verbatim::between(&begin, input)))
} else {
Ok(TraitItem::Type(TraitItemType {
attrs: Vec::new(),
@@ -2471,7 +2485,7 @@ pub(crate) mod parsing {
self_ty = if polarity.is_none() {
first_ty
} else {
- Type::Verbatim(verbatim::between(begin, input))
+ Type::Verbatim(verbatim::between(&begin, input))
};
}
@@ -2525,7 +2539,7 @@ pub(crate) mod parsing {
if let Some(item) = parse_impl_item_fn(input, allow_omitted_body)? {
Ok(ImplItem::Fn(item))
} else {
- Ok(ImplItem::Verbatim(verbatim::between(begin, input)))
+ Ok(ImplItem::Verbatim(verbatim::between(&begin, input)))
}
} else if lookahead.peek(Token![const]) {
input.advance_to(&ahead);
@@ -2554,7 +2568,7 @@ pub(crate) mod parsing {
}));
} else {
input.parse::<Token![;]>()?;
- return Ok(ImplItem::Verbatim(verbatim::between(begin, input)));
+ return Ok(ImplItem::Verbatim(verbatim::between(&begin, input)));
}
} else if lookahead.peek(Token![type]) {
parse_impl_item_type(begin, input)
@@ -2700,7 +2714,7 @@ pub(crate) mod parsing {
let (eq_token, ty) = match ty {
Some(ty) if colon_token.is_none() => ty,
- _ => return Ok(ImplItem::Verbatim(verbatim::between(begin, input))),
+ _ => return Ok(ImplItem::Verbatim(verbatim::between(&begin, input))),
};
Ok(ImplItem::Type(ImplItemType {
diff --git a/vendor/syn/src/lib.rs b/vendor/syn/src/lib.rs
index aeeb37ef9..b9fd8073f 100644
--- a/vendor/syn/src/lib.rs
+++ b/vendor/syn/src/lib.rs
@@ -249,7 +249,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/2.0.18")]
+#![doc(html_root_url = "https://docs.rs/syn/2.0.28")]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![allow(non_camel_case_types)]
#![allow(
@@ -373,6 +373,7 @@ pub use crate::generics::{
pub use crate::generics::{ImplGenerics, Turbofish, TypeGenerics};
mod ident;
+#[doc(inline)]
pub use crate::ident::Ident;
#[cfg(feature = "full")]
@@ -388,9 +389,11 @@ pub use crate::item::{
};
mod lifetime;
+#[doc(inline)]
pub use crate::lifetime::Lifetime;
mod lit;
+#[doc(inline)]
pub use crate::lit::{
Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, StrStyle,
};
diff --git a/vendor/syn/src/lit.rs b/vendor/syn/src/lit.rs
index 662ef8b22..4f36cf50b 100644
--- a/vendor/syn/src/lit.rs
+++ b/vendor/syn/src/lit.rs
@@ -228,7 +228,17 @@ impl LitStr {
let mut tokens = TokenStream::from_str(&self.value())?;
tokens = respan_token_stream(tokens, self.span());
- parser.parse2(tokens)
+ let result = parser.parse2(tokens)?;
+
+ let suffix = self.suffix();
+ if !suffix.is_empty() {
+ return Err(Error::new(
+ self.span(),
+ format!("unexpected suffix `{}` on string literal", suffix),
+ ));
+ }
+
+ Ok(result)
}
pub fn span(&self) -> Span {
@@ -1166,7 +1176,7 @@ mod value {
b'x' => {
let (byte, rest) = backslash_x(s);
s = rest;
- assert!(byte <= 0x80, "Invalid \\x byte in string literal");
+ assert!(byte <= 0x7F, "Invalid \\x byte in string literal");
char::from_u32(u32::from(byte)).unwrap()
}
b'u' => {
@@ -1273,8 +1283,7 @@ mod value {
b'"' => b'"',
b'\r' | b'\n' => loop {
let byte = byte(v, 0);
- let ch = char::from_u32(u32::from(byte)).unwrap();
- if ch.is_whitespace() {
+ if matches!(byte, b' ' | b'\t' | b'\n' | b'\r') {
v = &v[1..];
} else {
continue 'outer;
diff --git a/vendor/syn/src/pat.rs b/vendor/syn/src/pat.rs
index 2e6376b2f..df7da5bbe 100644
--- a/vendor/syn/src/pat.rs
+++ b/vendor/syn/src/pat.rs
@@ -422,7 +422,7 @@ pub(crate) mod parsing {
fn pat_box(begin: ParseBuffer, input: ParseStream) -> Result<Pat> {
input.parse::<Token![box]>()?;
Pat::parse_single(input)?;
- Ok(Pat::Verbatim(verbatim::between(begin, input)))
+ Ok(Pat::Verbatim(verbatim::between(&begin, input)))
}
fn pat_ident(input: ParseStream) -> Result<PatIdent> {
@@ -544,7 +544,7 @@ pub(crate) mod parsing {
};
let pat = if boxed.is_some() {
- Pat::Verbatim(verbatim::between(begin, input))
+ Pat::Verbatim(verbatim::between(&begin, input))
} else {
Pat::Ident(PatIdent {
attrs: Vec::new(),
@@ -762,7 +762,7 @@ pub(crate) mod parsing {
content.call(Attribute::parse_inner)?;
content.call(Block::parse_within)?;
- Ok(verbatim::between(begin, input))
+ Ok(verbatim::between(&begin, input))
}
}
diff --git a/vendor/syn/src/path.rs b/vendor/syn/src/path.rs
index e99a3f87d..883f179f5 100644
--- a/vendor/syn/src/path.rs
+++ b/vendor/syn/src/path.rs
@@ -53,8 +53,9 @@ impl Path {
/// }
/// }
/// ```
- pub fn is_ident<I: ?Sized>(&self, ident: &I) -> bool
+ pub fn is_ident<I>(&self, ident: &I) -> bool
where
+ I: ?Sized,
Ident: PartialEq<I>,
{
match self.get_ident() {
@@ -368,7 +369,6 @@ pub(crate) mod parsing {
return Ok(Expr::Lit(lit));
}
- #[cfg(feature = "full")]
if input.peek(Ident) {
let ident: Ident = input.parse()?;
return Ok(Expr::Path(ExprPath {
@@ -391,7 +391,7 @@ pub(crate) mod parsing {
let content;
braced!(content in input);
content.parse::<Expr>()?;
- let verbatim = verbatim::between(begin, input);
+ let verbatim = verbatim::between(&begin, input);
return Ok(Expr::Verbatim(verbatim));
}
}
@@ -649,6 +649,10 @@ pub(crate) mod parsing {
pub(crate) mod printing {
use super::*;
use crate::print::TokensOrDefault;
+ #[cfg(feature = "parsing")]
+ use crate::spanned::Spanned;
+ #[cfg(feature = "parsing")]
+ use proc_macro2::Span;
use proc_macro2::TokenStream;
use quote::ToTokens;
use std::cmp;
@@ -692,10 +696,21 @@ pub(crate) mod printing {
GenericArgument::Lifetime(lt) => lt.to_tokens(tokens),
GenericArgument::Type(ty) => ty.to_tokens(tokens),
GenericArgument::Const(expr) => match expr {
- Expr::Lit(_) => expr.to_tokens(tokens),
+ Expr::Lit(expr) => expr.to_tokens(tokens),
+
+ Expr::Path(expr)
+ if expr.attrs.is_empty()
+ && expr.qself.is_none()
+ && expr.path.get_ident().is_some() =>
+ {
+ expr.to_tokens(tokens);
+ }
#[cfg(feature = "full")]
- Expr::Block(_) => expr.to_tokens(tokens),
+ Expr::Block(expr) => expr.to_tokens(tokens),
+
+ #[cfg(not(feature = "full"))]
+ Expr::Verbatim(expr) => expr.to_tokens(tokens),
// ERROR CORRECTION: Add braces to make sure that the
// generated code is valid.
@@ -826,4 +841,21 @@ pub(crate) mod printing {
segment.to_tokens(tokens);
}
}
+
+ #[cfg(feature = "parsing")]
+ #[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "printing"))))]
+ impl Spanned for QSelf {
+ fn span(&self) -> Span {
+ struct QSelfDelimiters<'a>(&'a QSelf);
+
+ impl<'a> ToTokens for QSelfDelimiters<'a> {
+ fn to_tokens(&self, tokens: &mut TokenStream) {
+ self.0.lt_token.to_tokens(tokens);
+ self.0.gt_token.to_tokens(tokens);
+ }
+ }
+
+ QSelfDelimiters(self).span()
+ }
+ }
}
diff --git a/vendor/syn/src/punctuated.rs b/vendor/syn/src/punctuated.rs
index a4278081c..3ea8a1d4e 100644
--- a/vendor/syn/src/punctuated.rs
+++ b/vendor/syn/src/punctuated.rs
@@ -369,6 +369,11 @@ where
last: self.last.clone(),
}
}
+
+ fn clone_from(&mut self, other: &Self) {
+ self.inner.clone_from(&other.inner);
+ self.last.clone_from(&other.last);
+ }
}
#[cfg(feature = "extra-traits")]
diff --git a/vendor/syn/src/spanned.rs b/vendor/syn/src/spanned.rs
index 7e101d264..98aa0aa1e 100644
--- a/vendor/syn/src/spanned.rs
+++ b/vendor/syn/src/spanned.rs
@@ -112,4 +112,7 @@ mod private {
pub trait Sealed {}
impl<T: ?Sized + ToTokens> Sealed for T {}
+
+ #[cfg(any(feature = "full", feature = "derive"))]
+ impl Sealed for crate::QSelf {}
}
diff --git a/vendor/syn/src/stmt.rs b/vendor/syn/src/stmt.rs
index b5434f7ce..fb67feccb 100644
--- a/vendor/syn/src/stmt.rs
+++ b/vendor/syn/src/stmt.rs
@@ -180,7 +180,8 @@ pub(crate) mod parsing {
}
fn parse_stmt(input: ParseStream, allow_nosemi: AllowNoSemi) -> Result<Stmt> {
- let mut attrs = input.call(Attribute::parse_outer)?;
+ let begin = input.fork();
+ let attrs = input.call(Attribute::parse_outer)?;
// brace-style macros; paren and bracket macros get parsed as
// expression statements.
@@ -238,9 +239,7 @@ pub(crate) mod parsing {
|| input.peek(Token![macro])
|| is_item_macro
{
- let mut item: Item = input.parse()?;
- attrs.extend(item.replace_attrs(Vec::new()));
- item.replace_attrs(attrs);
+ let item = item::parsing::parse_rest_of_item(begin, attrs, input)?;
Ok(Stmt::Item(item))
} else {
stmt_expr(input, allow_nosemi, attrs)
diff --git a/vendor/syn/src/thread.rs b/vendor/syn/src/thread.rs
index 63fdea834..b33d248af 100644
--- a/vendor/syn/src/thread.rs
+++ b/vendor/syn/src/thread.rs
@@ -12,6 +12,9 @@ pub(crate) struct ThreadBound<T> {
unsafe impl<T> Sync for ThreadBound<T> {}
// Send bound requires Copy, as otherwise Drop could run in the wrong place.
+//
+// Today Copy and Drop are mutually exclusive so `T: Copy` implies `T: !Drop`.
+// This impl needs to be revisited if that restriction is relaxed in the future.
unsafe impl<T: Copy> Send for ThreadBound<T> {}
impl<T> ThreadBound<T> {
@@ -40,11 +43,18 @@ impl<T: Debug> Debug for ThreadBound<T> {
}
}
-impl<T: Clone> Clone for ThreadBound<T> {
+// Copy the bytes of T, even if the currently running thread is the "wrong"
+// thread. This is fine as long as the original thread is not simultaneously
+// mutating this value via interior mutability, which would be a data race.
+//
+// Currently `T: Copy` is sufficient to guarantee that T contains no interior
+// mutability, because _all_ interior mutability in Rust is built on
+// std::cell::UnsafeCell, which has no Copy impl. This impl needs to be
+// revisited if that restriction is relaxed in the future.
+impl<T: Copy> Copy for ThreadBound<T> {}
+
+impl<T: Copy> Clone for ThreadBound<T> {
fn clone(&self) -> Self {
- ThreadBound {
- value: self.value.clone(),
- thread_id: self.thread_id,
- }
+ *self
}
}
diff --git a/vendor/syn/src/ty.rs b/vendor/syn/src/ty.rs
index 9282ba4e6..0f41fe4fa 100644
--- a/vendor/syn/src/ty.rs
+++ b/vendor/syn/src/ty.rs
@@ -525,7 +525,7 @@ pub(crate) mod parsing {
let star_token: Option<Token![*]> = input.parse()?;
let bounds = TypeTraitObject::parse_bounds(dyn_span, input, allow_plus)?;
return Ok(if star_token.is_some() {
- Type::Verbatim(verbatim::between(begin, input))
+ Type::Verbatim(verbatim::between(&begin, input))
} else {
Type::TraitObject(TypeTraitObject {
dyn_token: Some(dyn_token),
@@ -947,7 +947,7 @@ pub(crate) mod parsing {
Some(ty) if !has_mut_self => ty,
_ => {
name = None;
- Type::Verbatim(verbatim::between(begin, input))
+ Type::Verbatim(verbatim::between(&begin, input))
}
};
diff --git a/vendor/syn/src/verbatim.rs b/vendor/syn/src/verbatim.rs
index 436d87343..54dc1cfa0 100644
--- a/vendor/syn/src/verbatim.rs
+++ b/vendor/syn/src/verbatim.rs
@@ -1,9 +1,9 @@
-use crate::parse::{ParseBuffer, ParseStream};
+use crate::parse::ParseStream;
use proc_macro2::{Delimiter, TokenStream};
use std::cmp::Ordering;
use std::iter;
-pub(crate) fn between<'a>(begin: ParseBuffer<'a>, end: ParseStream<'a>) -> TokenStream {
+pub(crate) fn between<'a>(begin: ParseStream<'a>, end: ParseStream<'a>) -> TokenStream {
let end = end.cursor();
let mut cursor = begin.cursor();
assert!(crate::buffer::same_buffer(end, cursor));