about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2019-10-01 16:03:25 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2019-10-01 16:06:38 +1000
commit475e131b3e877d3926b5869cde5b548825f0ceb1 (patch)
treeaf59fbce5c6794a97a8b857a156b891918cc9d16
parent3724e37b5a21c497a295129af0fe67072c6b89d1 (diff)
downloadrust-475e131b3e877d3926b5869cde5b548825f0ceb1.tar.gz
rust-475e131b3e877d3926b5869cde5b548825f0ceb1.zip
Inline and remove `intern_method!`.
It's only used in two places, and the code is shorter and more readable
with it gone.
-rw-r--r--src/librustc/ty/context.rs40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 7012d34479d..b520e66fc49 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -2154,23 +2154,6 @@ impl<'tcx> Borrow<[Goal<'tcx>]> for Interned<'tcx, List<Goal<'tcx>>> {
     }
 }
 
-macro_rules! intern_method {
-    ($lt_tcx:tt, $name:ident: $method:ident($alloc:ty,
-                                            $alloc_method:expr,
-                                            $alloc_to_key:expr) -> $ty:ty) => {
-        impl<$lt_tcx> TyCtxt<$lt_tcx> {
-            pub fn $method(self, v: $alloc) -> &$lt_tcx $ty {
-                let key = ($alloc_to_key)(&v);
-
-                self.interners.$name.intern_ref(key, || {
-                    Interned($alloc_method(&self.interners.arena, v))
-
-                }).0
-            }
-        }
-    }
-}
-
 macro_rules! direct_interners {
     ($lt_tcx:tt, $($name:ident: $method:ident($ty:ty)),+) => {
         $(impl<$lt_tcx> PartialEq for Interned<$lt_tcx, $ty> {
@@ -2187,11 +2170,13 @@ macro_rules! direct_interners {
             }
         }
 
-        intern_method!(
-            $lt_tcx,
-            $name: $method($ty,
-                           |a: &$lt_tcx SyncDroplessArena, v| -> &$lt_tcx $ty { a.alloc(v) },
-                           |x| x) -> $ty);)+
+        impl<$lt_tcx> TyCtxt<$lt_tcx> {
+            pub fn $method(self, v: $ty) -> &$lt_tcx $ty {
+                self.interners.$name.intern_ref(&v, || {
+                    Interned(self.interners.arena.alloc(v))
+                }).0
+            }
+        })+
     }
 }
 
@@ -2207,10 +2192,13 @@ direct_interners!('tcx,
 
 macro_rules! slice_interners {
     ($($field:ident: $method:ident($ty:ty)),+) => (
-        $(intern_method!( 'tcx, $field: $method(
-            &[$ty],
-            |a, v| List::from_arena(a, v),
-            Deref::deref) -> List<$ty>);)+
+        $(impl<'tcx> TyCtxt<'tcx> {
+            pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
+                self.interners.$field.intern_ref(v, || {
+                    Interned(List::from_arena(&self.interners.arena, v))
+                }).0
+            }
+        })+
     );
 }