What Is New in Rust 1.47
| Category | Highlights |
|---|---|
| New Features | Traits implemented for arrays of any length, -C control-flow-guard flag on Windows, Ayu theme for rustdoc |
| Improvements | Shorter default backtraces, many std APIs marked const, LLVM upgraded to version 11 |
| Bug Fixes | Regression that produced noisy backtraces has been fixed |
How does Rust 1.47 improve support for arrays of any length?
Rust 1.47 extends the standard library so that traits such as Debug are implemented for arrays of any compile-time length, not just 0-32.
In practice this means code like:
fn main() {
let xs = [0; 34];
println!("{:?}", xs);
}
now compiles and prints the array, whereas older versions emitted an error about LengthAtMost32. The implementation uses the compiler's const-generic support, paving the way for future generic-over-length APIs.
What changes make debugging panics easier in Rust 1.47?
Rust 1.47 shortens the default panic backtrace to show only the frames that are most relevant to the panic location.
- The backtrace now starts with the panic entry point, the user's function, and the core call site.
- All the internal library frames that previously cluttered the output are omitted unless
RUST_BACKTRACE=fullis set.
This matters if you need to quickly locate the source of a crash without sifting through dozens of lines of noise.
Which standard library APIs became const in Rust 1.47 and why does it matter?
Rust 1.47 marks a large set of integer and character helper methods as const, allowing them to be used in compile-time contexts.
- All
NonZeroconstructors. - Checked arithmetic:
checked_add,checked_sub,checked_mul,checked_neg,checked_shl,checked_shr. - Saturating arithmetic:
saturating_add,saturating_sub,saturating_mul,saturating_abs,saturating_neg. - Sign handling:
signumfor signed integers. - ASCII classification methods on
charandu8(e.g.,is_ascii_alphabetic,is_ascii_digit, etc.).
Having these as const means you can compute values at compile time, reducing runtime overhead and enabling more expressive const fn implementations.
What toolchain upgrades are included in Rust 1.47?
Rust 1.47 ships with several behind-the-scenes improvements that affect build performance and security.
- LLVM upgraded to version 11, bringing newer optimizations and better codegen support.
- New
-C control-flow-guardflag enables Windows Control Flow Guard hardening; other platforms ignore the flag. - Rustdoc now includes the Ayu visual theme, giving documentation a fresh look.
Most teams will see no breaking changes, but the LLVM bump may affect custom toolchains that pin an older LLVM version.
Frequently Asked Questions
Does Rust 1.47 require a new toolchain to compile existing projects?
No, you can continue using the same edition and simply run rustup update stable.
How can I enable Control Flow Guard on Windows with Rust 1.47?
Pass -C control-flow-guard to rustc or add RUSTFLAGS="-C control-flow-guard" in your build configuration.
Are the new const methods usable in const contexts today?
Yes, you can call them inside const fn or const blocks without any additional feature flags.
Will my code that uses arrays larger than 32 elements now compile without extra crates?
Yes, the standard library now provides trait implementations for any array length.
What should I do if I still see a full backtrace after a panic?
Set the environment variable RUST_BACKTRACE=full to get the detailed backtrace.