The goto fail problem could be avoided if a newline was not permitted between the if statement and its contents.
That can be a surprisingly difficult property to specify fully; e.g. with the simple definition, it'd still allow
if (condition) /*
*/ code;
because there's no medial newline token, just a comment. Similarly, it'd forbid the next-line open-bracket, which is used by the rustfmt style when the condition is long enough that it gets linewrapped.
The Rust grammar is currently completely whitespace agnostic, in that it only cares whether "trivia" (whitespace and (non-doc) comments) does or does not occur, and makes no care on what trivia is present. Breaking this property in the core language is extremely unlikely to happen.
8 Likes
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.