Open
Description
I tried compiling this code: lib.rs.zip
The code above was generated with the following python script:
print(
"""#[derive(Debug)]
pub enum Sprites {"""
)
for i in range(10000):
print(f" Sprite{i},")
print(
"""}
pub fn foo() {
println!("{:?}", Sprites::Sprite1);
}"""
)
I then compiled the code with cargo build --release
. It takes 21.00s to compile on my machine, which is rather slow. It would be nice if it compiled faster.
Note that reducing the number of variants from 10000 to 1000 makes the compilation take only 0.20s to compile on my machine. I suspect that something in the Debug trait impl is taking quadratic time, but only if you actually try to debug-print something.
This issue was discovered by tongke on the rust community discord.
Meta
rustc --version --verbose
:
rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: aarch64-apple-darwin
release: 1.83.0
LLVM version: 19.1.1