Skip to main content

Module cfg

Module cfg 

Source
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_cfgs to 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ยง

CheckCfg
The parsed --check-cfg options.

Enumsยง

ExpectedValues

Functionsยง

default_configuration ๐Ÿ”’
Generate the default configs for a given session
disallow_cfgs ๐Ÿ”’
Disallow builtin cfgs from the CLI.

Type Aliasesยง

Cfg
The parsed --cfg options that define the compilation environment of the crate, used to drive conditional compilation.