Rustfmt: Missing close parens causes insertion of closing brace

Created on 18 May 2020  路  1Comment  路  Source: rust-lang/rustfmt

Using rustfmt 1.4.14-nightly (a5cb5d26 2020-04-14), this code:

fn main() {
    println!("Hello!"
}

is formatted to:

fn main() {
    println!("Hello!")
    }
}

rustfmt prints out that there's a syntax error, exits with code zero, and breaks the file even further.

$ rustfmt < broken.rs
error: mismatched closing delimiter: `}`
 --> <stdin>:3:1
  |
1 | fn main() {
  |           - closing delimiter possibly meant for this
2 |     println!("Hello!"
  |             - unclosed delimiter
3 | }
  | ^ mismatched closing delimiter

fn main() {
    println!("Hello!")
    }
}
bug

Most helpful comment

This looks to be fixed on master

error: mismatched closing delimiter: `}`
 --> <stdin>:3:1
  |
1 | fn main() {
  |           - closing delimiter possibly meant for this
2 |     println!("Hello!"
  |             - unclosed delimiter
3 | }
  | ^ mismatched closing delimiter

fn main() {
    println!("Hello!")
}

>All comments

This looks to be fixed on master

error: mismatched closing delimiter: `}`
 --> <stdin>:3:1
  |
1 | fn main() {
  |           - closing delimiter possibly meant for this
2 |     println!("Hello!"
  |             - unclosed delimiter
3 | }
  | ^ mismatched closing delimiter

fn main() {
    println!("Hello!")
}
Was this page helpful?
0 / 5 - 0 ratings