Skip to content

rustc panics if output is set to directory while pretty printing #100770

Closed
@matthiaskrgr

Description

@matthiaskrgr

rustc 1.65.0-nightly (0b79f758c 2022-08-18)

If you rustc ./a.rs -o/tmp/, you get a normal error like

error: the generated executable for the input file "./a.rs" conflicts with the existing directory "/tmp/"

error: aborting due to previous error

but if you try to -Zunpretty at the same time: rustc ./a.rs -o/tmp/ -Zunpretty=ast-tree
rust will panic which is a bit weird. Mayne that panic should be demoted to a regular error?

thread 'rustc' panicked at 'print-print failed to write /tmp/ due to Is a directory (os error 21)', compiler/rustc_driver/src/pretty.rs:365:17
stack backtrace:
   0:     0x7f338bdd86d0 - std::backtrace_rs::backtrace::libunwind::trace::hdc27bfa6aa97f84d
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f338bdd86d0 - std::backtrace_rs::backtrace::trace_unsynchronized::hd260a87da0307fa5
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f338bdd86d0 - std::sys_common::backtrace::_print_fmt::h789cb96c4a337f2c
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f338bdd86d0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h36bc3de3612a60f5
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f338be3376e - core::fmt::write::h2db4bfe92ef037b0
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f338bdc94d5 - std::io::Write::write_fmt::hcd345fc714a96537
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/io/mod.rs:1672:15
   6:     0x7f338bddb393 - std::sys_common::backtrace::_print::hcf53c28899e66110
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f338bddb393 - std::sys_common::backtrace::print::hd8ec3e1ae139ef7a
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f338bddb393 - std::panicking::default_hook::{{closure}}::he70b99e2f9e5bd44
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/panicking.rs:295:22
   9:     0x7f338bddb07f - std::panicking::default_hook::h8d91a23b91011754
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/panicking.rs:314:9
  10:     0x7f338e61a644 - <rustc_driver[d9adb13473fd7853]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[97bb3a13db18d0cb]::ops::function::FnOnce<(&core[97bb3a13db18d0cb]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f338bddbbcd - std::panicking::rust_panic_with_hook::h5af783bc1124b2c1
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/panicking.rs:702:17
  12:     0x7f338bddba27 - std::panicking::begin_panic_handler::{{closure}}::h234d8ef84a25d2ee
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/panicking.rs:588:13
  13:     0x7f338bdd8bdc - std::sys_common::backtrace::__rust_end_short_backtrace::he0cdebe1a4227e87
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f338bddb742 - rust_begin_unwind
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/panicking.rs:584:5
  15:     0x7f338be30283 - core::panicking::panic_fmt::hfb889492842f4bec
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/core/src/panicking.rs:142:14
  16:     0x7f338e6117cc - rustc_driver[d9adb13473fd7853]::pretty::write_or_print
  17:     0x7f338e611911 - rustc_driver[d9adb13473fd7853]::pretty::print_after_parsing
  18:     0x7f338ddf1b52 - <rustc_interface[67a969eeca26ae2c]::interface::Compiler>::enter::<rustc_driver[d9adb13473fd7853]::run_compiler::{closure#1}::{closure#2}, core[97bb3a13db18d0cb]::result::Result<core[97bb3a13db18d0cb]::option::Option<rustc_interface[67a969eeca26ae2c]::queries::Linker>, rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>>
  19:     0x7f338dded1bc - rustc_span[8d4f92e92ba5c24b]::with_source_map::<core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>, rustc_interface[67a969eeca26ae2c]::interface::create_compiler_and_run<core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>, rustc_driver[d9adb13473fd7853]::run_compiler::{closure#1}>::{closure#1}>
  20:     0x7f338ddecba2 - rustc_interface[67a969eeca26ae2c]::interface::create_compiler_and_run::<core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>, rustc_driver[d9adb13473fd7853]::run_compiler::{closure#1}>
  21:     0x7f338ddeb741 - <scoped_tls[e4311800d1c0ff57]::ScopedKey<rustc_span[8d4f92e92ba5c24b]::SessionGlobals>>::set::<rustc_interface[67a969eeca26ae2c]::interface::run_compiler<core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>, rustc_driver[d9adb13473fd7853]::run_compiler::{closure#1}>::{closure#0}, core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>>
  22:     0x7f338ddeb42f - std[e5af5fec29962f4a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[67a969eeca26ae2c]::util::run_in_thread_pool_with_globals<rustc_interface[67a969eeca26ae2c]::interface::run_compiler<core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>, rustc_driver[d9adb13473fd7853]::run_compiler::{closure#1}>::{closure#0}, core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>>::{closure#0}, core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>>
  23:     0x7f338e441e79 - <<std[e5af5fec29962f4a]::thread::Builder>::spawn_unchecked_<rustc_interface[67a969eeca26ae2c]::util::run_in_thread_pool_with_globals<rustc_interface[67a969eeca26ae2c]::interface::run_compiler<core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>, rustc_driver[d9adb13473fd7853]::run_compiler::{closure#1}>::{closure#0}, core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>>::{closure#0}, core[97bb3a13db18d0cb]::result::Result<(), rustc_errors[713e2db940a8ff0d]::ErrorGuaranteed>>::{closure#1} as core[97bb3a13db18d0cb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7f338bde59c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h374ee76b025338a5
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/alloc/src/boxed.rs:1935:9
  25:     0x7f338bde59c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2bee731a5ba86295
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/alloc/src/boxed.rs:1935:9
  26:     0x7f338bde59c3 - std::sys::unix::thread::Thread::new::thread_start::h44c172ae3f11ec1f
                               at /rustc/0b79f758c9aa6646606662a6d623a0752286cd17/library/std/src/sys/unix/thread.rs:108:17
  27:     0x7f338bb4278d - <unknown>
  28:     0x7f338bbc38e4 - clone
  29:                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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.65.0-nightly (0b79f758c 2022-08-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unpretty=ast-tree

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions