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

ICE: let_else with -Zunpretty=hir, let-else-binding-immutable.r, None in compiler/rustc_ast_pretty/src/pp.rs #99318

Closed
matthiaskrgr opened this issue Jul 16, 2022 · 0 comments · Fixed by #100434
Labels
C-bug Category: This is a bug. F-let-else Issues related to let-else statements (RFC 3137) glacier ICE tracked in rust-lang/glacier. 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.

Comments

@matthiaskrgr
Copy link
Member

./src/test/ui/let-else/let-else-binding-immutable.rs

Code

// from rfc2005 test suite

#![feature(let_else)]

pub fn main() {
    let Some(x) = &Some(3) else {
        panic!();
    };
    *x += 1; //~ ERROR: cannot assign to `*x`, which is behind a `&` reference
}

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (87588a2af 2022-07-13)
binary: rustc
commit-hash: 87588a2afd9ca903366f0deaf84d805f34469384
commit-date: 2022-07-13
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

rustc ./src/test/ui/let-else/let-else-binding-immutable.rs -Zunpretty=hir

Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_ast_pretty/src/pp.rs:412:52
stack backtrace:
   0:     0x7fe2d78a2850 - std::backtrace_rs::backtrace::libunwind::trace::h546e34b136647819
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fe2d78a2850 - std::backtrace_rs::backtrace::trace_unsynchronized::h76e576fe0a1ec65e
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe2d78a2850 - std::sys_common::backtrace::_print_fmt::h3489fbb9d5d01094
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fe2d78a2850 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h401cfc97a3c2f247
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fe2d78fbe2c - core::fmt::write::h327c921ac5532dc9
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/core/src/fmt/mod.rs:1198:17
   5:     0x7fe2d7893e15 - std::io::Write::write_fmt::h334c1fe5d85b41a9
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/io/mod.rs:1672:15
   6:     0x7fe2d78a54e1 - std::sys_common::backtrace::_print::hddc5656bc817cc55
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fe2d78a54e1 - std::sys_common::backtrace::print::h46adcb0dcb6fbe81
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fe2d78a54e1 - std::panicking::default_hook::{{closure}}::h7e55301ce91fa17d
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:295:22
   9:     0x7fe2d78a51b3 - std::panicking::default_hook::he24b412fa8dea167
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:314:9
  10:     0x7fe2d8147e04 - rustc_driver[24990f24c5f9557a]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fe2d78a5cb6 - std::panicking::rust_panic_with_hook::hd6be56b55800f278
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:702:17
  12:     0x7fe2d78a5ac9 - std::panicking::begin_panic_handler::{{closure}}::h299e1cde9b2d55bf
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:586:13
  13:     0x7fe2d78a2d34 - std::sys_common::backtrace::__rust_end_short_backtrace::h217affeadc688779
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7fe2d78a5832 - rust_begin_unwind
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:584:5
  15:     0x7fe2d7869b73 - core::panicking::panic_fmt::hce80afc1c6c77893
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/core/src/panicking.rs:142:14
  16:     0x7fe2d7869a3d - core::panicking::panic::h3f12aada7d8b1473
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/core/src/panicking.rs:48:5
  17:     0x7fe2da289fcf - <rustc_ast_pretty[c2f1cb48f89c6c8]::pp::Printer>::eof
  18:     0x7fe2d8e5005c - rustc_hir_pretty[ace3b7ae5e9072c9]::print_crate
  19:     0x7fe2d8139ba3 - rustc_driver[24990f24c5f9557a]::pretty::print_after_hir_lowering::{closure#1}
  20:     0x7fe2d81397bc - rustc_driver[24990f24c5f9557a]::pretty::print_after_hir_lowering
  21:     0x7fe2d81223ba - <rustc_interface[d9e16a24b5464548]::passes::QueryContext>::enter::<rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}::{closure#2}::{closure#1}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>
  22:     0x7fe2da2ea90f - <rustc_interface[d9e16a24b5464548]::interface::Compiler>::enter::<rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}::{closure#2}, core[734affb1a3eaf053]::result::Result<core[734affb1a3eaf053]::option::Option<rustc_interface[d9e16a24b5464548]::queries::Linker>, rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>
  23:     0x7fe2da2e676f - rustc_span[b8cb56592c4d9b67]::with_source_map::<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_interface[d9e16a24b5464548]::interface::create_compiler_and_run<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>::{closure#1}>
  24:     0x7fe2da302880 - rustc_interface[d9e16a24b5464548]::interface::create_compiler_and_run::<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>
  25:     0x7fe2da316a02 - <scoped_tls[93927b52d599628f]::ScopedKey<rustc_span[b8cb56592c4d9b67]::SessionGlobals>>::set::<rustc_interface[d9e16a24b5464548]::interface::run_compiler<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>
  26:     0x7fe2da2e8cff - std[66dc708de7974585]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d9e16a24b5464548]::util::run_in_thread_pool_with_globals<rustc_interface[d9e16a24b5464548]::interface::run_compiler<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>
  27:     0x7fe2da302cd9 - <<std[66dc708de7974585]::thread::Builder>::spawn_unchecked_<rustc_interface[d9e16a24b5464548]::util::run_in_thread_pool_with_globals<rustc_interface[d9e16a24b5464548]::interface::run_compiler<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>::{closure#1} as core[734affb1a3eaf053]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7fe2d78af703 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h332a3f23c5b3d8bc
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/alloc/src/boxed.rs:1934:9
  29:     0x7fe2d78af703 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h33b3da7f4496df00
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/alloc/src/boxed.rs:1934:9
  30:     0x7fe2d78af703 - std::sys::unix::thread::Thread::new::thread_start::hf48274d01b2ded65
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys/unix/thread.rs:108:17
  31:     0x7fe2d768054d - <unknown>
  32:     0x7fe2d7705874 - clone
  33:                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.64.0-nightly (87588a2af 2022-07-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unpretty=hir

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. F-let-else Issues related to let-else statements (RFC 3137) labels Jul 16, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jul 17, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 13, 2022
@bors bors closed this as completed in 2126cc6 Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-let-else Issues related to let-else statements (RFC 3137) glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants