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

const_if_match ICE #67405

Closed
DutchGhost opened this issue Dec 18, 2019 · 6 comments
Closed

const_if_match ICE #67405

DutchGhost opened this issue Dec 18, 2019 · 6 comments
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Dec 18, 2019

The following code ICE's on beta and nightly, (notice how I DIDN'T use the ``#![feature(const_if_match)]` feature)

struct Bug {
    inner: [(); match || {1} {
        n => n(),
    }],
}
Backtrace:

 Compiling playground v0.0.1 (/playground)
error[E0658]: `match` is not allowed in a `const`
 --> src/lib.rs:2:17
  |
2 |       inner: [(); match || {1} {
  |  _________________^
3 | |         n => n(),
4 | |     }],
  | |_____^
  |
  = note: for more information, see https://github.com/rust-lang/rust/issues/49146
  = help: add `#![feature(const_if_match)]` to the crate attributes to enable

error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
 --> src/lib.rs:3:14
  |
3 |         n => n(),
  |              ^^^

error: internal compiler error: src/librustc_typeck/collect.rs:1869: to get the signature of a closure, use `closure_sig()` not `fn_sig()`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:892:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1025
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:193
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:475
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::bug_fmt
  20: rustc_typeck::collect::fn_sig
  21: rustc::ty::query::__query_compute::fn_sig
  22: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::fn_sig>::compute
  23: rustc::dep_graph::graph::DepGraph::with_task_impl
  24: rustc_rayon_core::tlv::with
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  26: rustc::ty::constness::provide::is_const_fn_raw
  27: rustc::ty::query::__query_compute::is_const_fn_raw
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::is_const_fn_raw>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc_rayon_core::tlv::with
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  32: <rustc_mir::const_eval::CompileTimeInterpreter as rustc_mir::interpret::machine::Machine>::find_mir_or_eval_fn
  33: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_fn_call
  34: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::step
  35: rustc_mir::const_eval::const_eval_raw_provider
  36: rustc::ty::query::__query_compute::const_eval_raw
  37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc_rayon_core::tlv::with
  40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  41: rustc_mir::const_eval::const_eval_provider
  42: rustc::ty::query::__query_compute::const_eval
  43: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  44: rustc::dep_graph::graph::DepGraph::with_task_impl
  45: rustc_rayon_core::tlv::with
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  47: rustc_mir::const_eval::const_eval_provider
  48: rustc::ty::query::__query_compute::const_eval
  49: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  50: rustc::dep_graph::graph::DepGraph::with_task_impl
  51: rustc_rayon_core::tlv::with
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  53: rustc::ty::sty::Const::eval::{{closure}}
  54: <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const
  55: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
  56: <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
  57: rustc::traits::project::normalize
  58: rustc_typeck::check::FnCtxt::normalize_associated_types_in
  59: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  60: rustc_rayon_core::tlv::with
  61: rustc::ty::context::GlobalCtxt::enter_local
  62: rustc_typeck::check::wfcheck::check_item_well_formed
  63: rustc::ty::query::__query_compute::check_item_well_formed
  64: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_item_well_formed>::compute
  65: rustc::dep_graph::graph::DepGraph::with_task_impl
  66: rustc_rayon_core::tlv::with
  67: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  68: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  69: rustc_rayon::iter::plumbing::Producer::fold_with
  70: rustc_rayon::iter::plumbing::bridge_producer_consumer::helper
  71: rustc_rayon_core::job::StackJob<L,F,R>::run_inline
  72: rustc_rayon_core::registry::in_worker
  73: rustc_rayon::iter::plumbing::bridge_producer_consumer::helper
  74: std::panicking::try::do_call
  75: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  76: <rustc_rayon_core::job::StackJob<L,F,R> as rustc_rayon_core::job::Job>::execute
  77: rustc_rayon_core::registry::WorkerThread::wait_until_cold
  78: rustc_rayon_core::registry::ThreadBuilder::run
  79: scoped_tls::ScopedKey<T>::set
  80: std::thread::local::LocalKey<T>::with
  81: scoped_tls::ScopedKey<T>::set
  82: crossbeam_utils::thread::ScopedThreadBuilder::spawn::{{closure}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.41.0-nightly (3ed3b8bb7 2019-12-17) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [fn_sig] processing `Bug::inner::{{constant}}#0::{{closure}}#0`
#1 [is_const_fn_raw] checking if item is const fn: `Bug::inner::{{constant}}#0::{{closure}}#0`
#2 [const_eval_raw] const-evaluating `Bug::inner::{{constant}}#0`
#3 [const_eval] const-evaluating + checking `Bug::inner::{{constant}}#0`
#4 [const_eval] const-evaluating + checking `Bug::inner::{{constant}}#0`
#5 [check_item_well_formed] processing `Bug`
#6 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.
error: could not compile `playground`.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. F-const_if_match 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 Dec 18, 2019
@estebank
Copy link
Contributor

estebank commented Dec 18, 2019

I believe it might have been introduced by #66866

CC @oli-obk

@estebank estebank added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Dec 18, 2019
@hellow554
Copy link
Contributor

This is a regression from stable to beta as well.

@oli-obk
Copy link
Contributor

oli-obk commented Dec 19, 2019

Ugh, typeck failing does not mean const eval won't run. I guess we need more tainted_by_errors (https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TypeckTables.html#structfield.tainted_by_errors) checks everywhere.

@jonas-schievink jonas-schievink added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Dec 19, 2019
@pnkfelix
Copy link
Member

triage: P-high. Leaving nominated.

@pnkfelix pnkfelix added the P-high High priority label Dec 19, 2019
@pnkfelix
Copy link
Member

discussed in T-compiler meeting. Downgrading to P-medium

@pnkfelix pnkfelix added P-medium Medium priority and removed P-high High priority I-nominated labels Dec 19, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 22, 2019
@pietroalbini pietroalbini added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Jan 27, 2020
@Alexendoo
Copy link
Member

Fixed by #68563

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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants