about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Poveda <git@christianpoveda.xyz>2020-06-19 14:46:04 -0500
committerChristian Poveda <git@christianpoveda.xyz>2020-06-19 14:46:04 -0500
commite75fbaee45a24816e8e2b27cd9f8896766aee6e3 (patch)
treee88da6044421afa60d4a9c337eefe7c445546de2
parentf315c35a77e40bd11ce81fedc0556be0f410bbf4 (diff)
downloadrust-e75fbaee45a24816e8e2b27cd9f8896766aee6e3.tar.gz
rust-e75fbaee45a24816e8e2b27cd9f8896766aee6e3.zip
add second message for livedrop errors
-rw-r--r--src/librustc_mir/transform/check_consts/ops.rs13
-rw-r--r--src/librustc_mir/transform/check_consts/post_drop_elaboration.rs2
-rw-r--r--src/librustc_mir/transform/check_consts/validation.rs5
3 files changed, 13 insertions, 7 deletions
diff --git a/src/librustc_mir/transform/check_consts/ops.rs b/src/librustc_mir/transform/check_consts/ops.rs
index d5059c98c95..7791ae7fa12 100644
--- a/src/librustc_mir/transform/check_consts/ops.rs
+++ b/src/librustc_mir/transform/check_consts/ops.rs
@@ -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();
     }
 }
 
diff --git a/src/librustc_mir/transform/check_consts/post_drop_elaboration.rs b/src/librustc_mir/transform/check_consts/post_drop_elaboration.rs
index 226e0e2049e..b17ee53bda8 100644
--- a/src/librustc_mir/transform/check_consts/post_drop_elaboration.rs
+++ b/src/librustc_mir/transform/check_consts/post_drop_elaboration.rs
@@ -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);
     }
 }
 
diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs
index 428a74bcdcb..e7886c50b7a 100644
--- a/src/librustc_mir/transform/check_consts/validation.rs
+++ b/src/librustc_mir/transform/check_consts/validation.rs
@@ -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,
+                    );
                 }
             }