Skip to content

error in format string : unreachable!("foo {bar,baz}"); no longer compiles #93761

Closed
@matthiaskrgr

Description

@matthiaskrgr

I tried this code:

unreachable!("passing both, --remove-if-{older,younger}-than was temporarily disabled!");

I expected to see this happen:
This used to compile with edition 2018 and 2021 until rustc 1.60.0-nightly (734368a20 2022-02-07)

Instead, this happened: (edition 2021)
https://github.com/matthiaskrgr/cargo-cache/blob/a9b9f30fe6726390288c2337663409adc666a8a3/src/date.rs#L179

 error: invalid format string: expected `'}'`, found `','`
   --> src/date.rs:179:59
    |
179 |             unreachable!("passing both, --remove-if-{older,younger}-than was temporarily disabled!")
    |                                                     -     ^ expected `}` in format string
    |                                                     |
    |                                                     because of this opening brace
    |
    = note: if you intended to print `{`, you can escape it using `{{`

I'm not sure why this didn't pop up in the crater run for #93394 so made a ticket just in case, cc @m-ou-se

Feel free to close if this is a a true positive. :)

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (734368a20 2022-02-07)
binary: rustc
commit-hash: 734368a200904ef9c21db86c595dc04263c87be0
commit-date: 2022-02-07
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions