Skip to content

ICE on const generic + static slice of fn() #88384

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
simon-auch opened this issue Aug 27, 2021 · 0 comments · Fixed by #89147
Closed

ICE on const generic + static slice of fn() #88384

simon-auch opened this issue Aug 27, 2021 · 0 comments · Fixed by #89147
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-adt_const_params `#![feature(adt_const_params)]` F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@simon-auch
Copy link

simon-auch commented Aug 27, 2021

Code

#![feature(fn_traits)]
#![feature(adt_const_params)]

#[derive(PartialEq, Eq)]
struct CompileTimeSettings{
    hooks: &'static[fn()],
}

struct Foo<const T: CompileTimeSettings>;

impl<const T: CompileTimeSettings> Foo<T> {
    fn callHooks(){
    }
}

fn main(){
    const settings: CompileTimeSettings = CompileTimeSettings{
        hooks: &[],
    };
    
    Foo::<settings>::callHooks();
}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (0afc20860 2021-08-25) running on x86_64-unknown-linux-gnu

Error output

error: internal compiler error: compiler/rustc_mir/src/const_eval/mod.rs:160:14: cannot destructure constant Const { ty: &[fn()], val: Value(ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, alloc4)] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1145:9
stack 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_mir::const_eval::destructure_const
   8: core::ops::function::FnOnce::call_once
   9: rustc_query_system::query::plumbing::get_query_impl
  10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::destructure_const
  11: rustc_middle::ty::relate::super_relate_consts
  12: <rustc_infer::infer::combine::ConstInferUnifier as rustc_middle::ty::relate::TypeRelation>::consts
  13: rustc_middle::ty::relate::super_relate_consts
  14: <rustc_infer::infer::combine::ConstInferUnifier as rustc_middle::ty::relate::TypeRelation>::consts
  15: rustc_infer::infer::combine::<impl rustc_infer::infer::InferCtxt>::unify_const_variable
  16: rustc_infer::infer::combine::<impl rustc_infer::infer::InferCtxt>::super_combine_consts
  17: <rustc_middle::ty::subst::GenericArg as rustc_middle::ty::relate::Relate>::relate
  18: <I as rustc_middle::ty::context::InternAs<[T],R>>::intern_with
  19: rustc_middle::ty::relate::super_relate_tys
  20: rustc_infer::infer::combine::<impl rustc_infer::infer::InferCtxt>::super_combine_tys
  21: <rustc_infer::infer::equate::Equate as rustc_middle::ty::relate::TypeRelation>::tys
  22: rustc_infer::infer::InferCtxt::commit_if_ok
  23: rustc_traits::type_op::AscribeUserTypeCx::relate
  24: rustc_traits::type_op::AscribeUserTypeCx::relate_mir_and_user_ty
  25: <rustc_infer::infer::InferCtxtBuilder as rustc_trait_selection::infer::InferCtxtBuilderExt>::enter_canonical_trait_query
  26: rustc_traits::type_op::type_op_ascribe_user_type
  27: rustc_query_system::query::plumbing::get_query_impl
  28: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_op_ascribe_user_type
  29: rustc_trait_selection::traits::query::type_op::ascribe_user_type::<impl rustc_trait_selection::traits::query::type_op::QueryTypeOp for rustc_middle::traits::query::type_op::AscribeUserType>::perform_query
  30: rustc_trait_selection::traits::query::type_op::QueryTypeOp::fully_perform_into
  31: <rustc_middle::ty::ParamEnvAnd<Q> as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform
  32: rustc_mir::borrow_check::type_check::canonical::<impl rustc_mir::borrow_check::type_check::TypeChecker>::fully_perform_op
  33: rustc_mir::borrow_check::type_check::type_check
  34: rustc_mir::borrow_check::nll::compute_regions
  35: rustc_mir::borrow_check::do_mir_borrowck
  36: rustc_infer::infer::InferCtxtBuilder::enter
  37: rustc_mir::borrow_check::mir_borrowck
  38: core::ops::function::FnOnce::call_once
  39: rustc_query_system::query::plumbing::get_query_impl
  40: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  41: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  42: rustc_interface::passes::analysis
  43: rustc_query_system::query::plumbing::get_query_impl
  44: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  45: rustc_interface::passes::QueryContext::enter
  46: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  47: rustc_span::with_source_map
  48: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@simon-auch simon-auch added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 27, 2021
@jonas-schievink jonas-schievink added the F-const_generics `#![feature(const_generics)]` label Aug 27, 2021
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue Sep 5, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Sep 5, 2021
@BoxyUwU BoxyUwU added F-adt_const_params `#![feature(adt_const_params)]` A-const-generics Area: const generics (parameters and arguments) labels Sep 15, 2021
@bors bors closed this as completed in a3e6c19 Sep 22, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-adt_const_params `#![feature(adt_const_params)]` F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants