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 with #[derive(rkyv::Archive)] on cyclic enum #123238

Open
nothendev opened this issue Mar 30, 2024 · 1 comment
Open

ICE with #[derive(rkyv::Archive)] on cyclic enum #123238

nothendev opened this issue Mar 30, 2024 · 1 comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example F-trivial_bounds `#![feature(trivial_bounds)]` 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

@nothendev
Copy link

nothendev commented Mar 30, 2024

Code

#![feature(trivial_bounds)]

use rkyv::{Archive, Serialize, Deserialize};

#[derive(Clone, Debug, PartialEq, Archive, Serialize, Deserialize)]
#[repr(u8)]
pub enum Nbt {
    Byte(i8) = 1,
    Short(i16) = 2,
    Int(i32) = 3,
    Long(i64) = 4,
    Float(f32) = 5,
    Double(f64) = 6,
    ByteArray(Vec<i8>) = 7,
    String(String) = 8,
    List(Vec<Nbt>) = 9,
    Compound(HashMap<String, Nbt>) = 0xA,
    IntArray(Vec<i32>) = 0xB,
    LongArray(Vec<i64>) = 0xC,
}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (c9f8f3438 2024-03-27)
binary: rustc
commit-hash: c9f8f3438a8134a413aa5d4903e0196e44e37bbc
commit-date: 2024-03-27
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Error output

error: internal compiler error: couldn't normalize struct field `<Vec<Nbt> as rkyv::Archive>::Resolver` when checking std::marker::Copy implementation
 --> src/proto/nbt.rs:5:35
  |
5 | #[derive(Clone, Debug, PartialEq, Archive, Serialize, Deserialize)]
  |                                   ^^^^^^^
error: internal compiler error: couldn't normalize struct field `<HashMap<String, Nbt> as rkyv::Archive>::Resolver` when checking std::marker::Copy implementation
 --> src/proto/nbt.rs:5:35
  |
5 | #[derive(Clone, Debug, PartialEq, Archive, Serialize, Deserialize)]
  |                                   ^^^^^^^
note: delayed at compiler/rustc_trait_selection/src/traits/misc.rs:177:27
Backtrace

Attached ice.txt file:

rustc-ice-2024-03-30T16_07_18-54801.txt

@nothendev nothendev 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 Mar 30, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 30, 2024
@nothendev
Copy link
Author

I fixed it with

// #![feature(trivial_bounds)]
use rkyv::{Archive, Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Archive)]
#[repr(u8)]
pub enum Nbt {
    Byte(i8) = 1,
    Short(i16) = 2,
    Int(i32) = 3,
    Long(i64) = 4,
    Float(f32) = 5,
    Double(f64) = 6,
    ByteArray(Vec<i8>) = 7,
    String(String) = 8,
    List(#[omit_bounds] Vec<Nbt>) = 9,
    Compound(#[omit_bounds] std::collections::HashMap<String, Nbt>) = 0xA,
    IntArray(Vec<i32>) = 0xB,
    LongArray(Vec<i64>) = 0xC,
}

but the ICE is still relevant as the error message is very confusing

@fmease fmease added F-trivial_bounds `#![feature(trivial_bounds)]` E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Mar 30, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 30, 2024
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. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example F-trivial_bounds `#![feature(trivial_bounds)]` 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

No branches or pull requests

4 participants