Update Rust crate syn to v3#108
Open
renovate[bot] wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
Test plan: CI should pass with updated dependencies. No review required: this is an automated dependency update PR.
Release Notes
dtolnay/syn (syn)
v3.0.0Compare Source
This release contains adjustments to the syntax tree to account for ongoing Rust language development from the 3 years since syn 2.0.0 and to anticipate some in-flight Rust language RFCs.
These include: default values in fields, pinned type sugar, raw lifetimes, generator blocks and functions, unnamed enum variants, attributes in tuple types and tuple patterns, named arguments in parenthesized generic argument lists, lightweight clones, const traits, const function pointers, mutability restricted fields, supertrait auto implementation, final associated functions, trait implementability restrictions, const blocks in path arguments, item-level const blocks, return type notation, never patterns, function delegation, mutable by-reference bindings, in-place initialization, field projections, explicitly dyn-compatible traits, view types, file-level frontmatter, generic const arguments, guard patterns, lazy type aliases, explicitly safe foreign items, super let, unsafe fields, pattern types, heterogeneous try-blocks, function contracts, async function trait bounds, static closure coroutine syntax, unsafe binder types, move expressions, for-await loops, and postfix keywords.
[API documentation for 3.0]
Breaking changes
Modifiers
To reserve more room for language evolution, there are 10 new non-exhaustive structs in the syntax tree having the following commonality:
Name ending in
Modifiers. {BlockModifiers,ClosureModifiers,ConstModifiers,FieldModifiers,FnModifiers,ImplModifiers,LocalModifiers,TraitBoundModifiers,TraitModifiers,TypeModifiers}Each implements
Default. The default value is guaranteed to comprise no tokens.Non-exhaustive. Can only be instantiated by Syn's parser or by creating and then mutating
▁▁Modifiers::default().Does not implement
Parse. When parsing, they are parsed by the enclosing syntax tree node.Does not implement
ToTokens. In some cases the syntax that these nodes might hold in the future is not necessarily contiguous tokens.Provides
.require_empty() -> Result<()>which returns a meaningfully spanned error if the modifiers are different from the empty default. This enables a caller to reject syntax it does not recognize without knowing what that syntax may be.Types
Type::BareFnhas been renamed toType::FnPtrto mirror the compiler's terminology. Together with this,BareVariadicis renamed toFnPtrVariadic.The mutually exclusive
const_tokenandmutabilityfields ofType::Ptrhave been unified into an enum of typePointerMutability, which was already previously used byExpr::RawAddr.Every
Typevariant now holds attributes, which can represent the attributes of element types inside a tuple type, or attributes for a function return type.BareFnArgis renamed toNamedArgand is used inParenthesizedGenericArguments, in addition to the existing use inType::FnPtr.Expressions
Expr::Closure, the fieldsor1_tokenandor2_tokenhave been renamed toinputs_beginandinputs_endto indicate the beginning and ending|token of the closure inputs.Statements
Patterns
guardfield ofArmis replaced by a newPat::Guardvariant held in the arm'spat.Items
The
unsafetyfield ofSignature, which represented the presence or absence ofunsafe, is replaced by a 3-waySafetyenum which may be safe, unsafe, or default.ForeignItem::Staticalso gets aSafety.Some of the fields of
Receiverhave been split to a non-exhaustiveReceiverKindenum to create room for proposed new kinds of method receivers, such as pinned.Type aliases now hold a
WhereClausePlacementto distinguish between early placement (which is the default for item-level type aliases and is deprecated in associated type aliases) and late placement (which is the default for associated type aliases and is unstable in item-level type aliases). Parsing and printing a syntax tree will now preserve the where-clause placement rather than rewriting it to the default placement for the item kind.Generics
WherePredicate::LifetimeandWherePredicate::Typehave a new field holding the attributes on the where-predicates.GenericParam::TypeandGenericParam::Constnow match the rest of the syntax tree in holding their optional default using a single Option of tuple, rather than a pair of Option.Literals
The
Parseimplementation ofLifetimeno longer permits keyword lifetimes, matching a change in Rust 1.81 to deny such lifetimes pre-expansion.Lifetime::parse_anymay be used to parse lifetimes permissive of keywords.LitIntandLitFloatno longer implementFrom<proc_macro2::Literal>. UseLit::new(literal)and then matchLit::IntorLit::Float.The
StrStyleenum was unused and has been deleted.More
Filecontains a newOption<Frontmatter>, but does not yet parse frontmatter insyn::parse_fileuntil that language feature progresses closer to stabilization.Some enums no longer provide
Fromimpls. Construct the variant by name instead, such asExpr::Array(e)in place ofe.into().The
popmethod ofPunctuated<T, P>now returnsOption<T>discarding the trailing punctuation if any, rather thanOption<Pair<T, P>>. A new methodpop_pairprovides the old behavior.Syntax tree traversal (
visit,visit_mut,fold) no longer provides a method for processingSpan. This was already incompletely supported and never walked most of the spans in a syntax tree.The
SpeculativeandAnyDelimitertraits have been sealed and cannot be implemented for types outside of Syn'sParseStream.v2.0.119Compare Source
v2.0.118Compare Source
v2.0.117Compare Source
self::pattern in first function argument (#1970)v2.0.116Compare Source
v2.0.115Compare Source
v2.0.114Compare Source
v2.0.113Compare Source
v2.0.112Compare Source
v2.0.111Compare Source
braced!,bracketed!,parenthesized!to be an otherwise unused variable (#1946)v2.0.110Compare Source
syn::ext::IdentExt::unrawavailable without "parsing" feature (#1940)syn::Metafollowed by=>(#1944)v2.0.109Compare Source
v2.0.108Compare Source
v2.0.107Compare Source
v2.0.106Compare Source
~constsyntax with[const]conditionally const syntax in trait bounds (#1896, rust-lang/rust#139858)v2.0.105Compare Source
impl !T {}(#1881, rust-lang/rust#144386)v2.0.104Compare Source
v2.0.103Compare Source
v2.0.102Compare Source
v2.0.101Compare Source
v2.0.100Compare Source
Visit::visit_token_stream,VisitMut::visit_token_stream_mut,Fold::fold_token_streamfor processing TokenStream during syntax tree traversals (#1852)v2.0.99Compare Source
v2.0.98Compare Source
ParseStream::callandPunctuatedparsers (#1847)v2.0.97Compare Source
v2.0.96Compare Source
v2.0.95Compare Source
v2.0.94Compare Source
v2.0.93Compare Source
x as T <<= y(#1804),break as T(#1805),match x { _ if .. => {} }(#1807)|| -> T 'a: {}(#1806),if break x {}(#1808, #1810)v2.0.92Compare Source
v2.0.91Compare Source
Vec<Arm>usingparse_quote!(#1796, #1797)v2.0.90Compare Source
(#[attr] thing).field(#1785)(thing.field)()andthing.0()(#1786)v2.0.89Compare Source
v2.0.88Compare Source
parse_str(#1783)v2.0.87Compare Source
Cursor::any_group(#1777)Expr::peek(#1778)v2.0.86Compare Source
parse_quote!to produce Vec<Attribute> (#1775)v2.0.85Compare Source
v2.0.84Compare Source
impl Sized + use<Self>(#1772)v2.0.83Compare Source
v2.0.82Compare Source
Parseimpls for PreciseCapture and CapturedParam (#1757, #1758)unsafeattributes (#1759)v2.0.81Compare Source
impl Trait + use<'a, T>(#1752, #1753, #1754)v2.0.80Compare Source
Expr::RawAddr(#1743)v2.0.79Compare Source
useitems containing absolute paths (#1742)v2.0.78Compare Source
v2.0.77Compare Source
Expr::Tuplein non-"full" mode (#1727)v2.0.76Compare Source
becomekeyword is followed by an expression (#1725)v2.0.75Compare Source
v2.0.74Compare Source
Genericsiterator methods (#1719)v2.0.73Compare Source
Fields::membersiterator (#1716, thanks @Fancyflame)v2.0.72Compare Source
use<'a, T>precise capturing bounds (#1707, thanks @compiler-errors)v2.0.71Compare Source
v2.0.70Compare Source
v2.0.69Compare Source
Punctuated::getandget_mut(#1693)v2.0.68Compare Source
parse_quote!parses invalid syntax (#1690, thanks @stepancheg)GroupandLifetime(#1687)v2.0.67Compare Source
LitCStrin ParseStream::peek (#1682)v2.0.66Compare Source
v2.0.65Compare Source
Foldto compile faster (#1666, #1667, #1668)v2.0.64Compare Source
catch_unwind(#1646)breakandreturnin loop headers (#1656)v2.0.63Compare Source
v2.0.62Compare Source
v2.0.61Compare Source
v2.0.60Compare Source
peek(#1625)v2.0.59Compare Source
c"…"andcr"…"C-string literal syntax asLit::CStr(#1502)v2.0.58Compare Source
$incustom_punctuation!macro (#1611)v2.0.57Compare Source
quotewhen built with default-features disabled and the "proc-macro" feature enabled (#1608, thanks @BD103)v2.0.56Compare Source
v2.0.55Compare Source
v2.0.54Compare Source
custom_keyword!with syn's "printing" feature disabled (#1602)v2.0.53Compare Source
v2.0.52Compare Source
v2.0.51Compare Source
v2.0.50Compare Source
v2.0.49Compare Source
LitStr::parse(#1590)v2.0.48Compare Source
else(#1578)v2.0.47Compare Source
v2.0.46Compare Source
v2.0.45Compare Source
DeriveInputasExpr::Verbatimin non-"full" mode, instead of error (#1513)PatTypewithparse_quote!(#1573)v2.0.44Compare Source
v2.0.43Compare Source
v2.0.42Compare Source
v2.0.41Compare Source
parse_quote!(#1548)v2.0.40Compare Source
v2.0.39Compare Source
v2.0.38Compare Source
boolas a custom keyword (#1518, thanks @Vanille-N)v2.0.37Compare Source
v2.0.36Compare Source
--generate-link-to-definitiondocumentation builds (#1514)v2.0.35Compare Source
Token!macro (#1510, #1512)v2.0.34Compare Source
v2.0.33Compare Source
(/*ERROR*/)placeholder that rustc uses for macros that fail to expandv2.0.32Compare Source
Path::require_identaccessor (#1496, thanks @Fancyflame)v2.0.31Compare Source
v2.0.30Compare Source
v2.0.29Compare Source
v2.0.28Compare Source
v2.0.27Compare Source
v2.0.26Compare Source
SpannedforQSelf(#1465)v2.0.25Compare Source
v2.0.24Compare Source
v2.0.23Compare Source
where [(); { T::COUNT }]:in non-"full" mode (#1478)v2.0.22Compare Source
c"…"c-string literals (tracking issue: rust-lang/rust#105723)v2.0.21Compare Source
LitByteStr::valuein the case of a cooked byte string literal containing form feed or vertical tab characters following an escaped newline (#1474)v2.0.20Compare Source
v2.0.19Compare Source
v2.0.18Compare Source
v2.0.17Compare Source
v2.0.16Compare Source
builtin #syntax as Expr::Verbatim (rust-lang/rust#110680, #1454)v2.0.15Compare Source
Type::Tupleof length 1 prints as a tuple even if trailing comma is not provided in the Punctuated (#1444, thanks @Fancyflame)v2.0.14Compare Source
v2.0.13Compare Source
v2.0.12Compare Source
compile_error!by absolute path in token stream produced by syn::Error::to_compile_error (#1431, thanks @smoelius)v2.0.11Compare Source
v2.0.10Compare Source
v2.0.9Compare Source
typeitems in an extern block, trait, or module from being markeddefaultimpl T { fn f(&self); }— omitted function bodies are allowed by TraitItemFn, but inimplblocks this syntax is now parsed as ImplItem::Verbatim rather than ImplItem::Fnv2.0.8Compare Source
trykeyword as 2015-edition identifier in definition of try macro (#1422)v2.0.7Compare Source
mut selfinside of Type::BareFnv2.0.6Compare Source
v2.0.5Compare Source
ExprMacrodata structure even whenfeatures="full"is not used (#1417)v2.0.4Compare Source
v2.0.3Compare Source
ExprGroupdata structure even whenfeatures="full"is not used (#1412)v2.0.2Compare Source
v2.0.1Compare Source
v2.0.0Compare Source
This release contains a batch of syntax tree improvements to incorporate ongoing Rust language development from the past 3.5 years since syn 1.
It never seems like an ideal time to finalize a syntax tree design, considering the frankly alarming number of syntax-disrupting language features currently in flight: keyword generics, restrictions, capabilities and contexts, conditional constness, new varieties of literals, dyn revamp such as explicitly dyn-safe traits and dyn-star, expression syntax in various phases of being added or being torn out (const blocks, try blocks, raw references), auto traits and negative impls, generalizations to higher rank trait bounds, async closures and static async trait methods, postfix keywords, pattern types, return type notation, unsafe attributes, …
The plan continues to be the same as laid out originally in the 1.0.0 release announcement:
If anything, the takeaway from the 3.5 year longevity of syn 1 is that this period was tamer from a language development perspective than anticipated, but that is unlikely to last and I think around 24 months is still the correct cadence to expect between releases going forward.
[API documentation for 2.0]
Breaking changes
Expressions
Support for
box exprsyntax has been deleted, as it has been deleted recently from rustc.Support for type ascription syntax
expr: Typein expression position has been deleted.Support for unstable
&raw const exprraw-pointer reference syntax has been deleted.The representation of generic arguments has been unified between method calls and non-method paths into a single
GenericArgumenttype, which supersedes the previousGenericMethodArgumentandMethodTurbofish.Generic arguments now distinguish between associated types (
AssocType) and associated constant values (AssocConst). Previously these would be parsed ambiguously asBinding.The binary assignment operators in
BinOphave been renamed to align with the naming used by the standard library'score::opsmodule's traits. For exampleBinOp::AddEqis now calledBinOp::AddAssign.Expr::Structstruct construction expressions now support structs which are a variant of an enum associated type of a trait, as in<Type as Trait>::Assoc::Variant { ... }, which has recently been added to Rust.Expr::Rangenow follows thestartandendnaming used by the standard library'sRangeBoundstrait, rather thanfrom/toorlo/hi.Expr::AssignOphas been merged intoExpr::Binary, which now represents both non-assignment and assignment binary operators.Stricter parsing of ranges. None of the following are valid expressions, but were previously accepted by syn:
..=,lo..=,...,...hi,lo...,lo...hi.Expr::Closurenow includes a representation forfor<...>lifetimes.Statements
Variants
Stmt::Expr(tail-position expression without trailing semicolon) andStmt::Semi(non-tail expression with trailing semicolon) have been combined intoStmt::Exprwith the optional semicolon represented byOption<Token![;]>.The syntax tree for
Stmt::Localhas been extended to handlelet/elsesyntax.Macros in statement position are now uniformly parsed as
Stmt::Macro. Previously these would be disambiguated toStmt::Item, although it was ambiguous whether a macro in statement position would expand to an item (likethread_local! { ... }) vs an expression (likeprintln! { ... }).Patterns
Pattern parsing for all the different syntactic positions in which patterns are allowed has been split into
Pat::parse_single(for function- and closure-argument position, where top-level|is not allowed),Pat::parse_multi(where|is allowed) andPat::parse_multi_with_leading_vert(for the pattern of match arms, which allow an optional leading|). Previously only a singleparsebehavior was supported and behaved like the newparse_single.The
Patsyntax tree now shares more common data structures with theExprsyntax tree where possible, such as for literals, paths, macros, and ranges in pattern position.Parsing of struct field patterns does a better job rejecting bogus syntax such
Configuration
📅 Schedule: (in timezone America/Los_Angeles)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.