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

Rust internal compiler error #35973

Closed
aleksanb opened this issue Aug 24, 2016 · 1 comment
Closed

Rust internal compiler error #35973

aleksanb opened this issue Aug 24, 2016 · 1 comment

Comments

@aleksanb
Copy link

I managed to crash the nightly compiler!

I tried this code:

fn main() {
    println!("Hello, world!");
}

trait functor<A, B, F: Fn(A) -> B> {
    type Output;

    fn map(&mut self, F) -> Self::Output;
}

impl<A, B, F: Fn(A) -> B> functor<A, B, F> for Option<A> {
    type Output = Option<B>;

    fn map(&mut self, f: F) -> B { 
        f(*self)
    }   
}

I expected the code to (perhaps) compile successfully.
Instead, this happened:

aleksanb@Capitalism-2:~/Projects/rust/functor$ RUST_BACKTRACE=1 cargo run --verbose
   Compiling functor v0.1.0 (file:///home/aleksanb/Projects/rust/functor)
     Running `rustc src/main.rs --crate-name functor --crate-type bin -g -C metadata=d523fcdd903acc69 --out-dir /home/aleksanb/Projects/rust/functor/target/debug --emit=dep-info,link -L dependency=/home/aleksanb/Projects/rust/functor/target/debug/deps`
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:326
stack backtrace:
   1:     0x7fa479f95c63 - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:     0x7fa479fa7d6c - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:     0x7fa479fa5fe7 - std::panicking::default_hook::h9e30d428ee3b0c43
   4:     0x7fa479fa67f8 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:     0x7fa479fa6692 - std::panicking::begin_panic::hcb11a4dc6d779ae5
   6:     0x7fa479fa65c0 - std::panicking::begin_panic_fmt::h310416c62f3935b3
   7:     0x7fa479fa6541 - rust_begin_unwind
   8:     0x7fa47a011cff - core::panicking::panic_fmt::hc5789f4e80194729
   9:     0x7fa47a011c2b - core::panicking::panic::h1953378f4b37b561
  10:     0x7fa478680ecc - rustc_typeck::check::compare_method::compare_impl_method::_{{closure}}::h08bef90d287aed42
  11:     0x7fa4785dcc99 - rustc_typeck::check::compare_method::compare_impl_method::he3538453c2efe177
  12:     0x7fa4785f1c22 - rustc_typeck::check::check_impl_items_against_trait::hb105ca8bb42a0b3d
  13:     0x7fa4785ef1a2 - rustc_typeck::check::check_item_type::hba3733559d49be1e
  14:     0x7fa4785e79eb - _<rustc_typeck..check..CheckItemTypesVisitor<'a, 'tcx> as rustc..hir..intravisit..Visitor<'tcx>>::visit_item::h369cacffbaa18923
  15:     0x7fa4785e98eb - rustc_typeck::check::check_item_types::h81e44a5d40f450fd
  16:     0x7fa47866128d - rustc_typeck::check_crate::h8ec8b2f490f5dc28
  17:     0x7fa47a391a03 - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h45e03cee16dcf298
  18:     0x7fa47a35db21 - rustc_driver::driver::phase_3_run_analysis_passes::hc0de40cea97d81a1
  19:     0x7fa47a34a146 - rustc_driver::driver::compile_input::hd9ecc57abd3cba85
  20:     0x7fa47a37d656 - rustc_driver::run_compiler::h184264500271cc39
  21:     0x7fa47a2b88c2 - std::panicking::try::do_call::h17a7a17ad7240c5c
  22:     0x7fa479fb60d6 - __rust_maybe_catch_panic
  23:     0x7fa47a2d22aa - _<F as alloc..boxed..FnBox<A>>::call_box::h93f9128277b2964a
  24:     0x7fa479fa43b2 - std::sys::thread::Thread::new::thread_start::he0bf102845911132
  25:     0x7fa4722816f9 - start_thread
  26:     0x7fa479be4b5c - clone
  27:                0x0 - <unknown>

error: Could not compile `functor`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name functor --crate-type bin -g -C metadata=d523fcdd903acc69 --out-dir /home/aleksanb/Projects/rust/functor/target/debug --emit=dep-info,link -L dependency=/home/aleksanb/Projects/rust/functor/target/debug/deps` (exit code: 101)

I'm not quite sure what to do from here 💃

Meta

rustc 1.13.0-nightly (3c5a0fa 2016-08-22)
binary: rustc
commit-hash: 3c5a0fa
commit-date: 2016-08-22
host: x86_64-unknown-linux-gnu
release: 1.13.0-nightly

@TimNN
Copy link
Contributor

TimNN commented Aug 24, 2016

Duplicate of #35869,

the actual error is

error: method `map` has an incompatible type for trait:
 expected enum `std::option::Option`,
    found type parameter [--explain E0053]
  --> <anon>:14:5
   |>
14 |>     fn map(&mut self, f: F) -> B {
   |>     ^

error: aborting due to previous error

(You'll get that on stable, beta and any nightlies before nightly-2016-08-18.

@sanxiyn sanxiyn closed this as completed Aug 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants