Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kpp opened this issue Jul 25, 2020 · 2 comments · Fixed by #74980
Closed

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

kpp opened this issue Jul 25, 2020 · 2 comments · Fixed by #74980
Assignees
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kpp
Copy link
Contributor

kpp commented Jul 25, 2020

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

@kpp kpp added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 25, 2020
@jonas-schievink jonas-schievink added A-pretty Area: Pretty printing (including `-Z unpretty`) requires-nightly This issue requires a nightly compiler in some way. labels Jul 25, 2020
@kpp kpp changed the title Fail to pretty format a file ending with a multiline comment without newline Failed to pretty format a file ending with a multiline comment without newline Jul 25, 2020
@davidtwco davidtwco self-assigned this Jul 31, 2020
@davidtwco
Copy link
Member

I've not been able to reproduce this on the latest nightly, I've bisected it to have been fixed in 2020-07-15 (report used 2020-07-11), probably by #74272; I've filed #74980 with a regression test.

@kpp
Copy link
Contributor Author

kpp commented Jul 31, 2020

I've not been able to reproduce this on the latest nightly

Me neither.

davidtwco added a commit to davidtwco/rust that referenced this issue Aug 2, 2020
This commit adds a regression test for rust-lang#74745. While a
`ignore-tidy-trailing-lines` header is required, this doesn't stop the
test from reproducing, so long as there is no newline at the end of the
file.

However, adding the header comments made the test fail due to a bug in
pprust, fixed in the previous commit.

Signed-off-by: David Wood <[email protected]>
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 2, 2020
…arth

Rollup of 5 pull requests

Successful merges:

 - rust-lang#74980 (pprust: adjust mixed comment printing and add regression test for rust-lang#74745)
 - rust-lang#75009 (Document the discrepancy in the mask type for _mm_shuffle_ps)
 - rust-lang#75031 (Do not trigger `unused_{braces,parens}` lints with `yield`)
 - rust-lang#75059 (fix typos)
 - rust-lang#75064 (compiletest: Support ignoring tests requiring missing LLVM components)

Failed merges:

r? @ghost
@bors bors closed this as completed in bf4a37d Aug 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants