Skip to content

Commit b2e0174

Browse files
committed
chore: wip
1 parent b288b53 commit b2e0174

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

  • compiler/rustc_session/src/config

compiler/rustc_session/src/config/cfg.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<T: Eq + Hash> ExpectedValues<T> {
6969
}
7070

7171
fn no_less(&mut self, value: T) {
72-
if let ExpectedValues::BoundedBelow(ref mut bound) = self {
72+
if let ExpectedValues::BoundedBelow(bound) = self {
7373
*bound = value.into();
7474
}
7575
}
@@ -87,7 +87,7 @@ impl<T: Eq + Hash> ExpectedValues<T> {
8787
}
8888

8989
pub fn lower_bound(&self) -> Option<&T> {
90-
if let ExpectedValues::BoundedBelow(bound) = self { bound } else { None }
90+
if let ExpectedValues::BoundedBelow(bound) = self { bound.as_ref() } else { None }
9191
}
9292
}
9393

@@ -463,7 +463,7 @@ impl CheckCfg {
463463

464464
if self.exhaustive_values {
465465
// Get all values map at once otherwise it would be costly.
466-
// (8 values * 220 targets ~= 1760 times, at the time of writing this comment).
466+
// (8 values * 220 targets =~ 1760 times, at the time of writing this comment).
467467
let [
468468
Some(values_target_abi),
469469
Some(values_target_arch),
@@ -483,12 +483,14 @@ impl CheckCfg {
483483
values_target_abi.insert(target.options.cfg_abi.desc_symbol());
484484
values_target_arch.insert(target.arch.desc_symbol());
485485
values_target_endian.insert(target.options.endian.desc_symbol());
486-
if target.options.os.desc() == "openbsd" {
487-
let openbsd_ver = target.options.env.bound().unwrap();
488-
values_target_env.lower_bound(sym::integer(openbsd_ver));
489-
} else {
490-
values_target_env.insert(target.options.env.desc_symbol());
491-
}
486+
target
487+
.options
488+
.env
489+
.bound()
490+
.and_then(|bound| {
491+
values_target_env.no_less(sym::integer(bound));
492+
})
493+
.or_else(|| values_target_env.insert(target.options.env.desc_symbol()));
492494
values_target_family.extend(
493495
target.options.families.iter().map(|family| Symbol::intern(family)),
494496
);

0 commit comments

Comments
 (0)