about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-03-11 09:43:05 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-03-23 13:05:30 -0700
commitce90db1ff103224bc2a63e7a9ac503259fbe7eb0 (patch)
treef9f436325d888c65d2062d687d1c9f2b350c5b38 /src
parent44730271f79e74def2dc09315268df64f3ea6271 (diff)
downloadrust-ce90db1ff103224bc2a63e7a9ac503259fbe7eb0.tar.gz
rust-ce90db1ff103224bc2a63e7a9ac503259fbe7eb0.zip
Deduplicate const eval error spans for better output
Diffstat (limited to 'src')
-rw-r--r--src/librustc/mir/interpret/error.rs4
-rw-r--r--src/test/ui/consts/const-eval/promoted_errors.stderr8
-rw-r--r--src/test/ui/consts/dangling-alloc-id-ice.stderr16
-rw-r--r--src/test/ui/consts/dangling_raw_ptr.stderr16
4 files changed, 15 insertions, 29 deletions
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index 5cd1ced2022..fc04c7672db 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -116,7 +116,9 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
                     // point to the `const` statement as a secondary span
                     // they don't have any label
                     for sp in primary_spans {
-                        lint.span_label(sp, "");
+                        if sp != span {
+                            lint.span_label(sp, "");
+                        }
                     }
                 }
                 lint.emit();
diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr
index ca870c649f5..c9d5ede61ad 100644
--- a/src/test/ui/consts/const-eval/promoted_errors.stderr
+++ b/src/test/ui/consts/const-eval/promoted_errors.stderr
@@ -50,15 +50,11 @@ warning: reaching this expression at runtime will panic or abort
   --> $DIR/promoted_errors.rs:14:20
    |
 LL |     println!("{}", 1/(false as u32));
-   |                    ^^^^^^^^^^^^^^^^
-   |                    |
-   |                    attempt to divide by zero
+   |                    ^^^^^^^^^^^^^^^^ attempt to divide by zero
 
 warning: reaching this expression at runtime will panic or abort
   --> $DIR/promoted_errors.rs:9:20
    |
 LL |     println!("{}", 1/(1-1));
-   |                    ^^^^^^^
-   |                    |
-   |                    attempt to divide by zero
+   |                    ^^^^^^^ attempt to divide by zero
 
diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr
index ba640b90e7d..87f84480bf6 100644
--- a/src/test/ui/consts/dangling-alloc-id-ice.stderr
+++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr
@@ -1,17 +1,11 @@
 error: any use of this value will cause an error
   --> $DIR/dangling-alloc-id-ice.rs:8:1
    |
-LL |    const FOO: &() = {
-   |   _^
-   |  |_|
-   | ||
-LL | ||     let y = ();
-LL | ||     unsafe { Foo { y: &y }.long_live_the_unit }
-LL | || };
-   | ||  ^
-   | ||__|
-   | |___type validation failed: encountered dangling pointer in final constant
-   | 
+LL | / const FOO: &() = {
+LL | |     let y = ();
+LL | |     unsafe { Foo { y: &y }.long_live_the_unit }
+LL | | };
+   | |__^ type validation failed: encountered dangling pointer in final constant
    |
    = note: #[deny(const_err)] on by default
 
diff --git a/src/test/ui/consts/dangling_raw_ptr.stderr b/src/test/ui/consts/dangling_raw_ptr.stderr
index cedcbf819e2..0168c08f011 100644
--- a/src/test/ui/consts/dangling_raw_ptr.stderr
+++ b/src/test/ui/consts/dangling_raw_ptr.stderr
@@ -1,17 +1,11 @@
 error: any use of this value will cause an error
   --> $DIR/dangling_raw_ptr.rs:1:1
    |
-LL |    const FOO: *const u32 = {
-   |   _^
-   |  |_|
-   | ||
-LL | ||     let x = 42;
-LL | ||     &x
-LL | || };
-   | ||  ^
-   | ||__|
-   | |___type validation failed: encountered dangling pointer in final constant
-   | 
+LL | / const FOO: *const u32 = {
+LL | |     let x = 42;
+LL | |     &x
+LL | | };
+   | |__^ type validation failed: encountered dangling pointer in final constant
    |
    = note: #[deny(const_err)] on by default