Parse error is reported for malformed body in `cfg_if!`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
On the current nightly, rustfmt errors out after suggesting to add braces in an inappropriate location to a closure where it doesn't make sense to use braces begin with.
Example of affected code: https://github.com/HadrienG2/grayscott/blob/e64ff006867e7c66c9834cff20d920612578df7f/data/src/concentration/simd/safe_arch.rs#L524 .
Error message:
error: closure bodies that contain statements must be surrounded by braces
--> /home/hadrien/Bureau/grayscott/data/src/concentration/simd/safe_arch.rs:524:45
|
524 | let masks256 = array2(|i| self[i].ge(other[i]));
| ^
525 | let [lo128; hi128] = masks256.map(safe_arch::convert_to_m128_from_m256d);
| ^
|
note: statement found outside of a block
--> /home/hadrien/Bureau/grayscott/data/src/concentration/simd/safe_arch.rs:525:31
|
524 | let masks256 = array2(|i| self[i].ge(other[i]));
| -------------------- this expression is a statement because of the trailing semicolon
525 | let [lo128; hi128] = masks256.map(safe_arch::convert_to_m128_from_m256d);
| ^ this `;` turns the preceding closure into a statement
note: the closure body may be incorrectly delimited
--> /home/hadrien/Bureau/grayscott/data/src/concentration/simd/safe_arch.rs:524:43
|
524 | let masks256 = array2(|i| self[i].ge(other[i]));
| ^^^^^^^^^^^^^^^^^^^^^^^^ this is the parsed closure...
525 | let [lo128; hi128] = masks256.map(safe_arch::convert_to_m128_from_m256d);
| - ...but likely you meant the closure to end here
help: try adding braces
|
524 ~ let masks256 = array2(|i| { self[i].ge(other[i]));
525 ~ let [lo128; hi128}] = masks256.map(safe_arch::convert_to_m128_from_m256d);
|
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the affected expression in data/src/concentration/simd/safe_arch.rs at the linked revision. Start by examining rustfmt's handling of the malformed closure body and its diagnostic suggestion. Done means the code no longer receives an inappropriate brace suggestion and reports the malformed body correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100