@@ -184,17 +184,22 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
184
184
185
185
ccx. stats . n_monos += 1 ;
186
186
187
- let depth = match ccx. monomorphizing . find ( & fn_id) {
188
- Some ( & d) => d, None => 0
189
- } ;
190
- // Random cut-off -- code that needs to instantiate the same function
191
- // recursively more than thirty times can probably safely be assumed to be
192
- // causing an infinite expansion.
193
- if depth > 30 {
194
- ccx. sess . span_fatal (
195
- span, "overly deep expansion of inlined function" ) ;
187
+ let depth;
188
+ {
189
+ let mut monomorphizing = ccx. monomorphizing . borrow_mut ( ) ;
190
+ depth = match monomorphizing. get ( ) . find ( & fn_id) {
191
+ Some ( & d) => d, None => 0
192
+ } ;
193
+
194
+ // Random cut-off -- code that needs to instantiate the same function
195
+ // recursively more than thirty times can probably safely be assumed
196
+ // to be causing an infinite expansion.
197
+ if depth > 30 {
198
+ ccx. sess . span_fatal (
199
+ span, "overly deep expansion of inlined function" ) ;
200
+ }
201
+ monomorphizing. get ( ) . insert ( fn_id, depth + 1 ) ;
196
202
}
197
- ccx. monomorphizing . insert ( fn_id, depth + 1 ) ;
198
203
199
204
let ( _, elt) = gensym_name ( ccx. sess . str_of ( name) ) ;
200
205
let mut pt = ( * pt) . clone ( ) ;
@@ -292,7 +297,11 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
292
297
ccx. tcx . sess . bug ( format ! ( "Can't monomorphize a {:?}" , map_node) )
293
298
}
294
299
} ;
295
- ccx. monomorphizing . insert ( fn_id, depth) ;
300
+
301
+ {
302
+ let mut monomorphizing = ccx. monomorphizing . borrow_mut ( ) ;
303
+ monomorphizing. get ( ) . insert ( fn_id, depth) ;
304
+ }
296
305
297
306
debug ! ( "leaving monomorphic fn {}" , ty:: item_path_str( ccx. tcx, fn_id) ) ;
298
307
( lldecl, must_cast)
0 commit comments