ICE with #[derive(rkyv::Archive)] on cyclic enum
Open
Nobody has claimed this yet.
C-bug
F-trivial_bounds
I-ICE
S-needs-repro
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the ICE from the enum in src/proto/nbt.rs with the reported nightly toolchain, then read the delayed location in compiler/rustc_trait_selection/src/traits/misc.rs. Compare the normalization failures for Vec and HashMap<String, Nbt>. Done means the reproducer no longer triggers an internal compiler error and has appropriate compiler behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100