Skip to content

Make erase_regions_ty no_hash and remove support for anon queries #59968

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

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ rustc_queries! {
// is not a good candidates for "replay" because it is essentially a
// pure function of its input (and hence the expectation is that
// no caller would be green **apart** from just these
// queries). Making it anonymous avoids hashing the result, which
// queries). Making it no_hash avoids hashing the result, which
// may save a bit of time.
anon
no_hash
no_force
desc { "erasing regions from `{:?}`", ty }
}
Expand Down
10 changes: 8 additions & 2 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2750,8 +2750,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>])
-> &'tcx List<ExistentialPredicate<'tcx>> {
assert!(!eps.is_empty());
assert!(eps.windows(2).all(|w| w[0].stable_cmp(self, &w[1]) != Ordering::Greater));
if cfg!(debug_assertions) {
assert!(!eps.is_empty());
self.dep_graph.with_ignore(|| {
assert!(eps.windows(2).all(|w| {
w[0].stable_cmp(self, &w[1]) != Ordering::Greater
}));
});
}
self._intern_existential_predicates(eps)
}

Expand Down
16 changes: 0 additions & 16 deletions src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,22 +366,6 @@ impl<'sess> OnDiskCache<'sess> {
"query result")
}

/// Stores a diagnostic emitted during computation of an anonymous query.
/// Since many anonymous queries can share the same `DepNode`, we aggregate
/// them -- as opposed to regular queries where we assume that there is a
/// 1:1 relationship between query-key and `DepNode`.
#[inline(never)]
#[cold]
pub fn store_diagnostics_for_anon_node(&self,
dep_node_index: DepNodeIndex,
diagnostics: ThinVec<Diagnostic>) {
let mut current_diagnostics = self.current_diagnostics.borrow_mut();

let x = current_diagnostics.entry(dep_node_index).or_insert(Vec::new());

x.extend(Into::<Vec<_>>::into(diagnostics));
}

fn load_indexed<'tcx, T>(&self,
tcx: TyCtxt<'_, 'tcx, 'tcx>,
dep_node_index: SerializedDepNodeIndex,
Expand Down
29 changes: 0 additions & 29 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,33 +387,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

let dep_node = Q::to_dep_node(self, &key);

if dep_node.kind.is_anon() {
profq_msg!(self, ProfileQueriesMsg::ProviderBegin);
self.sess.profiler(|p| p.start_query(Q::NAME));

let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
self.start_query(job.job.clone(), diagnostics, |tcx| {
tcx.dep_graph.with_anon_task(dep_node.kind, || {
Q::compute(tcx.global_tcx(), key)
})
})
});

self.sess.profiler(|p| p.end_query(Q::NAME));
profq_msg!(self, ProfileQueriesMsg::ProviderEnd);

self.dep_graph.read_index(dep_node_index);

if unlikely!(!diagnostics.is_empty()) {
self.queries.on_disk_cache
.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
}

job.complete(&result, dep_node_index);

return result;
}

if !dep_node.kind.is_eval_always() {
// The diagnostics for this query will be
// promoted to the current session during
Expand Down Expand Up @@ -606,8 +579,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
return;
}

// Ensuring an anonymous query makes no sense
assert!(!dep_node.kind.is_anon());
if self.dep_graph.try_mark_green_and_read(self, &dep_node).is_none() {
// A None return from `try_mark_green_and_read` means that this is either
// a new dep node or that the dep node has already been marked red.
Expand Down
20 changes: 0 additions & 20 deletions src/librustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ enum QueryModifier {
/// Don't force the query
NoForce,

/// Generate a dep node based on the dependencies of the query
Anon,

// Always evaluate the query, ignoring its depdendencies
EvalAlways,
}
Expand Down Expand Up @@ -110,8 +107,6 @@ impl Parse for QueryModifier {
Ok(QueryModifier::NoHash)
} else if modifier == "no_force" {
Ok(QueryModifier::NoForce)
} else if modifier == "anon" {
Ok(QueryModifier::Anon)
} else if modifier == "eval_always" {
Ok(QueryModifier::EvalAlways)
} else {
Expand Down Expand Up @@ -221,9 +216,6 @@ struct QueryModifiers {
/// Don't force the query
no_force: bool,

/// Generate a dep node based on the dependencies of the query
anon: bool,

// Always evaluate the query, ignoring its depdendencies
eval_always: bool,
}
Expand All @@ -237,7 +229,6 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
let mut cycle_delay_bug = false;
let mut no_hash = false;
let mut no_force = false;
let mut anon = false;
let mut eval_always = false;
for modifier in query.modifiers.0.drain(..) {
match modifier {
Expand Down Expand Up @@ -283,12 +274,6 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
}
no_force = true;
}
QueryModifier::Anon => {
if anon {
panic!("duplicate modifier `anon` for query `{}`", query.name);
}
anon = true;
}
QueryModifier::EvalAlways => {
if eval_always {
panic!("duplicate modifier `eval_always` for query `{}`", query.name);
Expand All @@ -305,7 +290,6 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
cycle_delay_bug,
no_hash,
no_force,
anon,
eval_always,
}
}
Expand Down Expand Up @@ -437,10 +421,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {

let mut attributes = Vec::new();

// Pass on the anon modifier
if modifiers.anon {
attributes.push(quote! { anon });
};
// Pass on the eval_always modifier
if modifiers.eval_always {
attributes.push(quote! { eval_always });
Expand Down