Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused DepTrackingMap #64794

Merged
merged 1 commit into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
29 changes: 1 addition & 28 deletions src/librustc/traits/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

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
Expand Down
41 changes: 2 additions & 39 deletions src/librustc/util/common.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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
}
}
}
}