-
Notifications
You must be signed in to change notification settings - Fork 13.3k
“help: place this code inside a block” is… pretty confusing #30037
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
Comments
This help message makes sense with the following code: fn main() {
let n = 1;
if n == 5
println!("five");
} because it needs curly braces for the body of the condition. |
One possible fix could be to attempt to parse an expression and only show the help message if it succeeded. So since |
This ticket can be closed, given: fn main() {
let n = 1;
if 5 == 1
println!("five");
}
fn foo() {
let n = 1;
if 5 == {
println!("five");
}
} error: expected `{`, found `println`
--> <anon>:4:9
|
4 | println!("five");
| ^^^^^^^
|
help: try placing this code inside a block
| { println!("five") }
error: expected `{`, found `}`
--> <anon>:11:1
|
11 | }
| ^ |
Definitely a bit better. |
Well, it does not seem to fix the issue in the first post. |
@antoyo - this one shows the code to put in the block |
What I meant is that the error from the first post:
does not seem to have changed:
|
@antoyo - that part of the error is still correct, but there's an additional part now which gives more information:
|
My understanding is that this error message is for the code in the second post: fn main() {
let n = 1;
if n == 5
println!("five");
} But the code from the first post still gives the same error, right? |
@antoyo #30035 is still open, this was a follow up only about the |
reports
The help message is pretty confusing. Which code it has in mind? There’s no code which you could place into a block to fix this error either, as far as I can see.
The text was updated successfully, but these errors were encountered: