Skip to content

ICE: fictitious type <i32 as ToRef>::Ref in sizing_type_of() #37109

Closed

Description

@jp-beaumont

This example causes an internal compiler error:

pub trait ToRef<'a> {
    type Ref: 'a;
}

impl<'a, U: 'a> ToRef<'a> for U {
    type Ref = &'a U;
}

fn example<'a, T>(value: &'a T) -> (<T as ToRef<'a>>::Ref, u32) {
    (value, 0)
}

fn main() {
    example(&0);
}

Small changes to example or main such as eliminating the tuple or printing the result produce working code.

Version:

rustc 1.14.0-nightly (a3bc191b5 2016-10-10)
binary: rustc
commit-hash: a3bc191b5f41df5143cc65084b13999896411817
commit-date: 2016-10-10
host: x86_64-unknown-linux-gnu
release: 1.14.0-nightly

Errror message and backtrace:

error: internal compiler error: ../src/librustc_trans/type_of.rs:98: fictitious type <i32 as ToRef>::Ref in sizing_type_of()
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>', ../src/librustc_errors/lib.rs:656
stack backtrace:
   1:     0x7f3497eb9aef - std::sys::backtrace::tracing::imp::write::h22f199c1dbb72ba2
   2:     0x7f3497ec901d - std::panicking::default_hook::{{closure}}::h9a389c462b6a22dd
   3:     0x7f3497ec6496 - std::panicking::default_hook::h852b4223c1c00c59
   4:     0x7f3497ec6b78 - std::panicking::rust_panic_with_hook::hcd9d05f53fa0dafc
   5:     0x7f3494325607 - std::panicking::begin_panic::h2f463d37998ebeba
   6:     0x7f3494335768 - rustc_errors::Handler::bug::haca77c19c882b432
   7:     0x7f349538aa9a - rustc::session::opt_span_bug_fmt::{{closure}}::hfeb850fbe828b399
   8:     0x7f34952c9ba5 - rustc::session::opt_span_bug_fmt::h46e45438a860a75e
   9:     0x7f34952c99e2 - rustc::session::bug_fmt::hde22f071bf5a80ea
  10:     0x7f3496b20147 - rustc_trans::type_of::sizing_type_of::hf7867aeeebdabbb0
  11:     0x7f3496abc480 - rustc_trans::common::type_is_immediate::h93795cb753d0e711
  12:     0x7f3496abc6f0 - rustc_trans::common::type_is_imm_pair::h7e59f57fc9ab4576
  13:     0x7f3496b097b9 - rustc_trans::mir::operand::<impl rustc_trans::mir::MirContext<'bcx, 'tcx>>::trans_load::h2c9d8b0a9e8182b8
  14:     0x7f3496aff4cb - rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'bcx, 'tcx>>::store_return::h4d500d9c42a44cf7
  15:     0x7f3496afc4f9 - rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'bcx, 'tcx>>::trans_block::he67d3259f79e4177
  16:     0x7f3496af6b58 - rustc_trans::mir::trans_mir::h2fb44ecb31cfdffa
  17:     0x7f3496a98cdc - rustc_trans::base::trans_closure::h941de14309416d66
  18:     0x7f3496b16a34 - rustc_trans::trans_item::TransItem::define::ha4a18b94a3d46bf3
  19:     0x7f3496a9c254 - rustc_trans::base::trans_crate::h9b06de31ed8799d1
  20:     0x7f349824ed4d - rustc_driver::driver::phase_4_translate_to_llvm::hc3883ea2c4750179
  21:     0x7f3498289cf7 - rustc_driver::driver::compile_input::{{closure}}::h9162a2fa292aeb3f
  22:     0x7f3498280ef3 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h1928c4704cfe9c61
  23:     0x7f349824c6ed - rustc_driver::driver::phase_3_run_analysis_passes::he578df6b8805151c
  24:     0x7f3498238f69 - rustc_driver::driver::compile_input::h5b63ccd49eeeb98b
  25:     0x7f34982622ba - rustc_driver::run_compiler::h98c7274e7cb1d11d
  26:     0x7f349819bf0b - std::panicking::try::do_call::h99ed0da044e497c3
  27:     0x7f3497ed0f16 - __rust_maybe_catch_panic
  28:     0x7f34981ba461 - <F as alloc::boxed::FnBox<A>>::call_box::hbdd5a14cd8e33b97
  29:     0x7f3497ec4ef0 - std::sys::thread::Thread::new::thread_start::h50b05608a499d2b2
  30:     0x7f34901c0483 - start_thread
  31:     0x7f3497b916dc - clone
  32:                0x0 - <unknown>

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    on Oct 12, 2016
  2. TimNN commented on Oct 12, 2016

    @TimNN
    Contributor

    Regression from 1.11 to 1.12.

  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Oct 12, 2016
  4. alexcrichton commented on Oct 12, 2016

    @alexcrichton
    Member

    cc @rust-lang/compiler, another stable-to-stable regression :(

  5. nikomatsakis commented on Oct 12, 2016

    @nikomatsakis
    Contributor

    Pending fix in #37110

  6. added a commit that references this issue on Oct 13, 2016
    ee338c3
  7. reopened this on Oct 14, 2016
  8. brson commented on Oct 14, 2016

    @brson
    Contributor

    There is a PR open to solve this in a different way.

  9. added 2 commits that reference this issue on Oct 18, 2016
    b477047
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions