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

Internal compiler error from an incorrect Deref impl #24356

Closed
niconii opened this issue Apr 12, 2015 · 0 comments · Fixed by #24367
Closed

Internal compiler error from an incorrect Deref impl #24356

niconii opened this issue Apr 12, 2015 · 0 comments · Fixed by #24367
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@niconii
Copy link
Contributor

niconii commented Apr 12, 2015

This code produces an ICE for both beta and nightly. The code and backtrace are reproduced below:

fn main() {
    {
        use std::ops::Deref;

        struct Thing(i8);

        /*
        // Correct impl
        impl Deref for Thing {
            type Target = i8;
            fn deref(&self) -> &i8 { &self.0 }
        }
        */

        // Causes ICE
        impl Deref for Thing {
            fn deref(&self) -> i8 { self.0 }
        }

        let thing = Thing(72);

        *thing
    };
}
ice.rs:2:5: 23:6 error: internal compiler error: cat_expr Errd
ice.rs:2     {
ice.rs:3         use std::ops::Deref;
ice.rs:4 
ice.rs:5         struct Thing(i8);
ice.rs:6 
ice.rs:7         /*
         ...
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/beta-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:130

stack backtrace:
   1:     0x7f759aea23c8 - sys::backtrace::write::h179e141147f9ee14IJC
   2:     0x7f759aecd770 - panicking::on_panic::h6aa569d33389f0cfsXI
   3:     0x7f759ae054a3 - rt::unwind::begin_unwind_inner::h082f07869f4b9731ACI
   4:     0x7f75981cb04d - rt::unwind::begin_unwind::h13428428822164950735
   5:     0x7f75981caff3 - diagnostic::SpanHandler::span_bug::he82cb6427e6a50a8jnB
   6:     0x7f7598a6cb63 - session::Session::span_bug::h460607360e8bf7cc5Xq
   7:     0x7f7599b2ed0d - check::regionck::visit_expr::hfc7cf3e25c050a92PJd
   8:     0x7f7599b29ce0 - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::hd4da730c0cf65ac9amd
   9:     0x7f7599bc4b91 - check::check_bare_fn::hb43e600383cf2ee2UQn
  10:     0x7f7599bbe674 - check::check_item::h77d9b4d4612f23cfF9n
  11:     0x7f7599c96a96 - check_crate::closure.36300
  12:     0x7f7599c90e73 - check_crate::h4b0848761f18a2bcbwC
  13:     0x7f759b5215cd - driver::phase_3_run_analysis_passes::hf7cad4098b28ceb1gGa
  14:     0x7f759b505425 - driver::compile_input::h7c62c2870ff901f6Qba
  15:     0x7f759b5bca25 - run_compiler::hc815b49ce638c28eV4b
  16:     0x7f759b5ba33d - boxed::F.FnBox<A>::call_box::h4290333406520961126
  17:     0x7f759b5b9879 - rt::unwind::try::try_fn::h13999576404798567721
  18:     0x7f759af49c68 - rust_try_inner
  19:     0x7f759af49c55 - rust_try
  20:     0x7f759b5b9b4b - boxed::F.FnBox<A>::call_box::h14489442628055152240
  21:     0x7f759aeb8781 - sys::thread::create::thread_start::h02b7da32b4d7a4aaExH
  22:     0x7f7594ca9373 - start_thread
  23:     0x7f759aa7827c - __clone
  24:                0x0 - <unknown>
@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 13, 2015
ebfull added a commit to ebfull/rust that referenced this issue Apr 13, 2015
An actual typeck error is the cause of many failed compilations but an
unrelated bug is being reported instead. It is triggered because a typeck
error is presumably not yet identified during compiler execution, which
would normally bypass an invariant in the presence of other errors. In
this particular situation, we delay the reporting of the bug until
abort_if_errors().

Closes rust-lang#23827, closes rust-lang#24356, closes rust-lang#23041, closes rust-lang#22897, closes rust-lang#23966,
closes rust-lang#24013, and closes rust-lang#23729
bors added a commit that referenced this issue Apr 26, 2015
An actual typeck error is the cause of many failed compilations but an
unrelated bug is being reported instead. It is triggered because a typeck
error is presumably not yet identified during compiler execution, which
would normally bypass an invariant in the presence of other errors. In
this particular situation, we delay the reporting of the bug until
abort_if_errors().

Closes #23827, closes #24356, closes #23041, closes #22897, closes #23966,
closes #24013, and closes #23729

**There is at least one situation where this bug may still be genuinely
triggered (#23437).**
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

Successfully merging a pull request may close this issue.

2 participants