Skip to content

ICE using [inline_const] and [generic_const_exprs] #102446

Closed
@mati1210

Description

@mati1210

i was bored and tried running this piece of cursed code

Code

#![feature(inline_const)]
#![feature(generic_const_exprs)]
use std::mem;

union AsBytes<T> {
    value: mem::ManuallyDrop<T>,
    as_bytes: [u8; const { mem::size_of::<T>() }],
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (470e518c4 2022-09-27)
binary: rustc
commit-hash: 470e518c4b43265020c882bcf3c86632f5494910
commit-date: 2022-09-27
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0

Error output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> main.rs:2:12
  |
2 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

warning: union `AsBytes` is never used
 --> main.rs:5:7
  |
5 | union AsBytes<T> {
  |       ^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 2 warnings emitted

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Missing value for constant, but no error reported?
 --> main.rs:7:15
  |
7 |     as_bytes: [u8; const { mem::size_of::<T>() }],
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:189:63

error: internal compiler error: `InferCtxt` incorrectly tainted by errors
  |
  = note: delayed at compiler/rustc_infer/src/infer/mod.rs:1282:27

error: internal compiler error: `ErrorGuaranteed` without an error
 --> main.rs:7:15
  |
7 |     as_bytes: [u8; const { mem::size_of::<T>() }],
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1070:31

error: internal compiler error: expected fullfillment errors
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:210:23

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1529:13
stack backtrace:
   0:     0x7f5afa6ce170 - std::backtrace_rs::backtrace::libunwind::trace::h6f0c1aea3f6a8f92
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f5afa6ce170 - std::backtrace_rs::backtrace::trace_unsynchronized::h246e054cc0c6474e
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5afa6ce170 - std::sys_common::backtrace::_print_fmt::he958bf8edb06c4b4
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f5afa6ce170 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5c96f6e60024ea09
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f5afa728e2e - core::fmt::write::h9220227ac4bd60db
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f5afa6becb5 - std::io::Write::write_fmt::h0baa4b904438720a
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/io/mod.rs:1679:15
   6:     0x7f5afa6d0ef3 - std::sys_common::backtrace::_print::h4e50715668854aea
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f5afa6d0ef3 - std::sys_common::backtrace::print::hc3d0dd731686e213
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f5afa6d0ef3 - std::panicking::default_hook::{{closure}}::hc630ddd34d05043a
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/panicking.rs:267:22
   9:     0x7f5afa6d0bdf - std::panicking::default_hook::hb98d54da30ecd030
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/panicking.rs:286:9
  10:     0x7f5afcf06a41 - rustc_driver[f0efc00e041104a1]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f5afa6d172b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8dbd399d0f831315
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/alloc/src/boxed.rs:1952:9
  12:     0x7f5afa6d172b - std::panicking::rust_panic_with_hook::h9d36e1ca30b3ec7a
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/panicking.rs:673:13
  13:     0x7f5afe028c41 - std[ede4ecd9ed8acb00]::panicking::begin_panic::<rustc_errors[cbe001ae92aecd94]::ExplicitBug>::{closure#0}
  14:     0x7f5afe028616 - std[ede4ecd9ed8acb00]::sys_common::backtrace::__rust_end_short_backtrace::<std[ede4ecd9ed8acb00]::panicking::begin_panic<rustc_errors[cbe001ae92aecd94]::ExplicitBug>::{closure#0}, !>
  15:     0x7f5afe0285e6 - std[ede4ecd9ed8acb00]::panicking::begin_panic::<rustc_errors[cbe001ae92aecd94]::ExplicitBug>
  16:     0x7f5afe0265a6 - std[ede4ecd9ed8acb00]::panic::panic_any::<rustc_errors[cbe001ae92aecd94]::ExplicitBug>
  17:     0x7f5afca51fd8 - <rustc_errors[cbe001ae92aecd94]::HandlerInner as core[7fef4cab63355933]::ops::drop::Drop>::drop
  18:     0x7f5afbd14db8 - core[7fef4cab63355933]::ptr::drop_in_place::<rustc_session[ffd18f1f609c177d]::parse::ParseSess>
  19:     0x7f5afbcd2718 - <alloc[9b15bfb767e51fba]::rc::Rc<rustc_session[ffd18f1f609c177d]::session::Session> as core[7fef4cab63355933]::ops::drop::Drop>::drop
  20:     0x7f5afbccf79d - core[7fef4cab63355933]::ptr::drop_in_place::<rustc_interface[f8a55cb2f21fea8d]::interface::Compiler>
  21:     0x7f5afbccce2c - rustc_interface[f8a55cb2f21fea8d]::interface::create_compiler_and_run::<core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>, rustc_driver[f0efc00e041104a1]::run_compiler::{closure#1}>
  22:     0x7f5afbccb331 - <scoped_tls[998c43719cb84b4a]::ScopedKey<rustc_span[4f1efeb85c089ac8]::SessionGlobals>>::set::<rustc_interface[f8a55cb2f21fea8d]::interface::run_compiler<core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>, rustc_driver[f0efc00e041104a1]::run_compiler::{closure#1}>::{closure#0}, core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>>
  23:     0x7f5afbccb01f - std[ede4ecd9ed8acb00]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f8a55cb2f21fea8d]::util::run_in_thread_pool_with_globals<rustc_interface[f8a55cb2f21fea8d]::interface::run_compiler<core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>, rustc_driver[f0efc00e041104a1]::run_compiler::{closure#1}>::{closure#0}, core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>>::{closure#0}, core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>>
  24:     0x7f5afcd677b0 - <<std[ede4ecd9ed8acb00]::thread::Builder>::spawn_unchecked_<rustc_interface[f8a55cb2f21fea8d]::util::run_in_thread_pool_with_globals<rustc_interface[f8a55cb2f21fea8d]::interface::run_compiler<core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>, rustc_driver[f0efc00e041104a1]::run_compiler::{closure#1}>::{closure#0}, core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>>::{closure#0}, core[7fef4cab63355933]::result::Result<(), rustc_errors[cbe001ae92aecd94]::ErrorGuaranteed>>::{closure#1} as core[7fef4cab63355933]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f5afa6db393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h073fd3d24d46d103
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/alloc/src/boxed.rs:1938:9
  26:     0x7f5afa6db393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d6d89ec5f806eed
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/alloc/src/boxed.rs:1938:9
  27:     0x7f5afa6db393 - std::sys::unix::thread::Thread::new::thread_start::hd7471e2b028e93f2
                               at /rustc/470e518c4b43265020c882bcf3c86632f5494910/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f5afa43d74d - <unknown>
  29:     0x7f5afa4bf700 - <unknown>
  30:                0x0 - <unknown>

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.66.0-nightly (470e518c4 2022-09-27) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
Backtrace

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> main.rs:2:12
  |
2 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

warning: union `AsBytes` is never used
 --> main.rs:5:7
  |
5 | union AsBytes<T> {
  |       ^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 2 warnings emitted

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Missing value for constant, but no error reported?
 --> main.rs:7:15
  |
7 |     as_bytes: [u8; const { mem::size_of::<T>() }],
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:189:63

error: internal compiler error: `InferCtxt` incorrectly tainted by errors
  |
  = note: delayed at compiler/rustc_infer/src/infer/mod.rs:1282:27

error: internal compiler error: `ErrorGuaranteed` without an error
 --> main.rs:7:15
  |
7 |     as_bytes: [u8; const { mem::size_of::<T>() }],
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1070:31

error: internal compiler error: expected fullfillment errors
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:210:23

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1529:13
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   3: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   4: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   6: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
   7: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
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.66.0-nightly (470e518c4 2022-09-27) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)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