diff --git a/src/librustc/ty/maps/on_disk_cache.rs b/src/librustc/ty/maps/on_disk_cache.rs index 7f126976a2e..84e566e57e6 100644 --- a/src/librustc/ty/maps/on_disk_cache.rs +++ b/src/librustc/ty/maps/on_disk_cache.rs @@ -796,15 +796,14 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder for CacheEncoder< // cache the allocation shorthand now, because the allocation itself might recursively // point to itself. self.interpret_alloc_shorthands.insert(*alloc_id, start); - let interpret_interner = self.tcx.interpret_interner.borrow(); - if let Some(alloc) = interpret_interner.get_alloc(*alloc_id) { + if let Some(alloc) = self.tcx.interpret_interner.borrow().get_alloc(*alloc_id) { trace!("encoding {:?} with {:#?}", alloc_id, alloc); usize::max_value().encode(self)?; alloc.encode(self)?; - interpret_interner + self.tcx.interpret_interner.borrow() .get_corresponding_static_def_id(*alloc_id) .encode(self)?; - } else if let Some(fn_instance) = interpret_interner.get_fn(*alloc_id) { + } else if let Some(fn_instance) = self.tcx.interpret_interner.borrow().get_fn(*alloc_id) { trace!("encoding {:?} with {:#?}", alloc_id, fn_instance); (usize::max_value() - 1).encode(self)?; fn_instance.encode(self)?; diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 71be3f28759..c74063c66bd 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -205,15 +205,14 @@ impl<'a, 'tcx> SpecializedEncoder for EncodeContext<'a, 'tcx // cache the allocation shorthand now, because the allocation itself might recursively // point to itself. self.interpret_alloc_shorthands.insert(*alloc_id, start); - let interpret_interner = self.tcx.interpret_interner.borrow(); - if let Some(alloc) = interpret_interner.get_alloc(*alloc_id) { + if let Some(alloc) = self.tcx.interpret_interner.borrow().get_alloc(*alloc_id) { trace!("encoding {:?} with {:#?}", alloc_id, alloc); usize::max_value().encode(self)?; alloc.encode(self)?; - interpret_interner + self.tcx.interpret_interner.borrow() .get_corresponding_static_def_id(*alloc_id) .encode(self)?; - } else if let Some(fn_instance) = interpret_interner.get_fn(*alloc_id) { + } else if let Some(fn_instance) = self.tcx.interpret_interner.borrow().get_fn(*alloc_id) { trace!("encoding {:?} with {:#?}", alloc_id, fn_instance); (usize::max_value() - 1).encode(self)?; fn_instance.encode(self)?; @@ -1155,7 +1154,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { _ => None, }, mir: match item.node { - hir::ItemStatic(..) if self.tcx.sess.opts.debugging_opts.always_encode_mir => { + hir::ItemStatic(..) => { self.encode_optimized_mir(def_id) } hir::ItemConst(..) => self.encode_optimized_mir(def_id), diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 160786ea021..a246898873c 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -375,11 +375,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { None => match self.uninitialized_statics.get(&id) { Some(a) => (a, " (static in the process of initialization)".to_owned()), None => { - let int = self.tcx.interpret_interner.borrow(); // static alloc? - match int.get_alloc(id) { + match self.tcx.interpret_interner.borrow().get_alloc(id) { Some(a) => (a, "(immutable)".to_owned()), - None => if let Some(func) = int.get_fn(id) { + None => if let Some(func) = self.tcx.interpret_interner.borrow().get_fn(id) { trace!("{} {}", msg, func); continue; } else { diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 0a8fd022dd1..35c561e02e0 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -1117,13 +1117,12 @@ fn collect_miri<'a, 'tcx>( alloc_id: AllocId, output: &mut Vec>, ) { - let interpret_interner = tcx.interpret_interner.borrow(); - if let Some(alloc) = interpret_interner.get_alloc(alloc_id) { + if let Some(alloc) = tcx.interpret_interner.borrow().get_alloc(alloc_id) { trace!("collecting {:?} with {:#?}", alloc_id, alloc); for &inner in alloc.relocations.values() { collect_miri(tcx, inner, output); } - } else if let Some(fn_instance) = interpret_interner.get_fn(alloc_id) { + } else if let Some(fn_instance) = tcx.interpret_interner.borrow().get_fn(alloc_id) { if should_monomorphize_locally(tcx, &fn_instance) { trace!("collecting {:?} with {:#?}", alloc_id, fn_instance); output.push(create_fn_mono_item(fn_instance)); diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index be5cb311b9c..1ca9bd81893 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -151,15 +151,19 @@ pub fn primval_to_llvm(cx: &CodegenCx, } }, PrimVal::Ptr(ptr) => { - let interpret_interner = cx.tcx.interpret_interner.borrow(); - if let Some(fn_instance) = interpret_interner.get_fn(ptr.alloc_id) { + if let Some(fn_instance) = cx.tcx.interpret_interner.borrow().get_fn(ptr.alloc_id) { callee::get_fn(cx, fn_instance) } else { - let static_ = interpret_interner.get_corresponding_static_def_id(ptr.alloc_id); + let static_ = cx + .tcx + .interpret_interner + .borrow() + .get_corresponding_static_def_id(ptr.alloc_id); let base_addr = if let Some(def_id) = static_ { assert!(cx.tcx.is_static(def_id).is_some()); consts::get_static(cx, def_id) - } else if let Some(alloc) = interpret_interner.get_alloc(ptr.alloc_id) { + } else if let Some(alloc) = cx.tcx.interpret_interner.borrow() + .get_alloc(ptr.alloc_id) { let init = global_initializer(cx, alloc); if alloc.mutable { consts::addr_of_mut(cx, init, alloc.align, "byte_str")