Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upExpected compile error because bad use of semicolon #28157
Comments
This comment has been minimized.
This comment has been minimized.
|
Code in question: fn main(){
if 4==4{;
println!("bogus");
}
}The grammar docs indeed disallow a bare |
arielb1
added
the
A-parser
label
Sep 2, 2015
fhahn
added a commit
to fhahn/rust
that referenced
this issue
Oct 21, 2015
fhahn
added a commit
to fhahn/rust
that referenced
this issue
Oct 21, 2015
fhahn
added a commit
to fhahn/rust
that referenced
this issue
Oct 21, 2015
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated |
rust-highfive
added
the
I-nominated
label
Oct 21, 2015
alexcrichton
added
the
T-lang
label
Oct 21, 2015
This comment has been minimized.
This comment has been minimized.
|
There's a PR to fix this issue (#29215), but as it's a language change I wanted to circulate among the lang team to ensure that it's intended. (fwiw I would personally consider this behavior fine, as shown by the fall out in the PR it's often convenient to rely on this in contexts like with macros) |
This comment has been minimized.
This comment has been minimized.
|
If this comes out as wontfix, I think it still would make sense to remove the trailing semicolons after the few function definitions. I would also be happy to update the documentation and the reference parser. |
This comment has been minimized.
This comment has been minimized.
|
We discussed in the @rust-lang/lang and came to the conclusion that parsing an empty semicolon here is not a bug and we should not attempt to issue warnings or make it an error. In fact, most of us rather expected it to work, perhaps because of C precendent. However, @nrc pointed out that a clippy lint might be suitable or -- perhaps better yet -- modifying rustfmt to drop such statements. I too would personally prefer to have rustfmt silently clean things up behind my back than to have to some lint nag me about it. :) |
This comment has been minimized.
This comment has been minimized.
|
(Also, it seems like a case where being backwards incompatible just isn't really necessary.) |
fhahn
added a commit
to fhahn/rust
that referenced
this issue
Oct 23, 2015
This comment has been minimized.
This comment has been minimized.
|
Sure that makes perfect senes. @jonas-schievink do you remember where you found the grammar definition which said a bare semicolon should not be allowed? I could not find it. |
This comment has been minimized.
This comment has been minimized.
|
I think I looked at http://doc.rust-lang.org/grammar.html#statements-and-expressions |
bors
added a commit
that referenced
this issue
Oct 24, 2015
bors
closed this
in
1e62bd2
Oct 24, 2015
This comment has been minimized.
This comment has been minimized.
|
@jonas-schievink thanks Jonas, I've updated the docs. |
wilcus commentedSep 1, 2015
Actual result compile and output "bogus"
Code:
https://pastebin.mozilla.org/8844697
rustc 1.4.0-dev (7b7fc67 2015-08-13)