Skip to content

ICE with 1.0.0 when accidentally using integer literal in a float expression #25745

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
rsaarelm opened this issue May 24, 2015 · 2 comments
Closed

Comments

@rsaarelm
Copy link

Replication:

#!/bin/bash

cat > ice.rs <<EOF
pub fn cubic_out(t: f32) -> f32 {
    let u = t - 1.0;
    u * u * u + 1.0
}

pub fn cubic_in_out(t: f32) -> f32 {
    if t < 0.5 {
        4.0 * t * t * t
    } else {
        let u = 2.0 * t - 2.0;
        0.5 * u * u * u + 1 // <- should have been 1.0
    }
}

fn main() {}
EOF

RUST_BACKTRACE=1 rustc ice.rs
rustc --version
uname -a

Output:

error: internal compiler error: Impl DefId { krate: 2, node: 22039 } was matchable against Obligation(predicate=Binder(TraitPredicate(core::ops::Add<_>)),depth=1) but now is not
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>', /home/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:209

stack backtrace:
   1:     0x7f2bee48b449 - sys::backtrace::write::hbc46dc0cfb3b9537d4r
   2:     0x7f2bee493156 - panicking::on_panic::h74d3c14d86c58ac8jrw
   3:     0x7f2bee456462 - rt::unwind::begin_unwind_inner::h382cea404b11eb00t6v
   4:     0x7f2beba433fd - rt::unwind::begin_unwind::h6365792021826883910
   5:     0x7f2beba43abb - diagnostic::Handler::bug::h8da0df7c5604a97agwB
   6:     0x7f2bec5da5c9 - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::hb810aa50e0642064QXT
   7:     0x7f2bec5da058 - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h11340253380734990355
   8:     0x7f2bec5c4691 - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::h8d339edae207ea7dSfT
   9:     0x7f2bec5a39d4 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::hb26a930282b51b57vhR
  10:     0x7f2bec5ae835 - middle::traits::project::project_type::hcc7bca026d7e1d2bCYP
  11:     0x7f2bec5ad418 - middle::traits::project::opt_normalize_projection_type::h4a097d94b366c5ceeRP
  12:     0x7f2bec5aa130 - middle::traits::project::project_and_unify_type::h9cf73365a74ef3d28zP
  13:     0x7f2bec5a853c - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h9241733706551492922
  14:     0x7f2bec5a0b5d - middle::traits::fulfill::FulfillmentContext<'tcx>::select::h2e0ac81f16f15072G9O
  15:     0x7f2bec5a058b - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::h0b137ff14b482b66U8O
  16:     0x7f2bed272bf8 - check::vtable::select_fcx_obligations_where_possible::ha6ba35a732d29514r5b
  17:     0x7f2bed290c6a - check::FnCtxt<'a, 'tcx>::resolve_type_vars_if_possible::h5ccd1e4895d48de9Vwo
  18:     0x7f2bed2f21ee - check::op::check_binop::h4d254cc3af37a49dXMm
  19:     0x7f2bed32f8fd - check::check_expr_with_unifier::h16758040784423113870
  20:     0x7f2bed2ffedc - check::check_block_with_expected::h31a6d6204e48ff42nUr
  21:     0x7f2bed33ba1e - check::check_expr_with_unifier::h7613982835395653666
  22:     0x7f2bed315d39 - check::check_expr_with_unifier::check_then_else::h2bc634554fa150fbxkq
  23:     0x7f2bed32fbdd - check::check_expr_with_unifier::h16758040784423113870
  24:     0x7f2bed2ffedc - check::check_block_with_expected::h31a6d6204e48ff42nUr
  25:     0x7f2bed2e26c6 - check::check_fn::h1656833949835747UGn
  26:     0x7f2bed2fb594 - check::check_bare_fn::h1ca89f422d965ecetwn
  27:     0x7f2bed2f96f2 - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::h29ccc99d00d684a7wtn
  28:     0x7f2bed3bd69a - check_crate::closure.38028
  29:     0x7f2bed3b8a30 - check_crate::h22dcd95e17a2d96dXcC
  30:     0x7f2bee9cfcc8 - driver::phase_3_run_analysis_passes::h43926ceca86caa9fnGa
  31:     0x7f2bee9b0dc5 - driver::compile_input::hb78754f2f33c01efQba
  32:     0x7f2beea724d1 - run_compiler::h258d36d5501c1cdfz4b
  33:     0x7f2beea70122 - boxed::F.FnBox<A>::call_box::h7239693171334256553
  34:     0x7f2beea6f659 - rt::unwind::try::try_fn::h14329119008520845439
  35:     0x7f2bee505ac8 - rust_try_inner
  36:     0x7f2bee505ab5 - rust_try
  37:     0x7f2beea6f908 - boxed::F.FnBox<A>::call_box::h17332056298259451807
  38:     0x7f2bee492041 - sys::thread::create::thread_start::h490278b5c3c0b49faqv
  39:     0x7f2be8d36373 - start_thread
  40:     0x7f2bee0ec27c - clone
  41:                0x0 - <unknown>

rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
Linux 3.19.3-3-ARCH #1 SMP PREEMPT Wed Apr 8 14:10:00 CEST 2015 x86_64 GNU/Linux
@arielb1
Copy link
Contributor

arielb1 commented May 24, 2015

This is a known bug. It is fixed in 1.2 (by #25344). Maybe we should backport that fix to 1.1?

@steveklabnik
Copy link
Member

We're being very conservative with backports, ICE fixes don't really qualify.

Thank you for the report @rsaarelm !

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