From a5e57c8055d25209cf1b06945dc628d7c0131394 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 3 Dec 2018 14:54:58 +0100 Subject: [PATCH] Monomorphize `AllocMap` struct --- src/librustc/mir/interpret/mod.rs | 21 ++++++++++----------- src/librustc/ty/context.rs | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 9369b6e56f1..6ac80d72b1b 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -41,7 +41,6 @@ macro_rules! err { use ty::layout::{self, Size}; use middle::region; use std::io; -use std::hash::Hash; use rustc_serialize::{Encoder, Decodable, Encodable}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{Lock as Mutex, HashMapExt}; @@ -302,19 +301,19 @@ pub enum AllocType<'tcx, M> { Memory(M) } -pub struct AllocMap<'tcx, M> { +pub struct AllocMap<'tcx> { /// Lets you know what an AllocId refers to - id_to_type: FxHashMap>, + id_to_type: FxHashMap>, /// Used to ensure that functions and statics only get one associated AllocId - type_interner: FxHashMap, AllocId>, + type_interner: FxHashMap, AllocId>, /// The AllocId to assign to the next requested id. /// Always incremented, never gets smaller. next_id: AllocId, } -impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> { +impl<'tcx> AllocMap<'tcx> { pub fn new() -> Self { AllocMap { id_to_type: Default::default(), @@ -337,7 +336,7 @@ pub fn reserve( next } - fn intern(&mut self, alloc_type: AllocType<'tcx, M>) -> AllocId { + fn intern(&mut self, alloc_type: AllocType<'tcx, &'tcx Allocation>) -> AllocId { if let Some(&alloc_id) = self.type_interner.get(&alloc_type) { return alloc_id; } @@ -355,11 +354,11 @@ pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> AllocId { self.intern(AllocType::Function(instance)) } - pub fn get(&self, id: AllocId) -> Option> { + pub fn get(&self, id: AllocId) -> Option> { self.id_to_type.get(&id).cloned() } - pub fn unwrap_memory(&self, id: AllocId) -> M { + pub fn unwrap_memory(&self, id: AllocId) -> &'tcx Allocation { match self.get(id) { Some(AllocType::Memory(mem)) => mem, _ => bug!("expected allocation id {} to point to memory", id), @@ -370,19 +369,19 @@ pub fn intern_static(&mut self, static_id: DefId) -> AllocId { self.intern(AllocType::Static(static_id)) } - pub fn allocate(&mut self, mem: M) -> AllocId { + pub fn allocate(&mut self, mem: &'tcx Allocation) -> AllocId { let id = self.reserve(); self.set_id_memory(id, mem); id } - pub fn set_id_memory(&mut self, id: AllocId, mem: M) { + pub fn set_id_memory(&mut self, id: AllocId, mem: &'tcx Allocation) { if let Some(old) = self.id_to_type.insert(id, AllocType::Memory(mem)) { bug!("tried to set allocation id {}, but it was already existing as {:#?}", id, old); } } - pub fn set_id_same_memory(&mut self, id: AllocId, mem: M) { + pub fn set_id_same_memory(&mut self, id: AllocId, mem: &'tcx Allocation) { self.id_to_type.insert_same(id, AllocType::Memory(mem)); } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 42a4de1682c..d2d3a805f0a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -946,7 +946,7 @@ pub struct GlobalCtxt<'tcx> { /// Stores the value of constants (and deduplicates the actual memory) allocation_interner: Lock>, - pub alloc_map: Lock>, + pub alloc_map: Lock>, layout_interner: Lock>, -- 2.44.0