Expand description
cfg and check-cfg configuration
This module contains the definition of Cfg and CheckCfg
as well as the logic for creating the default configuration for a
given Session.
It also contains the filling of the well known configs, which should ALWAYS be in sync with the default_configuration.
ยงAdding a new cfg
Adding a new feature requires two new symbols one for the cfg itself
and the second one for the unstable feature gate, those are defined in
rustc_span::symbol.
As well as the following points,
- Add the activation logic in
default_configuration - Add the cfg to
CheckCfg::fill_well_known(and related files), so that the compiler can know the cfg is expected - Add the cfg in
disallow_cfgsto disallow users from setting it via--cfg - Add the feature gating in
compiler/rustc_feature/src/builtin_attrs.rs
Re-exportsยง
use std::hash::Hash;๐use std::hash::Hash;๐use std::iter;๐use rustc_abi::Align;๐use rustc_data_structures::fx::FxHashMap;๐use rustc_data_structures::fx::FxHashSet;๐use rustc_data_structures::fx::FxIndexSet;๐use rustc_lint_defs::builtin::EXPLICIT_BUILTIN_CFGS_IN_FLAGS;๐use rustc_span::Symbol;๐use rustc_span::sym;๐use rustc_target::spec::PanicStrategy;๐use rustc_target::spec::RelocModel;๐use rustc_target::spec::SanitizerSet;๐use rustc_target::spec::Target;๐use crate::config::CrateType;๐use crate::config::FmtDebug;๐use crate::Session;๐use crate::diagnostics;๐
Structsยง
- Check
Cfg - The parsed
--check-cfgoptions.
Enumsยง
Functionsยง
- default_
configuration ๐ - Generate the default configs for a given session
- disallow_
cfgs ๐ - Disallow builtin cfgs from the CLI.
Type Aliasesยง
- Cfg
- The parsed
--cfgoptions that define the compilation environment of the crate, used to drive conditional compilation.