Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax errors for new associated type where clause position #11651

Closed
MingweiSamuel opened this issue Mar 7, 2022 · 1 comment · Fixed by #11672
Closed

Syntax errors for new associated type where clause position #11651

MingweiSamuel opened this issue Mar 7, 2022 · 1 comment · Fixed by #11672
Labels
A-parser parser issues C-bug Category: bug

Comments

@MingweiSamuel
Copy link

MingweiSamuel commented Mar 7, 2022

Associated type syntax has changed so the where clause comes after the assignment instead of before:

Minimized example code:

pub trait Trait {
    type AssociatedType where Self: Clone;
}

impl Trait for () {
    type AssociatedType = () where Self: Clone;
}

Result:

Syntax Error: expected SEMICOLON

Syntax Error: expected an item

Syntax Error: expected BANG
Syntax Error: expected `{`, `[`, `(`
Syntax Error: expected SEMICOLON
Syntax Error: expected an item

Syntax Error: expected BANG
Syntax Error: expected `{`, `[`, `(`

rust-analyzer version:

5fae65dd2 2022-03-07 stable
5fae65dd2 2022-03-07 nightly

rustc version: rustc 1.61.0-nightly (38a0b81b1 2022-03-06)

relevant settings: N/A

@MingweiSamuel MingweiSamuel changed the title Syntax errors for new GAT where clause position Syntax errors for new associated type where clause position Mar 7, 2022
@Veykril Veykril added A-parser parser issues C-bug Category: bug labels Mar 7, 2022
@MingweiSamuel
Copy link
Author

MingweiSamuel commented Mar 8, 2022

A simpler example:

type X = () where X: Copy;

Should parse, but isn't valid:

error: where clause not allowed here
 --> src/lib.rs:1:13
  |
1 | type X = () where X: Copy;
  |       -     ^^^^^^^^^^^^^
  |       |
  |       help: move it here: `where X: Copy`

However rust-analyzer does not parse it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants