Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ICE adt_const_params with slice of static str #88876

Closed
meowjesty opened this issue Sep 12, 2021 · 2 comments · Fixed by #89147
Closed

ICE adt_const_params with slice of static str #88876

meowjesty opened this issue Sep 12, 2021 · 2 comments · Fixed by #89147
Assignees
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)]` 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

@meowjesty
Copy link

meowjesty commented Sep 12, 2021

Looks a bit like #88384

Link to playground

Code

#![allow(incomplete_features)]
#![feature(adt_const_params)]

struct FooConst<const ARRAY: &'static [&'static str]> {}

const FOO_ARR: &[&'static str; 2] = &["Hello", "Friend"];

fn main() {
    // Commenting the following line avoids the panic.
    let foo = FooConst::<FOO_ARR> {};
}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (50171c310 2021-09-01) running on x86_64-unknown-linux-gnu
compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

rustc 1.57.0-nightly (b69fe5726 2021-09-10) running on x86_64-pc-windows-msvc
compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

Error output

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

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

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1147: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::Generalizer as rustc_middle::ty::relate::TypeRelation>::consts
  13: <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::relate_with_variance
  14: <core::result::Result<T,E> as rustc_middle::ty::context::InternIteratorElement<T,R>>::intern_with
  15: <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::relate_item_substs
  16: rustc_middle::ty::relate::super_relate_tys
  17: <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys
  18: rustc_infer::infer::combine::CombineFields::instantiate
  19: <rustc_infer::infer::sub::Sub as rustc_middle::ty::relate::TypeRelation>::tys
  20: rustc_infer::infer::InferCtxt::commit_if_ok
  21: rustc_infer::infer::fudge::<impl rustc_infer::infer::InferCtxt>::fudge_inference_if_ok
  22: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  23: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  24: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_decl_initializer
  25: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_decl_local
  26: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  27: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  28: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  29: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  30: rustc_typeck::check::check::check_fn
  31: rustc_infer::infer::InferCtxtBuilder::enter
  32: rustc_typeck::check::typeck
  33: rustc_query_system::query::plumbing::get_query_impl
  34: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  35: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  36: rustc_typeck::check::typeck_item_bodies
  37: rustc_query_system::query::plumbing::get_query_impl
  38: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  39: rustc_session::utils::<impl rustc_session::session::Session>::time
  40: rustc_typeck::check_crate
  41: rustc_interface::passes::analysis
  42: rustc_query_system::query::plumbing::get_query_impl
  43: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  44: rustc_interface::passes::QueryContext::enter
  45: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  46: rustc_span::with_source_map
  47: 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.56.0-nightly (50171c310 2021-09-01) 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 [destructure_const] destructure constant
#1 [typeck] type-checking `main`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground`

@meowjesty meowjesty 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 Sep 12, 2021
@hellow554
Copy link
Contributor

Used const_generics as feature and got this:

Regressed somewhere between f5d8117...36f1f04

Before
error[E0308]: mismatched types
  --> src/main.rs:10:15
   |
10 |     let foo = FooConst::<FOO_ARR> {};
   |               ^^^^^^^^^^^^^^^^^^^^^^ expected `FOO_ARR`, found `FOO_ARR`
   |
   = note: expected type `_`
            found struct `FooConst<FOO_ARR>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `abc`
After
error: internal compiler error: compiler/rustc_mir/src/const_eval/mod.rs:160:14: cannot destructure constant Const { ty: &'static [&'static str], val: Value(ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), alloc4))] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }

thread 'rustc' panicked at 'Box<Any>', /rustc/36f1f04f18b89ba4a999bcfd6584663fd6fc1c5d/library/std/src/panic.rs:59:5
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.52.0-nightly (36f1f04f1 2021-03-17) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [destructure_const] destructure constant
#1 [typeck] type-checking `main`
end of query stack

@BoxyUwU BoxyUwU added A-const-generics Area: const generics (parameters and arguments) F-adt_const_params `#![feature(adt_const_params)]` labels Sep 15, 2021
@b-naber
Copy link
Contributor

b-naber commented Sep 16, 2021

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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)]` 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.

5 participants