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

internal compiler error: Impl DefId { krate: 0, node: 12 }:u32.Stringify was matchable against Obligation(predicate=Binder(TraitPredicate(Stringify)),depth=0) but now is not #23825

Closed
huachaohuang opened this issue Mar 29, 2015 · 4 comments · Fixed by #25344
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@huachaohuang
Copy link
Contributor

  • I tried this code:
trait Stringify {
    fn to_string(&self) -> String;
}

impl Stringify for u32 {
    fn to_string(&self) -> String { format!("u32: {}", *self) }
}

impl Stringify for f32 {
    fn to_string(&self) -> String { format!("f32: {}", *self) }
}

fn print<T: Stringify>(x: T) {
    println!("{}", x.to_string());
}

fn main() {
    print(5);
    print(5.0);
}
  • I expected to see this happen:
u32: 5
f32: 5.0
  • Instead, this happened:

error: internal compiler error: Impl DefId { krate: 0, node: 12 }:u32.Stringify was matchable against Obligation(predicate=Binder(TraitPredicate(Stringify)),depth=0) 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

Meta

rustc 1.0.0-nightly (199bdcf 2015-03-26) (built 2015-03-26)
binary: rustc
commit-hash: 199bdcf
commit-date: 2015-03-26
build-date: 2015-03-26
host: x86_64-apple-darwin
release: 1.0.0-nightly

  • Backtrace:
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:190

stack backtrace:
   1:        0x10cdac8b4 - sys::backtrace::write::h56b628caa3d9f4e2WBD
   2:        0x10cdd7a08 - panicking::on_panic::ha7bc09956d9f12916rJ
   3:        0x10ccf499e - rt::unwind::begin_unwind_inner::h5ef900798574fe5egaJ
   4:        0x10c4ec45e - rt::unwind::begin_unwind::h2748891250859470333
   5:        0x10c4ecc89 - diagnostic::Handler::bug::h57426bf76a5037d4pgB
   6:        0x10a06b4bf - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::h3b4e834c3872ae21NVR
   7:        0x10a06ab56 - middle::infer::InferCtxt<'a, 'tcx>::try::h6881848181392734290
   8:        0x10a0510c4 - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::ha7bb241f7d3cdb480iR
   9:        0x10a025b8d - middle::traits::select::SelectionContext<'cx, 'tcx>::select::hb97262a482e0a260koP
  10:        0x10a0225e0 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::hcffa8f4e81b26cc8HhN
  11:        0x10a021aee - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::h0a2ed0d6733c5352VgN
  12:        0x10942d473 - check::vtable::select_fcx_obligations_where_possible::h796cff45179b9501A4b
  13:        0x10942cfc3 - check::vtable::select_all_fcx_obligations_and_apply_defaults::hfadb66c912bf39a2X0b
  14:        0x1094de47e - check::check_bare_fn::heb3c8094aebf74083nn
  15:        0x1094d68eb - check::check_item::h25c21617996c325dOGn
  16:        0x1095afed6 - check_crate::closure.35998
  17:        0x1095aad9a - check_crate::haa845b167eb64ccfOmC
  18:        0x1092e4477 - driver::phase_3_run_analysis_passes::h8f332883f9aa5c0arGa
  19:        0x1092ca4b7 - driver::compile_input::h0311d7070ac04983Rba
  20:        0x109384093 - run_compiler::hbe451b463527cb69s2b
  21:        0x109381bb5 - thunk::F.Invoke<A, R>::invoke::h777505636365567823
  22:        0x109380f77 - rt::unwind::try::try_fn::h5237749675862334843
  23:        0x10ce5dfa8 - rust_try_inner
  24:        0x10ce5df95 - rust_try
  25:        0x109381315 - thunk::F.Invoke<A, R>::invoke::h424791141543398798
  26:        0x10cdc299d - sys::thread::create::thread_start::h760927331a49c0e267H
  27:     0x7fff91d6b267 - _pthread_body
  28:     0x7fff91d6b1e4 - _pthread_start
@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 29, 2015
@mitchmindtree
Copy link
Contributor

I've also just run into this, here's the error and the backtrace.

error: internal compiler error: Impl DefId { krate: 2, node: 34078 } 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>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:190                                     

stack backtrace:                                                                                                                                                                 
   1:        0x1121339f4 - sys::backtrace::write::h79b5fc37599ff6dfazD                                                                                                           
   2:        0x1121614b0 - panicking::on_panic::h56cd7321a5392f568oJ                                                                                                             
   3:        0x112071c8e - rt::unwind::begin_unwind_inner::h9b1dd02e7e9b2523i7I                                                                                                  
   4:        0x1118565ce - rt::unwind::begin_unwind::h5359193300489870763                                                                                                        
   5:        0x111856e19 - diagnostic::Handler::bug::h0696301796c915b4ShB                                                                                                        
   6:        0x10f3ae6be - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::h00877b9f7d68b755V3R                                                               
   7:        0x10f3ae008 - middle::infer::InferCtxt<'a, 'tcx>::try::h1635483048343115861                                                                                         
   8:        0x10f38f454 - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::h2b843f592bb3d1ebJlR                                                          
   9:        0x10f3638e3 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::h48941a5b9b6aeafbApP                                                                     
  10:        0x10f37363a - middle::traits::project::project_type::h27f6c84f9a43d3fbK5N                                                                                           
  11:        0x10f371017 - middle::traits::project::opt_normalize_projection_type::h7647720dfb8d8959mYN                                                                          
  12:        0x10f36aa36 - middle::traits::project::poly_project_and_unify_type::closure.81002                                                                                   
  13:        0x10f368a40 - middle::traits::project::poly_project_and_unify_type::h14c21863493f04758EN                                                                            
  14:        0x10f3602e6 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::hd40ad264985439f7hhN                                                                       
  15:        0x10f35f928 - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::h0ebb717f715533c9vgN                                                        
  16:        0x10e724d63 - check::vtable::select_fcx_obligations_where_possible::hbca02d457f2550e2r4b                                                                            
  17:        0x10e75d48d - check::FnCtxt<'a, 'tcx>::resolve_type_vars_if_possible::h4ae213f9cb49bdadLYo                                                                          
  18:        0x10e7d91ae - check::op::check_binop::h03b611fd681fb03fM6m                                                                                                          
  19:        0x10e81e5cc - check::check_expr_with_unifier::h17623262095715920792                                                                                                 
  20:        0x10e8484f2 - check::check_decl_local::hceee65fb94b47336eis                                                                                                         
  21:        0x10e7e8ad1 - check::check_block_with_expected::ha2448513d5fb9fb9kos                                                                                                
  22:        0x10e82bf51 - check::check_expr_with_unifier::h15858122413925670105                                                                                                 
  23:        0x10e713b05 - check::_match::check_match::closure.28752                                                                                                             
  24:        0x10e713811 - check::_match::check_match::h6e204581d7b2887c9mb                                                                                                      
  25:        0x10e81eba4 - check::check_expr_with_unifier::h17623262095715920792                                                                                                 
  26:        0x10e7e8e0b - check::check_block_with_expected::ha2448513d5fb9fb9kos                                                                                                
  27:        0x10e803584 - check::check_block_no_value::he84d13599fd37c5alns                                                                                                     
  28:        0x10e82be51 - check::check_expr_with_unifier::h15858122413925670105                                                                                                 
  29:        0x10e713b05 - check::_match::check_match::closure.28752                                                                                                             
  30:        0x10e713811 - check::_match::check_match::h6e204581d7b2887c9mb                                                                                                      
  31:        0x10e81eba4 - check::check_expr_with_unifier::h17623262095715920792                                                                                                 
  32:        0x10e8484f2 - check::check_decl_local::hceee65fb94b47336eis                                                                                                         
  33:        0x10e7e8ad1 - check::check_block_with_expected::ha2448513d5fb9fb9kos                                                                                                
  34:        0x10e81ec21 - check::check_expr_with_unifier::h17623262095715920792                                                                                                 
  35:        0x10e7e8e0b - check::check_block_with_expected::ha2448513d5fb9fb9kos                                                                                                
   36:        0x10e82bf51 - check::check_expr_with_unifier::h15858122413925670105    
  37:        0x10e713b05 - check::_match::check_match::closure.28752                
  38:        0x10e713811 - check::_match::check_match::h6e204581d7b2887c9mb         
  39:        0x10e81eba4 - check::check_expr_with_unifier::h17623262095715920792    
  40:        0x10e7e8e0b - check::check_block_with_expected::ha2448513d5fb9fb9kos   
  41:        0x10e82bf51 - check::check_expr_with_unifier::h15858122413925670105    
  42:        0x10e713b05 - check::_match::check_match::closure.28752                
  43:        0x10e713811 - check::_match::check_match::h6e204581d7b2887c9mb         
  44:        0x10e81eba4 - check::check_expr_with_unifier::h17623262095715920792    
  45:        0x10e7e8e0b - check::check_block_with_expected::ha2448513d5fb9fb9kos   
  46:        0x10e7c33e5 - check::check_fn::h7a50c890b5419d55G1n                    
  47:        0x10e7e395e - check::check_bare_fn::hb7403022fad4c11dfRn               
  48:        0x10e7db85f - check::check_item::hede794dfa708b89909n                  
  49:        0x10e7e1ec2 - visit::walk_item::h9731833736362995753                   
  50:        0x10e8b8ff1 - check_crate::closure.36204                               
  51:        0x10e8b3437 - check_crate::h2a80ddc71481fbe04wC                        
  52:        0x10e5d7287 - driver::phase_3_run_analysis_passes::h6b1a4d735c5454a3oGa
  53:        0x10e5bb9c5 - driver::compile_input::hc433cbaf5268b434Qba              
  54:        0x10e679b75 - run_compiler::hfdf6389c24d7bf2fp2b                       
  55:        0x10e67748f - thunk::F.Invoke<A, R>::invoke::h17962875359394492347     
  56:        0x10e6765b7 - rt::unwind::try::try_fn::h2161268800680238185            
  57:        0x1121e8028 - rust_try_inner                                           
  58:        0x1121e8015 - rust_try                                                 
  59:        0x10e676988 - thunk::F.Invoke<A, R>::invoke::h12486231582466062018     
  60:        0x11214a91d - sys::thread::create::thread_start::h5cc5a46a7850c86a84H  
  61:     0x7fff82c3e267 - _pthread_body                                            
  62:     0x7fff82c3e1e4 - _pthread_start                                           

Could not compile `elmesque`.                                                       

I haven't yet been able to isolate the culprit code, I'll keep searching and post it if I come across it. Just thought I'd share this first.

This occurred on rustc 1.0.0-nightly (6cf3b0b74 2015-03-30) (built 2015-03-30)

@mitchmindtree
Copy link
Contributor

Not sure if this helps at all, but I was able to side-step this ICE in my own code by changing an incorrect generic integer to a correct generic float.

To be exact, I changed this (which should have been a compile error, but ICEd):

let mut half_prev_width = 0;

to this (which compiles fine):

let mut half_prev_width = 0.0;

The following is the block of code in which this occurred:

let multi = if let Direction::Right = direction { 1.0 } else { -1.0 };
let mut half_prev_width = 0;
for element in elements.into_iter() {
    let element = element.opacity(props.opacity * element.props.opacity);
    let half_width = width_of(&element) as f64 / 2.0;
    draw_element(element, matrix, g, draw_state);
    let x_trans = half_width + half_prev_width;
    let Transform2D(new_matrix) = Transform2D(matrix)
        .multiply(transform_2d::translation(x_trans * multi, 0.0));
    matrix = new_matrix;
    half_prev_width = half_width;
}

I think the error that rustc should have given was

error: mismatched types:
 expected `_`,
    found `f64`

Perhaps the ICE is related to the way this error is detected, or perhaps the way the generic number's type is inferred?

I tried recreating the ICE in a simpler playpen example to no avail. Hopefully this helps point someone in the right direction though!

@TimNN
Copy link
Contributor

TimNN commented Apr 19, 2015

I can reproduce this error with the following test case (playpen):

fn main() {
    let _ = 0f32 * 0.0 * 0;
}

The ICE also happens with the operators + - / %.

Adding or removing any type suffix, changing the operand order or using two different operators fixes the ICE.

Version: rustc 1.0.0-nightly (00978a987 2015-04-18) (built 2015-04-18) on OS X

Backtrace:

error: internal compiler error: Impl DefId { krate: 2, node: 41567 } was matchable against Obligation(predicate=Binder(TraitPredicate(<f32 as core::ops::Mul<_>>)),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>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:230

stack backtrace:
   1:        0x103bf907f - sys::backtrace::write::h652639cd75f0c63cnSs
   2:        0x103c01612 - panicking::on_panic::h669c4ea43c1379a9CPw
   3:        0x103bb7815 - rt::unwind::begin_unwind_inner::h3fc7f8f4791b4491lxw
   4:        0x1033b700e - rt::unwind::begin_unwind::h3264207737224415616
   5:        0x1033b77b2 - diagnostic::Handler::bug::h43c0dbadc7c09da91wB
   6:        0x100f43f4b - middle::traits::select::SelectionContext<'cx, 'tcx>::rematch_impl::hdaa10e90cc7f94c6fyS
   7:        0x100f43ad8 - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h12400076273368149998
   8:        0x100f2dc2d - middle::traits::select::SelectionContext<'cx, 'tcx>::confirm_candidate::h287b4d911777ca83hQR
   9:        0x100f09198 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::h4326d6c2fd759146URP
  10:        0x100f151dd - middle::traits::project::project_type::heec759ea04573f931yO
  11:        0x100f13b8b - middle::traits::project::opt_normalize_projection_type::h854a36e9d7fdc4baDrO
  12:        0x100f1033b - middle::traits::project::project_and_unify_type::h01572a7c3a6427d9xaO
  13:        0x100f0e5df - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h9136385102605535755
  14:        0x100f06519 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::h8e12571e1c1d6e2a5JN
  15:        0x100f05f38 - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::ha144bba9596c77dbjJN
  16:        0x1009a32a3 - check::vtable::select_fcx_obligations_where_possible::h11116134018e3c7eI0b
  17:        0x1009caef1 - check::FnCtxt<'a, 'tcx>::resolve_type_vars_if_possible::h2e09c238ad2631efOUo
  18:        0x100a2ba98 - check::op::check_binop::h63d2d3bb28d51501Qan
  19:        0x100a6a67e - check::check_expr_with_unifier::h13774552146527501464
  20:        0x100a911ab - check::check_decl_local::h05c9fe2a0c0769088bs
  21:        0x100a39bfa - check::check_block_with_expected::h638aab069ab365beeis
  22:        0x100a1b378 - check::check_fn::h9fa3978846dc7de3N4n
  23:        0x100a35379 - check::check_bare_fn::h43ce861f2a41909amUn
  24:        0x100a33466 - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::h9ea50cb814d6f016pRn
  25:        0x100afccea - check_crate::closure.38351
  26:        0x100af80f7 - check_crate::hb20169de249f4e69pCC
  27:        0x1003463c2 - driver::phase_3_run_analysis_passes::h48e7216953f4195erGa
  28:        0x10032819c - driver::compile_input::h8c0d6e2f0389eda0Qba
  29:        0x1003ef903 - run_compiler::h318b4521e91f682fD4b
  30:        0x1003ed42a - boxed::F.FnBox<A>::call_box::h15521220820018991817
  31:        0x1003ec8c7 - rt::unwind::try::try_fn::h6267384748210286924
  32:        0x103c8b3d8 - rust_try_inner
  33:        0x103c8b3c5 - rust_try
  34:        0x1003ecba0 - boxed::F.FnBox<A>::call_box::h12285395525992985164
  35:        0x103c0017d - sys::thread::create::thread_start::hbbc60a5321f29f07eVv
  36:     0x7fff932fe267 - _pthread_body
  37:     0x7fff932fe1e4 - _pthread_start

@arielb1
Copy link
Contributor

arielb1 commented May 12, 2015

Duplicate of #24325

arielb1 pushed a commit to arielb1/rust that referenced this issue May 12, 2015
There is no subtyping relationship between the types (or their non-freshened
variants), so they can not be merged.

Fixes rust-lang#22645
Fixes rust-lang#24352
Fixes rust-lang#23825

Should fix rust-lang#25235 (no test in issue).
Should fix rust-lang#19976 (test is outdated).
bors added a commit that referenced this issue May 13, 2015
There is no subtyping relationship between the types (or their non-freshened
variants), so they can not be merged.

Fixes #22645
Fixes #24352
Fixes #23825

Should fix #25235 (no test in issue).
Should fix #19976 (test is outdated).
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) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants