Skip to content

non_fmt_panics cannot migrate to 2021 for assert with non-string payload #87313

Closed
@ehuss

Description

@ehuss

I tried this code:

fn f() {
    assert!(true, 123);
}

I expected to see this happen: This includes a machine-applicable fix to migrate to 2021.

Instead, this happened: The suggestion is MaybeIncorrect preventing automatic migration.

Part of the problem is that there isn't an easy way to convert this to panic_any. For example, it could convert to:

fn f() {
    if !(expr) { ::std::panic::panic_any(123); }
}

which is pretty awful and probably has other downsides. Trying to format with {:?} is also probably not a reliable option, since it would require the payload to impl Debug, and the user's code may be relying on catching the panic and inspecting the payload.

I don't know what is really practical here.

Meta

rustc 1.55.0-nightly (014026d1a 2021-07-19)

Metadata

Metadata

Assignees

Labels

A-edition-2021Area: The 2021 editionC-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