Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Apr 27, 2018
1 parent 9a59789 commit f678bf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/librustc/ty/maps/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ pub trait QueryConfig<'tcx> {
type Value: Clone + for<'a> HashStable<StableHashingContext<'a>>;

fn query(key: Self::Key) -> Query<'tcx>;

// Don't use this method to access query results, instead use the methods on TyCtxt
fn query_map<'a>(tcx: TyCtxt<'a, 'tcx, '_>) -> &'a Lock<QueryMap<'tcx, Self>>;

fn to_dep_node(tcx: TyCtxt<'_, 'tcx, '_>, key: &Self::Key) -> DepNode;

// Don't use this method to compute query results, instead use the methods on TyCtxt
fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value;

fn handle_cycle_error(tcx: TyCtxt<'_, 'tcx, '_>) -> Self::Value;
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/ty/maps/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,18 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
// The TyCtxt stored in TLS has the same global interner lifetime
// as `tcx`, so we use `with_related_context` to relate the 'gcx lifetimes
// when accessing the ImplicitCtxt
let r = tls::with_related_context(tcx, move |icx| {
let r = tls::with_related_context(tcx, move |current_icx| {
// Update the ImplicitCtxt to point to our new query job
let icx = tls::ImplicitCtxt {
let new_icx = tls::ImplicitCtxt {
tcx,
query: Some(self.job.clone()),
layout_depth: icx.layout_depth,
task: icx.task,
layout_depth: current_icx.layout_depth,
task: current_icx.task,
};

// Use the ImplicitCtxt while we execute the query
tls::enter_context(&icx, |icx| {
compute(icx.tcx)
tls::enter_context(&new_icx, |_| {
compute(tcx)
})
});

Expand Down

0 comments on commit f678bf0

Please sign in to comment.