dtolnay / syn

Parser for Rust source code
Apache License 2.0
2.81k stars 308 forks source link

Add legalization for expressions inside AssocConst #1654

Closed dtolnay closed 3 months ago

dtolnay commented 3 months ago

Previously, if you created a GenericArgument::Const containing an expression that was not legal syntax within a path's const generics, such as:

impl Trait<1 + 1>
           ^^^^^

then Syn would automatically legalize it in the ToTokens impl to print with braces: impl Trait<{1 + 1}>. But for GenericArgument::AssocConst it was not doing this, although the syntax rules are the same.


impl Trait<ASSOC = 1 + 1>
                   ^^^^^