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: "Expected ConstKind::Param" in PatCtxt::lower_inline_const #104277

Closed
jruderman opened this issue Nov 11, 2022 · 0 comments · Fixed by #104294
Closed

ICE: "Expected ConstKind::Param" in PatCtxt::lower_inline_const #104277

jruderman opened this issue Nov 11, 2022 · 0 comments · Fixed by #104294
Assignees
Labels
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.

Comments

@jruderman
Copy link
Contributor

Found by fuzzing with a modified fuzz-rustc

Code

#![allow(incomplete_features)]
#![feature(inline_const_pat)]

fn main() {
    match () {
        const { (|| {})() } => {}
    }
}

Error output

error[E0015]: cannot call non-const closure in constants

error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/mod.rs:580:22: Expected ConstKind::Param
Full output with backtrace

error[E0015]: cannot call non-const closure in constants
 --> fm.rs:6:17
  |
6 |         const { (|| {})() } => {}
  |                 ^^^^^^^^^
  |
  = note: closures need an RFC before allowed to be called in constants
  = note: calls in constants are limited to constant functions, tuple structs and tuple variants

error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/mod.rs:580:22: Expected ConstKind::Param

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e75aab045fc476f176a58c408f6b06f0e275c6e1/compiler/rustc_errors/src/lib.rs:1551:9
stack backtrace:
   0:        0x1064f1f12 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b594e9bcc0c6898
   1:        0x1065504ba - core::fmt::write::h7c6f83d024852aa9
   2:        0x1064e3fec - std::io::Write::write_fmt::h97d969d4aea1606d
   3:        0x1064f1cda - std::sys_common::backtrace::print::h562dadf6028256bf
   4:        0x1064f50b6 - std::panicking::default_hook::{{closure}}::hee367e24075678e4
   5:        0x1064f4e07 - std::panicking::default_hook::hcce3553a0befadd1
   6:        0x112247f3d - rustc_driver[f93b8a3886cc8b65]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x1064f58b5 - std::panicking::rust_panic_with_hook::h4f6feaafc55c56a2
   8:        0x1169654d7 - std[38dd6138ba148cb2]::panicking::begin_panic::<rustc_errors[ef89fc2f19a46f90]::ExplicitBug>::{closure#0}
   9:        0x116964be9 - std[38dd6138ba148cb2]::sys_common::backtrace::__rust_end_short_backtrace::<std[38dd6138ba148cb2]::panicking::begin_panic<rustc_errors[ef89fc2f19a46f90]::ExplicitBug>::{closure#0}, !>
  10:        0x117010a39 - std[38dd6138ba148cb2]::panicking::begin_panic::<rustc_errors[ef89fc2f19a46f90]::ExplicitBug>
  11:        0x11695f2c9 - std[38dd6138ba148cb2]::panic::panic_any::<rustc_errors[ef89fc2f19a46f90]::ExplicitBug>
  12:        0x11695d53d - <rustc_errors[ef89fc2f19a46f90]::HandlerInner>::bug::<&alloc[dd1f1a43ef059f04]::string::String>
  13:        0x11695d007 - <rustc_errors[ef89fc2f19a46f90]::Handler>::bug::<&alloc[dd1f1a43ef059f04]::string::String>
  14:        0x116ab9872 - rustc_middle[85091bb6846d2e9a]::ty::context::tls::with_context_opt::<rustc_middle[85091bb6846d2e9a]::ty::context::tls::with_opt<rustc_middle[85091bb6846d2e9a]::util::bug::opt_span_bug_fmt<rustc_span[50ad8565b2f1bbfb]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  15:        0x116aba7d1 - rustc_middle[85091bb6846d2e9a]::util::bug::opt_span_bug_fmt::<rustc_span[50ad8565b2f1bbfb]::span_encoding::Span>
  16:        0x1170123ee - rustc_middle[85091bb6846d2e9a]::util::bug::bug_fmt
  17:        0x115468e69 - <rustc_mir_build[703b7840e825b276]::thir::pattern::PatCtxt>::lower_lit
  18:        0x115464810 - <rustc_mir_build[703b7840e825b276]::thir::pattern::PatCtxt>::lower_pattern
  19:        0x1154535d7 - <rustc_mir_build[703b7840e825b276]::thir::pattern::check_match::MatchVisitor>::lower_pattern
  20:        0x1154259c4 - <alloc[dd1f1a43ef059f04]::vec::Vec<rustc_mir_build[703b7840e825b276]::thir::pattern::usefulness::MatchArm> as alloc[dd1f1a43ef059f04]::vec::spec_from_iter::SpecFromIter<rustc_mir_build[703b7840e825b276]::thir::pattern::usefulness::MatchArm, core[322641b34a183a]::iter::adapters::map::Map<core[322641b34a183a]::slice::iter::Iter<rustc_hir[99b15258362c6b97]::hir::Arm>, <rustc_mir_build[703b7840e825b276]::thir::pattern::check_match::MatchVisitor>::check_match::{closure#0}>>>::from_iter
  21:        0x115451154 - <rustc_mir_build[703b7840e825b276]::thir::pattern::check_match::MatchVisitor as rustc_hir[99b15258362c6b97]::intravisit::Visitor>::visit_expr
  22:        0x115450f10 - <rustc_mir_build[703b7840e825b276]::thir::pattern::check_match::MatchVisitor as rustc_hir[99b15258362c6b97]::intravisit::Visitor>::visit_expr
  23:        0x115450b63 - rustc_mir_build[703b7840e825b276]::thir::pattern::check_match::check_match
  24:        0x115a7eac6 - rustc_query_system[38b064a260926677]::query::plumbing::try_execute_query::<rustc_query_impl[fcf86a589ba14889]::plumbing::QueryCtxt, rustc_query_system[38b064a260926677]::query::caches::DefaultCache<rustc_span[50ad8565b2f1bbfb]::def_id::DefId, ()>>
  25:        0x115b2be4c - rustc_query_system[38b064a260926677]::query::plumbing::get_query::<rustc_query_impl[fcf86a589ba14889]::queries::check_match, rustc_query_impl[fcf86a589ba14889]::plumbing::QueryCtxt>
  26:        0x1122ced3b - <rustc_session[304ed9bc7c986c94]::session::Session>::time::<(), rustc_interface[bab52cec3fba6e57]::passes::analysis::{closure#1}::{closure#0}::{closure#0}>
  27:        0x1122d1407 - <rustc_session[304ed9bc7c986c94]::session::Session>::time::<(), rustc_interface[bab52cec3fba6e57]::passes::analysis::{closure#1}>
  28:        0x11230b3dc - rustc_interface[bab52cec3fba6e57]::passes::analysis
  29:        0x115ac6b7c - rustc_query_system[38b064a260926677]::query::plumbing::try_execute_query::<rustc_query_impl[fcf86a589ba14889]::plumbing::QueryCtxt, rustc_query_system[38b064a260926677]::query::caches::DefaultCache<(), core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>>>
  30:        0x115b40f39 - rustc_query_system[38b064a260926677]::query::plumbing::get_query::<rustc_query_impl[fcf86a589ba14889]::queries::analysis, rustc_query_impl[fcf86a589ba14889]::plumbing::QueryCtxt>
  31:        0x1121d7416 - <rustc_interface[bab52cec3fba6e57]::passes::QueryContext>::enter::<rustc_driver[f93b8a3886cc8b65]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>>
  32:        0x11221b68d - rustc_span[50ad8565b2f1bbfb]::with_source_map::<core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>, rustc_interface[bab52cec3fba6e57]::interface::run_compiler<core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>, rustc_driver[f93b8a3886cc8b65]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  33:        0x11220b5bc - <scoped_tls[5d80669e9829205e]::ScopedKey<rustc_span[50ad8565b2f1bbfb]::SessionGlobals>>::set::<rustc_interface[bab52cec3fba6e57]::interface::run_compiler<core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>, rustc_driver[f93b8a3886cc8b65]::run_compiler::{closure#1}>::{closure#0}, core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>>
  34:        0x1121da37a - std[38dd6138ba148cb2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[bab52cec3fba6e57]::util::run_in_thread_pool_with_globals<rustc_interface[bab52cec3fba6e57]::interface::run_compiler<core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>, rustc_driver[f93b8a3886cc8b65]::run_compiler::{closure#1}>::{closure#0}, core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>>
  35:        0x1121c0b4b - <<std[38dd6138ba148cb2]::thread::Builder>::spawn_unchecked_<rustc_interface[bab52cec3fba6e57]::util::run_in_thread_pool_with_globals<rustc_interface[bab52cec3fba6e57]::interface::run_compiler<core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>, rustc_driver[f93b8a3886cc8b65]::run_compiler::{closure#1}>::{closure#0}, core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[322641b34a183a]::result::Result<(), rustc_errors[ef89fc2f19a46f90]::ErrorGuaranteed>>::{closure#1} as core[322641b34a183a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:        0x1064fe967 - std::sys::unix::thread::Thread::new::thread_start::hae9a83a2ac729f3b
  37:     0x7ff80d84d4e1 - __pthread_start

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.67.0-nightly (e75aab045 2022-11-09) running on x86_64-apple-darwin

query stack during panic:
#0 [check_match] match-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0015`.

Regression

This input has ICEd for a year, but the failure point has changed during that time:

2021-11-10: first ice

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: InterpErrorInfo(InterpErrorInfoInner { kind: referenced constant has errors, backtrace: None })', compiler/rustc_const_eval/src/const_eval/mod.rs:146:41

2021-11-24: ice no longer requires #![feature(inline_const)]

2022-05-19: changed to "Expected either ConstKind::Param or ConstKind::Unevaluated"

2022-09-18: changed to "Expected ConstKind::Param"

Version

rustc 1.67.0-nightly (e75aab045 2022-11-09)
binary: rustc
commit-hash: e75aab045fc476f176a58c408f6b06f0e275c6e1
commit-date: 2022-11-09
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
@jruderman jruderman 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 Nov 11, 2022
@compiler-errors compiler-errors self-assigned this Nov 11, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 14, 2022
…ir-build, r=davidtwco

Don't ICE with inline const errors during MIR build

Fixes rust-lang#104277
@bors bors closed this as completed in f8e5b1c Nov 15, 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. 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