Skip to content

Failed to pretty format a file ending with a multiline comment without newline #74745

Closed
@kpp

Description

@kpp

Code

/*
*/
$ hexdump -C src/lib.rs 
00000000  2f 2a 0a 2a 2f                                    |/*.*/|
00000005

Note: missing newline after */ is essential.

Meta

$ cargo expand --version
cargo-expand 0.6.4
$ rustc -vV
rustc 1.46.0-nightly (346aec9b0 2020-07-11)
binary: rustc
commit-hash: 346aec9b02f3c74f3fce97fd6bda24709d220e49
commit-date: 2020-07-11
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0

Howto reproduce:

$ cat src/lib.rs 
/*
*/
$ cargo expand

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `2`,
 right: `1`', src/librustc_ast_pretty/pprust.rs:453:17
Backtrace

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `2`,
 right: `1`', src/librustc_ast_pretty/pprust.rs:453:17
stack backtrace:
   0:     0x7f24ee5938a5 - backtrace::backtrace::libunwind::trace::h34afbfad7fd770fc
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x7f24ee5938a5 - backtrace::backtrace::trace_unsynchronized::h460d522b1619a600
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x7f24ee5938a5 - std::sys_common::backtrace::_print_fmt::ha45fac10086813b4
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x7f24ee5938a5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hde84f63fcfd0e6de
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x7f24ee5d032c - core::fmt::write::h540ac4a6a1232abc
                               at src/libcore/fmt/mod.rs:1076
   5:     0x7f24ee585622 - std::io::Write::write_fmt::hc344eafd6e850b4d
                               at src/libstd/io/mod.rs:1537
   6:     0x7f24ee598740 - std::sys_common::backtrace::_print::h4db88ff15cb5d61d
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x7f24ee598740 - std::sys_common::backtrace::print::h5fc39e1b1f610bd3
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x7f24ee598740 - std::panicking::default_hook::{{closure}}::h59e55edacb1d974a
                               at src/libstd/panicking.rs:198
   9:     0x7f24ee59848c - std::panicking::default_hook::heee4c8016dfbf328
                               at src/libstd/panicking.rs:217
  10:     0x7f24eed03489 - rustc_driver::report_ice::h779cc1b2c44c51e9
  11:     0x7f24ee598eb8 - std::panicking::rust_panic_with_hook::h8405b6301c79fb5a
                               at src/libstd/panicking.rs:530
  12:     0x7f24ee598a8b - rust_begin_unwind
                               at src/libstd/panicking.rs:437
  13:     0x7f24ee5989fb - std::panicking::begin_panic_fmt::h0ed87aa3b2c392e6
                               at src/libstd/panicking.rs:391
  14:     0x7f24f1788089 - rustc_ast_pretty::pprust::PrintState::print_comment::hb7688baa5694b459
  15:     0x7f24f1781ab1 - rustc_ast_pretty::pprust::print_crate::h0649e5f63a4e91e9
  16:     0x7f24eed5341a - rustc_driver::pretty::print_after_hir_lowering::{{closure}}::ha78d8b6d9f904e65
  17:     0x7f24eed52db1 - rustc_driver::pretty::print_after_hir_lowering::h84fb69d62f17543e
  18:     0x7f24eecebac9 - rustc_middle::ty::context::tls::enter_global::h54e539688be819e0
  19:     0x7f24eecbd1a6 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hfbc63b8f1bb864b3
  20:     0x7f24eed5ce17 - rustc_span::with_source_map::h276db6bb3fd85930
  21:     0x7f24eecbeae6 - rustc_interface::interface::create_compiler_and_run::h7654f3523c3fe4ef
  22:     0x7f24eece935d - scoped_tls::ScopedKey<T>::set::hec735e67099211f0
  23:     0x7f24eed0f542 - std::sys_common::backtrace::__rust_begin_short_backtrace::hc623bbd3fa27b625
  24:     0x7f24eeccc88e - core::ops::function::FnOnce::call_once{{vtable.shim}}::he5d650d3d699089a
  25:     0x7f24ee5a7c7a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h13d34828db364579
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/liballoc/boxed.rs:1081
  26:     0x7f24ee5a7c7a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hd51b619e0f884abf
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/liballoc/boxed.rs:1081
  27:     0x7f24ee5a7c7a - std::sys::unix::thread::Thread::new::thread_start::h02c6e34c2c73f344
                               at src/libstd/sys/unix/thread.rs:87
  28:     0x7f24ee30b6db - start_thread
                               at /build/glibc-2ORdQG/glibc-2.27/nptl/pthread_create.c:463
  29:     0x7f24edc28a3f - __clone
  30:                0x0 - <unknown>
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.46.0-nightly (346aec9b0 2020-07-11) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z unstable-options -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack

Metadata

Metadata

Assignees

Labels

A-prettyArea: Pretty printing (including `-Z unpretty`)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions