Skip to content

ICE with unannotated literals #18954

Closed
@r10r

Description

@r10r
[ruben@MacBook-Pro src]$ rustc --version=verbose
rustc 0.13.0-nightly (40fb87d40 2014-11-10 23:01:57 +0000)
binary: rustc
commit-hash: 40fb87d40f681f5356af42175fc7b85da387f037
commit-date: 2014-11-10 23:01:57 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly
trait Adder<Number> {
  fn sum(&self, summands: &[Number]) -> Number;
}

struct Calculator {
  foo: int,
}

impl Adder<int> for Calculator {

  fn sum(&self, summands: &[int]) -> int {
    println!("sum int");
    let mut result = 0i;
    for num in summands.iter() {
      result += *num;
    }
    result
  }
}

impl Adder<f32> for Calculator {

  fn sum(&self, summands: &[f32]) -> f32 {
    println!("sum f32");
    let mut result = 0f32;
    for num in summands.iter() {
      result += *num;
    }
    result
  }
}


fn main() {
  let calc = Calculator { foo: 4711 };
  println!("1 + 1 = {}", calc.sum([1,1].as_slice()));

  // raises the compiler error
  println!("1.0 + 2.3 = {}", calc.sum([1.0,2.3].as_slice()));
  // compiles and runs properly
  //println!("1.0 + 2.3 = {}", calc.sum([1.0f32,2.3f32].as_slice()));
}
error: internal compiler error: Impl DefId { krate: 0, node: 26 }:Calculator.Adder<int> was matchable against Obligation(trait_ref=<_ : Adder<_>>,depth=0) but now is not
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:175

stack backtrace:
   1:        0x11011e01f - rt::backtrace::imp::write::h37f6e30fade15cb76mt
   2:        0x1101211a7 - failure::on_fail::h4075de659ea4adb9VDt
   3:        0x1103a4415 - unwind::begin_unwind_inner::h9e12d6856ac2af42j1c
   4:        0x10e086757 - unwind::begin_unwind::h887212781071489879
   5:        0x10e086f93 - diagnostic::Handler::bug::he58e2d0573e8d5d4L5F
   6:        0x10d105271 - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::h35320cfc53204d2fFbZ
   7:        0x10d0f3607 - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::hb7278faaf8bd08bdDRY
   8:        0x10d0ea1b7 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::h20d24e63da941032znX
   9:        0x10d0e8e86 - middle::traits::fulfill::FulfillmentContext::select::h4f9eb03bbb3d4aa6gUW
  10:        0x10d0e8656 - middle::traits::fulfill::FulfillmentContext::select_where_possible::h212cad5c41e6ff5evTW
  11:        0x10d0014d2 - middle::traits::fulfill::FulfillmentContext::select_all_or_error::ha09a57d720916db7iRW
  12:        0x10d26dc78 - middle::typeck::check::vtable::select_all_fcx_obligations_or_error::h4291cb6f90f0ee15K7N
  13:        0x10d2c5ccb - middle::typeck::check::check_bare_fn::hec13c0cf792a848da8V
  14:        0x10d2c1e1d - middle::typeck::check::check_item::h7dd222d42ec19845jsW
  15:        0x10d2c5b10 - middle::typeck::check::check_item_types::hdbb49e408a7799c1k7V
  16:        0x10cdd1156 - util::common::time::h3942551398258420223
  17:        0x10d5d1eee - middle::typeck::check_crate::hcb0ab152bef1200chup
  18:        0x10d639d9f - driver::driver::phase_3_run_analysis_passes::hc02fc7265031485eIdC
  19:        0x10d634bd8 - driver::driver::compile_input::h2ba3685ec9df4f6btUB
  20:        0x10d6b23ed - driver::run_compiler::h6e93cd8bbb72fd50KKF
  21:        0x10d6b092e - driver::run::closure.146334
  22:        0x10cde940b - task::TaskBuilder<S>::try_future::closure.104770
  23:        0x10cde9303 - task::TaskBuilder<S>::spawn_internal::closure.104741
  24:        0x10cda27bd - task::NativeSpawner.Spawner::spawn::closure.2551
  25:        0x110402a0c - rust_try_inner
  26:        0x1104029f6 - rust_try
  27:        0x1103a1be7 - unwind::try::h009a35089a5882701Pc
  28:        0x1103a1a7c - task::Task::run::h4878cb7b665069bf61b
  29:        0x10cda25e3 - task::NativeSpawner.Spawner::spawn::closure.2475
  30:        0x1103a32a7 - thread::thread_start::h8e83ad43ae75daab3mc
  31:     0x7fff914642fc - _pthread_body
  32:     0x7fff91464279 - _pthread_body

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions