Skip to content

Commit 475e131

Browse files
committed
Inline and remove intern_method!.
It's only used in two places, and the code is shorter and more readable with it gone.
1 parent 3724e37 commit 475e131

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

src/librustc/ty/context.rs

+14-26
Original file line numberDiff line numberDiff line change
@@ -2154,23 +2154,6 @@ impl<'tcx> Borrow<[Goal<'tcx>]> for Interned<'tcx, List<Goal<'tcx>>> {
21542154
}
21552155
}
21562156

2157-
macro_rules! intern_method {
2158-
($lt_tcx:tt, $name:ident: $method:ident($alloc:ty,
2159-
$alloc_method:expr,
2160-
$alloc_to_key:expr) -> $ty:ty) => {
2161-
impl<$lt_tcx> TyCtxt<$lt_tcx> {
2162-
pub fn $method(self, v: $alloc) -> &$lt_tcx $ty {
2163-
let key = ($alloc_to_key)(&v);
2164-
2165-
self.interners.$name.intern_ref(key, || {
2166-
Interned($alloc_method(&self.interners.arena, v))
2167-
2168-
}).0
2169-
}
2170-
}
2171-
}
2172-
}
2173-
21742157
macro_rules! direct_interners {
21752158
($lt_tcx:tt, $($name:ident: $method:ident($ty:ty)),+) => {
21762159
$(impl<$lt_tcx> PartialEq for Interned<$lt_tcx, $ty> {
@@ -2187,11 +2170,13 @@ macro_rules! direct_interners {
21872170
}
21882171
}
21892172

2190-
intern_method!(
2191-
$lt_tcx,
2192-
$name: $method($ty,
2193-
|a: &$lt_tcx SyncDroplessArena, v| -> &$lt_tcx $ty { a.alloc(v) },
2194-
|x| x) -> $ty);)+
2173+
impl<$lt_tcx> TyCtxt<$lt_tcx> {
2174+
pub fn $method(self, v: $ty) -> &$lt_tcx $ty {
2175+
self.interners.$name.intern_ref(&v, || {
2176+
Interned(self.interners.arena.alloc(v))
2177+
}).0
2178+
}
2179+
})+
21952180
}
21962181
}
21972182

@@ -2207,10 +2192,13 @@ direct_interners!('tcx,
22072192

22082193
macro_rules! slice_interners {
22092194
($($field:ident: $method:ident($ty:ty)),+) => (
2210-
$(intern_method!( 'tcx, $field: $method(
2211-
&[$ty],
2212-
|a, v| List::from_arena(a, v),
2213-
Deref::deref) -> List<$ty>);)+
2195+
$(impl<'tcx> TyCtxt<'tcx> {
2196+
pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
2197+
self.interners.$field.intern_ref(v, || {
2198+
Interned(List::from_arena(&self.interners.arena, v))
2199+
}).0
2200+
}
2201+
})+
22142202
);
22152203
}
22162204

0 commit comments

Comments
 (0)