Skip to content

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

Open
@nothendev

Description

@nothendev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleF-trivial_bounds`#![feature(trivial_bounds)]`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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions