Skip to content

internal error: entered unreachable code #4357

@ehuss

Description

@ehuss

Describe the bug
In some situations, rustfmt will panic with the following error:

thread 'main' panicked at 'internal error: entered unreachable code', src/tools/rustfmt/src/types.rs:764:59

To Reproduce

This is a repost of rust-lang/cargo#8388, so I don't know the original code (the reporter said it was close source and could not share). However, here are some examples that can trigger it:

type T = typeof(1);
struct S;

impl T for .. {

}

Of course these aren't valid, but they hit this line. I'm not sure if there are legitimate cases that would hit this. Another guess is that maybe the user had format-on-save, and was in the middle of some unfinished code?

Meta

  • rustfmt version: rustfmt 1.4.19-nightly (cef1c0d5 2020-07-21)
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: cargo fmt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions