Closed
Description
I tried this code:
#![feature(const_trait_impl)]
#![feature(fn_traits)]
#![feature(unboxed_closures)]
struct Closure;
impl const FnOnce<&usize> for Closure {
type Output = usize;
extern "rust-call" fn call_once(self, arg: &usize) -> Self::Output {
*arg
}
}
enum Bug<T = [(); Closure.call_once(&0) ]> {
V(T),
}
I expected to see this happen: Maybe it should've compiled? Maybe it should've just emitted an error explaining I did something wrong?
Instead, this happened: It crashed!
Meta
rustc --version --verbose
:
1.43.0-nightly (6fd8798f4 2020-02-25)
Backtrace
error: internal compiler error: src/librustc_mir/interpret/eval_context.rs:143: The type checker should prevent reading from a never-written local
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:881:9
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1052
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1428
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:204
9: std::panicking::default_hook
at src/libstd/panicking.rs:224
10: rustc_driver::report_ice
11: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:474
12: std::panicking::begin_panic
13: rustc_errors::HandlerInner::bug
14: rustc_errors::Handler::bug
15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
16: rustc::ty::context::tls::with_opt::{{closure}}
17: rustc::ty::context::tls::with_opt
18: rustc::util::bug::opt_span_bug_fmt
19: rustc::util::bug::bug_fmt
20: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::access_local
21: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_place_to_op
22: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_operand
23: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
24: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
25: rustc_mir::const_eval::eval_queries::const_eval_raw_provider
26: rustc::ty::query::__query_compute::const_eval_raw
27: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute
28: rustc::dep_graph::graph::DepGraph::with_task_impl
29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
30: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
31: rustc::ty::query::__query_compute::const_eval_validated
32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_validated>::compute
33: rustc::dep_graph::graph::DepGraph::with_task_impl
34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
35: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
36: rustc::ty::query::__query_compute::const_eval_validated
37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_validated>::compute
38: rustc::dep_graph::graph::DepGraph::with_task_impl
39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
40: rustc::mir::interpret::queries::<impl rustc::ty::context::TyCtxt>::const_eval_resolve
41: rustc::ty::sty::Const::eval::{{closure}}
42: <rustc_infer::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const
43: <rustc_infer::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
44: rustc::ty::fold::TypeFoldable::fold_with
45: rustc::ty::fold::TypeFoldable::fold_with
46: rustc_infer::traits::project::normalize
47: rustc_infer::infer::InferCtxt::partially_normalize_associated_types_in
48: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::next
49: rustc_typeck::check::wfcheck::check_where_clauses
50: rustc::ty::context::GlobalCtxt::enter_local
51: rustc_typeck::check::wfcheck::check_item_well_formed
52: rustc::ty::query::__query_compute::check_item_well_formed
53: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_item_well_formed>::compute
54: rustc::dep_graph::graph::DepGraph::with_task_impl
55: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
56: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
57: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:86
58: rustc_data_structures::sync::par_for_each_in
59: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:86
60: rustc_hir::hir::Crate::par_visit_all_item_likes
61: rustc_typeck::check_crate
62: rustc_interface::passes::analysis
63: rustc::ty::query::__query_compute::analysis
64: rustc::dep_graph::graph::DepGraph::with_task_impl
65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
66: rustc::ty::context::tls::enter_global
67: rustc_interface::interface::run_compiler_in_existing_thread_pool
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.43.0-nightly (6fd8798f4 2020-02-25) running on x86_64-unknown-linux-gnu
note: compiler flags: -C opt-level=3 -C codegen-units=1 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [const_eval_raw] const-evaluating `Bug::{{constant}}#0`
#1 [const_eval_validated] const-evaluating + checking `Bug::{{constant}}#0`
#2 [const_eval_validated] const-evaluating + checking `Bug::{{constant}}#0`
#3 [check_item_well_formed] processing `Bug`
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
Area: Closures (`|…| { … }`)Area: Constant evaluation, covers all const contexts (static, const fn, ...)Category: This is a bug.`#![feature(const_trait_impl)]``#![feature(unboxed_closures)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.Performance or correctness regression from one stable version to another.