]> git.lizzy.rs Git - rust.git/commitdiff
Deduplicate const eval error spans for better output
authorEsteban Küber <esteban@kuber.com.ar>
Mon, 11 Mar 2019 16:43:05 +0000 (09:43 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Sat, 23 Mar 2019 20:05:30 +0000 (13:05 -0700)
src/librustc/mir/interpret/error.rs
src/test/ui/consts/const-eval/promoted_errors.stderr
src/test/ui/consts/dangling-alloc-id-ice.stderr
src/test/ui/consts/dangling_raw_ptr.stderr

index 5cd1ced20220ae5e7a1aa28db45a87902c1e7322..fc04c7672db68757380b368122ad5aac323db927 100644 (file)
@@ -116,7 +116,9 @@ pub fn report_as_lint(&self,
                     // 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();
index ca870c649f5b23f5cdc4456cc79ab64c4c988006..c9d5ede61ade47c89e8fe420755173b9c80c3ea4 100644 (file)
@@ -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
 
index ba640b90e7d79a4c2ce05e0ac8cdf7ed154fa490..87f84480bf66b93313f4088ddd7ef677c3446885 100644 (file)
@@ -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
 
index cedcbf819e2d82a1d7124c5adc5a108a5484bf65..0168c08f011d4c49426ce4b38dccf3be86f582dd 100644 (file)
@@ -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