Description
When trying to cast a slice, I encountered an ICE in nightly rust. It works in at least two different nightly versions: rustc 1.46.0-nightly (7750c3d 2020-06-26) and rustc 1.46.0-nightly (0ca7f74 2020-06-29). I haven't tested any other versions. In stable rust (1.44.1), no ICE occurs.
Code
A minimal example to reproduce this is here:
fn main() {
let _ = &&[0] as &[_];
}
I expected the following result:
error[E0605]: non-primitive cast: `&&[i32; 1]` as `&[_]`
--> src\main.rs:2:13
|
2 | let _ = &&[0] as &[_];
| ^^^^^^^^^^^^^
|
= note: an `as` expression can only be used to convert between primitive types. Consider
using the `From` trait
Instead, I encountered an ICE.
From the little testing I have done, it seems to require slices for the ICE to occur. Replacing the slices with structs causes the ICE to disappear.
Meta
I got the ICE to work with the following two versions:
rustc --version --verbose
:
rustc 1.46.0-nightly (7750c3d46 2020-06-26)
binary: rustc
commit-hash: 7750c3d46bc19784adb1ee6e37a5ec7e4cd7e772
commit-date: 2020-06-26
host: x86_64-pc-windows-msvc
release: 1.46.0-nightly
LLVM version: 10.0
and
rustc 1.46.0-nightly (0ca7f74db 2020-06-29)
binary: rustc
commit-hash: 0ca7f74dbd23a3e8ec491cd3438f490a3ac22741
commit-date: 2020-06-29
host: x86_64-pc-windows-msvc
release: 1.46.0-nightly
LLVM version: 10.0
It might work with earlier versions of nightly as well, but I haven't checked this. It does not occur with the latest stable version (1.44.1).
Error output
error: internal compiler error: src\librustc_middle\ich\impls_ty.rs:167:9: ty::TyKind::hash_stable() - can't hash a TyVid _#1t.
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:916:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
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.46.0-nightly (0ca7f74db 2020-06-29) running on x86_64-pc-windows-msvc
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
Backtrace
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:916:9
stack backtrace:
0: 0x7ff86f6ba20e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9fa330dd7e3de9bd
1: 0x7ff86f6e815c - core::fmt::write::he569a1ab62a01108
2: 0x7ff86f6ab853 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h41603fb87d485071
3: 0x7ff86f6bf96b - std::panicking::take_hook::h755d174ec3438590
4: 0x7ff86f6bf5b8 - std::panicking::take_hook::h755d174ec3438590
5: 0x7fffd723faca - rustc_driver::report_ice::h9fcbfccbdbf5470b
6: 0x7ff86f6c02f0 - std::panicking::rust_panic_with_hook::hbd7d7a2973bcd31a
7: 0x7fffdb334715 - <rustc_errors::styled_buffer::StyledBuffer as core::fmt::Debug>::fmt::h093a348323a4579c
8: 0x7fffdb365c2f - rustc_errors::HandlerInner::err_count::h0673b8cbad4b83ef
9: 0x7fffdb364222 - rustc_errors::Handler::bug::h8ac18f4fd02a0396
10: 0x7fffdaf0d81f - rustc_middle::util::bug::bug_fmt::hd49a82f454d9c592
11: 0x7fffdaf0bff0 - <rustc_middle::ty::consts::ConstInt as core::fmt::Debug>::fmt::hd2c7213db65e4e8a
12: 0x7fffdaf0b9c8 - <rustc_middle::ty::consts::ConstInt as core::fmt::Debug>::fmt::hd2c7213db65e4e8a
13: 0x7fffdaf0d74c - rustc_middle::util::bug::bug_fmt::hd49a82f454d9c592
14: 0x7fffdaf0d6b0 - rustc_middle::util::bug::bug_fmt::hd49a82f454d9c592
15: 0x7fffdae30357 - rustc_middle::ich::impls_ty::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::TyVid>::hash_stable::h73acb992d8c7b31b
16: 0x7fffdae76707 - ZN12rustc_middle2ty3sty108_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_InferTy161_$LT$impl$u20$rustc_data_structures..stable_hasher..HashStable$LT$rustc_middle..ich..hcx..StableHashingContext$GT$$u20
17: 0x7fffdae72893 - ZN12rustc_middle2ty3sty107_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_TyKind160_$LT$impl$u20$rustc_data_structures..stable_hasher..HashStable$LT$rustc_middle..ich..hcx..StableHashingContext$GT$$u20$
18: 0x7fffd983d7a8 - <rustc_typeck::check::closure::ExpectedSig as core::fmt::Debug>::fmt::h28946985bdaf598f
19: 0x7fffd97853d9 - <rustc_typeck::variance::constraints::ConstraintContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::hf74e1f2a942c895d
20: 0x7fffd9727c55 - <rustc_typeck::outlives::explicit::ExplicitPredicatesMap as core::fmt::Debug>::fmt::hbabb74bd34d6f06e
21: 0x7fffd96b6e28 - rustc_typeck::check::FnCtxt::field_ty::hd3c3fabc7a5594e0
22: 0x7fffd974a0a2 - <rustc_typeck::variance::constraints::ConstraintContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::hf74e1f2a942c895d
23: 0x7fffd969d1f7 - <rustc_typeck::check::fixup_opaque_types::FixupFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty::hdd1705c99306d697
24: 0x7fffd9833a6e - <rustc_typeck::check::closure::ExpectedSig as core::fmt::Debug>::fmt::h28946985bdaf598f
25: 0x7fffd976e546 - <rustc_typeck::variance::constraints::ConstraintContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::hf74e1f2a942c895d
26: 0x7fffd980fca8 - <rustc_typeck::check::op::Op as core::fmt::Debug>::fmt::h4d1ad030ff5c62b0
27: 0x7fffd981ca22 - <rustc_typeck::check::op::Op as core::fmt::Debug>::fmt::h4d1ad030ff5c62b0
28: 0x7fffd977858c - <rustc_typeck::variance::constraints::ConstraintContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::hf74e1f2a942c895d
29: 0x7fffd97df132 - <rustc_typeck::variance::constraints::ConstraintContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::hf74e1f2a942c895d
30: 0x7fffd969caf4 - <rustc_typeck::check::CheckItemTypesVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h7a4fa0a9cfe88a7f
31: 0x7fffd98ebe4d - <rustc_typeck::astconv::Bounds as core::fmt::Debug>::fmt::h70515e593af6043a
32: 0x7fffd9770786 - <rustc_typeck::variance::constraints::ConstraintContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::hf74e1f2a942c895d
33: 0x7fffd980e263 - <rustc_typeck::check::op::Op as core::fmt::Debug>::fmt::h4d1ad030ff5c62b0
34: 0x7fffd981e702 - <rustc_typeck::check::op::Op as core::fmt::Debug>::fmt::h4d1ad030ff5c62b0
35: 0x7fffd979e595 - <rustc_typeck::variance::constraints::ConstraintContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::hf74e1f2a942c895d
36: 0x7fffd98624d3 - rustc_typeck::check_crate::hc6421be2473852fa
37: 0x7fffd73b785a - rustc_interface::passes::QueryContext::print_stats::h054eebba2bf29675
38: 0x7fffd722672b - <env_logger::filter::inner::Filter as core::fmt::Display>::fmt::ha8cb8d62fcfb1df4
39: 0x7fffd72291d6 - <env_logger::filter::inner::Filter as core::fmt::Display>::fmt::ha8cb8d62fcfb1df4
40: 0x7fffd729b523 - rustc_driver::pretty::print_after_hir_lowering::hfe862cf5f8fae20a
41: 0x7fffd71fb352 - <rustc_codegen_ssa::back::linker::MsvcLinker as rustc_codegen_ssa::back::linker::Linker>::group_start::h547d707086852577
42: 0x7fffd7292df3 - rustc_driver::pretty::print_after_hir_lowering::hfe862cf5f8fae20a
43: 0x7fffd7226d76 - <env_logger::filter::inner::Filter as core::fmt::Display>::fmt::ha8cb8d62fcfb1df4
44: 0x7fffd71f8521 - <rustc_codegen_ssa::back::linker::MsvcLinker as rustc_codegen_ssa::back::linker::Linker>::group_start::h547d707086852577
45: 0x7fffd722434e - <env_logger::filter::inner::Filter as core::fmt::Display>::fmt::ha8cb8d62fcfb1df4
46: 0x7fffd724ac5d - <rustc_span::symbol::SymbolStr as core::fmt::Display>::fmt::hc00ebfa5a26d5596
47: 0x7fffd71fc903 - <rustc_codegen_ssa::back::linker::MsvcLinker as rustc_codegen_ssa::back::linker::Linker>::group_start::h547d707086852577
48: 0x7ff86f6cfc1a - std::sys::windows::thread::Thread::new::h9c6ccf8206794202
49: 0x7ff88cba6fd4 - BaseThreadInitThunk
50: 0x7ff88cefcec1 - RtlUserThreadStart
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.46.0-nightly (0ca7f74db 2020-06-29) running on x86_64-pc-windows-msvc
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [typeck_tables_of] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error