rust-lang / rust-lang/rustfmt

rustfmt changes return type of loop and causes code to not compile

Open
#5,377 1 comment 0 reactions 1 assignee View on GitHub

@carsonRadtke is already working on this.

Since Jun 23, 2022.

C-bug
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Most basic example:

fn main() {
    loop {
        break false
    };
}

This just runs and does nothing.

If you run rustfmt it yields

fn main() {
    loop {
        break false;
    }
}

This now fails to compile

Compiling playground v0.0.1 (/playground)
error[[E0308]](https://doc.rust-lang.org/stable/error-index.html#E0308): mismatched types
 --> src/main.rs:3:15
  |
3 |         break false;
  |               ^^^^^ expected `()`, found `bool`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.