Skip to content

ICE with const_evaluatable_checked and lifetime parameter #85031

Closed
@Johannesd3

Description

@Johannesd3

Code

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

pub struct Ref<'a, const NUM: usize>(&'a i32);

impl<'a, const NUM: usize> Ref<'a, NUM> {
    pub fn foo<const A: usize>(r: Ref<'a, A>) -> Self
    where
        ([(); NUM - A], [(); A - NUM]): Sized,
    {
        Self::bar(r)
    }

    pub fn bar<const A: usize>(r: Ref<'a, A>) -> Self
    where
        ([(); NUM - A], [(); A - NUM]): Sized,
    {
        Self(r.0)
    }
}

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (676ee1472 2021-05-06)
binary: rustc
commit-hash: 676ee14729462585b969bbc52f32c307403f4126
commit-date: 2021-05-06
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.0

Error output

note: run with `RUST_BACKTRACE=1` environment variable to display a 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.54.0-nightly (676ee1472 2021-05-06) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [typeck] type-checking `<impl at src/lib.rs:6:1: 20:2>::foo`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to previous error

error: could not compile `ice-minimal`

To learn more, run the command again with --verbose.
Backtrace

   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_middle::ich::impls_ty::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::RegionKind>::hash_stable
   8: std::thread::local::LocalKey<T>::with
   9: rustc_query_system::dep_graph::dep_node::DepNode<K>::construct
  10: rustc_query_system::query::plumbing::get_query_impl
  11: rustc_query_system::query::plumbing::get_query
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_unify_abstract_consts
  13: rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations
  14: rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations
  15: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_where_possible
  16: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_vars_with_obligations
  17: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::structurally_resolved_type
  18: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  19: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  20: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  21: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  22: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  23: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  24: rustc_typeck::check::check::check_fn
  25: rustc_typeck::check::inherited::InheritedBuilder::enter
  26: rustc_typeck::check::typeck
  27: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_query_system::query::plumbing::force_query_with_job
  31: rustc_query_system::query::plumbing::get_query_impl
  32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  33: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  34: rustc_typeck::check::typeck_item_bodies
  35: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  36: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  37: rustc_data_structures::stack::ensure_sufficient_stack
  38: rustc_query_system::query::plumbing::force_query_with_job
  39: rustc_query_system::query::plumbing::get_query_impl
  40: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  41: rustc_session::utils::<impl rustc_session::session::Session>::time
  42: rustc_typeck::check_crate
  43: rustc_interface::passes::analysis
  44: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  45: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  46: rustc_data_structures::stack::ensure_sufficient_stack
  47: rustc_query_system::query::plumbing::force_query_with_job
  48: rustc_query_system::query::plumbing::get_query_impl
  49: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  50: rustc_interface::passes::QueryContext::enter
  51: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  52: rustc_span::with_source_map
  53: rustc_interface::interface::create_compiler_and_run
  54: scoped_tls::ScopedKey<T>::set

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-incr-compArea: Incremental compilationC-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.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions