In an effort to make Rust’s grammar more tolerant of macros and people, I’d like to collect a list of grammatical forms that are currently not allowed.
Note that the forms that may be illegal now but possibly legal in the future are not an indication of a recommended one-true-style by rustfmt. Instead, it is a philosophy in Rust language design to have a flexible grammar that accepts things that people find abhorrent.
Some forms that are illegal now are:
- Leading comma
fn main() {
let arr = [
, 1
, 2
, 3
];
}
struct Foo {
, foo: usize
, bar: u8
}
fn foo<, T>() {}
- Leading plus
fn foo<T: + Copy>() {}
If you can think of any other “strange” forms that are illegal today please make a note of them here.
The end result of this thread will likely be an RFC proposing that some of these forms be legal.