Check RUSTC_CTFE_BACKTRACE much less by generating fewer errors by wesleywiser · Pull Request #69290 · rust-lang/rust (original) (raw)

Before this change, get_size_and_align() calls get_fn_alloc() a lot in CTFE heavy code. This previously returned an Error which would
check if RUSTC_CTFE_BACKTRACE was set on construction. Doing this
turned out to be a performance hotspot as @nnethercote discovered in
#68792.

This is an alternate take on that PR which resolves the performance
issue by generating many fewer errors. Previously, ctfe-stress-4
would generate over 5,000,000 errors each of which would check for the
presence of the environment variable. With these changes, that number is
reduced to 30.

r? @RalfJung