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

Parse lazy type alias syntax #1525

Open
dtolnay opened this issue Nov 5, 2023 · 1 comment
Open

Parse lazy type alias syntax #1525

dtolnay opened this issue Nov 5, 2023 · 1 comment
Labels

Comments

@dtolnay
Copy link
Owner

dtolnay commented Nov 5, 2023

Tracking issue: rust-lang/rust#112792

pub type ReadWrite<R, W> = Pair<R, W>
where
    R: std::io::Read,
    W: std::io::Write;

Ordinarily Rust does not accept where in this position. But with feature(lazy_type_alias), it does.

error: where clauses are not allowed after the type for type aliases
  --> src/main.rs:23:1
   |
23 | / where
24 | |     R: std::io::Read,
25 | |     W: std::io::Write;
   | |_____________________^
   |
   = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
   = help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable
@dtolnay dtolnay added the syntax label Nov 5, 2023
@fmease
Copy link

fmease commented Nov 15, 2023

NB: Since the stabilization of GATs, rustc syntactically accepts both where-clause locations (before, after, before & after).

I don't know how syn usually fares in these kinds of situations but technically speaking type T = () where; has been syntactically valid1 for quite a while now.

Footnotes

  1. according to rustc, not syn

@dtolnay dtolnay changed the title Support lazy_type_alias syntax Parse lazy type alias syntax Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants