Unstable features are unsupported by default in Chromium. Any use of an unstable language or library feature should be agreed upon by the Rust toolchain team before enabling it.
Since Chromium imports the Rust toolchain at its HEAD and builds it in a nightly-like configuration, it is technically possible to depend on unstable features. However, unstable features often change in a backwards-incompatible way without a warning. If such incompatible changes are introduced, importing a new version of toolchain now requires the owner to fix forward, instead of being an automated process. This makes toolchain upgrades prohibitively difficult.
When an exception is required, consider:
The following directories have a stricter policy toward unstable features:
//build accepts patches for community-maintained support for working with a stable version of the Rust compiler. See also rustc_nightly_capability and https://crbug.com/410596442//v8 tentatively disallows unstable features to provide community-maintained support for building V8 with a stable version of the Rust compiler. See also https://crbug.com/450577984This section maintains a list of exceptions from the policy above:
#![feature(portable_simd)] needed by the ETC1 encoder (see the discussion in the doc here//ui/android/texture_compressor//third_party/rust/bytemuck#![feature(linkage)] and #![feature(rustc_attrs)] needed to use PartitionAlloc from Rust (removal is tracked by https://crbug.com/410596442)//build/rust/allocatormaybe_uninit_write_slice, assert_matches, maybe_uninit_slice: Grandfathered-in exception in prototype code (i.e. not used and not shipping)mojo/public/rust/...Example BUILD.gn for first-party code:
```
# BUILD.gn:
rust_static_library("some_target_name") {
configs -= [ "//build/config/compiler:disallow_unstable_features" ]
rustflags = [ "-Zallow-features=portable_simd" ]
}
```
Example gnrt_config.toml entry for a third-party crate (run tools/crates/run_gnrt.py gen to regenerate the crate's BUILD.gn file):
``` # gnrt_config.toml: [crate.bytemuck.extra_kv] allow_unstable_features = ["portable_simd"] ```