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

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

Closed
jp-beaumont opened this issue Oct 12, 2016 · 4 comments
Closed

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

jp-beaumont opened this issue Oct 12, 2016 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jp-beaumont
Copy link

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>
@TimNN TimNN added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Oct 12, 2016
@TimNN
Copy link
Contributor

TimNN commented Oct 12, 2016

Regression from 1.11 to 1.12.

@TimNN TimNN added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 12, 2016
@alexcrichton
Copy link
Member

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

@nikomatsakis
Copy link
Contributor

Pending fix in #37110

@bors bors closed this as completed in 27043b1 Oct 13, 2016
arielb1 added a commit to arielb1/rust that referenced this issue Oct 13, 2016
Associated type normalization is inhibited by higher-ranked regions.
Therefore, every time we erase them, we must re-normalize.

I was meaning to introduce this change some time ago, but we used
to erase regions in generic context, which broke this terribly (because
you can't always normalize in a generic context). That seems to be gone
now.

Ensure this by having a `erase_late_bound_regions_and_normalize`
function.

Fixes rust-lang#37109 (the missing call was in mir::block).
@brson brson reopened this Oct 14, 2016
@brson
Copy link
Contributor

brson commented Oct 14, 2016

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

bors added a commit that referenced this issue Oct 16, 2016
normalize types every time HR regions are erased

Associated type normalization is inhibited by higher-ranked regions.
Therefore, every time we erase them, we must re-normalize.

I was meaning to introduce this change some time ago, but we used
to erase regions in generic context, which broke this terribly (because
you can't always normalize in a generic context). That seems to be gone
now.

Ensure this by having a `erase_late_bound_regions_and_normalize`
function.

Fixes #37109 (the missing call was in mir::block).

r? @eddyb
brson pushed a commit to brson/rust that referenced this issue Oct 18, 2016
Associated type normalization is inhibited by higher-ranked regions.
Therefore, every time we erase them, we must re-normalize.

I was meaning to introduce this change some time ago, but we used
to erase regions in generic context, which broke this terribly (because
you can't always normalize in a generic context). That seems to be gone
now.

Ensure this by having a `erase_late_bound_regions_and_normalize`
function.

Fixes rust-lang#37109 (the missing call was in mir::block).
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) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants