diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-12-11 10:24:40 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-12-13 10:39:15 -0800 |
| commit | 80581be2c00ae9c9b24dea1c5a1465f6863564f3 (patch) | |
| tree | ebee4ecc5c7e21b9048ed16db50fdfda16325fa8 | |
| parent | 2b5ae1cb061f6599d108d9a0fc0b7b4e17abb5e7 (diff) | |
| download | rust-80581be2c00ae9c9b24dea1c5a1465f6863564f3.tar.gz rust-80581be2c00ae9c9b24dea1c5a1465f6863564f3.zip | |
Replace `Index` impl with `enabled` method
| -rw-r--r-- | src/librustc_feature/active.rs | 8 | ||||
| -rw-r--r-- | src/librustc_passes/check_const.rs | 4 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/librustc_feature/active.rs b/src/librustc_feature/active.rs index 123188944b2..a4099187762 100644 --- a/src/librustc_feature/active.rs +++ b/src/librustc_feature/active.rs @@ -52,14 +52,10 @@ macro_rules! declare_features { pub fn walk_feature_fields(&self, mut f: impl FnMut(&str, bool)) { $(f(stringify!($feature), self.$feature);)+ } - } - - impl std::ops::Index<Symbol> for Features { - type Output = bool; - fn index(&self, feature: Symbol) -> &Self::Output { + pub fn enabled(&self, feature: Symbol) -> bool { match feature { - $( sym::$feature => &self.$feature, )* + $( sym::$feature => self.$feature, )* _ => panic!("`{}` was not listed in `declare_features`", feature), } diff --git a/src/librustc_passes/check_const.rs b/src/librustc_passes/check_const.rs index 713dd3a7c83..e382d76f120 100644 --- a/src/librustc_passes/check_const.rs +++ b/src/librustc_passes/check_const.rs @@ -137,7 +137,7 @@ impl<'tcx> CheckConstVisitor<'tcx> { let gates = expr.required_feature_gates(); match gates { // Don't emit an error if the user has enabled the requisite feature gates. - Some(gates) if gates.iter().all(|&g| features[g]) => return, + Some(gates) if gates.iter().all(|&g| features.enabled(g)) => return, // `-Zunleash-the-miri-inside-of-you` only works for expressions that don't have a // corresponding feature gate. This encourages nightly users to use feature gates when @@ -158,7 +158,7 @@ impl<'tcx> CheckConstVisitor<'tcx> { let missing_gates: Vec<_> = gates .iter() .copied() - .filter(|&g| !features[g]) + .filter(|&g| !features.enabled(g)) .collect(); match missing_gates.as_slice() { |
