Skip to content

chore(lang/syn): migrate CrateContext::parse from syn 1.x to syn 2.0 #4521

@eteen12

Description

@eteen12

Background

lang/syn currently depends on syn v1, which was last released in December 2022. Anchor's MSRV has since moved past that point, meaning we officially support Rust versions whose syntax syn v1 cannot parse — for example:

  • Precise-capturing syntax use<T> (stabilised Rust 1.82, October 2024)
  • C-string literals c"hello" (stabilised Rust 1.77, March 2024)

This mismatch caused a regression in #4325: CrateContext::parse would hard-fail on any project using modern Rust syntax, breaking IDL generation. PR #4520 worked around it by restoring silent-fail behaviour (caching None on parse failure), but that's a bandaid — type alias resolution and external type handling silently don't work for crates with unparseable files.

Goal

Upgrade CrateContext::parse (and anything else in lang/syn that depends on syn 1.x) to syn 2.0. This would let us parse modern Rust syntax correctly and remove the None-on-failure workaround introduced in #4520.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions