Closed
Description
The following code results in an internal compiler error:
trait ArraySizeTrait {
const SIZE: usize = 0;
}
// remove this impl to get error E0599 instead of ICE
impl<T : ?Sized> ArraySizeTrait for T {
const SIZE: usize = 1;
}
struct SomeArray<T: ArraySizeTrait> {
array: [u8; T::SIZE],
phantom: std::marker::PhantomData<T>,
}
fn main() {
}
I expected to see something like error E0599, since removing impl<T : ?Sized> ArraySizeTrait for T
makes this code quite similar to issue #26402 and causes error E0599.
I tested it with rustc versions 1.32.0 and 1.33.0-nightly.
Meta
Output of the linked playground including backtrace:
Compiling playground v0.0.1 (/playground)
error: internal compiler error: src/librustc/ty/subst.rs:480: Type parameter `T/#0` (T/0) out of range when substituting (root type=Some(T)) substs=[]
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:526:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:58
at src/libstd/panicking.rs:200
3: std::panicking::default_hook
at src/libstd/panicking.rs:215
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:482
6: std::panicking::begin_panic
7: rustc_errors::Handler::span_bug
8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
9: rustc::ty::context::tls::with_opt::{{closure}}
10: rustc::ty::context::tls::with_context_opt
11: rustc::ty::context::tls::with_opt
12: rustc::util::bug::opt_span_bug_fmt
13: rustc::util::bug::span_bug_fmt
14: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
15: <smallvec::SmallVec<A> as core::iter::traits::FromIterator<<A as smallvec::Array>::Item>>::from_iter
16: rustc::ty::fold::TypeFoldable::fold_with
17: rustc::traits::codegen::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>::subst_and_normalize_erasing_regions
18: <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::resolve
19: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::const_value_to_op
20: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::run
21: rustc_mir::const_eval::eval_body_using_ecx
22: rustc_mir::const_eval::const_eval_raw_provider
23: rustc::ty::query::__query_compute::const_eval_raw
24: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval_raw<'tcx>>::compute
25: rustc::dep_graph::graph::DepGraph::with_task_impl
26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
27: rustc_mir::const_eval::const_eval_provider
28: rustc::ty::query::__query_compute::const_eval
29: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute
30: rustc::dep_graph::graph::DepGraph::with_task_impl
31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
32: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
33: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
34: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
35: rustc::traits::project::normalize
36: rustc::infer::InferCtxt::partially_normalize_associated_types_in
37: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::fold
38: rustc::ty::context::GlobalCtxt::enter_local
39: rustc_typeck::check::wfcheck::check_item_well_formed
40: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::check_item_well_formed<'tcx>>::compute
41: rustc::dep_graph::graph::DepGraph::with_task_impl
42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
44: rustc::session::Session::track_errors
45: rustc::util::common::time
46: rustc_typeck::check_crate
47: <std::thread::local::LocalKey<T>>::with
48: rustc::ty::context::TyCtxt::create_and_enter
49: rustc_driver::driver::compile_input
50: rustc_driver::run_compiler_with_pool
51: <scoped_tls::ScopedKey<T>>::set
52: rustc_driver::run_compiler
53: <scoped_tls::ScopedKey<T>>::set
query stack during panic:
#0 [const_eval_raw] const-evaluating `SomeArray::array::{{constant}}`
#1 [const_eval] const-evaluating + checking `SomeArray::array::{{constant}}`
#2 [check_item_well_formed] processing `SomeArray`
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.33.0-nightly (daa53a52a 2019-01-17) running on x86_64-unknown-linux-gnu
note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Lazy normalization (tracking issue: #60471)Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.