Skip to content

Commit

Permalink
Rollup merge of rust-lang#64794 - Mark-Simulacrum:rm-dep-track-map, r…
Browse files Browse the repository at this point in the history
…=estebank

Remove unused DepTrackingMap

Deletes some related code (MemoizationMap trait, etc.)

I believe this became unused with red/green incremental introduction, but am uncertain.
  • Loading branch information
Centril authored Sep 28, 2019
2 parents 4db233e + 9b00e21 commit 85175b7
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
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
}
}
}
}

0 comments on commit 85175b7

Please sign in to comment.