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

ICE When Swapping Const Generic & Generic In Trait Method Impl #97541

Closed
danii opened this issue May 30, 2022 · 2 comments
Closed

ICE When Swapping Const Generic & Generic In Trait Method Impl #97541

danii opened this issue May 30, 2022 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@danii
Copy link
Contributor

danii commented May 30, 2022

Code

This is really as simple as ICEs get.

// No ICE here.
trait CrunchICE {
    fn crunch<const N: usize, T>(ice: T);
}

// Cold crunchy ICE here.
impl CrunchICE for () {
    // Note that the const generic and generic have swapped places here.
    fn crunch<T, const N: usize>(ice: T) {}
}

Meta

rustc --version --verbose:

rustc 1.62.0-nightly (69a5d2481 2022-04-27)
binary: rustc
commit-hash: 69a5d2481e856a5a18885390b8cf6950b9ff8dd3
commit-date: 2022-04-27
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

This also appears to work on stable from play.rust-lang.org.

note: rustc 1.61.0 (fe5b13d68 2022-05-18) running on x86_64-unknown-linux-gnu

Error output

Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:621:17: expected type for `W/#3` (W/3) but found Const(Const { ty: usize, val: Param(N/#3) }) when substituting, substs=[mode::Reader<T>, R, W, Const { ty: usize, val: Param(N/#3) }]

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/compiler/rustc_errors/src/lib.rs:1253:9
stack backtrace:
   0:     0x7f4f7a49dfed - std::backtrace_rs::backtrace::libunwind::trace::hc5abd1cb436aa528
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f4f7a49dfed - std::backtrace_rs::backtrace::trace_unsynchronized::h16e652276c3c1a5f
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4f7a49dfed - std::sys_common::backtrace::_print_fmt::h866806c7f5375be1
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f4f7a49dfed - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7aeaa12c4281d2c8
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f4f7a4f9d6c - core::fmt::write::h03de7e659b82a590
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/core/src/fmt/mod.rs:1194:17
   5:     0x7f4f7a48f6e1 - std::io::Write::write_fmt::h008eedacdce877e9
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/io/mod.rs:1655:15
   6:     0x7f4f7a4a0d05 - std::sys_common::backtrace::_print::h4079f736a61c453b
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f4f7a4a0d05 - std::sys_common::backtrace::print::h610c7be10303d303
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f4f7a4a0d05 - std::panicking::default_hook::{{closure}}::hb2fea27db75549e4
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/panicking.rs:295:22
   9:     0x7f4f7a4a0979 - std::panicking::default_hook::h6acb360d1343cfb8
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/panicking.rs:314:9
  10:     0x7f4f7acce781 - rustc_driver[a5dbbc9ca67f5eff]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f4f7a4a14d6 - std::panicking::rust_panic_with_hook::h2c796f347414ce5b
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/panicking.rs:702:17
  12:     0x7f4f7bc98e81 - std[1c075e4e42f0cfa5]::panicking::begin_panic::<rustc_errors[ee6c0c75111f4e19]::ExplicitBug>::{closure#0}
  13:     0x7f4f7bc987e6 - std[1c075e4e42f0cfa5]::sys_common::backtrace::__rust_end_short_backtrace::<std[1c075e4e42f0cfa5]::panicking::begin_panic<rustc_errors[ee6c0c75111f4e19]::ExplicitBug>::{closure#0}, !>
  14:     0x7f4f7bcceb1f - std[1c075e4e42f0cfa5]::panicking::begin_panic::<rustc_errors[ee6c0c75111f4e19]::ExplicitBug>
  15:     0x7f4f7bc87ff6 - std[1c075e4e42f0cfa5]::panic::panic_any::<rustc_errors[ee6c0c75111f4e19]::ExplicitBug>
  16:     0x7f4f7bc84441 - <rustc_errors[ee6c0c75111f4e19]::HandlerInner>::span_bug::<rustc_span[77ab89dfdf07db3a]::span_encoding::Span, &alloc[a937766a13aeb85d]::string::String>
  17:     0x7f4f7bc83fa0 - <rustc_errors[ee6c0c75111f4e19]::Handler>::span_bug::<rustc_span[77ab89dfdf07db3a]::span_encoding::Span, &alloc[a937766a13aeb85d]::string::String>
  18:     0x7f4f7bc9f698 - rustc_middle[37425aa7f7ab8925]::ty::context::tls::with_opt::<rustc_middle[37425aa7f7ab8925]::util::bug::opt_span_bug_fmt<rustc_span[77ab89dfdf07db3a]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7f4f7bc9f856 - rustc_middle[37425aa7f7ab8925]::util::bug::opt_span_bug_fmt::<rustc_span[77ab89dfdf07db3a]::span_encoding::Span>
  20:     0x7f4f7bc9f817 - rustc_middle[37425aa7f7ab8925]::util::bug::span_bug_fmt::<rustc_span[77ab89dfdf07db3a]::span_encoding::Span>
  21:     0x7f4f7ccad8b9 - <rustc_middle[37425aa7f7ab8925]::ty::Predicate as rustc_middle[37425aa7f7ab8925]::ty::subst::Subst>::subst
  22:     0x7f4f7cbd7204 - <rustc_middle[37425aa7f7ab8925]::ty::generics::GenericPredicates>::instantiate_own
  23:     0x7f4f7d00d377 - rustc_typeck[44b08195efa16631]::check::compare_method::compare_impl_method
  24:     0x7f4f7c1b7e08 - rustc_typeck[44b08195efa16631]::check::check::check_item_type
  25:     0x7f4f7c2a77db - <rustc_middle[37425aa7f7ab8925]::hir::map::Map>::visit_item_likes_in_module::<rustc_typeck[44b08195efa16631]::check::CheckItemTypesVisitor>
  26:     0x7f4f7cfa4b3c - rustc_typeck[44b08195efa16631]::check::check::check_mod_item_types
  27:     0x7f4f7d2ba42f - <rustc_query_system[cf4e8b18efdea24]::dep_graph::graph::DepGraph<rustc_middle[37425aa7f7ab8925]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[37425aa7f7ab8925]::ty::context::TyCtxt, rustc_span[77ab89dfdf07db3a]::def_id::LocalDefId, ()>
  28:     0x7f4f7c700fce - rustc_query_system[cf4e8b18efdea24]::query::plumbing::try_execute_query::<rustc_query_impl[613f3d57b9125cc2]::plumbing::QueryCtxt, rustc_query_system[cf4e8b18efdea24]::query::caches::DefaultCache<rustc_span[77ab89dfdf07db3a]::def_id::LocalDefId, ()>>
  29:     0x7f4f7d243e13 - rustc_query_system[cf4e8b18efdea24]::query::plumbing::get_query::<rustc_query_impl[613f3d57b9125cc2]::queries::check_mod_item_types, rustc_query_impl[613f3d57b9125cc2]::plumbing::QueryCtxt>
  30:     0x7f4f7d0218bd - <rustc_middle[37425aa7f7ab8925]::hir::map::Map>::for_each_module::<rustc_typeck[44b08195efa16631]::check_crate::{closure#6}::{closure#0}>
  31:     0x7f4f7cfcd0e8 - <rustc_session[8d74270965aad24]::session::Session>::time::<(), rustc_typeck[44b08195efa16631]::check_crate::{closure#6}>
  32:     0x7f4f7cfbdee3 - rustc_typeck[44b08195efa16631]::check_crate
  33:     0x7f4f7cd4f427 - rustc_interface[4e7b840a6791346]::passes::analysis
  34:     0x7f4f7d2d1675 - <rustc_query_system[cf4e8b18efdea24]::dep_graph::graph::DepGraph<rustc_middle[37425aa7f7ab8925]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[37425aa7f7ab8925]::ty::context::TyCtxt, (), core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>
  35:     0x7f4f7d212281 - rustc_query_system[cf4e8b18efdea24]::query::plumbing::try_execute_query::<rustc_query_impl[613f3d57b9125cc2]::plumbing::QueryCtxt, rustc_query_system[cf4e8b18efdea24]::query::caches::DefaultCache<(), core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>>
  36:     0x7f4f7d252e0e - rustc_query_system[cf4e8b18efdea24]::query::plumbing::get_query::<rustc_query_impl[613f3d57b9125cc2]::queries::analysis, rustc_query_impl[613f3d57b9125cc2]::plumbing::QueryCtxt>
  37:     0x7f4f7cd2ad07 - <rustc_interface[4e7b840a6791346]::passes::QueryContext>::enter::<rustc_driver[a5dbbc9ca67f5eff]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>
  38:     0x7f4f7cd15af8 - <rustc_interface[4e7b840a6791346]::interface::Compiler>::enter::<rustc_driver[a5dbbc9ca67f5eff]::run_compiler::{closure#1}::{closure#2}, core[8e7cf360a047e58a]::result::Result<core[8e7cf360a047e58a]::option::Option<rustc_interface[4e7b840a6791346]::queries::Linker>, rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>
  39:     0x7f4f7cd3f2df - rustc_span[77ab89dfdf07db3a]::with_source_map::<core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>, rustc_interface[4e7b840a6791346]::interface::create_compiler_and_run<core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>, rustc_driver[a5dbbc9ca67f5eff]::run_compiler::{closure#1}>::{closure#1}>
  40:     0x7f4f7cd29de4 - rustc_interface[4e7b840a6791346]::interface::create_compiler_and_run::<core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>, rustc_driver[a5dbbc9ca67f5eff]::run_compiler::{closure#1}>
  41:     0x7f4f7cd14592 - <scoped_tls[4941b86c876e991e]::ScopedKey<rustc_span[77ab89dfdf07db3a]::SessionGlobals>>::set::<rustc_interface[4e7b840a6791346]::interface::run_compiler<core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>, rustc_driver[a5dbbc9ca67f5eff]::run_compiler::{closure#1}>::{closure#0}, core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>
  42:     0x7f4f7cd39c4f - std[1c075e4e42f0cfa5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4e7b840a6791346]::util::run_in_thread_pool_with_globals<rustc_interface[4e7b840a6791346]::interface::run_compiler<core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>, rustc_driver[a5dbbc9ca67f5eff]::run_compiler::{closure#1}>::{closure#0}, core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>::{closure#0}, core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>
  43:     0x7f4f7cd2c249 - <<std[1c075e4e42f0cfa5]::thread::Builder>::spawn_unchecked_<rustc_interface[4e7b840a6791346]::util::run_in_thread_pool_with_globals<rustc_interface[4e7b840a6791346]::interface::run_compiler<core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>, rustc_driver[a5dbbc9ca67f5eff]::run_compiler::{closure#1}>::{closure#0}, core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>::{closure#0}, core[8e7cf360a047e58a]::result::Result<(), rustc_errors[ee6c0c75111f4e19]::ErrorGuaranteed>>::{closure#1} as core[8e7cf360a047e58a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7f4f7a4ab423 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb45e490160efb1da
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/alloc/src/boxed.rs:1866:9
  45:     0x7f4f7a4ab423 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h69d59fb5e559732f
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/alloc/src/boxed.rs:1866:9
  46:     0x7f4f7a4ab423 - std::sys::unix::thread::Thread::new::thread_start::h93dc4d530899e0b7
                               at /rustc/69a5d2481e856a5a18885390b8cf6950b9ff8dd3/library/std/src/sys/unix/thread.rs:108:17
  47:     0x7f4f7a27f54d - <unknown>
  48:     0x7f4f7a304b14 - clone
  49:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.62.0-nightly (69a5d2481 2022-04-27) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [check_mod_item_types] checking item types in module `mode`
#1 [analysis] running analysis passes on this crate
end of query stack

@danii danii added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 30, 2022
@matthiaskrgr
Copy link
Member

matthiaskrgr commented May 30, 2022

can't reproduce with latest nightly rustc 1.63.0-nightly (ebbcbfc23 2022-05-27)

error[E0053]: method `crunch` has an incompatible generic parameter for trait `CrunchICE`
 --> 97541.rs:9:15
  |
2 | trait CrunchICE {
  |       ---------
3 |     fn crunch<const N: usize, T>(ice: T);
  |               -------------- expected const parameter of type `usize`
...
7 | impl CrunchICE for () {
  | ---------------------
8 |     // Note that the const generic and generic have swapped places here.
9 |     fn crunch<T, const N: usize>(ice: T) {}
  |               ^ found type parameter

error: aborting due to previous error

For more information about this error, try `rustc --explain E0053`.

@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 1, 2022

#96717 fixed this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants