A new project with the following code:
#![feature(const_generics)]
struct Struct<T>(T);
impl<T, const N: usize> Struct<[T; N]> {
fn f() {}
fn g() { Self::f(); }
}
fn main() {}
Causes the following error:
Checking rust6 v0.1.0 (/home/carado/tmp/rust6)
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> src/main.rs:1:12
|
1 | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
error: internal compiler error: src/librustc/infer/canonical/canonicalizer.rs:553: failed to lift `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(TraitPredicate(<T as std::marker::Sized>))], reveal: UserFacing, def_id: None }, value: AscribeUserType { mir_ty: fn() {Struct::<[T; _]>::f}, def_id: DefId(0:20 ~ rust6[383a]::{{impl}}[0]::f[0]), user_substs: UserSubsts { substs: [^0, Const { ty: _, val: Infer(Canonical(DebruijnIndex(0), 1)) }], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(0:16 ~ rust6[383a]::{{impl}}[0]), self_ty: Struct<[T; _]> }) } } }`, canonicalized from `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(TraitPredicate(<T as std::marker::Sized>))], reveal: UserFacing, def_id: None }, value: AscribeUserType { mir_ty: fn() {Struct::<[T; _]>::f}, def_id: DefId(0:20 ~ rust6[383a]::{{impl}}[0]::f[0]), user_substs: UserSubsts { substs: [_, Const { ty: _, val: Infer(Var(_#0c)) }], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(0:16 ~ rust6[383a]::{{impl}}[0]), self_ty: Struct<[T; _]> }) } } }`
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:637:9
stack backtrace:
0: 0x7f346fd87cfa - backtrace::backtrace::libunwind::trace::h27e79239ae132594
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.25/src/backtrace/libunwind.rs:97
1: 0x7f346fd87cfa - backtrace::backtrace::trace_unsynchronized::h4d06032f1d31ea4f
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.25/src/backtrace/mod.rs:66
2: 0x7f346fd87cfa - std::sys_common::backtrace::_print::h87f958e4afa789cc
at src/libstd/sys_common/backtrace.rs:47
3: 0x7f346fd87cfa - std::sys_common::backtrace::print::h9701366bda361a82
at src/libstd/sys_common/backtrace.rs:36
4: 0x7f346fd87cfa - std::panicking::default_hook::{{closure}}::hdeb6e1bffcdd7ad2
at src/libstd/panicking.rs:197
5: 0x7f346fd879fb - std::panicking::default_hook::hda59c88c4e0c7e8b
at src/libstd/panicking.rs:211
6: 0x7f346db034c0 - rustc::util::common::panic_hook::h5c18c3a9efba48a4
7: 0x7f346fd88558 - std::panicking::rust_panic_with_hook::hb309d4b58eca6d76
at src/libstd/panicking.rs:478
8: 0x7f346c776f2c - std::panicking::begin_panic::h7eade2292f31029b
9: 0x7f346c7930be - rustc_errors::Handler::bug::h1c5624823189268b
10: 0x7f346d7b4b72 - rustc::util::bug::opt_span_bug_fmt::{{closure}}::h07e1c0d72b0417a3
11: 0x7f346d7b4979 - rustc::ty::context::tls::with_opt::{{closure}}::h1b6716cf20847d91
12: 0x7f346d7b4894 - rustc::ty::context::tls::with_context_opt::hff146530e0a4a88d
13: 0x7f346d7b4926 - rustc::ty::context::tls::with_opt::h9af956ee096d242b
14: 0x7f346d7b4a87 - rustc::util::bug::opt_span_bug_fmt::had3d583fee4c61ad
15: 0x7f346d7b49f1 - rustc::util::bug::bug_fmt::ha79344e8985ddc8d
16: 0x7f346e50d522 - rustc::infer::canonical::canonicalizer::Canonicalizer::canonicalize::{{closure}}::h4c72e42f9213dd11
17: 0x7f346e50b793 - rustc::infer::canonical::canonicalizer::Canonicalizer::canonicalize::h6679b6bef6064e96
18: 0x7f346e50e522 - rustc::traits::query::type_op::QueryTypeOp::fully_perform_into::h1c7a9c8df8f0ae25
19: 0x7f346e3283c7 - <rustc::ty::ParamEnvAnd<Q> as rustc::traits::query::type_op::TypeOp>::fully_perform::h5bff7317f6a4c90b
20: 0x7f346e5f1aa5 - rustc_mir::borrow_check::nll::type_check::TypeChecker::fully_perform_op::h4acfee346b7c791d
21: 0x7f346e5ecc77 - rustc_mir::borrow_check::nll::type_check::type_check::hc5f371a7d1e9eb97
22: 0x7f346e27a68e - rustc_mir::borrow_check::nll::compute_regions::h4278fc7ec4877ea6
23: 0x7f346e3bcb5c - rustc_mir::borrow_check::do_mir_borrowck::h9fc4396b8511f41f
24: 0x7f346e6b136b - rustc::ty::context::GlobalCtxt::enter_local::h59db5d38d6335a2a
25: 0x7f346e3bc196 - rustc_mir::borrow_check::mir_borrowck::h0828765d0bd2d619
26: 0x7f346f7b4286 - rustc::ty::query::__query_compute::mir_borrowck::h34514b79ec87f9e3
27: 0x7f346f7ebdd4 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute::h7bfa182ab296aa77
28: 0x7f346f81a3a0 - rustc::dep_graph::graph::DepGraph::with_task_impl::h1665deacec9882e5
29: 0x7f346f7f465b - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h34aab210cf157a65
30: 0x7f346f7ebac2 - rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::h723cbe87a89f9fb9
31: 0x7f346f7b5f77 - rustc::util::common::time::h42aa5289a745a6dc
32: 0x7f346f761551 - rustc_interface::passes::analysis::h2ed6994fd4b83e0e
33: 0x7f34700ebcb5 - rustc::ty::query::__query_compute::analysis::h099fddfbefe8be42
34: 0x7f3470057ad1 - rustc::dep_graph::graph::DepGraph::with_task_impl::he089af1d85a1e53e
35: 0x7f347004fb46 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h171199e934f91167
36: 0x7f3470061775 - rustc::ty::context::tls::enter_global::h3f37dacdb92b2b83
37: 0x7f3470083716 - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::hd921952b93938b11
38: 0x7f346f7c6734 - rustc_interface::passes::create_global_ctxt::{{closure}}::h02c0671e3a3747e1
39: 0x7f3470085c49 - rustc_interface::interface::run_compiler_in_existing_thread_pool::hdc9adcf187c1c745
40: 0x7f34700eea45 - std::thread::local::LocalKey<T>::with::hb4d77454d8f5b39f
41: 0x7f347009c304 - scoped_tls::ScopedKey<T>::set::hf0af9addd0db626a
42: 0x7f34700b1103 - syntax::with_globals::hf05470816f33fc03
43: 0x7f34700dfd2c - std::sys_common::backtrace::__rust_begin_short_backtrace::hfd0071cd5db5cd9e
44: 0x7f346fd99499 - __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:85
45: 0x7f3470069e58 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h101536dc4ddcc287
46: 0x7f346fd6ba9e - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h08bd7d4edd708d24
at /rustc/37d001e4deb206ed954fde5d91690221e8306fc3/src/liballoc/boxed.rs:746
47: 0x7f346fd9816f - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::he2a07dcda49e9385
at /rustc/37d001e4deb206ed954fde5d91690221e8306fc3/src/liballoc/boxed.rs:746
48: 0x7f346fd9816f - std::sys_common::thread::start_thread::h9f229612a1fc41e1
at src/libstd/sys_common/thread.rs:13
49: 0x7f346fd9816f - std::sys::unix::thread::Thread::new::thread_start::h5b2c91946063a815
at src/libstd/sys/unix/thread.rs:79
50: 0x7f346fccffa7 - start_thread
at /builddir/glibc-2.29/nptl/pthread_create.c:486
51: 0x7f346fbf1a1e - __GI___clone
52: 0x0 - <unknown>
query stack during panic:
#0 [mir_borrowck] processing `Struct::<[T; _]>::g`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
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: rustc 1.37.0-nightly (37d001e4d 2019-05-29) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `rust6`.
To learn more, run the command again with --verbose.
Reduced:
#![feature(const_generics)]
struct Struct<T>(T);
impl<T, const N: usize> Struct<[T; N]> {
fn f() {}
fn g() { <Struct<[T; N]>>::f(); }
}
fn main() {}
cc @varkor
Latest nightly shows a different compile error:
error: internal compiler error: src/librustc/ich/impls_ty.rs:213: ty::TyKind::hash_stable() - can't hash a TyVid _#1t.
Does not ICE anymore on playground -> https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=2b645bb8d4c71206ce6eef1a16ea3390.
But does ICE in my local PC with latest nightly.
Can confirm it still ICE's with the latest nightly both in my little testing crate, and my larger project.
The lack of ICE on the playground is very weird. Even copying my testing crate's code exactly doesn't make the ICE occur, even though both the playground and my computer run rustc 481068a70 2019-07-05.
Maybe a compiler flag? Not sure if playground uses rustup.
cc @shepmaster
with latest nightly
The playground attempts to build each night, but it sometimes fails. You can always review exactly what version you are using in the channel dropdown:

For what it鈥檚 worth, I don鈥檛 see the reduced example producing an error locally or in the playground.
$ rustc +nightly --version
rustc 1.38.0-nightly (6e310f2ab 2019-07-07)
$ rustc +nightly c.rs
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> c.rs:1:12
|
1 | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
warning: struct is never constructed: `Struct`
--> c.rs:3:1
|
3 | struct Struct<T>(T);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
warning: method is never used: `f`
--> c.rs:6:2
|
6 | fn f() {}
| ^^^^^^
warning: method is never used: `g`
--> c.rs:7:2
|
7 | fn g() { <Struct<[T; N]>>::f(); }
| ^^^^^^
Thank you very much, @shepmaster
It is clear now that incremental compilation is the source of this behavior.
To make a successful compilation with cargo, it is possible to use, for example, CARGO_INCREMENTAL=0 cargo build.
Most helpful comment
Latest nightly shows a different compile error:
error: internal compiler error: src/librustc/ich/impls_ty.rs:213: ty::TyKind::hash_stable() - can't hash a TyVid _#1t.