Skip to content

Commit 66c9a59

Browse files
committed
don't return an Option from try_find_dep_kind
1 parent 45f1981 commit 66c9a59

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

compiler/rustc_query_impl/src/plumbing.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,16 @@ impl QueryContext for QueryCtxt<'_> {
153153
}
154154

155155
fn depth_limit_error(self, job: QueryJobId) {
156-
let mut span = None;
157-
let mut note = None;
158-
if let Some((info, depth)) = job.try_find_dep_kind_root(self.collect_active_jobs()) {
159-
span = Some(info.job.span);
160-
note = Some(QueryOverflowNote { desc: info.query.description, depth });
161-
}
156+
let (info, depth) = job.find_dep_kind_root(self.collect_active_jobs());
162157

163158
let suggested_limit = match self.recursion_limit() {
164159
Limit(0) => Limit(2),
165160
limit => limit * 2,
166161
};
167162

168163
self.sess.dcx().emit_fatal(QueryOverflow {
169-
span,
170-
note,
164+
span: info.job.span,
165+
note: QueryOverflowNote { desc: info.query.description, depth },
171166
suggested_limit,
172167
crate_name: self.crate_name(LOCAL_CRATE),
173168
});

compiler/rustc_query_system/src/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ pub(crate) struct IncrementCompilation {
8282
#[diag(query_system_query_overflow)]
8383
pub struct QueryOverflow {
8484
#[primary_span]
85-
pub span: Option<Span>,
85+
pub span: Span,
8686
#[subdiagnostic]
87-
pub note: Option<QueryOverflowNote>,
87+
pub note: QueryOverflowNote,
8888
pub suggested_limit: Limit,
8989
pub crate_name: Symbol,
9090
}

compiler/rustc_query_system/src/query/job.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,18 @@ impl QueryJobId {
136136

137137
#[cold]
138138
#[inline(never)]
139-
pub fn try_find_dep_kind_root(&self, query_map: QueryMap) -> Option<(QueryJobInfo, usize)> {
139+
pub fn find_dep_kind_root(&self, query_map: QueryMap) -> (QueryJobInfo, usize) {
140140
let mut depth = 1;
141141
let info = query_map.get(&self).unwrap();
142142
let dep_kind = info.query.dep_kind;
143143
let mut current_id = info.job.parent;
144-
let mut last_layout = Some((info.clone(), depth));
144+
let mut last_layout = (info.clone(), depth);
145145

146146
while let Some(id) = current_id {
147147
let info = query_map.get(&id).unwrap();
148148
if info.query.dep_kind == dep_kind {
149149
depth += 1;
150-
last_layout = Some((info.clone(), depth));
150+
last_layout = (info.clone(), depth);
151151
}
152152
current_id = info.job.parent;
153153
}

0 commit comments

Comments
 (0)