about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-10-26 13:38:38 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2023-10-31 08:00:53 +1100
commitbb3e09f1444ee10c5bbbaf971eb1e6e8994cb046 (patch)
treee6932530c3d648274c0169bd4f8cf0796525e40e
parent236ac911de2f4b6210ba99e25c6c4843c9381a1a (diff)
downloadrust-bb3e09f1444ee10c5bbbaf971eb1e6e8994cb046.tar.gz
rust-bb3e09f1444ee10c5bbbaf971eb1e6e8994cb046.zip
Streamline `gate_feature_*` macros.
The debug probably isn't useful, and assigning all the `$foo`
metavariables to `foo` variables is verbose and weird. Also, `$x:expr`
usually doesn't have a space after the `:`.
-rw-r--r--Cargo.lock1
-rw-r--r--compiler/rustc_ast_passes/Cargo.toml1
-rw-r--r--compiler/rustc_ast_passes/src/feature_gate.rs44
3 files changed, 14 insertions, 32 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 2b1e918e2f5..ba72a33e9ef 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3501,7 +3501,6 @@ dependencies = [
  "rustc_span",
  "rustc_target",
  "thin-vec",
- "tracing",
 ]
 
 [[package]]
diff --git a/compiler/rustc_ast_passes/Cargo.toml b/compiler/rustc_ast_passes/Cargo.toml
index c1ebfb3e6d0..0001394c8d3 100644
--- a/compiler/rustc_ast_passes/Cargo.toml
+++ b/compiler/rustc_ast_passes/Cargo.toml
@@ -19,5 +19,4 @@ rustc_session = { path = "../rustc_session" }
 rustc_span = { path = "../rustc_span" }
 rustc_target = { path = "../rustc_target" }
 thin-vec = "0.2.12"
-tracing = "0.1"
 # tidy-alphabetical-end
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs
index a1bd2679137..6288e9f8b36 100644
--- a/compiler/rustc_ast_passes/src/feature_gate.rs
+++ b/compiler/rustc_ast_passes/src/feature_gate.rs
@@ -10,51 +10,35 @@ use rustc_span::symbol::sym;
 use rustc_span::Span;
 use rustc_target::spec::abi;
 use thin_vec::ThinVec;
-use tracing::debug;
 
 use crate::errors;
 
 macro_rules! gate_feature_fn {
-    ($visitor: expr, $has_feature: expr, $span: expr, $name: expr, $explain: expr, $help: expr) => {{
-        let (visitor, has_feature, span, name, explain, help) =
-            (&*$visitor, $has_feature, $span, $name, $explain, $help);
-        let has_feature: bool = has_feature(visitor.features);
-        debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", name, span, has_feature);
-        if !has_feature && !span.allows_unstable($name) {
-            feature_err(&visitor.sess.parse_sess, name, span, explain).help(help).emit();
+    ($visitor:expr, $has_feature:expr, $span:expr, $name:expr, $explain:expr, $help:expr) => {{
+        if !$has_feature($visitor.features) && !$span.allows_unstable($name) {
+            feature_err(&$visitor.sess.parse_sess, $name, $span, $explain).help($help).emit();
         }
     }};
-    ($visitor: expr, $has_feature: expr, $span: expr, $name: expr, $explain: expr) => {{
-        let (visitor, has_feature, span, name, explain) =
-            (&*$visitor, $has_feature, $span, $name, $explain);
-        let has_feature: bool = has_feature(visitor.features);
-        debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", name, span, has_feature);
-        if !has_feature && !span.allows_unstable($name) {
-            feature_err(&visitor.sess.parse_sess, name, span, explain).emit();
+    ($visitor:expr, $has_feature:expr, $span:expr, $name:expr, $explain:expr) => {{
+        if !$has_feature($visitor.features) && !$span.allows_unstable($name) {
+            feature_err(&$visitor.sess.parse_sess, $name, $span, $explain).emit();
         }
     }};
-    (future_incompatible; $visitor: expr, $has_feature: expr, $span: expr, $name: expr, $explain: expr) => {{
-        let (visitor, has_feature, span, name, explain) =
-            (&*$visitor, $has_feature, $span, $name, $explain);
-        let has_feature: bool = has_feature(visitor.features);
-        debug!(
-            "gate_feature(feature = {:?}, span = {:?}); has? {} (future_incompatible)",
-            name, span, has_feature
-        );
-        if !has_feature && !span.allows_unstable($name) {
-            feature_warn(&visitor.sess.parse_sess, name, span, explain);
+    (future_incompatible; $visitor:expr, $has_feature:expr, $span:expr, $name:expr, $explain:expr) => {{
+        if !$has_feature($visitor.features) && !$span.allows_unstable($name) {
+            feature_warn(&$visitor.sess.parse_sess, $name, $span, $explain);
         }
     }};
 }
 
 macro_rules! gate_feature_post {
-    ($visitor: expr, $feature: ident, $span: expr, $explain: expr, $help: expr) => {
-        gate_feature_fn!($visitor, |x: &Features| x.$feature, $span, sym::$feature, $explain, $help)
+    ($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {
+        gate_feature_fn!($visitor, |x:&Features| x.$feature, $span, sym::$feature, $explain, $help)
     };
-    ($visitor: expr, $feature: ident, $span: expr, $explain: expr) => {
-        gate_feature_fn!($visitor, |x: &Features| x.$feature, $span, sym::$feature, $explain)
+    ($visitor:expr, $feature:ident, $span:expr, $explain:expr) => {
+        gate_feature_fn!($visitor, |x:&Features| x.$feature, $span, sym::$feature, $explain)
     };
-    (future_incompatible; $visitor: expr, $feature: ident, $span: expr, $explain: expr) => {
+    (future_incompatible; $visitor:expr, $feature:ident, $span:expr, $explain:expr) => {
         gate_feature_fn!(future_incompatible; $visitor, |x: &Features| x.$feature, $span, sym::$feature, $explain)
     };
 }