Skip to content

ICE: deref invoked on expr of illegal type #13044

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
alexcrichton opened this issue Mar 20, 2014 · 1 comment
Closed

ICE: deref invoked on expr of illegal type #13044

alexcrichton opened this issue Mar 20, 2014 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@alexcrichton
Copy link
Member

// baz.rs

pub struct Foo<T> {
    t: T,
}
pub struct Bar<'a, T> {
    other: &'a Foo<T>,
}

impl<T:Clone> Foo<T> {
    pub fn get(&self) -> T {
        self.borrow().clone() // this causes the bug, (*self.borrow()).clone() does not cause the bug
    }
}

impl<T> Foo<T> {
    pub fn borrow<'a>(&'a self) -> Bar<'a, T> {
        Bar { other: self }
    }
}

impl<'a, T> Deref<T> for Bar<'a, T> {
    fn deref<'a>(&'a self) -> &'a T { &self.other.t }
}
// bar.rs
extern crate baz;

pub fn main() {
    let a = baz::Foo { t: 3 };
    a.get();
}
$ rustc baz.rs --crate-type=lib
$ rustc bar.rs -L. --crate-type=lib
bar.rs:1:1: 1:1 error: internal compiler error: deref invoked on expr of illegal type baz::Bar<,int>
bar.rs:1 extern crate baz;
         ^
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at '~Any', /home/alex/code/rust2/src/libsyntax/diagnostic.rs:67
stack backtrace:
   1:     0x7fc477b70600 - rt::backtrace::imp::write::h0a3da0d1a2b69852CFb::v0.10.pre
   2:     0x7fc477ad5e10 - rt::unwind::begin_unwind_inner::h47835116a042632f6fb::v0.10.pre
   3:     0x7fc4769936d0 - rt::unwind::begin_unwind::h0455dc0cf4617207WJY::v0.10.pre
   4:     0x7fc476993600 - diagnostic::SpanHandler::span_bug::h87a637929a2ba539J2b::v0.10.pre
   5:     0x7fc4787d0db0 - driver::session::Session::span_bug::h3e329875996d4503iNg::v0.10.pre
   6:     0x7fc4787fd180 - middle::trans::expr::deref_once::hfc675e5cf83d870djNg::v0.10.pre
   7:     0x7fc4787adc20 - middle::trans::expr::trans::hb9d355dc1389919b3re::v0.10.pre
   8:     0x7fc4787df4a0 - middle::trans::callee::trans_args::h801ef5329faee7b88Yd::v0.10.pre
   9:     0x7fc4787dbad0 - middle::trans::callee::trans_call_inner::hf880ecf3afa1b9e3cMd::v0.10.pre
  10:     0x7fc4787dd310 - middle::trans::callee::trans_method_call::h4181e13357fc6c884Ed::v0.10.pre
  11:     0x7fc4787e5330 - middle::trans::expr::trans_rvalue_dps_unadjusted::h7fce2857982094dd0ef::v0.10.pre
  12:     0x7fc4787ab170 - middle::trans::expr::trans_into::h875b09228cc9c1bd0ne::v0.10.pre
  13:     0x7fc4787ac220 - middle::trans::controlflow::trans_block::hac82528c93237c1e43a::v0.10.pre
  14:     0x7fc47884ee90 - middle::trans::base::trans_closure::h5d95a9706f2fbe34nwo::v0.10.pre
  15:     0x7fc47877df00 - middle::trans::base::trans_fn::h89bd72d9d81085f7bEo::v0.10.pre
  16:     0x7fc47877e400 - middle::trans::monomorphize::monomorphic_fn::h1a20bed6a8247e12hma::v0.10.pre
  17:     0x7fc4787d4030 - middle::trans::callee::trans_fn_ref_with_vtables::hdd0050d098541e109ld::v0.10.pre
  18:     0x7fc4787d0e80 - middle::trans::callee::trans_fn_ref::h118979777dc53710kfd::v0.10.pre
  19:     0x7fc4787dda50 - middle::trans::meth::trans_method_callee::h18e3f0a6a2686880Muv::v0.10.pre
  20:     0x7fc4787dd9e0 - middle::trans::callee::trans_method_call::closure.56544
  21:     0x7fc4787dbad0 - middle::trans::callee::trans_call_inner::hf880ecf3afa1b9e3cMd::v0.10.pre
  22:     0x7fc4787dd310 - middle::trans::callee::trans_method_call::h4181e13357fc6c884Ed::v0.10.pre
  23:     0x7fc4787e5330 - middle::trans::expr::trans_rvalue_dps_unadjusted::h7fce2857982094dd0ef::v0.10.pre
  24:     0x7fc4787ab170 - middle::trans::expr::trans_into::h875b09228cc9c1bd0ne::v0.10.pre
  25:     0x7fc4787aa670 - middle::trans::controlflow::trans_stmt::hf5d8676d4091ff500Za::v0.10.pre
  26:     0x7fc4787ac220 - middle::trans::controlflow::trans_block::hac82528c93237c1e43a::v0.10.pre
  27:     0x7fc47884ee90 - middle::trans::base::trans_closure::h5d95a9706f2fbe34nwo::v0.10.pre
  28:     0x7fc47877df00 - middle::trans::base::trans_fn::h89bd72d9d81085f7bEo::v0.10.pre
  29:     0x7fc478778e40 - middle::trans::base::trans_item::hc3e103cd7fd45af3MPo::v0.10.pre
  30:     0x7fc4788538f0 - middle::trans::base::trans_mod::h8284b7b2a3c44204XUo::v0.10.pre
  31:     0x7fc47885d560 - middle::trans::base::trans_crate::h06075c2881b3db50Rvq::v0.10.pre
  32:     0x7fc478ea9a20 - driver::driver::phase_4_translate_to_llvm::h0e9ee050f04a37a04bf::v0.10.pre
  33:     0x7fc478eabbf0 - driver::driver::compile_input::h25694f7d6d3db52c2rf::v0.10.pre
  34:     0x7fc478ecf9c0 - run_compiler::h29c4ca08e9ca1aa715m::v0.10.pre
  35:     0x7fc478ee2ca0 - main_args::closure.91093
  36:     0x7fc478ee15d0 - monitor::closure.90978
  37:     0x7fc478edcfa0 - task::TaskBuilder::try::closure.90789
  38:     0x7fc478207340 - task::spawn_opts::closure.7482
  39:     0x7fc477b6bd20 - rt::task::Task::run::closure.40664
  40:     0x7fc477b77110 - rust_try
  41:     0x7fc477b6bb60 - rt::task::Task::run::h62fd53fd1182d536d58::v0.10.pre
  42:     0x7fc4782070e0 - task::spawn_opts::closure.7455
  43:     0x7fc477b6f0c0 - rt::thread::thread_start::h3097fcbfdebaed97FL9::v0.10.pre
  44:     0x7fc4750fcea0 - start_thread
  45:     0x7fc477795999 - __clone
  46:                0x0 - <unknown>

@alexcrichton
Copy link
Member Author

minimized case posted.

bors added a commit that referenced this issue Mar 22, 2014
This commit removes the `get()` method from `Ref` and `RefMut` in favor of the `*` operator, and removes all usage of the `deref()` function manually from rustc, favoring using `*` instead.

Some of the code is a little wacky, but that's due to either #13044 or #13042
@bors bors closed this as completed in 087ec2a Mar 23, 2014
lnicola pushed a commit to lnicola/rust that referenced this issue Aug 23, 2022
fix: a bunch of typos

This PR will fix some typos detected by [typos].

There are also some other typos in the function names, variable names, and file
names, which I leave as they are. I'm more certain that typos in comments
should be fixed.

[typos]: https://github.com/crate-ci/typos
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 11, 2024
Refactor `bool_to_int_with_if`

Rearranges things to check the HIR tree first and simplifies how the literals are read.

changelog: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

1 participant