Skip to content

Commit 80581be

Browse files
Replace Index impl with enabled method
1 parent 2b5ae1c commit 80581be

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/librustc_feature/active.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,10 @@ macro_rules! declare_features {
5252
pub fn walk_feature_fields(&self, mut f: impl FnMut(&str, bool)) {
5353
$(f(stringify!($feature), self.$feature);)+
5454
}
55-
}
56-
57-
impl std::ops::Index<Symbol> for Features {
58-
type Output = bool;
5955

60-
fn index(&self, feature: Symbol) -> &Self::Output {
56+
pub fn enabled(&self, feature: Symbol) -> bool {
6157
match feature {
62-
$( sym::$feature => &self.$feature, )*
58+
$( sym::$feature => self.$feature, )*
6359

6460
_ => panic!("`{}` was not listed in `declare_features`", feature),
6561
}

src/librustc_passes/check_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
137137
let gates = expr.required_feature_gates();
138138
match gates {
139139
// Don't emit an error if the user has enabled the requisite feature gates.
140-
Some(gates) if gates.iter().all(|&g| features[g]) => return,
140+
Some(gates) if gates.iter().all(|&g| features.enabled(g)) => return,
141141

142142
// `-Zunleash-the-miri-inside-of-you` only works for expressions that don't have a
143143
// corresponding feature gate. This encourages nightly users to use feature gates when
@@ -158,7 +158,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
158158
let missing_gates: Vec<_> = gates
159159
.iter()
160160
.copied()
161-
.filter(|&g| !features[g])
161+
.filter(|&g| !features.enabled(g))
162162
.collect();
163163

164164
match missing_gates.as_slice() {

0 commit comments

Comments
 (0)