Skip to content

Compiler panicked unexpectedly on instantiation of struct parametrized by nested const generic exprs #94227

Closed
@jlogan03

Description

@jlogan03

Code

Offending line here: https://github.com/jlogan03/catnip/blob/f7ff6dc5fb3ac36f3c06e2cb81f842b0b34e3eed/catnip/examples/packet.rs#L55

    const P: usize = UDPPacket::<0, 2>::LENGTH;
    let enetframe: EthernetFrame<UDPPacket<0, 2>, P> = EthernetFrame {
        header: enetheader,
        data: udppacket
    };

Meta

rustc --version --verbose:

rustc 1.59.0-nightly (cfa3fe5af 2021-12-31)
binary: rustc
commit-hash: cfa3fe5af339e724209b25715282adae0c61628f
commit-date: 2021-12-31
host: x86_64-apple-darwin
release: 1.59.0-nightly
LLVM version: 13.0.0

Error output

Jamess-MacBook-Pro:catnip jlogan$ cargo check --example packet
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/lib.rs:6:12
  |
6 | #![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: `catnip` (lib) generated 1 warning
    Checking catnip v0.1.1 (/Users/jlogan/git/catnip/catnip)
warning: unused import: `EthernetPacket`
 --> examples/packet.rs:3:51
  |
3 | use catnip::enet::{EthernetHeader, EthernetFrame, EthernetPacket, EtherType};
  |                                                   ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `enetframe`
  --> examples/packet.rs:55:9
   |
55 |     let enetframe: EthernetFrame<UDPPacket<0, 2>, P> = EthernetFrame {
   |         ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_enetframe`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: Error finalizing incremental compilation session directory `/Users/jlogan/git/catnip/catnip/target/debug/incremental/packet-3oosyva6ltrh2/s-g79pxlnfwv-13gud55-working`: No such file or directory (os error 2)

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<catnip::udp::UDPPacket<0_usize, 2_usize> as catnip::Transportable<36_usize>>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:68:32

error: internal compiler error: ty::ConstKind::Error constructed but no error reported.
  |
  = note: delayed at /rustc/cfa3fe5af339e724209b25715282adae0c61628f/compiler/rustc_middle/src/ty/consts.rs:240:43

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_typeck/src/check/coercion.rs:158:49

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_typeck/src/check/fn_ctxt/checks.rs:788:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_typeck/src/check/coercion.rs:1353:42

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_infer/src/infer/sub.rs:121:31

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_typeck/src/check/fallback.rs:120:58

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/cfa3fe5af339e724209b25715282adae0c61628f/compiler/rustc_middle/src/ty/relate.rs:390:59

error: internal compiler error: cat_expr Errd
  --> examples/packet.rs:9:17
   |
9  |   fn main() -> () {
   |  _________________^
10 | |     // Some made-up addresses
11 | |     // MAC address in locally-administered address range
12 | |     // IP addresses in local network range
...  |
58 | |     };
59 | | }
   | |_^
   |
   = note: delayed at compiler/rustc_typeck/src/check/regionck.rs:469:31

error: internal compiler error: cat_expr Errd
  --> examples/packet.rs:55:56
   |
55 |       let enetframe: EthernetFrame<UDPPacket<0, 2>, P> = EthernetFrame {
   |  ________________________________________________________^
56 | |         header: enetheader,
57 | |         data: udppacket
58 | |     };
   | |_____^
   |
   = note: delayed at compiler/rustc_typeck/src/check/regionck.rs:469:31

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_mir_build/src/build/mod.rs:721:18

error: internal compiler error: PromoteTemps: MIR had errors
 --> examples/packet.rs:9:1
  |
9 | fn main() -> () {
  | ^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/promote_consts.rs:53:22

error: internal compiler error: broken MIR in DefId(0:44 ~ packet[f25f]::main) ("return type"): bad type [type error]
 --> examples/packet.rs:9:1
  |
9 | fn main() -> () {
  | ^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:319:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:794:20

error: internal compiler error: broken MIR in DefId(0:44 ~ packet[f25f]::main) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: examples/packet.rs:9:1: 9:16 (#0), scope: scope[0] } }): bad type [type error]
 --> examples/packet.rs:9:1
  |
9 | fn main() -> () {
  | ^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:319:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.59.0-nightly (cfa3fe5af 2021-12-31) running on x86_64-apple-darwin

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

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

query stack during panic:
end of query stack
warning: `catnip` (example "packet") generated 3 warnings
error: could not compile `catnip`; 3 warnings emitted
Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
stack backtrace:
   0:        0x101522ea1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h85d27a8e284fe0bc
   1:        0x10157955b - core::fmt::write::h811afcfb2cc9fb5f
   2:        0x101513c9a - std::io::Write::write_fmt::hfcd83cc2a0eab4db
   3:        0x1015271c5 - std::panicking::default_hook::{{closure}}::hdeec781c17ec77d4
   4:        0x101526dac - std::panicking::default_hook::hde700d0e25c42b00
   5:        0x111605b3d - rustc_driver[44cf0a46dc43c607]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x10152798a - std::panicking::rust_panic_with_hook::h9eabc51596fbd5ca
   7:        0x1015276de - std::panicking::begin_panic_handler::{{closure}}::h3b61bac0ee43ec1a
   8:        0x101523307 - std::sys_common::backtrace::__rust_end_short_backtrace::hae0de2227c9289b6
   9:        0x1015273ea - _rust_begin_unwind
  10:        0x1015a222f - core::panicking::panic_fmt::hf448e2fe515dc44f
  11:        0x115c86aa2 - core[313838a0196ec485]::panicking::panic_display::<&str>
  12:        0x115c83e55 - <rustc_errors[58bfe2a0b1d83843]::HandlerInner>::flush_delayed
  13:        0x115c80138 - <rustc_errors[58bfe2a0b1d83843]::HandlerInner as core[313838a0196ec485]::ops::drop::Drop>::drop
  14:        0x11167a8aa - core[313838a0196ec485]::ptr::drop_in_place::<rustc_session[a3ed5af2e8657d44]::parse::ParseSess>
  15:        0x1116832f7 - <alloc[f1a859187e893214]::rc::Rc<rustc_session[a3ed5af2e8657d44]::session::Session> as core[313838a0196ec485]::ops::drop::Drop>::drop
  16:        0x111613dd2 - core[313838a0196ec485]::ptr::drop_in_place::<rustc_interface[1658e7de0f71f99e]::interface::Compiler>
  17:        0x11161597c - rustc_span[6b62af7a7a91e72]::with_source_map::<core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>, rustc_interface[1658e7de0f71f99e]::interface::create_compiler_and_run<core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>, rustc_driver[44cf0a46dc43c607]::run_compiler::{closure#1}>::{closure#1}>
  18:        0x11166715f - rustc_interface[1658e7de0f71f99e]::interface::create_compiler_and_run::<core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>, rustc_driver[44cf0a46dc43c607]::run_compiler::{closure#1}>
  19:        0x111622a9e - std[ab968d190f62ef24]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1658e7de0f71f99e]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[1658e7de0f71f99e]::interface::run_compiler<core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>, rustc_driver[44cf0a46dc43c607]::run_compiler::{closure#1}>::{closure#0}, core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>>::{closure#0}, core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>>
  20:        0x111681105 - <<std[ab968d190f62ef24]::thread::Builder>::spawn_unchecked<rustc_interface[1658e7de0f71f99e]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[1658e7de0f71f99e]::interface::run_compiler<core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>, rustc_driver[44cf0a46dc43c607]::run_compiler::{closure#1}>::{closure#0}, core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>>::{closure#0}, core[313838a0196ec485]::result::Result<(), rustc_errors[58bfe2a0b1d83843]::ErrorReported>>::{closure#1} as core[313838a0196ec485]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:        0x101534397 - std::sys::unix::thread::Thread::new::thread_start::h04ec690274cf9f89
  22:     0x7ff8067464f4 - __pthread_start

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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.requires-incomplete-featuresThis issue requires the use of incomplete features.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