Skip to content

Commit e4edc16

Browse files
Give name to extra Span in LiveDrop error
1 parent c3607bd commit e4edc16

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

compiler/rustc_mir/src/transform/check_consts/ops.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ pub struct InlineAsm;
148148
impl NonConstOp for InlineAsm {}
149149

150150
#[derive(Debug)]
151-
pub struct LiveDrop(pub Option<Span>);
151+
pub struct LiveDrop {
152+
pub dropped_at: Option<Span>,
153+
}
152154
impl NonConstOp for LiveDrop {
153155
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
154156
let mut diagnostic = struct_span_err!(
@@ -158,7 +160,7 @@ impl NonConstOp for LiveDrop {
158160
"destructors cannot be evaluated at compile-time"
159161
);
160162
diagnostic.span_label(span, format!("{}s cannot evaluate destructors", ccx.const_kind()));
161-
if let Some(span) = self.0 {
163+
if let Some(span) = self.dropped_at {
162164
diagnostic.span_label(span, "value is dropped here");
163165
}
164166
diagnostic.emit();

compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl std::ops::Deref for CheckLiveDrops<'mir, 'tcx> {
5252

5353
impl CheckLiveDrops<'mir, 'tcx> {
5454
fn check_live_drop(&self, span: Span) {
55-
ops::non_const(self.ccx, ops::LiveDrop(None), span);
55+
ops::non_const(self.ccx, ops::LiveDrop { dropped_at: None }, span);
5656
}
5757
}
5858

compiler/rustc_mir/src/transform/check_consts/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
576576

577577
if needs_drop {
578578
self.check_op_spanned(
579-
ops::LiveDrop(Some(terminator.source_info.span)),
579+
ops::LiveDrop { dropped_at: Some(terminator.source_info.span) },
580580
err_span,
581581
);
582582
}

0 commit comments

Comments
 (0)