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

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

Closed
jlogan03 opened this issue Feb 21, 2022 · 6 comments
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jlogan03
Copy link

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

@jlogan03 jlogan03 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 Feb 21, 2022
@compiler-errors
Copy link
Member

compiler-errors commented Feb 24, 2022

@jlogan03 have you tried building this with the latest version of nightly? Curious if it still shows up since 2021-12-31.

@jlogan03
Copy link
Author

@compiler-errors yes, it still shows up on the latest version

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

@compiler-errors
Copy link
Member

@jlogan03, did you run rustup update? I'm expecting something newer than 2021-12-31, since nightly is released every day or so. Unless I'm misunderstanding something about that version output or your testing environment.

@jlogan03
Copy link
Author

@compiler-errors right you are, looks like I managed to break my automation for updating. I still get an error, but it's a new one.

rustc 1.61.0-nightly (d3ad51b48 2022-02-25)
binary: rustc
commit-hash: d3ad51b48f83329fac0cd8a9f1253f3146613c1c
commit-date: 2022-02-25
host: x86_64-apple-darwin
release: 1.61.0-nightly
LLVM version: 14.0.0
New error and backtrace

Jamess-MacBook-Pro:catnip jlogan$ RUST_BACKTRACE=full 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-f7ff6dc5fb3ac36f3c06e2cb81f842b0b34e3eed/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-f7ff6dc5fb3ac36f3c06e2cb81f842b0b34e3eed/catnip/target/debug/incremental/packet-aiij2leu8w3u/s-g7fesapbqo-1k1ehmu-working`: No such file or directory (os error 2)

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

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:69:32

error: internal compiler error: ty::ConstKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/d3ad51b48f83329fac0cd8a9f1253f3146613c1c/compiler/rustc_middle/src/ty/consts.rs:267: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:869:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_typeck/src/check/coercion.rs:1348: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/d3ad51b48f83329fac0cd8a9f1253f3146613c1c/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:463: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:463: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[1334]::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:541:13

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

error: internal compiler error: broken MIR in DefId(0:44 ~ packet[1334]::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:541:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1188:13
stack backtrace:
   0:        0x10e73f401 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h76fb20920f6a83cf
   1:        0x10e79f35b - core::fmt::write::h862e4b55ad2069b4
   2:        0x10e7304ee - std::io::Write::write_fmt::h8083c2fcbfe2364d
   3:        0x10e743770 - std::panicking::default_hook::{{closure}}::h66a9173bcb465cf5
   4:        0x10e743454 - std::panicking::default_hook::hb2e31fbd015eb3d1
   5:        0x117eea80a - rustc_driver[55b90faad7aa1d7b]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x10e74403c - std::panicking::rust_panic_with_hook::h87ab016847b73da9
   7:        0x11c4e2547 - std[7522013a281df534]::panicking::begin_panic::<rustc_errors[1ec2a23e13b589f5]::ExplicitBug>::{closure#0}
   8:        0x11c4e24f9 - std[7522013a281df534]::sys_common::backtrace::__rust_end_short_backtrace::<std[7522013a281df534]::panicking::begin_panic<rustc_errors[1ec2a23e13b589f5]::ExplicitBug>::{closure#0}, !>
   9:        0x11c821191 - std[7522013a281df534]::panicking::begin_panic::<rustc_errors[1ec2a23e13b589f5]::ExplicitBug>
  10:        0x11c518329 - std[7522013a281df534]::panic::panic_any::<rustc_errors[1ec2a23e13b589f5]::ExplicitBug>
  11:        0x11c5120aa - <rustc_errors[1ec2a23e13b589f5]::HandlerInner as core[c951771928f8d9c9]::ops::drop::Drop>::drop
  12:        0x117f01d8a - core[c951771928f8d9c9]::ptr::drop_in_place::<rustc_session[75ebba5516f37af0]::parse::ParseSess>
  13:        0x117f0a537 - <alloc[57a39d941921ee5e]::rc::Rc<rustc_session[75ebba5516f37af0]::session::Session> as core[c951771928f8d9c9]::ops::drop::Drop>::drop
  14:        0x117ea260f - core[c951771928f8d9c9]::ptr::drop_in_place::<rustc_interface[112a8d2e82d7db12]::interface::Compiler>
  15:        0x117ea9bec - rustc_span[be5d9d9c22212131]::with_source_map::<core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>, rustc_interface[112a8d2e82d7db12]::interface::create_compiler_and_run<core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>, rustc_driver[55b90faad7aa1d7b]::run_compiler::{closure#1}>::{closure#1}>
  16:        0x117e9c681 - rustc_interface[112a8d2e82d7db12]::interface::create_compiler_and_run::<core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>, rustc_driver[55b90faad7aa1d7b]::run_compiler::{closure#1}>
  17:        0x117e81785 - <scoped_tls[77dae606f0013de7]::ScopedKey<rustc_span[be5d9d9c22212131]::SessionGlobals>>::set::<rustc_interface[112a8d2e82d7db12]::interface::run_compiler<core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>, rustc_driver[55b90faad7aa1d7b]::run_compiler::{closure#1}>::{closure#0}, core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>>
  18:        0x117e7edd7 - std[7522013a281df534]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[112a8d2e82d7db12]::util::run_in_thread_pool_with_globals<rustc_interface[112a8d2e82d7db12]::interface::run_compiler<core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>, rustc_driver[55b90faad7aa1d7b]::run_compiler::{closure#1}>::{closure#0}, core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>>::{closure#0}, core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>>
  19:        0x117e7b031 - <<std[7522013a281df534]::thread::Builder>::spawn_unchecked_<rustc_interface[112a8d2e82d7db12]::util::run_in_thread_pool_with_globals<rustc_interface[112a8d2e82d7db12]::interface::run_compiler<core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>, rustc_driver[55b90faad7aa1d7b]::run_compiler::{closure#1}>::{closure#0}, core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>>::{closure#0}, core[c951771928f8d9c9]::result::Result<(), rustc_errors[1ec2a23e13b589f5]::ErrorReported>>::{closure#1} as core[c951771928f8d9c9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  20:        0x10e7516a7 - std::sys::unix::thread::Thread::new::thread_start::h6dc4137c539c4ff0
  21:     0x7ff8163424f4 - __pthread_start

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.61.0-nightly (d3ad51b48 2022-02-25) running on x86_64-apple-darwin

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

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

@workingjubilee workingjubilee added requires-nightly This issue requires a nightly compiler in some way. F-generic_const_exprs `#![feature(generic_const_exprs)]` requires-incomplete-features This issue requires the use of incomplete features. labels Mar 4, 2023
@RodBurman
Copy link

Using 1.87 nightly:

% cargo -v -V
cargo 1.87.0-nightly (2622e844b 2025-02-28)
release: 1.87.0-nightly
commit-hash: 2622e844bc1e2e6123e54e94e4706f7b6195ce3d
commit-date: 2025-02-28
host: aarch64-apple-darwin
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.7.1 (sys:0.4.79+curl-8.12.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.4.1 11 Feb 2025
os: Mac OS 15.3.1 [64-bit]

The example does not compile but there doesn't seem to be a problem with the compile, output is:

% cargo build
   Compiling rusterr v0.1.0 (/Users/rod/code/rust/triage/rusterr)
error[E0432]: unresolved import `catnip::enet::EthernetPacket`
 --> src/main.rs:3:51
  |
3 | use catnip::enet::{EthernetHeader, EthernetFrame, EthernetPacket, EtherType};
  |                                                   ^^^^^^^^^^^^^^ no `EthernetPacket` in `enet`

error[E0432]: unresolved imports `catnip::ip::IPV4Addr`, `catnip::ip::IPV4Header`
 --> src/main.rs:4:18
  |
4 | use catnip::ip::{IPV4Addr, IPV4Header, DSCP};
  |                  ^^^^^^^^  ^^^^^^^^^^ no `IPV4Header` in `ip`
  |                  |
  |                  no `IPV4Addr` in `ip`
  |
help: a similar name exists in the module
  |
4 - use catnip::ip::{IPV4Addr, IPV4Header, DSCP};
4 + use catnip::ip::{IpV4Addr, IPV4Header, DSCP};
  |
help: a similar name exists in the module
  |
4 - use catnip::ip::{IPV4Addr, IPV4Header, DSCP};
4 + use catnip::ip::{IPV4Addr, IpV4Header, DSCP};
  |

error[E0432]: unresolved imports `catnip::udp::UDPHeader`, `catnip::udp::UDPPacket`
 --> src/main.rs:5:19
  |
5 | use catnip::udp::{UDPHeader, UDPPacket};
  |                   ^^^^^^^^^  ^^^^^^^^^ no `UDPPacket` in `udp`
  |                   |
  |                   no `UDPHeader` in `udp`
  |                   help: a similar name exists in the module: `UdpHeader`

error[E0432]: unresolved imports `catnip::Data`, `catnip::MACAddr`, `catnip::Transportable`
 --> src/main.rs:6:14
  |
6 | use catnip::{Data, MACAddr, Transportable};
  |              ^^^^  ^^^^^^^  ^^^^^^^^^^^^^ no `Transportable` in the root
  |              |     |
  |              |     no `MACAddr` in the root
  |              |     help: a similar name exists in the module: `MacAddr`
  |              no `Data` in the root

error[E0603]: enum `DSCP` is private
 --> src/main.rs:4:40
  |
4 | use catnip::ip::{IPV4Addr, IPV4Header, DSCP};
  |                                        ^^^^ private enum
  |
note: the enum `DSCP` is defined here
 --> /Users/rod/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/catnip-0.3.1/src/ip.rs:3:33
  |
3 | use crate::{IpV4Addr, Protocol, DSCP};
  |                                 ^^^^
help: import `DSCP` directly
  |
4 | use catnip::ip::{IPV4Addr, IPV4Header, catnip::DSCP};
  |                                        ++++++++

error[E0107]: struct takes 1 generic argument but 2 generic arguments were supplied
  --> src/main.rs:55:20
   |
55 |     let enetframe: EthernetFrame<UDPPacket<0, 2>, P> = EthernetFrame {
   |                    ^^^^^^^^^^^^^                --- help: remove the unnecessary generic argument
   |                    |
   |                    expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `T`
  --> /Users/rod/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/catnip-0.3.1/src/enet.rs:37:12
   |
37 | pub struct EthernetFrame<T>
   |            ^^^^^^^^^^^^^ -

error[E0599]: no function or associated item named `new` found for struct `EthernetHeader` in the current scope
  --> src/main.rs:51:54
   |
51 |     let enetheader: EthernetHeader = EthernetHeader::new(src_macaddr, dst_macaddr, EtherType::IPV4);
   |                                                      ^^^ function or associated item not found in `EthernetHeader`
   |
help: there is a method `ne` with a similar name, but with different arguments
  --> /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library/core/src/cmp.rs:261:5

error[E0599]: no variant or associated item named `IPV4` found for enum `EtherType` in the current scope
  --> src/main.rs:51:95
   |
51 |     let enetheader: EthernetHeader = EthernetHeader::new(src_macaddr, dst_macaddr, EtherType::IPV4);
   |                                                                                               ^^^^ variant or associated item not found in `EtherType`
   |
help: there is a variant with a similar name
   |
51 -     let enetheader: EthernetHeader = EthernetHeader::new(src_macaddr, dst_macaddr, EtherType::IPV4);
51 +     let enetheader: EthernetHeader = EthernetHeader::new(src_macaddr, dst_macaddr, EtherType::IpV4;
   |

error[E0063]: missing field `checksum` in initializer of `EthernetFrame<_>`
  --> src/main.rs:55:56
   |
55 |     let enetframe: EthernetFrame<UDPPacket<0, 2>, P> = EthernetFrame {
   |                                                        ^^^^^^^^^^^^^ missing `checksum`

Some errors have detailed explanations: E0063, E0107, E0432, E0599, E0603.
For more information about an error, try `rustc --explain E0063`.
error: could not compile `rusterr` (bin "rusterr") due to 9 previous errors

This does seem to be progress, but I am unsure as to whether the code should compile cleanly or if some or all the current errors are valid. Or if indeed the example code I downloaded is meant to use the version of "catnip" that cargo found when I added it. May be @jlogan03 could comment?

@jlogan03
Copy link
Author

jlogan03 commented Mar 6, 2025

The remaining errors look valid - the versions of catnip published to cargo have diverged somewhat from the version on the original ticket.

Here's how it runs with latest nightly on the exact version of catnip from the original ticket - the compiler no longer panics, and it produces some legitimate and helpful errors instead, mostly related to the incomplete state of the project at that point in time.

I think we're good to close this ticket

jlogan@jlogan-framework-13:~/Downloads/catnip-f7ff6dc5fb3ac36f3c06e2cb81f842b0b34e3eed/catnip$ rustc --version --verbose
rustc 1.87.0-nightly (30f168ef8 2025-03-05)
binary: rustc
commit-hash: 30f168ef811aec63124eac677e14699baa9395bd
commit-date: 2025-03-05
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0
jlogan@jlogan-framework-13:~/Downloads/catnip-f7ff6dc5fb3ac36f3c06e2cb81f842b0b34e3eed/catnip$ cargo check --example packet
    Updating crates.io index
     Locking 2 packages to latest compatible versions
  Downloaded crc32fast v1.4.2
  Downloaded cfg-if v1.0.0
  Downloaded 2 crates (46.4 KB) in 0.11s
    Checking cfg-if v1.0.0
    Checking crc32fast v1.4.2
    Checking catnip v0.1.1 (/home/jlogan/Downloads/catnip-f7ff6dc5fb3ac36f3c06e2cb81f842b0b34e3eed/catnip)
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: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: `catnip` (lib) generated 1 warning
warning: unused import: `EthernetPacket`
 --> examples/packet.rs:3:51
  |
3 | use catnip::enet::{EthernetHeader, EthernetFrame, EthernetPacket, EtherTy...
  |                                                   ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0277]: the trait bound `UDPPacket<'_, 0, 2>: Transportable<P>` is not satisfied
   --> examples/packet.rs:55:20
    |
55  |     let enetframe: EthernetFrame<UDPPacket<0, 2>, P> = EthernetFrame {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Transportable<P>` is not implemented for `UDPPacket<'_, 0, 2>`
    |
    = help: the trait `Transportable<P>` is not implemented for `UDPPacket<'_, 0, 2>`
            but trait `Transportable<catnip::::udp::{impl#3}::{constant#3}>` is implemented for it
note: required by a bound in `EthernetFrame`
   --> /home/jlogan/Downloads/catnip-f7ff6dc5fb3ac36f3c06e2cb81f842b0b34e3eed/catnip/src/enet.rs:105:8
    |
103 | pub struct EthernetFrame<T, const P: usize>
    |            ------------- required by a bound in this struct
104 | where
105 |     T: Transportable<P>,
    |        ^^^^^^^^^^^^^^^^ required by this bound in `EthernetFrame`

error[E0277]: the trait bound `UDPPacket<'_, 0, 2>: Transportable<P>` is not satisfied
   --> examples/packet.rs:57:15
    |
57  |         data: udppacket
    |               ^^^^^^^^^ the trait `Transportable<P>` is not implemented for `UDPPacket<'_, 0, 2>`
    |
    = help: the trait `Transportable<P>` is not implemented for `UDPPacket<'_, 0, 2>`
            but trait `Transportable<catnip::::udp::{impl#3}::{constant#3}>` is implemented for it
note: required by a bound in `EthernetFrame`
   --> /home/jlogan/Downloads/catnip-f7ff6dc5fb3ac36f3c06e2cb81f842b0b34e3eed/catnip/src/enet.rs:105:8
    |
103 | pub struct EthernetFrame<T, const P: usize>
    |            ------------- required by a bound in this struct
104 | where
105 |     T: Transportable<P>,
    |        ^^^^^^^^^^^^^^^^ required by this bound in `EthernetFrame`

For more information about this error, try `rustc --explain E0277`.
warning: `catnip` (example "packet") generated 1 warning

@jlogan03 jlogan03 closed this as completed Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants