Make Cfg
and CheckCfg
non-generic.
They now only ever contains symbols.
This commit is contained in:
parent
8e4ac980fd
commit
5c6a12c1af
5 changed files with 20 additions and 40 deletions
|
@ -1247,8 +1247,8 @@ pub const fn default_lib_output() -> CrateType {
|
|||
CrateType::Rlib
|
||||
}
|
||||
|
||||
fn default_configuration(sess: &Session) -> Cfg<Symbol> {
|
||||
// NOTE: This should be kept in sync with `CheckCfg::<Symbol>::fill_well_known` below.
|
||||
fn default_configuration(sess: &Session) -> Cfg {
|
||||
// NOTE: This should be kept in sync with `CheckCfg::fill_well_known` below.
|
||||
let end = &sess.target.endian;
|
||||
let arch = &sess.target.arch;
|
||||
let wordsz = sess.target.pointer_width.to_string();
|
||||
|
@ -1358,32 +1358,21 @@ fn default_configuration(sess: &Session) -> Cfg<Symbol> {
|
|||
}
|
||||
|
||||
/// The parsed `--cfg` options that define the compilation environment of the
|
||||
/// crate, used to drive conditional compilation. `T` is always `String` or
|
||||
/// `Symbol`. Strings are used temporarily very early on. Once the the main
|
||||
/// symbol interner is running, they are converted to symbols.
|
||||
/// crate, used to drive conditional compilation.
|
||||
///
|
||||
/// An `FxIndexSet` is used to ensure deterministic ordering of error messages
|
||||
/// relating to `--cfg`.
|
||||
pub type Cfg<T> = FxIndexSet<(T, Option<T>)>;
|
||||
pub type Cfg = FxIndexSet<(Symbol, Option<Symbol>)>;
|
||||
|
||||
/// The parsed `--check-cfg` options. The `<T>` structure is similar to `Cfg`.
|
||||
pub struct CheckCfg<T> {
|
||||
/// The parsed `--check-cfg` options.
|
||||
#[derive(Default)]
|
||||
pub struct CheckCfg {
|
||||
/// Is well known names activated
|
||||
pub exhaustive_names: bool,
|
||||
/// Is well known values activated
|
||||
pub exhaustive_values: bool,
|
||||
/// All the expected values for a config name
|
||||
pub expecteds: FxHashMap<T, ExpectedValues<T>>,
|
||||
}
|
||||
|
||||
impl<T> Default for CheckCfg<T> {
|
||||
fn default() -> Self {
|
||||
CheckCfg {
|
||||
exhaustive_names: false,
|
||||
exhaustive_values: false,
|
||||
expecteds: FxHashMap::default(),
|
||||
}
|
||||
}
|
||||
pub expecteds: FxHashMap<Symbol, ExpectedValues<Symbol>>,
|
||||
}
|
||||
|
||||
pub enum ExpectedValues<T> {
|
||||
|
@ -1418,7 +1407,7 @@ impl<'a, T: Eq + Hash + Copy + 'a> Extend<&'a T> for ExpectedValues<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl CheckCfg<Symbol> {
|
||||
impl CheckCfg {
|
||||
pub fn fill_well_known(&mut self, current_target: &Target) {
|
||||
if !self.exhaustive_values && !self.exhaustive_names {
|
||||
return;
|
||||
|
@ -1558,7 +1547,7 @@ impl CheckCfg<Symbol> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn build_configuration(sess: &Session, mut user_cfg: Cfg<Symbol>) -> Cfg<Symbol> {
|
||||
pub fn build_configuration(sess: &Session, mut user_cfg: Cfg) -> Cfg {
|
||||
// Combine the configuration requested by the session (command line) with
|
||||
// some default and generated configuration items.
|
||||
let default_cfg = default_configuration(sess);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue