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 panic ICE: ref_to_mplace called on non-ptr type #68782

Closed
DutchGhost opened this issue Feb 2, 2020 · 1 comment
Closed

const panic ICE: ref_to_mplace called on non-ptr type #68782

DutchGhost opened this issue Feb 2, 2020 · 1 comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DutchGhost
Copy link
Contributor

The following ICE's:

#![feature(const_if_match)]
#![feature(const_fn)]
#![feature(const_panic)]

const fn bug(mut array: &[isize], mut ip: usize) {
    match array[ip] {
        _ => panic!(1),
    }
    
}

const _: () = bug(&[1], 0);
Backtrace:
 Compiling playground v0.0.1 (/playground)
warning: function is never used: `bug`
 --> src/lib.rs:5:10
  |
5 | const fn bug(array: &[isize], ip: usize) {
  |          ^^^
  |
  = note: `#[warn(dead_code)]` on by default

thread 'rustc' panicked at '`ref_to_mplace` called on non-ptr type', src/librustc_mir/interpret/place.rs:309:13
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:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  12: rust_begin_unwind
             at src/libstd/panicking.rs:378
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  14: core::option::expect_failed
             at src/libcore/option.rs:1191
  15: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::ref_to_mplace
  16: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::deref_operand
  17: rustc_mir::interpret::intrinsics::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::hook_panic_fn
  18: <rustc_mir::const_eval::machine::CompileTimeInterpreter as rustc_mir::interpret::machine::Machine>::find_mir_or_eval_fn
  19: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_fn_call
  20: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  21: rustc_mir::const_eval::eval_queries::const_eval_raw_provider
  22: rustc::ty::query::__query_compute::const_eval_raw
  23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  24: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  25: rustc::ty::query::__query_compute::const_eval_validated
  26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  27: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  28: rustc::ty::query::__query_compute::const_eval_validated
  29: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_validated>::compute
  30: rustc::dep_graph::graph::DepGraph::with_task_impl
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  32: rustc::mir::interpret::queries::<impl rustc::ty::context::TyCtxt>::const_eval_poly
  33: <rustc_lint::BuiltinCombinedLateLintPass as rustc_lint::passes::LateLintPass>::check_item
  34: rustc_hir::intravisit::Visitor::visit_nested_item
  35: rustc_hir::intravisit::walk_crate
  36: rustc_session::utils::<impl rustc_session::session::Session>::time
  37: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  38: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  39: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  40: rustc_session::utils::<impl rustc_session::session::Session>::time
  41: rustc_interface::passes::analysis
  42: rustc::ty::query::__query_compute::analysis
  43: rustc::dep_graph::graph::DepGraph::with_task_impl
  44: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  45: rustc::ty::context::tls::enter_global
  46: rustc_interface::interface::run_compiler_in_existing_thread_pool
  47: scoped_tls::ScopedKey<T>::set
  48: syntax::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0-nightly (13db6501c 2020-02-01) 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 [const_eval_raw] const-evaluating `_`
#1 [const_eval_validated] const-evaluating + checking `_`
#2 [const_eval_validated] const-evaluating + checking `_`
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground`.

To learn more, run the command again with --verbose.
@DutchGhost DutchGhost changed the title const fn ICE const panic ICE Feb 2, 2020
@DutchGhost DutchGhost changed the title const panic ICE const panic ICE: ref_to_mplace called on non-ptr type Feb 2, 2020
@jonas-schievink jonas-schievink added A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. F-const_fn I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 2, 2020
@jonas-schievink
Copy link
Contributor

Duplicate of #66693

@jonas-schievink jonas-schievink marked this as a duplicate of #66693 Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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

2 participants