rust-lang / wg-grammar

Where the work of WG-grammar, aiming to provide a canonical grammar for Rust, resides
Apache License 2.0
99 stars 20 forks source link

Should generic argument order be part of the syntax? #40

Open ehuss opened 5 years ago

ehuss commented 5 years ago

In 1.34, via https://github.com/rust-lang/rust/pull/58191, the restriction that lifetimes appear before types in generic arguments was removed from libsyntax. However, type bindings are still required to be after types and lifetimes.

Should this order constraint be part of the syntax? The current lyg grammar (and libsyntax) encodes this restriction. But after discussing this on Discord, I was wondering why relax one constraint but not the other?

Example:

fn test<W, I: Trait<Item=(), W> >() {}

See parse_generic_args which I think implies this should not be restricted.

Centril commented 5 years ago

I believe this is a bug on rustc's end since we never signed off on this parser change. (it may very well be that it should not matter syntactically, just semantically...). On the other hand, we (the language team) could also decide that this is fine and leave it be. I'll bring it up on a T-Lang meeting to see what we want to do.