Skip to content
Open
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
13 changes: 13 additions & 0 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ pub struct CycleError<I = QueryStackFrameExtra> {
}

impl<'tcx> CycleError<QueryStackDeferred<'tcx>> {
pub fn is_similar_to(&self, other: &Self) -> bool {
(match (&self.usage, &other.usage) {
(None, None) => true,
(None, Some(_)) | (Some(_), None) => false,
(Some((s1, f1)), Some((s2, f2))) => s1 == s2 && f1.is_similar_to(&f2),
}) && self.cycle.len() == other.cycle.len()
&& self
.cycle
.iter()
.zip(&other.cycle)
.all(|(q1, q2)| q1.span == q2.span && q1.frame.is_similar_to(&q2.frame))
}

pub fn lift(&self) -> CycleError<QueryStackFrameExtra> {
CycleError {
usage: self.usage.as_ref().map(|(span, frame)| (*span, frame.lift())),
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/query/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ impl<'tcx> QueryStackFrame<QueryStackDeferred<'tcx>> {
def_id_for_ty_in_cycle: self.def_id_for_ty_in_cycle,
}
}

pub fn is_similar_to(&self, other: &Self) -> bool {
self.dep_kind == other.dep_kind
&& self.def_id == other.def_id
&& self.def_id_for_ty_in_cycle == other.def_id_for_ty_in_cycle
}
}

#[derive(Clone, Debug)]
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_query_impl/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ fn cycle_error<'tcx, C: QueryCache>(
.ok()
.expect("failed to collect active queries");

let error = find_cycle_in_stack(try_execute, job_map, &current_query_job(tcx), span);
let error = find_cycle_in_stack(try_execute, &job_map, current_query_job(tcx), span)
.expect("did not find a cycle");
(mk_cycle(query, tcx, error.lift()), None)
}

Expand Down
Loading
Loading