-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Suggest parentheses when match
or if
expression in binop is parsed as statement
#146044
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
Conversation
… { () => 1 }` ``` error[E0308]: mismatched types --> $DIR/expr-as-stmt.rs:69:5 | LL | match () { () => 1 } + match () { () => 1 } | ^^^^^^^^^^^^^^^^^^^^ expected `()`, found integer | help: consider using a semicolon here | LL | match () { () => 1 }; + match () { () => 1 } | + help: alternatively, parentheses are required to parse this as an expression | LL | (match () { () => 1 }) + match () { () => 1 } | + + ``` Parentheses are needed for the `match` to be unambiguously parsed as an expression and not a statement when chaining with binops that are also unops.
…expression ``` error[E0308]: mismatched types --> $DIR/expr-as-stmt.rs:69:5 | LL | match () { () => 1 } + match () { () => 1 } | ^^^^^^^^^^^^^^^^^^^^ expected `()`, found integer | help: parentheses are required to parse this as an expression | LL | (match () { () => 1 }) + match () { () => 1 } | + + ```
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
r? @chenyukang |
``` error[E0308]: mismatched types --> $DIR/expr-as-stmt-2.rs:15:15 | LL | if true { true } else { false } && true; | ----------^^^^----------------- | | | | | expected `()`, found `bool` | expected this to be `()` | help: parentheses are required to parse this as an expression | LL | (if true { true } else { false }) && true; | + + ```
match
expression in binop is parsed as statementmatch
or if
expression in binop is parsed as statement
@@ -1897,7 +1897,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { | |||
fcx.suggest_semicolon_at_end(cond_expr.span, &mut err); | |||
} | |||
} | |||
}; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a style lint to check this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we do.
@bors r=chenyukang |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing c559c4a (parent) -> 9cd272d (this PR) Test differencesShow 30 test diffs30 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 9cd272dc85320e85a8c83a1a338870de52c005f3 --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (9cd272d): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 0.6%, secondary 0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -1.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 469.348s -> 466.363s (-0.64%) |
Address the common case from #88727. The original parse error is still outstanding, but the cases brought up in the thread are resolved.