add second message for livedrop errors
This commit is contained in:
parent
f315c35a77
commit
e75fbaee45
3 changed files with 13 additions and 7 deletions
|
|
@ -160,17 +160,20 @@ pub struct InlineAsm;
|
|||
impl NonConstOp for InlineAsm {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LiveDrop;
|
||||
pub struct LiveDrop(pub Option<Span>);
|
||||
impl NonConstOp for LiveDrop {
|
||||
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
|
||||
struct_span_err!(
|
||||
let mut diagnostic = struct_span_err!(
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
E0493,
|
||||
"destructors cannot be evaluated at compile-time"
|
||||
)
|
||||
.span_label(span, format!("{}s cannot evaluate destructors", ccx.const_kind()))
|
||||
.emit();
|
||||
);
|
||||
diagnostic.span_label(span, format!("{}s cannot evaluate destructors", ccx.const_kind()));
|
||||
if let Some(span) = self.0 {
|
||||
diagnostic.span_label(span, "value is dropped here");
|
||||
}
|
||||
diagnostic.emit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ impl std::ops::Deref for CheckLiveDrops<'mir, 'tcx> {
|
|||
|
||||
impl CheckLiveDrops<'mir, 'tcx> {
|
||||
fn check_live_drop(&self, span: Span) {
|
||||
ops::non_const(self.ccx, ops::LiveDrop, span);
|
||||
ops::non_const(self.ccx, ops::LiveDrop(None), span);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -588,7 +588,10 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
|
|||
};
|
||||
|
||||
if needs_drop {
|
||||
self.check_op_spanned(ops::LiveDrop, err_span);
|
||||
self.check_op_spanned(
|
||||
ops::LiveDrop(Some(terminator.source_info.span)),
|
||||
err_span,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue