Skip to content

ICE: Rvalue::Discriminant on Lvalue of type #45885

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

Closed
sinkuu opened this issue Nov 9, 2017 · 1 comment
Closed

ICE: Rvalue::Discriminant on Lvalue of type #45885

sinkuu opened this issue Nov 9, 2017 · 1 comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@sinkuu
Copy link
Contributor

sinkuu commented Nov 9, 2017

Compiling this code with mir-opt-level=2 or higher produces an ICE.

pub enum Enum {
    A,
    B,
}

fn foo(s: &[Enum]) {
    match s[1-1] { Enum::A => true, _ => false };
}

fn main() {
    foo(&[Enum::A]);
}

backtrace:

error: internal compiler error: /checkout/src/librustc/mir/tcx.rs:187: Rvalue::Discriminant on Lvalue of type <usize as std::slice::SliceIndex<[Enum]>>::Output

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.23.0-nightly (ee2286149 2017-11-07) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:507:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:69
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:58
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::bug
   7: <std::thread::local::LocalKey<T>>::with
   8: rustc::ty::context::tls::with_opt
   9: _ZN5rustc7session16opt_span_bug_fmt17h28653ab0ad5ebc6eE.llvm.80CEBD21
  10: rustc::session::bug_fmt
  11: rustc::mir::tcx::<impl rustc::mir::Rvalue<'tcx>>::ty
  12: _ZN11rustc_trans3mir6rvalue76_$LT$impl$u20$rustc_trans..mir..MirContext$LT$$u27$a$C$$u20$$u27$tcx$GT$$GT$20trans_rvalue_operand17hb51fa7a56ff80228E.llvm.42CB1140
  13: rustc_trans::base::trans_instance
  14: rustc_trans::trans_item::TransItemExt::define
  15: _ZN11rustc_trans4base20compile_codegen_unit17ha4116c55c0998339E.llvm.42CB1140
  16: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::compute_result
  17: _ZN5rustc9dep_graph5graph8DepGraph14with_task_impl17h65fbb140f0b6ef1aE.llvm.828C6C6A
  18: rustc_errors::Handler::track_diagnostics
  19: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  20: _ZN5rustc2ty4maps80_$LT$impl$u20$rustc..ty..maps..queries..compile_codegen_unit$LT$$u27$tcx$GT$$GT$5force17had4524b73e79c5fbE.llvm.6336F49B
  21: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::try_get
  22: rustc::ty::maps::TyCtxtAt::compile_codegen_unit
  23: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::compile_codegen_unit
  24: rustc_trans::base::trans_crate
  25: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
  26: rustc::util::common::time
  27: rustc_driver::driver::phase_4_translate_to_llvm
  28: _ZN12rustc_driver6driver13compile_input28_$u7b$$u7b$closure$u7d$$u7d$17hb5bec2b4d6fc98bbE.llvm.5ECE37CB
  29: <std::thread::local::LocalKey<T>>::with
  30: <std::thread::local::LocalKey<T>>::with
  31: rustc::ty::context::TyCtxt::create_and_enter
  32: rustc_driver::driver::compile_input
  33: rustc_driver::run_compiler

rustc --version --verbose:

rustc 1.23.0-nightly (ee2286149 2017-11-07)
binary: rustc
commit-hash: ee2286149a5f0b148334841d4f067dc819dcca3b
commit-date: 2017-11-07
host: x86_64-unknown-linux-gnu
release: 1.23.0-nightly
LLVM version: 4.0
@arielb1
Copy link
Contributor

arielb1 commented Nov 9, 2017

Sounds like someone (I bet inlining) is not normalizing after substituting.

@estebank estebank added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Nov 9, 2017
bors added a commit that referenced this issue Nov 14, 2017
Normalize inlined function in MIR inliner

Fixes #45885

r? @arielb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants