about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/librustc_middle/ty/query/plumbing.rs76
1 files changed, 19 insertions, 57 deletions
diff --git a/src/librustc_middle/ty/query/plumbing.rs b/src/librustc_middle/ty/query/plumbing.rs
index 612507711fd..f3a49438f5b 100644
--- a/src/librustc_middle/ty/query/plumbing.rs
+++ b/src/librustc_middle/ty/query/plumbing.rs
@@ -242,59 +242,9 @@ macro_rules! define_queries {
     }
 }
 
-macro_rules! define_query_helper {
-    (TyCtxtAt<$tcx:tt>, $(#[$attr:meta])* $name:ident(DefId) -> $V:ty) => {
-        $(#[$attr])*
-        #[inline(always)]
-        pub fn $name(self, key: impl Into<DefId>) -> $V {
-            fn mono(this: TyCtxtAt<$tcx>, key: DefId) -> $V {
-                get_query::<queries::$name<'_>, _>(this.tcx, this.span, key)
-            }
-
-            mono(self, key.into())
-        }
-    };
-    (TyCtxtAt<$tcx:tt>, $(#[$attr:meta])* $name:ident($K:ty) -> $V:ty) => {
-        $(#[$attr])*
-        #[inline(always)]
-        pub fn $name(self, key: $K) -> $V {
-            get_query::<queries::$name<'_>, _>(self.tcx, self.span, key)
-        }
-    };
-
-    (TyCtxt<$tcx:tt>, $(#[$attr:meta])* $name:ident(DefId) -> $V:ty) => {
-        $(#[$attr])*
-        #[inline(always)]
-        pub fn $name(self, key: impl Into<DefId>) -> $V {
-            self.at(DUMMY_SP).$name(key)
-        }
-    };
-    (TyCtxt<$tcx:tt>, $(#[$attr:meta])* $name:ident($K:ty) -> $V:ty) => {
-        $(#[$attr])*
-        #[inline(always)]
-        pub fn $name(self, key: $K) -> $V {
-            self.at(DUMMY_SP).$name(key)
-        }
-    };
-
-    (TyCtxtEnsure<$tcx:tt>, $(#[$attr:meta])* $name:ident(DefId) -> $V:ty) => {
-        $(#[$attr])*
-        #[inline(always)]
-        pub fn $name(self, key: impl Into<DefId>) {
-            fn mono(this: TyCtxtEnsure<$tcx>, key: DefId) {
-                ensure_query::<queries::$name<'_>, _>(this.tcx, key)
-            }
-
-            mono(self, key.into())
-        }
-    };
-    (TyCtxtEnsure<$tcx:tt>, $(#[$attr:meta])* $name:ident($K:ty) -> $V:ty) => {
-        $(#[$attr])*
-        #[inline(always)]
-        pub fn $name(self, key: $K) {
-            ensure_query::<queries::$name<'_>, _>(self.tcx, key)
-        }
-    };
+macro_rules! query_helper_param_ty {
+    (DefId) => { impl Into<DefId> };
+    ($K:ty) => { $K };
 }
 
 macro_rules! define_queries_inner {
@@ -432,8 +382,12 @@ macro_rules! define_queries_inner {
             pub tcx: TyCtxt<'tcx>,
         }
 
-        impl TyCtxtEnsure<'tcx> {
-            $( define_query_helper!(TyCtxtEnsure<'tcx>, $(#[$attr])* $name($($K)*) -> $V); )*
+        impl TyCtxtEnsure<$tcx> {
+            $($(#[$attr])*
+            #[inline(always)]
+            pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
+                ensure_query::<queries::$name<'_>, _>(self.tcx, key.into())
+            })*
         }
 
         #[derive(Copy, Clone)]
@@ -470,7 +424,11 @@ macro_rules! define_queries_inner {
                 }
             }
 
-            $( define_query_helper!(TyCtxt<$tcx>, $(#[$attr])* $name($($K)*) -> $V); )*
+            $($(#[$attr])*
+            #[inline(always)]
+            pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V {
+                self.at(DUMMY_SP).$name(key)
+            })*
 
             /// All self-profiling events generated by the query engine use
             /// virtual `StringId`s for their `event_id`. This method makes all
@@ -503,7 +461,11 @@ macro_rules! define_queries_inner {
         }
 
         impl TyCtxtAt<$tcx> {
-            $( define_query_helper!(TyCtxtAt<$tcx>, $(#[$attr])* $name($($K)*) -> $V); )*
+            $($(#[$attr])*
+            #[inline(always)]
+            pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V {
+                get_query::<queries::$name<'_>, _>(self.tcx, self.span, key.into())
+            })*
         }
 
         define_provider_struct! {