Skip to content

Update Rust crate syn to v3#108

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/syn-3.x
Open

Update Rust crate syn to v3#108
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/syn-3.x

Conversation

@renovate

@renovate renovate Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

ℹ️ Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Type Update New value References Sourcegraph
syn dependencies major 3.0.0 source code search for "syn"

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.0

Compare 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::BareFn has been renamed to Type::FnPtr to mirror the compiler's terminology. Together with this, BareVariadic is renamed to FnPtrVariadic.

  • The mutually exclusive const_token and mutability fields of Type::Ptr have been unified into an enum of type PointerMutability, which was already previously used by Expr::RawAddr.

  • Every Type variant now holds attributes, which can represent the attributes of element types inside a tuple type, or attributes for a function return type.

  • BareFnArg is renamed to NamedArg and is used in ParenthesizedGenericArguments, in addition to the existing use in Type::FnPtr.

Expressions

  • In Expr::Closure, the fields or1_token and or2_token have been renamed to inputs_begin and inputs_end to indicate the beginning and ending | token of the closure inputs.

Statements

  • Attributes are now preserved on all expression kinds in statement position. Previously, parsing would silently lose attributes on some expression statements without a dedicated Expr variant, such as tail-call expressions.

Patterns

  • The guard field of Arm is replaced by a new Pat::Guard variant held in the arm's pat.

Items

  • The unsafety field of Signature, which represented the presence or absence of unsafe, is replaced by a 3-way Safety enum which may be safe, unsafe, or default. ForeignItem::Static also gets a Safety.

  • Some of the fields of Receiver have been split to a non-exhaustive ReceiverKind enum to create room for proposed new kinds of method receivers, such as pinned.

  • Type aliases now hold a WhereClausePlacement to 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::Lifetime and WherePredicate::Type have a new field holding the attributes on the where-predicates.

  • GenericParam::Type and GenericParam::Const now 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 Parse implementation of Lifetime no longer permits keyword lifetimes, matching a change in Rust 1.81 to deny such lifetimes pre-expansion. Lifetime::parse_any may be used to parse lifetimes permissive of keywords.

  • LitInt and LitFloat no longer implement From<proc_macro2::Literal>. Use Lit::new(literal) and then match Lit::Int or Lit::Float.

  • The StrStyle enum was unused and has been deleted.

More

  • File contains a new Option<Frontmatter>, but does not yet parse frontmatter in syn::parse_file until that language feature progresses closer to stabilization.

  • Some enums no longer provide From impls. Construct the variant by name instead, such as Expr::Array(e) in place of e.into().

  • The pop method of Punctuated<T, P> now returns Option<T> discarding the trailing punctuation if any, rather than Option<Pair<T, P>>. A new method pop_pair provides the old behavior.

  • Syntax tree traversal (visit, visit_mut, fold) no longer provides a method for processing Span. This was already incompletely supported and never walked most of the spans in a syntax tree.

  • The Speculative and AnyDelimiter traits have been sealed and cannot be implemented for types outside of Syn's ParseStream.

v2.0.119

Compare Source

  • Preserve attributes on tail-call expressions in statement position (#​1994)
  • Parse field-representing types builtin in type position (#​1996)

v2.0.118

Compare Source

  • Documentation improvements

v2.0.117

Compare Source

  • Fix parsing of self:: pattern in first function argument (#​1970)

v2.0.116

Compare Source

  • Optimize parse_fn_arg_or_variadic for less lookahead on erroneous receiver (#​1968)

v2.0.115

Compare Source

  • Enable GenericArgument::Constraint parsing in non-full mode (#​1966)

v2.0.114

Compare Source

  • Make std dependencies more easily discoverable in source code (#​1956, thanks @​tamird)

v2.0.113

Compare Source

  • Allow parsing TypeParam with colon not followed by any type param bounds (#​1953, thanks @​wyfo)

v2.0.112

Compare Source

v2.0.111

Compare Source

  • Allow first argument of braced!, bracketed!, parenthesized! to be an otherwise unused variable (#​1946)

v2.0.110

Compare Source

  • Tweaks to improve build speed (#​1939, thanks @​dishmaker)
  • Make syn::ext::IdentExt::unraw available without "parsing" feature (#​1940)
  • Support parsing syn::Meta followed by => (#​1944)

v2.0.109

Compare Source

v2.0.108

Compare Source

  • Parse unrecognized or invalid literals as Lit::Verbatim (#​1925)

v2.0.107

Compare Source

  • Improve panic message when constructing a LitInt, LitFloat, or Lit from invalid syntax (#​1917)
  • Improve panic message on Punctuated index out of bounds (#​1922)

v2.0.106

Compare Source

v2.0.105

Compare Source

v2.0.104

Compare Source

  • Disallow attributes on range expression (#​1872)

v2.0.103

Compare Source

  • Insert parentheses around binary operation with attribute (#​1871)

v2.0.102

Compare Source

  • Fix printing of nested Expr::Index and Expr::Tuple in non-full mode (#​1869)

v2.0.101

Compare Source

  • Improve TypeGenerics::as_turbofish to return longer-lived return value (#​1861)

v2.0.100

Compare Source

  • Add Visit::visit_token_stream, VisitMut::visit_token_stream_mut, Fold::fold_token_stream for processing TokenStream during syntax tree traversals (#​1852)

v2.0.99

Compare Source

  • Documentation improvements

v2.0.98

Compare Source

  • Allow lifetimes in function pointer return values in ParseStream::call and Punctuated parsers (#​1847)

v2.0.97

Compare Source

  • Documentation improvements

v2.0.96

Compare Source

v2.0.95

Compare Source

  • Fix parenthesization of struct literals in let-chains (#​1832)

v2.0.94

Compare Source

v2.0.93

Compare Source

v2.0.92

Compare Source

  • Fix parenthesization of jumps inside ranges (#​1798)

v2.0.91

Compare Source

v2.0.90

Compare Source

  • Fix automatic parenthesization of subexpressions containing outer attributes, such as (#[attr] thing).field (#​1785)
  • Fix automatic parenthesization of function calls via a struct field, such as (thing.field)() and thing.0() (#​1786)

v2.0.89

Compare Source

v2.0.88

Compare Source

  • Improve error recovery in parse_str (#​1783)

v2.0.87

Compare Source

v2.0.86

Compare Source

  • Support peeking the end of a parse stream (#​1689)
  • Allow parse_quote! to produce Vec<Attribute> (#​1775)

v2.0.85

Compare Source

  • Preserve extern static unsafety in ForeignItem::Verbatim (#​1773)

v2.0.84

Compare Source

v2.0.83

Compare Source

  • Documentation improvements

v2.0.82

Compare Source

  • Provide Parse impls for PreciseCapture and CapturedParam (#​1757, #​1758)
  • Support parsing unsafe attributes (#​1759)
  • Add Fold and VisitMut methods for Vec<Attribute> (#​1762)

v2.0.81

Compare Source

  • Add TypeParamBound::PreciseCapture to represent precise capture syntax impl Trait + use<'a, T> (#​1752, #​1753, #​1754)

v2.0.80

Compare Source

  • Add Expr::RawAddr (#​1743)
  • Reject precise captures and ~const in inappropriate syntax positions (#​1747)
  • Reject trait bound containing only precise capture (#​1748)

v2.0.79

Compare Source

  • Fix infinite loop on parsing chained ranges (#​1741)
  • Fix panic in parsing use items containing absolute paths (#​1742)

v2.0.78

Compare Source

  • Fix infinite loop on chained comparison (#​1739)

v2.0.77

Compare Source

  • Support parsing Expr::Tuple in non-"full" mode (#​1727)

v2.0.76

Compare Source

  • Enforce that tail call become keyword is followed by an expression (#​1725)

v2.0.75

Compare Source

  • Automatically fill in missing turbofish when printing ExprPath and other paths in expression position (#​1722)

v2.0.74

Compare Source

  • Fix "temporary is dropped and runs the destructor for type `impl Iterator`" regression affecting certain use of Generics iterator methods (#​1719)

v2.0.73

Compare Source

v2.0.72

Compare Source

v2.0.71

Compare Source

v2.0.70

Compare Source

v2.0.69

Compare Source

  • Correctly parenthesize labeled loops inside a break value (#​1692)
  • Add Punctuated::get and get_mut (#​1693)

v2.0.68

Compare Source

  • Improve panic location when parse_quote! parses invalid syntax (#​1690, thanks @​stepancheg)
  • More efficient peek implementation for Group and Lifetime (#​1687)

v2.0.67

Compare Source

  • Produce more accurate error message locations for errors located at the end of a nested group (#​1679, #​1680)
  • Support peeking LitCStr in ParseStream::peek (#​1682)

v2.0.66

Compare Source

  • Allow braced structs when parsing ExprLet (#​1671)

v2.0.65

Compare Source

v2.0.64

Compare Source

  • Support using ParseBuffer across catch_unwind (#​1646)
  • Validate that the expression in a let-else ends in brace as required by rustc (#​1648, #​1649)
  • Legalize invalid const generic arguments by wrapping in braces (#​1654, #​1655)
  • Fix some expression precedence edge cases involving break and return in loop headers (#​1656)
  • Always print closure bodies with a brace when the closure has an explicit return type (#​1658)
  • Automatically insert necessary parentheses in ToTokens for Expr when required by expression precedence (#​1659)
  • Support struct literal syntax in match guard expressions (#​1662)

v2.0.63

Compare Source

  • Parse and print long if-else-if chains without reliance on deep recursion to avoid overflowing stack (#​1644, #​1645)

v2.0.62

Compare Source

  • Reject invalid unparenthesized range and comparison operator expressions (#​1642, #​1643)

v2.0.61

Compare Source

  • Check for legal binding name in the ident of Pat::Ident (#​1627)
  • Resolve unexpected_cfgs warning (#​1635)

v2.0.60

Compare Source

  • Improve how None-delimited groups are counted by peek (#​1625)

v2.0.59

Compare Source

  • Parse c"…" and cr"…" C-string literal syntax as Lit::CStr (#​1502)

v2.0.58

Compare Source

  • Support $ in custom_punctuation! macro (#​1611)

v2.0.57

Compare Source

  • Eliminate dependency on quote when built with default-features disabled and the "proc-macro" feature enabled (#​1608, thanks @​BD103)

v2.0.56

Compare Source

  • Apply RUSTC_WORKSPACE_WRAPPER when deciding whether to run nightly-only tests (#​1605)

v2.0.55

Compare Source

  • Restore compatibility with rustc 1.56 through 1.59 (#​1603)

v2.0.54

Compare Source

  • Fix dead code warning in generated code when using custom_keyword! with syn's "printing" feature disabled (#​1602)

v2.0.53

Compare Source

  • Implement Copy, Clone, and ToTokens for syn::parse::Nothing (#​1597)

v2.0.52

Compare Source

  • Add an expression parser that uses match-arm's boundary rules (#​1593)

v2.0.51

Compare Source

  • Resolve non_local_definitions warnings in generated code under rustc 1.78-nightly

v2.0.50

Compare Source

  • Fix unused_imports warnings when compiled by rustc 1.78

v2.0.49

Compare Source

  • Improve error location when parsing from an empty string literal using LitStr::parse (#​1590)

v2.0.48

Compare Source

  • Improve error message on unexpected token after else (#​1578)

v2.0.47

Compare Source

  • Improve error messages related to proc_macro::LexError (#​1575)

v2.0.46

Compare Source

  • Update proc-macro2 to fix caching issue when using a rustc-wrapper such as sccache

v2.0.45

Compare Source

  • Parse unsupported expressions in enum discriminants of DeriveInput as Expr::Verbatim in non-"full" mode, instead of error (#​1513)
  • Support parsing PatType with parse_quote! (#​1573)

v2.0.44

Compare Source

  • Documentation improvements

v2.0.43

Compare Source

  • Insert trailing comma if not already present when printing a 1-tuple in pattern position (#​1553)

v2.0.42

Compare Source

  • Documentation improvements

v2.0.41

Compare Source

  • Support parsing syn::Field in parse_quote! (#​1548)

v2.0.40

Compare Source

v2.0.39

Compare Source

  • Fix parsing of return expression in match guards (#​1528)
  • Improve error message on labeled loop as value expression for break (#​1531)

v2.0.38

Compare Source

  • Fix "method 'peek' has an incompatible type for trait" error when defining bool as a custom keyword (#​1518, thanks @​Vanille-N)

v2.0.37

Compare Source

  • Work around incorrect future compatibility warning in rustc 1.74.0-nightly

v2.0.36

Compare Source

  • Restore compatibility with --generate-link-to-definition documentation builds (#​1514)

v2.0.35

Compare Source

  • Make rust-analyzer produce preferred brackets for invocations of Token! macro (#​1510, #​1512)

v2.0.34

Compare Source

  • Documentation improvements

v2.0.33

Compare Source

  • Special handling for the (/*ERROR*/) placeholder that rustc uses for macros that fail to expand

v2.0.32

Compare Source

v2.0.31

Compare Source

v2.0.30

Compare Source

v2.0.29

Compare Source

v2.0.28

Compare Source

  • Fix inconsistency between full and non-full expression parse errors (#​1491)

v2.0.27

Compare Source

v2.0.26

Compare Source

  • Implement Spanned for QSelf (#​1465)

v2.0.25

Compare Source

  • Support single identifier as unbraced const generic argument (#​1483)
  • Produce error message when LitStr::parse is used on a suffixed string literal (#​1484)

v2.0.24

Compare Source

  • Fix duplication of braces around const generic argument in non-full mode (#​1482)

v2.0.23

Compare Source

  • Preserve attributes on verbatim Item in statement position (#​1476)
  • Support generic_const_exprs where-clauses such as where [(); { T::COUNT }]: in non-"full" mode (#​1478)

v2.0.22

Compare Source

v2.0.21

Compare Source

  • Fix value computed by LitByteStr::value in the case of a cooked byte string literal containing form feed or vertical tab characters following an escaped newline (#​1474)

v2.0.20

Compare Source

  • Documentation improvements

v2.0.19

Compare Source

v2.0.18

Compare Source

  • Permit empty attr in syn::meta::parser (#​1460)

v2.0.17

Compare Source

  • Enable proc_macro support on wasm targets (#​1459)

v2.0.16

Compare Source

v2.0.15

Compare Source

  • Ensure Type::Tuple of length 1 prints as a tuple even if trailing comma is not provided in the Punctuated (#​1444, thanks @​Fancyflame)

v2.0.14

Compare Source

v2.0.13

Compare Source

v2.0.12

Compare Source

  • Refer to compile_error! by absolute path in token stream produced by syn::Error::to_compile_error (#​1431, thanks @​smoelius)

v2.0.11

Compare Source

  • Improve error message on empty parens inside parse_nested_meta (#​1428)

v2.0.10

Compare Source

  • Fix visibility being parsed incorrectly on macro invocations inside of a trait

v2.0.9

Compare Source

  • Disallow type items in an extern block, trait, or module from being marked default
  • Disallow ImplItemFn from having an omitted function body, as in impl T { fn f(&self); } — omitted function bodies are allowed by TraitItemFn, but in impl blocks this syntax is now parsed as ImplItem::Verbatim rather than ImplItem::Fn

v2.0.8

Compare Source

  • Treat try keyword as 2015-edition identifier in definition of try macro (#​1422)

v2.0.7

Compare Source

  • Fix parsing of mut self inside of Type::BareFn

v2.0.6

Compare Source

  • Improve error message on missing ';' between statements (#​1419)
  • Keep non-brace macro invocations in trailing expr position as Expr::Macro (#​1420)

v2.0.5

Compare Source

  • Expose ExprMacro data structure even when features="full" is not used (#​1417)

v2.0.4

Compare Source

  • Improve error reporting when parsing identifiers and paths (#​1415, #​1416)

v2.0.3

Compare Source

  • Expose ExprGroup data structure even when features="full" is not used (#​1412)

v2.0.2

Compare Source

  • Documentation improvements

v2.0.1

Compare Source

  • Add methods on syn::Meta for reporting error on an incorrect kind of attribute (#​1409)

v2.0.0

Compare 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:

Be aware that the underlying Rust language will continue to evolve. Syn is able to accommodate most kinds of Rust grammar changes via the nonexhaustive enums and Verbatim variants in the syntax tree, but we will plan to put out new major versions on a 12 to 24 month cadence to incorporate ongoing language changes as needed.

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

  • Minimum required Rust version is raised from rustc 1.31 to 1.56.
Expressions
  • Support for box expr syntax has been deleted, as it has been deleted recently from rustc.

  • Support for type ascription syntax expr: Type in expression position has been deleted.

  • Support for unstable &raw const expr raw-pointer reference syntax has been deleted.

  • The representation of generic arguments has been unified between method calls and non-method paths into a single GenericArgument type, which supersedes the previous GenericMethodArgument and MethodTurbofish.

  • Generic arguments now distinguish between associated types (AssocType) and associated constant values (AssocConst). Previously these would be parsed ambiguously as Binding.

  • The binary assignment operators in BinOp have been renamed to align with the naming used by the standard library's core::ops module's traits. For example BinOp::AddEq is now called BinOp::AddAssign.

  • Expr::Struct struct 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::Range now follows the start and end naming used by the standard library's RangeBounds trait, rather than from/to or lo/hi.

  • Expr::AssignOp has been merged into Expr::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::Closure now includes a representation for for<...> lifetimes.

Statements
  • Variants Stmt::Expr (tail-position expression without trailing semicolon) and Stmt::Semi (non-tail expression with trailing semicolon) have been combined into Stmt::Expr with the optional semicolon represented by Option<Token![;]>.

  • The syntax tree for Stmt::Local has been extended to handle let/else syntax.

  • Macros in statement position are now uniformly parsed as Stmt::Macro. Previously these would be disambiguated to Stmt::Item, although it was ambiguous whether a macro in statement position would expand to an item (like thread_local! { ... }) vs an expression (like println! { ... }).

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) and Pat::parse_multi_with_leading_vert (for the pattern of match arms, which allow an optional leading |). Previously only a single parse behavior was supported and behaved like the new parse_single.

  • The Pat syntax tree now shares more common data structures with the Expr syntax 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

Note

PR body was truncated to here.


Configuration

📅 Schedule: (in timezone America/Los_Angeles)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 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.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot added the bot label Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants