Closed
Description
trait ToBytes {
const SIZE: usize;
fn a(self) -> [u8; ToBytes::SIZE];
// error happens because a previous type error happened I think
fn b(self) -> [u8; ToBytes::SIZE];
}
Error message
error: internal compiler error: src/librustc/traits/codegen/mod.rs:51: Encountered ambiguity selecting
Binder(<[type error] as ToBytes>) during codegen, presuming due to overflow
This only happens if there are two erroneous functions, if I take out b
it works fine.
It seems like I was trying to do this wrong in the first place since the first function gives an error error[E0283]: type annotations required: cannot resolve '_: ToBytes'
. Not sure what the right way to do this is.
Traceback
error: internal compiler error: src/librustc/traits/codegen/mod.rs:51: Encountered ambiguity selecting `Binder(<[type error] as ToBytes>)` during codegen, presuming due to overflow
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:637: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:71
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:197
3: std::panicking::default_hook
at src/libstd/panicking.rs:211
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
6: std::panicking::begin_panic
7: rustc_errors::Handler::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::bug_fmt
14: rustc::ty::context::GlobalCtxt::enter_local
15: rustc::traits::codegen::codegen_fulfill_obligation
16: rustc::ty::query::__query_compute::codegen_fulfill_obligation
17: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::codegen_fulfill_obligation>::compute
18: rustc::dep_graph::graph::DepGraph::with_task_impl
19: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
20: rustc::ty::instance::Instance::resolve
21: rustc_mir::interpret::eval_context::InterpretCx<M>::resolve
22: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpretCx<M>>::eval_const_to_op
23: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpretCx<M>>::run
24: rustc_mir::const_eval::eval_body_using_ecx
25: rustc_mir::const_eval::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::const_eval_provider
31: rustc::ty::query::__query_compute::const_eval
32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
33: rustc::dep_graph::graph::DepGraph::with_task_impl
34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
35: <rustc::traits::project::AssociatedTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const
36: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
37: <rustc::traits::project::AssociatedTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
38: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
39: rustc::ty::fold::TypeFoldable::fold_with
40: rustc::traits::project::normalize
41: rustc_typeck::check::FnCtxt::normalize_associated_types_in
42: rustc::ty::context::GlobalCtxt::enter_local
43: rustc_typeck::check::wfcheck::check_associated_item
44: rustc::ty::query::__query_compute::check_trait_item_well_formed
45: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_trait_item_well_formed>::compute
46: rustc::dep_graph::graph::DepGraph::with_task_impl
47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
48: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc::hir::itemlikevisit::ParItemLikeVisitor>::visit_trait_item
49: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:85
50: rustc_data_structures::sync::par_for_each_in
51: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:85
52: rustc::hir::Crate::par_visit_all_item_likes
53: rustc::util::common::time
54: rustc_typeck::check_crate
55: rustc_interface::passes::analysis
56: rustc::ty::query::__query_compute::analysis
57: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
58: rustc::dep_graph::graph::DepGraph::with_task_impl
59: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
60: rustc::ty::context::tls::enter_global
61: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
62: rustc_interface::passes::create_global_ctxt::{{closure}}
63: rustc_interface::interface::run_compiler_in_existing_thread_pool
64: std::thread::local::LocalKey<T>::with
65: scoped_tls::ScopedKey<T>::set
66: syntax::with_globals
query stack during panic:
#0 [codegen_fulfill_obligation] checking if `ToBytes` fulfills its obligations
#1 [const_eval_raw] const-evaluating `ToBytes::b::{{constant}}#0`
#2 [const_eval] const-evaluating + checking `ToBytes::b::{{constant}}#0`
#3 [check_trait_item_well_formed] processing `ToBytes::b`
#4 [analysis] running analysis passes on this crate
end of query stack
Version
$ rustc --version -v
rustc 1.36.0 (a53f9df32 2019-07-03)
binary: rustc
commit-hash: a53f9df32fbb0b5f4382caaad8f1a46f36ea887c
commit-date: 2019-07-03
host: x86_64-unknown-linux-gnu
release: 1.36.0
LLVM version: 8.0
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Code generationArea: Lazy normalization (tracking issue: #60471)Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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.