After reading this topic on the D forum, I was wondering how rustc would behave when prodded in the right places. I present the following program:
#[derive(Copy, Clone, Debug)]
struct S<T, U, V>(T, U, V);
fn f<T: Copy>(t: T) -> S<T, T, T> { S(t, t, t) }
fn main() {
let val = f(f(f(f(f(f(f(f(f(f(f(5)))))))))));
println!("{:?}", ((((((((((val.0).0).0).0).0).0).0).0).0).0).0);
}
This program, when compiled with rustc -g --emit asm explosion.rs
produces a 10MB assembly file, most of which consists of generated function and type names. One of the shorter types looks like this:
"_ZN9explosion102f<explosion::S<explosion::S<i32, i32, i32>, explosion::S<i32, i32, i32>, explosion::S<i32, i32, i32>>>E"
When I compile with rustc -g --emit obj explosion.rs
I hit an assertion:
Assertion failed: isIntN(Size * 8 + 1, Value) && "Value does not fit in the Fixup field", file C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\llvm\lib\Target\X86\MCTargetDesc\X86AsmBackend.cpp, line 115
This is on Windows, I’m not sure how it behaves on linux.
Should this behavior (generating exponentially large debug symbols) be considered a bug? If so, what should be done about it?