@@ -161,12 +161,12 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
161
161
-> Ty < ' tcx > {
162
162
let ty = {
163
163
let mut interner = self . type_ . borrow_mut ( ) ;
164
- let global_interner = global_interners. map ( |interners| {
165
- interners. type_ . borrow_mut ( )
166
- } ) ;
167
164
if let Some ( & Interned ( ty) ) = interner. get ( & st) {
168
165
return ty;
169
166
}
167
+ let global_interner = global_interners. map ( |interners| {
168
+ interners. type_ . borrow_mut ( )
169
+ } ) ;
170
170
if let Some ( ref interner) = global_interner {
171
171
if let Some ( & Interned ( ty) ) = interner. get ( & st) {
172
172
return ty;
@@ -1010,17 +1010,16 @@ impl<'tcx> InterpretInterner<'tcx> {
1010
1010
}
1011
1011
}
1012
1012
1013
- impl < ' tcx > GlobalCtxt < ' tcx > {
1013
+ impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
1014
1014
/// Get the global TyCtxt.
1015
- pub fn global_tcx < ' a > ( & ' a self ) -> TyCtxt < ' a , ' tcx , ' tcx > {
1015
+ #[ inline]
1016
+ pub fn global_tcx ( self ) -> TyCtxt < ' a , ' gcx , ' gcx > {
1016
1017
TyCtxt {
1017
- gcx : self ,
1018
- interners : & self . global_interners
1018
+ gcx : self . gcx ,
1019
+ interners : & self . gcx . global_interners ,
1019
1020
}
1020
1021
}
1021
- }
1022
1022
1023
- impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
1024
1023
pub fn alloc_generics ( self , generics : ty:: Generics ) -> & ' gcx ty:: Generics {
1025
1024
self . global_arenas . generics . alloc ( generics)
1026
1025
}
@@ -1081,12 +1080,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1081
1080
self ,
1082
1081
alloc : interpret:: Allocation ,
1083
1082
) -> & ' gcx interpret:: Allocation {
1084
- if let Some ( alloc) = self . interpret_interner . inner . borrow ( ) . allocs . get ( & alloc) {
1083
+ let allocs = & mut self . interpret_interner . inner . borrow_mut ( ) . allocs ;
1084
+ if let Some ( alloc) = allocs. get ( & alloc) {
1085
1085
return alloc;
1086
1086
}
1087
1087
1088
1088
let interned = self . global_arenas . const_allocs . alloc ( alloc) ;
1089
- if let Some ( prev) = self . interpret_interner . inner . borrow_mut ( ) . allocs . replace ( interned) {
1089
+ if let Some ( prev) = allocs. replace ( interned) {
1090
1090
bug ! ( "Tried to overwrite interned Allocation: {:#?}" , prev)
1091
1091
}
1092
1092
interned
@@ -1113,24 +1113,26 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1113
1113
}
1114
1114
1115
1115
pub fn intern_stability ( self , stab : attr:: Stability ) -> & ' gcx attr:: Stability {
1116
- if let Some ( st) = self . stability_interner . borrow ( ) . get ( & stab) {
1116
+ let mut stability_interner = self . stability_interner . borrow_mut ( ) ;
1117
+ if let Some ( st) = stability_interner. get ( & stab) {
1117
1118
return st;
1118
1119
}
1119
1120
1120
1121
let interned = self . global_interners . arena . alloc ( stab) ;
1121
- if let Some ( prev) = self . stability_interner . borrow_mut ( ) . replace ( interned) {
1122
+ if let Some ( prev) = stability_interner. replace ( interned) {
1122
1123
bug ! ( "Tried to overwrite interned Stability: {:?}" , prev)
1123
1124
}
1124
1125
interned
1125
1126
}
1126
1127
1127
1128
pub fn intern_layout ( self , layout : LayoutDetails ) -> & ' gcx LayoutDetails {
1128
- if let Some ( layout) = self . layout_interner . borrow ( ) . get ( & layout) {
1129
+ let mut layout_interner = self . layout_interner . borrow_mut ( ) ;
1130
+ if let Some ( layout) = layout_interner. get ( & layout) {
1129
1131
return layout;
1130
1132
}
1131
1133
1132
1134
let interned = self . global_arenas . layout . alloc ( layout) ;
1133
- if let Some ( prev) = self . layout_interner . borrow_mut ( ) . replace ( interned) {
1135
+ if let Some ( prev) = layout_interner. replace ( interned) {
1134
1136
bug ! ( "Tried to overwrite interned Layout: {:?}" , prev)
1135
1137
}
1136
1138
interned
0 commit comments