Closed as not planned
Description
code
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#[derive(PartialEq, Eq)]
pub enum A {
A,
B,
}
pub trait B<const __: &'static A> {
fn a(&self) {}
}
struct C;
impl B<{ &A::A }> for C {}
impl B<{ &A::B }> for C {}
fn ice() {
B::<{ &A::A }>::a(&C);
}
meta
this is only possible on the nightly version, due to it using an unstable and incomplete feature (adt_const_params
)
rustc --version --verbose
:
rustc 1.57.0-nightly (485ced56b 2021-10-07)
error
thread 'rustc' panicked at 'forcing query with already existing `DepNode`
- query-key: Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: Binder(TraitPredicate(<C as B<{&_: &'static A}>>), []) } }
- dep-node: evaluate_obligation(bcbd867fecf3da2d-c598572d933665fd)', /rustc/485ced56b8753ec86936903f2a8c95e9be8996a1/compiler/rustc_query_system/src/dep_graph/graph.rs:247:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.57.0-nightly (485ced56b 2021-10-07) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `C: B<{&_: &'static A}>`
#1 [typeck] type-checking `test::ice`
end of query stack
error: could not compile `rust`
backtrace
thread 'rustc' panicked at 'forcing query with already existing `DepNode`
- query-key: Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: Binder(TraitPredicate(<C as B<{&_: &'static A}>>), []) } }
- dep-node: evaluate_obligation(bcbd867fecf3da2d-c598572d933665fd)', /rustc/485ced56b8753ec86936903f2a8c95e9be8996a1/compiler/rustc_query_system/src/dep_graph/graph.rs:247:9
stack backtrace:
0: rust_begin_unwind
at /rustc/485ced56b8753ec86936903f2a8c95e9be8996a1/library/std/src/panicking.rs:517:5
1: core::panicking::panic_fmt
at /rustc/485ced56b8753ec86936903f2a8c95e9be8996a1/library/core/src/panicking.rs:100:14
2: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
3: rustc_data_structures::stack::ensure_sufficient_stack
4: rustc_query_system::query::plumbing::get_query
5: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::evaluate_obligation
6: rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations
7: rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations
8: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_with_constness_where_possible
9: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
10: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
11: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
12: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
13: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
14: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
15: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
16: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
17: rustc_typeck::check::check::check_fn
18: rustc_infer::infer::InferCtxtBuilder::enter
19: rustc_typeck::check::typeck
20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
21: rustc_data_structures::stack::ensure_sufficient_stack
22: rustc_query_system::query::plumbing::try_execute_query
23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
24: rustc_typeck::collect::type_of::opt_const_param_of
25: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
26: rustc_data_structures::stack::ensure_sufficient_stack
27: rustc_query_system::query::plumbing::try_execute_query
28: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::opt_const_param_of
29: rustc_typeck::check::typeck
30: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
31: rustc_data_structures::stack::ensure_sufficient_stack
32: rustc_query_system::query::plumbing::try_execute_query
33: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
34: rustc_data_structures::sync::par_for_each_in
35: rustc_typeck::check::typeck_item_bodies
36: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
37: rustc_data_structures::stack::ensure_sufficient_stack
38: rustc_query_system::query::plumbing::try_execute_query
39: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
40: rustc_session::utils::<impl rustc_session::session::Session>::time
41: rustc_typeck::check_crate
42: rustc_interface::passes::analysis
43: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
44: rustc_data_structures::stack::ensure_sufficient_stack
45: rustc_query_system::query::plumbing::try_execute_query
46: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
47: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
48: rustc_span::with_source_map
49: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.57.0-nightly (485ced56b 2021-10-07) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `C: B<{&_: &'static A}>`
#1 [typeck] type-checking `test::ice`
#2 [opt_const_param_of] computing the optional const parameter of `test::ice::{constant#0}`
#3 [typeck] type-checking `test::ice::{constant#0}`
#4 [typeck_item_bodies] type-checking all item bodies
#5 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `rust`
details
this panic is not triggered if the source is compiled with rustc
directly (assuming the ice
function is renamed to main
). this detail may or may not be useful, but i ran into this distinction trying to reproduce it.
the error returned instead is this:
error[E0277]: the trait bound `C: B<{&_: &'static A}>` is not satisfied
--> lib.rs:22:23
|
22 | B::<{ &A::A }>::a(&C);
| ----------------- ^^ the trait `B<{&_: &'static A}>` is not implemented for `C`
| |
| required by a bound introduced by this call
|
= help: the following implementations were found:
<C as B<{&_: &'static A}>>
<C as B<{&_: &'static A}>>
note: required by `B::a`
--> lib.rs:11:5
|
11 | fn a(&self) {}
| ^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.