about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2019-12-10 12:41:27 -0800
committerDylan MacKenzie <ecstaticmorse@gmail.com>2019-12-13 10:38:29 -0800
commit8f3021bd2cc49eda82ae01ac2e769a7e0fd0aa36 (patch)
tree67ebbccc0e9c103f60a16ed970e5059301863d3a /src
parent3964a55ba59bb6c3d4badcbddc49f6929ef76862 (diff)
downloadrust-8f3021bd2cc49eda82ae01ac2e769a7e0fd0aa36.tar.gz
rust-8f3021bd2cc49eda82ae01ac2e769a7e0fd0aa36.zip
Get active features dynamically by their `Symbol`
Diffstat (limited to 'src')
-rw-r--r--src/librustc_feature/active.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/librustc_feature/active.rs b/src/librustc_feature/active.rs
index 363621b3ca4..8794d830961 100644
--- a/src/librustc_feature/active.rs
+++ b/src/librustc_feature/active.rs
@@ -53,6 +53,18 @@ macro_rules! declare_features {
                 $(f(stringify!($feature), self.$feature);)+
             }
         }
+
+        impl std::ops::Index<Symbol> for Features {
+            type Output = bool;
+
+            fn index(&self, feature: Symbol) -> &Self::Output {
+                match feature {
+                    $( sym::$feature => &self.$feature, )*
+
+                    _ => panic!("{} was not defined in `declare_features`", feature),
+                }
+            }
+        }
     };
 }