Skip to content

ICE in const_evaluatable_checked #76595

Description

@DutchGhost

I got a little excited with #76559 merged, soooo I gave it a try, and I found this rather funny ICE. Notice how I call test::<2>(), without a type parameter, while the function expects a type parameter.

Code

#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]

struct Bool<const B: bool>;

trait True {}

impl True for Bool<true> {}

fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
    todo!()
}

fn main() {
    test::<2>();
}

Meta

rustc --version --verbose:

rustc 1.48.0-nightly (a1947b3f9 2020-09-10)

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:1263:17: Layout::compute: unexpected type `^0`
Backtrace

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::bug
   2: rustc_errors::Handler::bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::bug_fmt
   8: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::layout_raw_uncached
   9: rustc_middle::ty::layout::layout_raw
  10: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::layout_raw>::compute
  11: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  12: rustc_data_structures::stack::ensure_sufficient_stack
  13: rustc_query_system::query::plumbing::get_query_impl
  14: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  15: rustc_mir::interpret::intrinsics::eval_nullary_intrinsic
  16: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  17: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::get_query_impl
  21: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  22: rustc_mir::interpret::eval_context::InterpCx<M>::const_eval
  23: rustc_mir::interpret::intrinsics::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::emulate_intrinsic
  24: <rustc_mir::const_eval::machine::CompileTimeInterpreter as rustc_mir::interpret::machine::Machine>::call_intrinsic
  25: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_fn_call
  26: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  27: rustc_mir::const_eval::eval_queries::const_eval_raw_provider
  28: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_raw>::compute
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_query_system::query::plumbing::get_query_impl
  32: rustc_mir::const_eval::machine::<impl rustc_mir::interpret::eval_context::InterpCx<rustc_mir::const_eval::machine::CompileTimeInterpreter>>::try_eval_const_fn_call
  33: <rustc_mir::const_eval::machine::CompileTimeInterpreter as rustc_mir::interpret::machine::Machine>::find_mir_or_eval_fn
  34: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_fn_call
  35: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  36: rustc_mir::const_eval::eval_queries::const_eval_raw_provider
  37: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_raw>::compute
  38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  39: rustc_data_structures::stack::ensure_sufficient_stack
  40: rustc_query_system::query::plumbing::get_query_impl
  41: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  42: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute
  43: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  44: rustc_data_structures::stack::ensure_sufficient_stack
  45: rustc_query_system::query::plumbing::get_query_impl
  46: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  47: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  48: rustc_infer::infer::InferCtxt::const_eval_resolve
  49: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
  50: rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations
  51: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_where_possible
  52: rustc_typeck::check::FnCtxt::resolve_vars_with_obligations
  53: rustc_typeck::check::FnCtxt::structurally_resolved_type
  54: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
  55: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  56: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
  57: rustc_typeck::check::FnCtxt::check_stmt
  58: rustc_typeck::check::FnCtxt::check_block_with_expected
  59: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  60: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
  61: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  62: rustc_typeck::check::check_fn
  63: rustc_infer::infer::InferCtxtBuilder::enter
  64: rustc_typeck::check::typeck
  65: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  66: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  67: rustc_data_structures::stack::ensure_sufficient_stack
  68: rustc_query_system::query::plumbing::get_query_impl
  69: rustc_query_system::query::plumbing::ensure_query_impl
  70: rustc_typeck::check::typeck_item_bodies
  71: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  72: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  73: rustc_data_structures::stack::ensure_sufficient_stack
  74: rustc_query_system::query::plumbing::get_query_impl
  75: rustc_typeck::check_crate
  76: rustc_interface::passes::analysis
  77: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  78: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  79: rustc_data_structures::stack::ensure_sufficient_stack
  80: rustc_query_system::query::plumbing::get_query_impl
  81: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  82: rustc_span::with_source_map
  83: rustc_interface::interface::create_compiler_and_run
  84: scoped_tls::ScopedKey<T>::set
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.48.0-nightly (a1947b3f9 2020-09-10) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [layout_raw] computing layout of `^0`
#1 [const_eval_validated] const-evaluating + checking `std::intrinsics::size_of`
#2 [const_eval_raw] const-evaluating `std::mem::size_of`
#3 [const_eval_raw] const-evaluating `test::{{constant}}#0`
#4 [const_eval_validated] const-evaluating + checking `test::{{constant}}#0`
#5 [typeck] type-checking `main`
#6 [typeck_item_bodies] type-checking all item bodies
#7 [analysis] running analysis passes on this crate
end of query stack

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions