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
Background
lang/syncurrently depends onsynv1, 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:use<T>(stabilised Rust 1.82, October 2024)c"hello"(stabilised Rust 1.77, March 2024)This mismatch caused a regression in #4325:
CrateContext::parsewould hard-fail on any project using modern Rust syntax, breaking IDL generation. PR #4520 worked around it by restoring silent-fail behaviour (cachingNoneon 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 inlang/synthat depends on syn 1.x) to syn 2.0. This would let us parse modern Rust syntax correctly and remove theNone-on-failure workaround introduced in #4520.References
CrateContext#4325