Skip to content

Commit

Permalink
Remove unused DepTrackingMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Sep 26, 2019
1 parent 6c2c29c commit 9b00e21
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 156 deletions.
87 changes: 0 additions & 87 deletions src/librustc/dep_graph/dep_tracking_map.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/librustc/dep_graph/mod.rs
@@ -1,14 +1,12 @@
pub mod debug; pub mod debug;
mod dep_node; mod dep_node;
mod dep_tracking_map;
mod graph; mod graph;
mod prev; mod prev;
mod query; mod query;
mod safe; mod safe;
mod serialized; mod serialized;
pub mod cgu_reuse_tracker; 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::dep_node::{DepNode, DepKind, DepConstructor, WorkProductId, RecoverKey, label_strs};
pub use self::graph::{DepGraph, WorkProduct, DepNodeIndex, DepNodeColor, TaskDeps, hash_result}; pub use self::graph::{DepGraph, WorkProduct, DepNodeIndex, DepNodeColor, TaskDeps, hash_result};
pub use self::graph::WorkProductFileKind; pub use self::graph::WorkProductFileKind;
Expand Down
29 changes: 1 addition & 28 deletions src/librustc/traits/codegen/mod.rs
Expand Up @@ -3,12 +3,10 @@
// seems likely that they should eventually be merged into more // seems likely that they should eventually be merged into more
// general routines. // general routines.


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


Expand Down Expand Up @@ -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 // # 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> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// Finishes processes any obligations that remain in the /// Finishes processes any obligations that remain in the
/// fulfillment context, and then returns the result with all type /// fulfillment context, and then returns the result with all type
Expand Down
41 changes: 2 additions & 39 deletions src/librustc/util/common.rs
@@ -1,10 +1,9 @@
#![allow(non_camel_case_types)] #![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::fmt::Debug;
use std::hash::Hash;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};


use std::sync::mpsc::{Sender}; use std::sync::mpsc::{Sender};
Expand Down Expand Up @@ -279,39 +278,3 @@ pub fn indenter() -> Indenter {
debug!(">>"); debug!(">>");
Indenter { _cannot_construct_outside_of_this_module: () } 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.