Added in PR #39987.
RFC for stabilization: rust-lang/rfcs#2386 (merged)
This is an experimental feature and requires an RFC before it goes through the stabilization process.
Usage
Preserves static variables up to the object file level. This feature doesn't affect link time garbage collections of unused symbols / sections.
// foo.rs
#![crate_type = "lib"]
#![feature(used)]
#[used]
static FOO: u32 = 0;
$ rustc -C opt-level=3 --emit=obj foo.rs
$ nm -C foo.o
0000000000000000 r foo::FOO::h367266b77811307c
Added in PR #39987.
RFC for stabilization: rust-lang/rfcs#2386 (merged)
This is an experimental feature and requires an RFC before it goes through the stabilization process.
Usage
Preserves
staticvariables up to the object file level. This feature doesn't affect link time garbage collections of unused symbols / sections.