Skip to content

internal compiler error: Type parameter Self/SelfSpace.0 (Self/SelfSpace/0) out of range when substituting #33070

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
scottmcm opened this issue Apr 18, 2016 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@scottmcm
Copy link
Member

I was trying to figure out how to write things with traits and hit an ICE. It looked similar to #28344, but that was closed well before 1.8, so hopefully this is useful.

I tried this code:

use std::ops::{AddAssign, Mul};

struct Vec3<T:Default>(T,T,T);

trait DotProduct {
    type Output;
    fn dot(&self, &Self) -> Self::Output;
}

impl<T:Default> DotProduct for Vec3<T> where T : Mul, <T as Mul>::Output : AddAssign+Default {
    type Output = <T as Mul>::Output;
    fn dot(&self, rhs: &Self) -> Self::Output {
        <T as Mul>::Output::default()
    }
}

And this happened:

compiler_panic.rs:13:6: 13:33 error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Some(Self)) substs=Substs[types=[[];[];[]], regions=[[];[];[]]]
compiler_panic.rs:13            <T as Mul>::Output::default()
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.

Meta

rustc --version --verbose:

rustc 1.8.0 (db2939409 2016-04-11)
binary: rustc
commit-hash: db2939409db26ab4904372c82492cd3488e4c44e
commit-date: 2016-04-11
host: x86_64-pc-windows-gnu
release: 1.8.0

Backtrace:

stack backtrace:
   0:         0x61cc34dc - strncmp
   1:         0x61cc2b5c - strncmp
   2:         0x61c84d6f - strncmp
   3:         0x67e9b9fb - strncmp
   4:         0x67e9b991 - strncmp
   5:         0x67f16665 - strncmp
   6:           0x9b96e0 - strncmp
   7:           0xa7af85 - strncmp
   8:           0xa793ca - strncmp
   9:           0xa81c26 - strncmp
  10:           0xa80e38 - strncmp
  11:           0xa8756e - strncmp
  12:           0xa1a9f5 - strncmp
  13:           0x9d9440 - strncmp
  14:           0xa0b816 - strncmp
  15:           0x9dfad2 - strncmp
  16:           0x9f7c3d - strncmp
  17:           0x9acf31 - strncmp
  18:           0x9a3d90 - strncmp
  19:           0x9a053d - strncmp
  20:           0x9b1a89 - strncmp
  21:           0x99b343 - strncmp
  22:           0x98eb58 - strncmp
  23:           0x985947 - strncmp
  24:         0x6b34a430 - strncmp
  25:         0x6b3488ac - strncmp
  26:         0x6b3455f7 - strncmp
  27:         0x6b317f4d - strncmp
  28:         0x6b306226 - strncmp
  29:         0x6b30376b - strncmp
  30:         0x61caf9ba - strncmp
  31:         0x6b30400c - strncmp
  32:         0x61cc1209 - strncmp
  33:         0x77125a4c - strncmp
@mitaa
Copy link
Contributor

mitaa commented Apr 18, 2016

Hopefully a more useful playpen backtrace (nightly):

stack backtrace:
   1:     0x7f5820eff610 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:     0x7f5820f0cd0b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:     0x7f5820f0c8ac - std::panicking::default_hook::hc2c969e7453d080c
   4:     0x7f5820ed18bf - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e25
   5:     0x7f581a7a3ed8 - std::sys_common::unwind::begin_unwind::h24c4c0fa2cfe995a
   6:     0x7f581a7a3e7b - syntax::errors::Handler::span_bug::h1c6b996df38ae8d7
   7:     0x7f581a7a3d4a - rustc::session::opt_span_bug_fmt::_$u7b$$u7b$closure$u7d$$u7d$::hf0fb5697f8f25f40
   8:     0x7f581a7a3bf2 - rustc::session::opt_span_bug_fmt::hc581ba88c4e2ec53
   9:     0x7f581a7a3b34 - rustc::session::span_bug_fmt::h4591bcbadfc38558
  10:     0x7f581a88518d - _<ty..subst..SubstFolder<'a, 'tcx> as ty..fold..TypeFolder<'tcx>>::fold_ty::hce07f4b40d3cacb2
  11:     0x7f581b66495b - _<check..FnCtxt<'a, 'tcx> as astconv..AstConv<'tcx>>::ty_infer::h36a2788135ab3af5
  12:     0x7f581b7090c6 - _<std..iter..Map<I, F> as std..iter..Iterator>::next::h0128742a87f770ca
  13:     0x7f581b70766b - rustc_typeck::astconv::create_substs_for_ast_path::h6fa21d9ce590a57f
  14:     0x7f581b70dbba - rustc_typeck::astconv::create_substs_for_ast_trait_ref::h03de7676f19db52c
  15:     0x7f581b70cf0c - rustc_typeck::astconv::ast_path_to_mono_trait_ref::h8a557d894b7dff9f
  16:     0x7f581b712ace - rustc_typeck::astconv::qpath_to_ty::h233b0002fda3dbc0
  17:     0x7f581b6af872 - rustc_typeck::astconv::finish_resolving_def_to_ty::hf17fb92b2d6f4861
  18:     0x7f581b6821e3 - rustc_typeck::check::resolve_ty_and_def_ufcs::hb950623f3fdffcaa
  19:     0x7f581b67f9fd - rustc_typeck::check::check_expr_with_expectation_and_lvalue_pref::hdaa9a3d5d214eeb7
  20:     0x7f581b69273a - rustc_typeck::check::callee::check_call::h581c68eea83787eb
  21:     0x7f581b67b71e - rustc_typeck::check::check_expr_with_expectation_and_lvalue_pref::hdaa9a3d5d214eeb7
  22:     0x7f581b6599a7 - rustc_typeck::check::check_block_with_expected::hc05ff1e7fff64a1e
  23:     0x7f581b651459 - rustc_typeck::check::check_fn::hb43882d54094ac4a
  24:     0x7f581b64ed0c - rustc_typeck::check::check_bare_fn::h7e4c2ad58d1814dd
  25:     0x7f581b65e04f - rustc_typeck::check::check_method_body::h7863cacbf117e455
  26:     0x7f581b649d3e - rustc_typeck::check::check_item_body::h7ffec660fc242796
  27:     0x7f581b641ab1 - rustc_typeck::check::check_item_bodies::ha729008a2e67410e
  28:     0x7f581b63901f - rustc_typeck::check_crate::hb08ba31a6a5f65b5
  29:     0x7f582145b850 - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::h5a042a091cd7658c
  30:     0x7f5821459a5b - rustc::ty::context::TyCtxt::create_and_enter::h3f9051bcccbd93e4
  31:     0x7f582145650e - rustc_driver::driver::phase_3_run_analysis_passes::h9c723484c588a35b
  32:     0x7f5821428f5f - rustc_driver::driver::compile_input::h0629572e6f316b31
  33:     0x7f582140f4d4 - rustc_driver::run_compiler::h8902aebf8b1849a8
  34:     0x7f582140c941 - std::sys_common::unwind::try::try_fn::h4c74456035d0fcc7
  35:     0x7f5820efcdab - __rust_try
  36:     0x7f5820efcd3d - std::sys_common::unwind::inner_try::h47a4d9cd4a369dcd
  37:     0x7f582140d18a - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
  38:     0x7f5820f0aea4 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  39:     0x7f5818d8a423 - start_thread
  40:     0x7f5820b69cbc - clone
  41:                0x0 - <unknown>

@nagisa nagisa added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 18, 2016
@kbknapp
Copy link

kbknapp commented May 12, 2016

Got the same error from:

trait Ice<'a, T=&'a i32> {
    fn foo() -> T;
}

fn foo<'a, T>() -> T where T: Ice<'a> {
    Ice::foo()
}

Backtrace:

thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:545
stack backtrace:
   1:     0x7f04f913a160 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:     0x7f04f9147d6b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:     0x7f04f914790c - std::panicking::default_hook::hc2c969e7453d080c
   4:     0x7f04f910d338 - std::panicking::rust_panic_with_hook::hfe203e3083c2b544
   5:     0x7f04f56d34c8 - std::panicking::begin_panic::hf2bac3a63b4cf82e
   6:     0x7f04f56d33cf - syntax::errors::Handler::span_bug::h1878d6587b8bfd95
   7:     0x7f04f56d322d - rustc::session::opt_span_bug_fmt::_$u7b$$u7b$closure$u7d$$u7d$::hf0fb5697f8f25f40
   8:     0x7f04f56d313d - rustc::session::opt_span_bug_fmt::hc581ba88c4e2ec53
   9:     0x7f04f56d2ff4 - rustc::session::span_bug_fmt::h4591bcbadfc38558
  10:     0x7f04f592287e - _<ty..subst..SubstFolder<'a, 'gcx, 'tcx> as ty..fold..TypeFolder<'gcx, 'tcx>>::fold_region::h04b91b1acd88fd7a
  11:     0x7f04f57c9b97 - _<ty..subst..SubstFolder<'a, 'gcx, 'tcx> as ty..fold..TypeFolder<'gcx, 'tcx>>::fold_ty::h85d957d19ba2e322
  12:     0x7f04f57c966f - rustc::infer::InferCtxt::type_vars_for_defs::h7fb1ca6642fcbdb6
  13:     0x7f04f7ef2206 - rustc_typeck::check::FnCtxt::instantiate_path::hae3b9f0a269ab36f
  14:     0x7f04f7ed50b2 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::hf7a336bf3f6d489c
  15:     0x7f04f7efaf91 - rustc_typeck::check::callee::_<impl check..FnCtxt<'a, 'gcx, 'tcx>>::check_call::hb1af81fdd6670b2d
  16:     0x7f04f7ed0920 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::hf7a336bf3f6d489c
  17:     0x7f04f7eacded - rustc_typeck::check::FnCtxt::check_block_with_expected::hb3119871f6a1bbfa
  18:     0x7f04f7ea3d32 - rustc_typeck::check::check_fn::h4bb517663c83e412
  19:     0x7f04f7ea07fe - rustc_typeck::check::check_bare_fn::ha3f2d22e33abb8cf
  20:     0x7f04f7e9c272 - rustc_typeck::check::check_item_body::h7ffec660fc242796
  21:     0x7f04f7e92eb9 - rustc_typeck::check::check_item_bodies::ha729008a2e67410e
  22:     0x7f04f7e8bee6 - rustc_typeck::check_crate::hab54f1dbb6479f2b
  23:     0x7f04f969bf8c - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::he8e0792bce031dff
  24:     0x7f04f9699fda - rustc::ty::context::TyCtxt::create_and_enter::h9e0841510a9ae184
  25:     0x7f04f965d141 - rustc_driver::driver::compile_input::h0629572e6f316b31
  26:     0x7f04f964d41d - rustc_driver::run_compiler::h8902aebf8b1849a8
  27:     0x7f04f964a51e - std::panicking::try::call::hb9e578062982aefa
  28:     0x7f04f915650b - __rust_try
  29:     0x7f04f91564ae - __rust_maybe_catch_panic
  30:     0x7f04f964b004 - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
  31:     0x7f04f9145e74 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  32:     0x7f04f0dba473 - start_thread
  33:     0x7f04f8d9dacc - clone
  34:                0x0 - <unknown>

error: Could not compile `ice`.

To learn more, run the command again with --verbose.

version:

rustc 1.10.0-nightly (22ac88f1a 2016-05-11)
binary: rustc
commit-hash: 22ac88f1a47a82195a49fbff3cf24a2c395d7a81
commit-date: 2016-05-11
host: x86_64-unknown-linux-gnu
release: 1.10.0-nightly

@Mark-Simulacrum
Copy link
Member

No longer ICEs.

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

No branches or pull requests

5 participants