Sitelet https://github.com/dtolnay/syn/pull/2084
Skip to content

Improve error when parsing assign/range without full feature - #2084

Open
00200200 wants to merge 1 commit into
dtolnay:masterfrom
00200200:fix-nofull-assign-range-error
Open

00200200 wants to merge 1 commit into
dtolnay:masterfrom
00200200:fix-nofull-assign-range-error

Conversation

@00200200

Copy link
Copy Markdown

Fixes #1971.

Without the full feature, parsing an assignment or range as Expr (for example via Attribute::parse_args or parse_str) successfully parsed only the left-hand side, then failed with a generic unexpected token on the leftover = / ... Other unsupported forms already report unsupported expression; enable syn's features=["full"].

This makes assign and range take that same path in the non-full parse_expr implementation.

Test plan

  • On this branch (and fails on master):
    cargo test --lib --no-default-features --features 'derive parsing printing clone-impls proc-macro test' nofull_expr_tests
  • CI also runs that lib test configuration alongside the existing --all-features suite.

Without the full feature, `parse_str::<Expr>("a = b")` and similar
range forms returned a partial LHS and then a generic "unexpected
token" for the leftover operator. Emit the same "enable full" message
already used for other unsupported expression forms.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uninformative error from Attribute::parse_args for some expressions without "full" feature.

1 participant