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 ices when placed in a const _: () = { ... } #100373

Closed
tuxmark5 opened this issue Aug 10, 2022 · 3 comments · Fixed by #100434
Closed

ICE: let_else ices when placed in a const _: () = { ... } #100373

tuxmark5 opened this issue Aug 10, 2022 · 3 comments · Fixed by #100434
Assignees
Labels
C-bug Category: This is a bug. F-let_else Issues related to let-else statements (RFC 3137) 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

@tuxmark5
Copy link

Code

Link to playground

#![feature(let_else)]

const _: () = {
    fn foo(x: Option<u32>) { 
        let Some(_) = x else { panic!() };
    }
};

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (d394408fb 2022-08-07)
binary: rustc
commit-hash: d394408fb38c4de61f765a3ed5189d2731a1da91
commit-date: 2022-08-07
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 14.0.6

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_ast_pretty/src/pp.rs:412:52
Backtrace

Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_ast_pretty/src/pp.rs:412:52
stack backtrace:
   0:     0x7f5b91273c60 - std::backtrace_rs::backtrace::libunwind::trace::he9fb4f8b6a719925
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f5b91273c60 - std::backtrace_rs::backtrace::trace_unsynchronized::h9b7fbe883834f3d3
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5b91273c60 - std::sys_common::backtrace::_print_fmt::he6dc464748e1c2a6
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f5b91273c60 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbbebb5a127178bd8
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f5b912cf62c - core::fmt::write::h0cbbad9957d29634
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/core/src/fmt/mod.rs:1198:17
   5:     0x7f5b91264ca5 - std::io::Write::write_fmt::h7bfbf18cf3112e27
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/io/mod.rs:1672:15
   6:     0x7f5b91276941 - std::sys_common::backtrace::_print::h00538e56e1e7f9f3
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f5b91276941 - std::sys_common::backtrace::print::h5045ae575039f7dc
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f5b91276941 - std::panicking::default_hook::{{closure}}::hb244797a8318c775
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/panicking.rs:295:22
   9:     0x7f5b9127660e - std::panicking::default_hook::hf1c8bb50e38d503a
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/panicking.rs:314:9
  10:     0x7f5b93afde54 - <rustc_driver[a8b7cf0aaae3bece]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[14a5817fc6fced97]::ops::function::FnOnce<(&core[14a5817fc6fced97]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f5b91277176 - std::panicking::rust_panic_with_hook::h1e44cac8640df897
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/panicking.rs:702:17
  12:     0x7f5b91276f89 - std::panicking::begin_panic_handler::{{closure}}::h5846a4a3859a5834
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/panicking.rs:586:13
  13:     0x7f5b91274184 - std::sys_common::backtrace::__rust_end_short_backtrace::hb9460bca71f51584
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f5b91276cf2 - rust_begin_unwind
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/panicking.rs:584:5
  15:     0x7f5b912cc103 - core::panicking::panic_fmt::h218ea2f8c3932e1a
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/core/src/panicking.rs:142:14
  16:     0x7f5b912cbf4d - core::panicking::panic::h9f951b05a104beec
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/core/src/panicking.rs:48:5
  17:     0x7f5b92f4db48 - <rustc_ast_pretty[9702ff83c931f4ee]::pp::Printer>::eof
  18:     0x7f5b933afb06 - rustc_hir_pretty[73b8d10daec5c303]::to_string::<<rustc_metadata[841ddd31d681d6d0]::rmeta::encoder::EncodeContext>::encode_rendered_const_for_body::{closure#0}>
  19:     0x7f5b933a5433 - <rustc_metadata[841ddd31d681d6d0]::rmeta::encoder::EncodeContext as rustc_hir[8d56236dc9dc55b]::intravisit::Visitor>::visit_item
  20:     0x7f5b933a307c - <rustc_middle[eac570560e79f144]::hir::map::Map>::visit_all_item_likes_in_crate::<rustc_metadata[841ddd31d681d6d0]::rmeta::encoder::EncodeContext>
  21:     0x7f5b9338f316 - <rustc_metadata[841ddd31d681d6d0]::rmeta::encoder::EncodeContext>::encode_crate_root
  22:     0x7f5b9330c482 - rustc_metadata[841ddd31d681d6d0]::rmeta::encoder::encode_metadata_impl
  23:     0x7f5b932f21de - rustc_data_structures[13739aee9e3adeb3]::sync::join::<rustc_metadata[841ddd31d681d6d0]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[841ddd31d681d6d0]::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
  24:     0x7f5b932f20b9 - rustc_metadata[841ddd31d681d6d0]::rmeta::encoder::encode_metadata
  25:     0x7f5b932f12a0 - rustc_metadata[841ddd31d681d6d0]::fs::encode_and_write_metadata
  26:     0x7f5b932eb73f - <rustc_interface[8fcbc5e5f8656a70]::passes::QueryContext>::enter::<<rustc_interface[8fcbc5e5f8656a70]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[14a5817fc6fced97]::result::Result<alloc[276615df98e61306]::boxed::Box<dyn core[14a5817fc6fced97]::any::Any>, rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>>
  27:     0x7f5b932e3b93 - <rustc_interface[8fcbc5e5f8656a70]::queries::Queries>::ongoing_codegen
  28:     0x7f5b932e2923 - <rustc_interface[8fcbc5e5f8656a70]::interface::Compiler>::enter::<rustc_driver[a8b7cf0aaae3bece]::run_compiler::{closure#1}::{closure#2}, core[14a5817fc6fced97]::result::Result<core[14a5817fc6fced97]::option::Option<rustc_interface[8fcbc5e5f8656a70]::queries::Linker>, rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>>
  29:     0x7f5b932d62ca - rustc_span[1d346f2d776e330f]::with_source_map::<core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>, rustc_interface[8fcbc5e5f8656a70]::interface::create_compiler_and_run<core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>, rustc_driver[a8b7cf0aaae3bece]::run_compiler::{closure#1}>::{closure#1}>
  30:     0x7f5b932d5ca0 - rustc_interface[8fcbc5e5f8656a70]::interface::create_compiler_and_run::<core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>, rustc_driver[a8b7cf0aaae3bece]::run_compiler::{closure#1}>
  31:     0x7f5b932d4011 - <scoped_tls[72dc8926b5a0bddb]::ScopedKey<rustc_span[1d346f2d776e330f]::SessionGlobals>>::set::<rustc_interface[8fcbc5e5f8656a70]::interface::run_compiler<core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>, rustc_driver[a8b7cf0aaae3bece]::run_compiler::{closure#1}>::{closure#0}, core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>>
  32:     0x7f5b932d3cff - std[5f292d4f9c23a90f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8fcbc5e5f8656a70]::util::run_in_thread_pool_with_globals<rustc_interface[8fcbc5e5f8656a70]::interface::run_compiler<core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>, rustc_driver[a8b7cf0aaae3bece]::run_compiler::{closure#1}>::{closure#0}, core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>>::{closure#0}, core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>>
  33:     0x7f5b93928079 - <<std[5f292d4f9c23a90f]::thread::Builder>::spawn_unchecked_<rustc_interface[8fcbc5e5f8656a70]::util::run_in_thread_pool_with_globals<rustc_interface[8fcbc5e5f8656a70]::interface::run_compiler<core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>, rustc_driver[a8b7cf0aaae3bece]::run_compiler::{closure#1}>::{closure#0}, core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>>::{closure#0}, core[14a5817fc6fced97]::result::Result<(), rustc_errors[1e52fd968b2fd3e0]::ErrorGuaranteed>>::{closure#1} as core[14a5817fc6fced97]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7f5b91281143 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2d81a5fef99140ee
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/alloc/src/boxed.rs:1935:9
  35:     0x7f5b91281143 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1499905d273c8ff9
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/alloc/src/boxed.rs:1935:9
  36:     0x7f5b91281143 - std::sys::unix::thread::Thread::new::thread_start::hd9acf2283a0a68a9
                               at /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/std/src/sys/unix/thread.rs:108:17
  37:     0x7f5b91153609 - start_thread
  38:     0x7f5b91076133 - clone
  39:                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 (34a6cae28 2022-08-09) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground`

@tuxmark5 tuxmark5 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 Aug 10, 2022
@Noratrieb
Copy link
Member

searched nightlies: from nightly-2022-01-01 to nightly-2022-08-08
regressed nightly: nightly-2022-07-14
searched commit range: 1c7b36d...87588a2
regressed commit: c80dde4

bisected with cargo-bisect-rustc v0.6.4

Host triple: aarch64-apple-darwin
Reproduce with:

cargo bisect-rustc 2022-01-01 --end 2022-08-08 -- check

@Noratrieb
Copy link
Member

It was probably regressed by #98574, cc @dingxiangfei2009

@est31
Copy link
Member

est31 commented Aug 11, 2022

@rustbot label F-let-else

@rustbot rustbot added the F-let_else Issues related to let-else statements (RFC 3137) label Aug 11, 2022
@compiler-errors compiler-errors self-assigned this Aug 12, 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) 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.

5 participants