Skip to content
Permalink
Browse files

Remove unused DepTrackingMap

  • Loading branch information...
Mark-Simulacrum committed Sep 26, 2019
1 parent 6c2c29c commit 9b00e219fef1d315829d0e21b24c20ec7e9630ab

This file was deleted.

@@ -1,14 +1,12 @@
pub mod debug;
mod dep_node;
mod dep_tracking_map;
mod graph;
mod prev;
mod query;
mod safe;
mod serialized;
pub mod cgu_reuse_tracker;

pub use self::dep_tracking_map::{DepTrackingMap, DepTrackingMapConfig};
pub use self::dep_node::{DepNode, DepKind, DepConstructor, WorkProductId, RecoverKey, label_strs};
pub use self::graph::{DepGraph, WorkProduct, DepNodeIndex, DepNodeColor, TaskDeps, hash_result};
pub use self::graph::WorkProductFileKind;
@@ -3,12 +3,10 @@
// seems likely that they should eventually be merged into more
// general routines.

use crate::dep_graph::{DepKind, DepTrackingMapConfig};
use std::marker::PhantomData;
use crate::infer::InferCtxt;
use crate::traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext,
TraitEngine, Vtable};
use crate::ty::{self, Ty, TyCtxt};
use crate::ty::{self, TyCtxt};
use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::fold::TypeFoldable;

@@ -100,33 +98,8 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

// Implement DepTrackingMapConfig for `trait_cache`
pub struct TraitSelectionCache<'tcx> {
data: PhantomData<&'tcx ()>
}

impl<'tcx> DepTrackingMapConfig for TraitSelectionCache<'tcx> {
type Key = (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>);
type Value = Vtable<'tcx, ()>;
fn to_dep_kind() -> DepKind {
DepKind::TraitSelect
}
}

// # Global Cache

pub struct ProjectionCache<'tcx> {
data: PhantomData<&'tcx ()>,
}

impl<'tcx> DepTrackingMapConfig for ProjectionCache<'tcx> {
type Key = Ty<'tcx>;
type Value = Ty<'tcx>;
fn to_dep_kind() -> DepKind {
DepKind::TraitSelect
}
}

impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// Finishes processes any obligations that remain in the
/// fulfillment context, and then returns the result with all type
@@ -1,10 +1,9 @@
#![allow(non_camel_case_types)]

use rustc_data_structures::{fx::FxHashMap, sync::Lock};
use rustc_data_structures::sync::Lock;

use std::cell::{RefCell, Cell};
use std::cell::Cell;
use std::fmt::Debug;
use std::hash::Hash;
use std::time::{Duration, Instant};

use std::sync::mpsc::{Sender};
@@ -279,39 +278,3 @@ pub fn indenter() -> Indenter {
debug!(">>");
Indenter { _cannot_construct_outside_of_this_module: () }
}

pub trait MemoizationMap {
type Key: Clone;
type Value: Clone;

/// If `key` is present in the map, return the value,
/// otherwise invoke `op` and store the value in the map.
///
/// N.B., if the receiver is a `DepTrackingMap`, special care is
/// needed in the `op` to ensure that the correct edges are
/// added into the dep graph. See the `DepTrackingMap` impl for
/// more details!
fn memoize<OP>(&self, key: Self::Key, op: OP) -> Self::Value
where OP: FnOnce() -> Self::Value;
}

impl<K, V> MemoizationMap for RefCell<FxHashMap<K,V>>
where K: Hash+Eq+Clone, V: Clone
{
type Key = K;
type Value = V;

fn memoize<OP>(&self, key: K, op: OP) -> V
where OP: FnOnce() -> V
{
let result = self.borrow().get(&key).cloned();
match result {
Some(result) => result,
None => {
let result = op();
self.borrow_mut().insert(key, result.clone());
result
}
}
}
}

0 comments on commit 9b00e21

Please sign in to comment.
You can’t perform that action at this time.