Skip to content

Commit 7c65c59

Browse files
committed
review comment: Remove FrameInfo.is_last
1 parent b4308d1 commit 7c65c59

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ pub fn get_span_and_frames<'tcx>(
8989
};
9090

9191
let mut last_frame: Option<errors::FrameNote> = None;
92-
for frame_info in &stacktrace {
93-
let frame = frame_info.as_note(*tcx);
92+
for (i, frame_info) in stacktrace.iter().enumerate() {
93+
let frame = frame_info.as_note(*tcx, i + 1 == stacktrace.len());
9494
match last_frame.as_mut() {
9595
Some(last_frame)
9696
if last_frame.span == frame.span

compiler/rustc_const_eval/src/interpret/stack.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ impl<'tcx, Prov: Provenance> LocalState<'tcx, Prov> {
209209
pub struct FrameInfo<'tcx> {
210210
pub instance: ty::Instance<'tcx>,
211211
pub span: Span,
212-
pub is_last: bool,
213212
}
214213

215214
// FIXME: only used by miri, should be removed once translatable.
@@ -229,28 +228,22 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
229228
}
230229

231230
impl<'tcx> FrameInfo<'tcx> {
232-
pub fn as_note(&self, tcx: TyCtxt<'tcx>) -> errors::FrameNote {
231+
pub fn as_note(&self, tcx: TyCtxt<'tcx>, is_last: bool) -> errors::FrameNote {
233232
let span = self.span;
234233
if tcx.def_key(self.instance.def_id()).disambiguated_data.data == DefPathData::Closure {
235234
errors::FrameNote {
236235
where_: "closure",
237236
span,
238237
instance: String::new(),
239238
times: 0,
240-
is_last: self.is_last,
239+
is_last,
241240
}
242241
} else {
243242
let instance = format!("{}", self.instance);
244243
// Note: this triggers a `must_produce_diag` state, which means that if we ever get
245244
// here we must emit a diagnostic. We should never display a `FrameInfo` unless we
246245
// actually want to emit a warning or error to the user.
247-
errors::FrameNote {
248-
where_: "instance",
249-
span,
250-
instance,
251-
times: 0,
252-
is_last: self.is_last,
253-
}
246+
errors::FrameNote { where_: "instance", span, instance, times: 0, is_last }
254247
}
255248
}
256249
}
@@ -335,15 +328,15 @@ impl<'tcx, Prov: Provenance, Extra> Frame<'tcx, Prov, Extra> {
335328
let mir::SourceInfo { mut span, scope } = *frame.body.source_info(loc);
336329
let mut scope_data = &frame.body.source_scopes[scope];
337330
while let Some((instance, call_span)) = scope_data.inlined {
338-
frames.push(FrameInfo { span, instance, is_last: false });
331+
frames.push(FrameInfo { span, instance });
339332
span = call_span;
340333
scope_data = &frame.body.source_scopes[scope_data.parent_scope.unwrap()];
341334
}
342335
span
343336
}
344337
Right(span) => span,
345338
};
346-
frames.push(FrameInfo { span, instance: frame.instance, is_last: false });
339+
frames.push(FrameInfo { span, instance: frame.instance });
347340
}
348341
trace!("generate stacktrace: {:#?}", frames);
349342
frames

0 commit comments

Comments
 (0)