Skip to content

Commit 4ff360e

Browse files
committed
Rename some query-related things.
Various `QueryStackFrame` variables are called `query`; `frame` is a better name. And various `QueryInfo` variables are called `frame`; `info` is a better name. This eliminates some confusing `query.query()` occurrences, which is a good sign, and some `frame.query` occurrences become `info.frame`.
1 parent cd1c773 commit 4ff360e

4 files changed

Lines changed: 47 additions & 47 deletions

File tree

compiler/rustc_middle/src/values.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::Binder<'_, ty::FnSig<'_>> {
5050
) -> Self {
5151
let err = Ty::new_error(tcx, guar);
5252

53-
let arity = if let Some(frame) = cycle_error.cycle.get(0)
54-
&& frame.query.dep_kind == dep_kinds::fn_sig
55-
&& let Some(def_id) = frame.query.def_id
53+
let arity = if let Some(info) = cycle_error.cycle.get(0)
54+
&& info.frame.dep_kind == dep_kinds::fn_sig
55+
&& let Some(def_id) = info.frame.def_id
5656
&& let Some(node) = tcx.hir_get_if_local(def_id)
5757
&& let Some(sig) = node.fn_sig()
5858
{
@@ -85,10 +85,10 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
8585
let mut item_and_field_ids = Vec::new();
8686
let mut representable_ids = FxHashSet::default();
8787
for info in &cycle_error.cycle {
88-
if info.query.dep_kind == dep_kinds::representability
89-
&& let Some(field_id) = info.query.def_id
88+
if info.frame.dep_kind == dep_kinds::representability
89+
&& let Some(field_id) = info.frame.def_id
9090
&& let Some(field_id) = field_id.as_local()
91-
&& let Some(DefKind::Field) = info.query.info.def_kind
91+
&& let Some(DefKind::Field) = info.frame.info.def_kind
9292
{
9393
let parent_id = tcx.parent(field_id.to_def_id());
9494
let item_id = match tcx.def_kind(parent_id) {
@@ -99,8 +99,8 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
9999
}
100100
}
101101
for info in &cycle_error.cycle {
102-
if info.query.dep_kind == dep_kinds::representability_adt_ty
103-
&& let Some(def_id) = info.query.def_id_for_ty_in_cycle
102+
if info.frame.dep_kind == dep_kinds::representability_adt_ty
103+
&& let Some(def_id) = info.frame.def_id_for_ty_in_cycle
104104
&& let Some(def_id) = def_id.as_local()
105105
&& !item_and_field_ids.iter().any(|&(id, _)| id == def_id)
106106
{
@@ -141,9 +141,9 @@ impl<'tcx> Value<TyCtxt<'tcx>> for &[ty::Variance] {
141141
search_for_cycle_permutation(
142142
&cycle_error.cycle,
143143
|cycle| {
144-
if let Some(frame) = cycle.get(0)
145-
&& frame.query.dep_kind == dep_kinds::variances_of
146-
&& let Some(def_id) = frame.query.def_id
144+
if let Some(info) = cycle.get(0)
145+
&& info.frame.dep_kind == dep_kinds::variances_of
146+
&& let Some(def_id) = info.frame.def_id
147147
{
148148
let n = tcx.generics_of(def_id).own_params.len();
149149
ControlFlow::Break(vec![ty::Bivariant; n].leak())
@@ -189,8 +189,8 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>>
189189
let diag = search_for_cycle_permutation(
190190
&cycle_error.cycle,
191191
|cycle| {
192-
if cycle[0].query.dep_kind == dep_kinds::layout_of
193-
&& let Some(def_id) = cycle[0].query.def_id_for_ty_in_cycle
192+
if cycle[0].frame.dep_kind == dep_kinds::layout_of
193+
&& let Some(def_id) = cycle[0].frame.def_id_for_ty_in_cycle
194194
&& let Some(def_id) = def_id.as_local()
195195
&& let def_kind = tcx.def_kind(def_id)
196196
&& matches!(def_kind, DefKind::Closure)
@@ -213,18 +213,18 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>>
213213
tcx.def_kind_descr_article(def_kind, def_id.to_def_id()),
214214
tcx.def_kind_descr(def_kind, def_id.to_def_id()),
215215
);
216-
for (i, frame) in cycle.iter().enumerate() {
217-
if frame.query.dep_kind != dep_kinds::layout_of {
216+
for (i, info) in cycle.iter().enumerate() {
217+
if info.frame.dep_kind != dep_kinds::layout_of {
218218
continue;
219219
}
220-
let Some(frame_def_id) = frame.query.def_id_for_ty_in_cycle else {
220+
let Some(frame_def_id) = info.frame.def_id_for_ty_in_cycle else {
221221
continue;
222222
};
223223
let Some(frame_coroutine_kind) = tcx.coroutine_kind(frame_def_id) else {
224224
continue;
225225
};
226226
let frame_span =
227-
frame.query.info.default_span(cycle[(i + 1) % cycle.len()].span);
227+
info.frame.info.default_span(cycle[(i + 1) % cycle.len()].span);
228228
if frame_span.is_dummy() {
229229
continue;
230230
}

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'tcx> QueryContext<'tcx> for QueryCtxt<'tcx> {
167167

168168
self.tcx.sess.dcx().emit_fatal(QueryOverflow {
169169
span: info.job.span,
170-
note: QueryOverflowNote { desc: info.query.info.extract().description, depth },
170+
note: QueryOverflowNote { desc: info.frame.info.extract().description, depth },
171171
suggested_limit,
172172
crate_name: self.tcx.crate_name(LOCAL_CRATE),
173173
});
@@ -728,14 +728,14 @@ macro_rules! define_queries {
728728
qmap: &mut QueryMap<'tcx>,
729729
require_complete: bool,
730730
) -> Option<()> {
731-
let make_query = |tcx, key| {
731+
let make_frame = |tcx, key| {
732732
let kind = rustc_middle::dep_graph::dep_kinds::$name;
733733
let name = stringify!($name);
734734
$crate::plumbing::create_query_frame(tcx, rustc_middle::query::descs::$name, key, kind, name)
735735
};
736736
let res = tcx.query_system.states.$name.collect_active_jobs(
737737
tcx,
738-
make_query,
738+
make_frame,
739739
qmap,
740740
require_complete,
741741
);

compiler/rustc_query_system/src/query/job.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ use crate::query::{QueryContext, QueryStackFrame};
2323
pub struct QueryInfo<I> {
2424
/// The span corresponding to the reason for which this query was required.
2525
pub span: Span,
26-
pub query: QueryStackFrame<I>,
26+
pub frame: QueryStackFrame<I>,
2727
}
2828

2929
impl<'tcx> QueryInfo<QueryStackDeferred<'tcx>> {
3030
pub(crate) fn lift(&self) -> QueryInfo<QueryStackFrameExtra> {
31-
QueryInfo { span: self.span, query: self.query.lift() }
31+
QueryInfo { span: self.span, frame: self.frame.lift() }
3232
}
3333
}
3434

@@ -39,8 +39,8 @@ pub type QueryMap<'tcx> = FxHashMap<QueryJobId, QueryJobInfo<'tcx>>;
3939
pub struct QueryJobId(pub NonZero<u64>);
4040

4141
impl QueryJobId {
42-
fn query<'a, 'tcx>(self, map: &'a QueryMap<'tcx>) -> QueryStackFrame<QueryStackDeferred<'tcx>> {
43-
map.get(&self).unwrap().query.clone()
42+
fn frame<'a, 'tcx>(self, map: &'a QueryMap<'tcx>) -> QueryStackFrame<QueryStackDeferred<'tcx>> {
43+
map.get(&self).unwrap().frame.clone()
4444
}
4545

4646
fn span<'a, 'tcx>(self, map: &'a QueryMap<'tcx>) -> Span {
@@ -58,7 +58,7 @@ impl QueryJobId {
5858

5959
#[derive(Clone, Debug)]
6060
pub struct QueryJobInfo<'tcx> {
61-
pub query: QueryStackFrame<QueryStackDeferred<'tcx>>,
61+
pub frame: QueryStackFrame<QueryStackDeferred<'tcx>>,
6262
pub job: QueryJob<'tcx>,
6363
}
6464

@@ -122,7 +122,7 @@ impl QueryJobId {
122122

123123
while let Some(job) = current_job {
124124
let info = query_map.get(&job).unwrap();
125-
cycle.push(QueryInfo { span: info.job.span, query: info.query.clone() });
125+
cycle.push(QueryInfo { span: info.job.span, frame: info.frame.clone() });
126126

127127
if job == *self {
128128
cycle.reverse();
@@ -137,7 +137,7 @@ impl QueryJobId {
137137
.job
138138
.parent
139139
.as_ref()
140-
.map(|parent| (info.job.span, parent.query(&query_map)));
140+
.map(|parent| (info.job.span, parent.frame(&query_map)));
141141
return CycleError { usage, cycle };
142142
}
143143

@@ -155,13 +155,13 @@ impl QueryJobId {
155155
) -> (QueryJobInfo<'tcx>, usize) {
156156
let mut depth = 1;
157157
let info = query_map.get(&self).unwrap();
158-
let dep_kind = info.query.dep_kind;
158+
let dep_kind = info.frame.dep_kind;
159159
let mut current_id = info.job.parent;
160160
let mut last_layout = (info.clone(), depth);
161161

162162
while let Some(id) = current_id {
163163
let info = query_map.get(&id).unwrap();
164-
if info.query.dep_kind == dep_kind {
164+
if info.frame.dep_kind == dep_kind {
165165
depth += 1;
166166
last_layout = (info.clone(), depth);
167167
}
@@ -386,7 +386,7 @@ where
386386
.iter()
387387
.min_by_key(|v| {
388388
let (span, query) = f(v);
389-
let hash = query.query(query_map).hash;
389+
let hash = query.frame(query_map).hash;
390390
// Prefer entry points which have valid spans for nicer error messages
391391
// We add an integer to the tuple ensuring that entry points
392392
// with valid spans are picked first
@@ -470,14 +470,14 @@ fn remove_cycle<'tcx>(
470470
stack.rotate_left(pos);
471471
}
472472

473-
let usage = usage.as_ref().map(|(span, query)| (*span, query.query(query_map)));
473+
let usage = usage.as_ref().map(|(span, query)| (*span, query.frame(query_map)));
474474

475475
// Create the cycle error
476476
let error = CycleError {
477477
usage,
478478
cycle: stack
479479
.iter()
480-
.map(|&(s, ref q)| QueryInfo { span: s, query: q.query(query_map) })
480+
.map(|&(s, ref q)| QueryInfo { span: s, frame: q.frame(query_map) })
481481
.collect(),
482482
};
483483

@@ -556,17 +556,17 @@ pub fn report_cycle<'a>(
556556
) -> Diag<'a> {
557557
assert!(!stack.is_empty());
558558

559-
let span = stack[0].query.info.default_span(stack[1 % stack.len()].span);
559+
let span = stack[0].frame.info.default_span(stack[1 % stack.len()].span);
560560

561561
let mut cycle_stack = Vec::new();
562562

563563
use crate::error::StackCount;
564564
let stack_count = if stack.len() == 1 { StackCount::Single } else { StackCount::Multiple };
565565

566566
for i in 1..stack.len() {
567-
let query = &stack[i].query;
568-
let span = query.info.default_span(stack[(i + 1) % stack.len()].span);
569-
cycle_stack.push(CycleStack { span, desc: query.info.description.to_owned() });
567+
let frame = &stack[i].frame;
568+
let span = frame.info.default_span(stack[(i + 1) % stack.len()].span);
569+
cycle_stack.push(CycleStack { span, desc: frame.info.description.to_owned() });
570570
}
571571

572572
let mut cycle_usage = None;
@@ -578,9 +578,9 @@ pub fn report_cycle<'a>(
578578
}
579579

580580
let alias =
581-
if stack.iter().all(|entry| matches!(entry.query.info.def_kind, Some(DefKind::TyAlias))) {
581+
if stack.iter().all(|entry| matches!(entry.frame.info.def_kind, Some(DefKind::TyAlias))) {
582582
Some(crate::error::Alias::Ty)
583-
} else if stack.iter().all(|entry| entry.query.info.def_kind == Some(DefKind::TraitAlias)) {
583+
} else if stack.iter().all(|entry| entry.frame.info.def_kind == Some(DefKind::TraitAlias)) {
584584
Some(crate::error::Alias::Trait)
585585
} else {
586586
None
@@ -589,7 +589,7 @@ pub fn report_cycle<'a>(
589589
let cycle_diag = crate::error::Cycle {
590590
span,
591591
cycle_stack,
592-
stack_bottom: stack[0].query.info.description.to_owned(),
592+
stack_bottom: stack[0].frame.info.description.to_owned(),
593593
alias,
594594
cycle_usage,
595595
stack_count,
@@ -625,12 +625,12 @@ pub fn print_query_stack<'tcx, Qcx: QueryContext<'tcx>>(
625625
let Some(query_info) = query_map.get(&query) else {
626626
break;
627627
};
628-
let query_extra = query_info.query.info.extract();
628+
let query_extra = query_info.frame.info.extract();
629629
if Some(count_printed) < limit_frames || limit_frames.is_none() {
630630
// Only print to stderr as many stack frames as `num_frames` when present.
631631
dcx.struct_failure_note(format!(
632632
"#{} [{:?}] {}",
633-
count_printed, query_info.query.dep_kind, query_extra.description
633+
count_printed, query_info.frame.dep_kind, query_extra.description
634634
))
635635
.with_span(query_info.job.span)
636636
.emit();
@@ -642,7 +642,7 @@ pub fn print_query_stack<'tcx, Qcx: QueryContext<'tcx>>(
642642
file,
643643
"#{} [{}] {}",
644644
count_total,
645-
qcx.dep_context().dep_kind_vtable(query_info.query.dep_kind).name,
645+
qcx.dep_context().dep_kind_vtable(query_info.frame.dep_kind).name,
646646
query_extra.description
647647
);
648648
}

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ where
8282
pub fn collect_active_jobs<Qcx: Copy>(
8383
&self,
8484
qcx: Qcx,
85-
make_query: fn(Qcx, K) -> QueryStackFrame<QueryStackDeferred<'tcx>>,
85+
make_frame: fn(Qcx, K) -> QueryStackFrame<QueryStackDeferred<'tcx>>,
8686
jobs: &mut QueryMap<'tcx>,
8787
require_complete: bool,
8888
) -> Option<()> {
@@ -108,11 +108,11 @@ where
108108
}
109109
}
110110

111-
// Call `make_query` while we're not holding a `self.active` lock as `make_query` may call
111+
// Call `make_frame` while we're not holding a `self.active` lock as `make_frame` may call
112112
// queries leading to a deadlock.
113113
for (key, job) in active {
114-
let query = make_query(qcx, key);
115-
jobs.insert(job.id, QueryJobInfo { query, job });
114+
let frame = make_frame(qcx, key);
115+
jobs.insert(job.id, QueryJobInfo { frame, job });
116116
}
117117

118118
Some(())
@@ -170,7 +170,7 @@ where
170170
}
171171
CycleErrorHandling::Stash => {
172172
let guar = if let Some(root) = cycle_error.cycle.first()
173-
&& let Some(span) = root.query.info.span
173+
&& let Some(span) = root.frame.info.span
174174
{
175175
error.stash(span, StashKey::Cycle).unwrap()
176176
} else {

0 commit comments

Comments
 (0)