Skip to content

Extra type parameters make compiler panic calling Option::unwrap() on None #36708

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
raviqqe opened this issue Sep 25, 2016 · 1 comment
Closed
Assignees
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@raviqqe
Copy link

raviqqe commented Sep 25, 2016

This works.

use std::ops::Div;

struct Foo(u64);

impl Div for Foo {
  type Output = Self;

  fn div(self, rhs: Self) -> Self::Output {
    Foo(0)
  }
}

fn main() {}

However, the code below doesn't because div has an extra parametric type T. But, the compiler doesn't emit proper error messages and says the compiler unexpectedly panicked. this is a bug..

use std::ops::Div;

struct Foo(u64);

impl Div for Foo {
  type Output = Self;

  fn div<T>(self, rhs: Self) -> Self::Output {
    Foo(0)
  }
}

fn main() {}

Error message

$ rustc main.rs
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 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:325
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Meta

$ rustc --version --verbose
rustc 1.13.0-nightly (4f9812a59 2016-09-21)
binary: rustc
commit-hash: 4f9812a59ab7247f0f52b01ca89b0793a2d289c3
commit-date: 2016-09-21
host: x86_64-unknown-linux-gnu
release: 1.13.0-nightly

Backtrace

$ RUST_BACKTRACE=1 rustc main.rs
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                                                                       

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:325
stack backtrace:
   1:     0x7fad5818a612 - std::sys::backtrace::tracing::imp::write::h4b09e6e8c01db097
   2:     0x7fad5819b42d - std::panicking::default_hook::{{closure}}::h1d3243f546573ff4
   3:     0x7fad5819887e - std::panicking::default_hook::h96c288d728df3ebf
   4:     0x7fad58198f68 - std::panicking::rust_panic_with_hook::hb1322e5f2588b4db
   5:     0x7fad58198e02 - std::panicking::begin_panic::hfbeda5aad583dc32
   6:     0x7fad58198d40 - std::panicking::begin_panic_fmt::h4fe9fb9d5109c4bf
   7:     0x7fad58198cc1 - rust_begin_unwind
   8:     0x7fad581e655c - core::panicking::panic_fmt::h4395919ece15c671
   9:     0x7fad581e648b - core::panicking::panic::hc74ff52ed78364e1
  10:     0x7fad5653534c - rustc_typeck::check::compare_method::compare_impl_method::h8b4c10d2a59ffd1f
  11:     0x7fad5654759f - rustc_typeck::check::check_impl_items_against_trait::h7d9aa9ff182ea156
  12:     0x7fad565452a8 - rustc_typeck::check::check_item_type::hb34d7fe10dce9af2
  13:     0x7fad5653eedb - <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::hf0cba92c71ce3aaf
  14:     0x7fad56540b28 - rustc_typeck::check::check_item_types::hb459f0bcef68d00b
  15:     0x7fad565acdfe - rustc_typeck::check_crate::h56444fcd0efce52e
  16:     0x7fad58548941 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::hcac3a2328cd9259a
  17:     0x7fad5851599e - rustc_driver::driver::phase_3_run_analysis_passes::h9865057b323cad0e
  18:     0x7fad5850740a - rustc_driver::driver::compile_input::hc0edbed7edb3eb18
  19:     0x7fad58534d41 - rustc_driver::run_compiler::h22d678d32fb7c300
  20:     0x7fad5846e763 - std::panicking::try::do_call::h4d040997e2efdaf3
  21:     0x7fad581a3326 - __rust_maybe_catch_panic
  22:     0x7fad5848d7b9 - <F as alloc::boxed::FnBox<A>>::call_box::hba0b436c79e56b23
  23:     0x7fad581972d0 - std::sys::thread::Thread::new::thread_start::h022e3887023c6290
  24:     0x7fad503ad6f9 - start_thread
  25:     0x7fad57e58b5c - clone
  26:                0x0 - <unknown>
@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 25, 2016
@TimNN
Copy link
Contributor

TimNN commented Sep 25, 2016

Only occurs if the trait originates from an extern crate.

Introduced between nightly-2016-09-16 and nightly-2016-09-17 (Changes)

Edit: Introduced in #36383, I'll send a fix sometime today.

@TimNN TimNN added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. A-compiler labels Sep 25, 2016
@TimNN TimNN self-assigned this Sep 25, 2016
bors added a commit that referenced this issue Sep 25, 2016
don't unwrap non-local span

Fixes #36708.
@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 24, 2017
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-nightly Performance or correctness regression from stable to nightly. 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

4 participants