Skip to content

Internal error if license check fails #3679

@shaunxw

Description

@shaunxw

When the license header in rust code file doesn't match license template, cargo fmt would panic with internal error: entered unreachable code.

Backtrace is as follows:

$ RUST_BACKTRACE=1 cargo fmt
thread 'main' panicked at 'internal error: entered unreachable code', src/tools/rustfmt/src/formatting.rs:322:18
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic
   4: <rustfmt_nightly::format_report_formatter::FormatReportFormatter as core::fmt::Display>::fmt
   5: core::fmt::write
   6: <std::io::stdio::Stderr as std::io::Write>::write_fmt
   7: std::io::stdio::_eprint
   8: rustfmt::format_and_emit_report
   9: rustfmt_nightly::Session<T>::override_config
  10: rustfmt::execute
  11: rustfmt::main
  12: std::rt::lang_start::{{closure}}
  13: std::panicking::try::do_call
  14: __rust_maybe_catch_panic
  15: std::rt::lang_start_internal
  16: main

Meta

$ rustc --version --verbose
rustc 1.38.0-nightly (cd2cd4c96 2019-07-10)
binary: rustc
commit-hash: cd2cd4c9627e52c33e68e8c93a8916dc11094cbb
commit-date: 2019-07-10
host: x86_64-apple-darwin
release: 1.38.0-nightly
LLVM version: 8.0

$ cargo fmt --version
rustfmt 1.3.0-nightly (d3345024 2019-06-09)

Demo

I created a repo reproducing this issue at here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions