Skip to content

ICE when comparing two *const Trait for equality #27449

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Twinklebear opened this issue Aug 1, 2015 · 1 comment
Closed

ICE when comparing two *const Trait for equality #27449

Twinklebear opened this issue Aug 1, 2015 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Twinklebear
Copy link

Hey all,

I'm trying to see if two &Trait refer to the same object. It sounds like the correct way to do this is by casting to *const Trait and comparing those pointers for equality, however this produces an ICE. Here's a simple repro on playpen and pasted below:

trait MyTrait {}

struct Foo;
impl MyTrait for Foo {}

fn main() {
    let x = Foo;
    let a = &x;
    let y = Foo;
    let z = &y as &MyTrait;

    if a as *const MyTrait == z as *const MyTrait {
        println!("They match");
    }
}

Below is the output of compiling the reproduction with RUST_BACKTRACE=1 on rustc 1.3.0-nightly (4dfe7a16c 2015-07-30)

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
thread 'rustc' panicked at 'assertion failed: self.appropriate_rvalue_mode(bcx.ccx()) == ByValue', ../src/librustc_trans/trans/datum.rs:767

stack backtrace:
   1:     0x7fe6e5afa28e - sys::backtrace::write::h40e4abee08c0ae4cCys
   2:     0x7fe6e5b027f4 - panicking::on_panic::h2d2b781277adb4bfLnx
   3:     0x7fe6e5ac3ace - rt::unwind::begin_unwind_inner::ha8a0cd4a16a72098o3w
   4:     0x7fe6e48969a1 - rt::unwind::begin_unwind::h10748794639547756261
   5:     0x7fe6e49171c4 - trans::datum::Datum<'tcx, K>::to_llscalarish::h18191786700678863130
   6:     0x7fe6e499223b - trans::expr::trans_binary::h0bd5cb5f100e03c3SvD
   7:     0x7fe6e4987ffb - trans::expr::trans_unadjusted::hd19df31c310773b8oXB
   8:     0x7fe6e48d2c49 - trans::expr::trans::hc28cc636bef2e50fYpB
   9:     0x7fe6e4989bcf - trans::expr::trans_rvalue_dps_unadjusted::he43b91a5a089a8ed4tC
  10:     0x7fe6e49627de - trans::expr::trans_into::h8c4ef2d012c8a2c0IjB
  11:     0x7fe6e48f28b3 - trans::controlflow::trans_block::h05d9494ae3fe12b5BWv
  12:     0x7fe6e48f1666 - trans::base::trans_closure::h3121f3bcc11648c5sDi
  13:     0x7fe6e48f2ea8 - trans::base::trans_fn::ha3af5a02c0e336d7fNi
  14:     0x7fe6e48f5fa8 - trans::base::trans_item::h55d2aa0c004afbf9qcj
  15:     0x7fe6e4902a68 - trans::base::trans_crate::ha1fc42a69e474159uZj
  16:     0x7fe6e60708d4 - driver::phase_4_translate_to_llvm::hc4ec4f8818648bb75Oa
  17:     0x7fe6e606ad68 - driver::phase_3_run_analysis_passes::closure.16499
  18:     0x7fe6e6064fe1 - middle::ty::ctxt<'tcx>::create_and_enter::h11776421653616432545
  19:     0x7fe6e606000f - driver::phase_3_run_analysis_passes::h8749574581471310871
  20:     0x7fe6e6044751 - driver::compile_input::h2888e18c0246b44eTba
  21:     0x7fe6e6129360 - run_compiler::h216b759eb7845cb3A7b
  22:     0x7fe6e6126f2e - boxed::F.FnBox<A>::call_box::h6091736725415782619
  23:     0x7fe6e6126859 - rt::unwind::try::try_fn::h7532542645103148343
  24:     0x7fe6e5b022bf - __rust_try_inner
  25:     0x7fe6e5b022fa - __rust_try
  26:     0x7fe6e5aed7a7 - rt::unwind::try::inner_try::hec4722a4abfa91b1hZw
  27:     0x7fe6e6126a78 - boxed::F.FnBox<A>::call_box::h7421094806661540209
  28:     0x7fe6e5b01411 - sys::thread::Thread::new::thread_start::h0036aa54802cb8d7X8v
  29:     0x7fe6df71d0da - start_thread
  30:     0x7fe6e575390c - __clone
  31:                0x0 - <unknown>
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Aug 1, 2015
@arielb1
Copy link
Contributor

arielb1 commented Aug 1, 2015

Known issue (duplicate of #18829). The relevant RFC (rust-lang/rfcs#1135) is entering FCP.

@arielb1 arielb1 closed this as completed Aug 1, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants