about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-05-30 09:54:05 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-06-15 09:06:57 -0700
commitbc1579060981b5e95a18409e876c92bf0c9307e6 (patch)
tree31709514a8f1ecfa6e1293da12f6894d05095f64
parente75588934c01d6bc9abb02979eb61168a7b5c598 (diff)
downloadrust-bc1579060981b5e95a18409e876c92bf0c9307e6.tar.gz
rust-bc1579060981b5e95a18409e876c92bf0c9307e6.zip
Tweak output for overlapping required/captured spans
-rw-r--r--src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs10
-rw-r--r--src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr28
-rw-r--r--src/test/ui/issues/issue-16922.stderr7
-rw-r--r--src/test/ui/regions/region-object-lifetime-in-coercion.stderr21
-rw-r--r--src/test/ui/regions/regions-close-object-into-object-2.stderr7
-rw-r--r--src/test/ui/regions/regions-close-object-into-object-4.stderr7
-rw-r--r--src/test/ui/regions/regions-proc-bound-capture.stderr7
7 files changed, 15 insertions, 72 deletions
diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs
index cc95441b68a..253057536f1 100644
--- a/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs
+++ b/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs
@@ -76,12 +76,10 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
                             //    |           |
                             //    |           this data with the anonymous lifetime `'_`...
                             //    |
-                            // note: ...is required to be `'static` by this
-                            //    |
-                            // LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) }
-                            //    |                                         ^^^^^^^^^^^
-                            err.span_label(sup_origin.span(), "...is captured here...");
-                            err.span_note(return_sp, "...and required to be `'static` by this");
+                            err.span_label(
+                                sup_origin.span(),
+                                "...is captured here with a `'static` requirement",
+                            );
                         } else if sup_origin.span() <= return_sp {
                             err.span_label(sup_origin.span(), "...is captured here...");
                             err.span_label(return_sp, "...and required to be `'static` by this");
diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
index 2da49379ea8..82e44cff9cc 100644
--- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
+++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
@@ -109,15 +109,10 @@ error: cannot infer an appropriate lifetime
   --> $DIR/must_outlive_least_region_or_bound.rs:18:50
    |
 LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) }
-   |               ----                               ^ ...is captured here...
+   |               ----                               ^ ...is captured here with a `'static` requirement
    |               |
    |               this data with the anonymous lifetime `'_`...
    |
-note: ...and required to be `'static` by this
-  --> $DIR/must_outlive_least_region_or_bound.rs:18:41
-   |
-LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) }
-   |                                         ^^^^^^^^^^^
 help: to permit non-static references in a trait object value, you can add an explicit bound for the anonymous lifetime `'_`
    |
 LL | fn elided3(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
@@ -127,15 +122,10 @@ error: cannot infer an appropriate lifetime
   --> $DIR/must_outlive_least_region_or_bound.rs:21:59
    |
 LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) }
-   |                     -------                               ^ ...is captured here...
+   |                     -------                               ^ ...is captured here with a `'static` requirement
    |                     |
    |                     this data with lifetime `'a`...
    |
-note: ...and required to be `'static` by this
-  --> $DIR/must_outlive_least_region_or_bound.rs:21:50
-   |
-LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) }
-   |                                                  ^^^^^^^^^^^
 help: to permit non-static references in a trait object value, you can add an explicit bound for lifetime `'a`
    |
 LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
@@ -145,15 +135,10 @@ error: cannot infer an appropriate lifetime
   --> $DIR/must_outlive_least_region_or_bound.rs:24:60
    |
 LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
-   |               ----                                         ^ ...is captured here...
+   |               ----                                         ^ ...is captured here with a `'static` requirement
    |               |
    |               this data with the anonymous lifetime `'_`...
    |
-note: ...and required to be `'static` by this
-  --> $DIR/must_outlive_least_region_or_bound.rs:24:51
-   |
-LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
-   |                                                   ^^^^^^^^^^^
 help: consider changing the trait object's explicit `'static` bound to the anonymous lifetime `'_`
    |
 LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
@@ -167,13 +152,8 @@ error: cannot infer an appropriate lifetime
   --> $DIR/must_outlive_least_region_or_bound.rs:27:69
    |
 LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
-   |                     ------- this data with lifetime `'a`...         ^ ...is captured here...
+   |                     ------- this data with lifetime `'a`...         ^ ...is captured here with a `'static` requirement
    |
-note: ...and required to be `'static` by this
-  --> $DIR/must_outlive_least_region_or_bound.rs:27:60
-   |
-LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
-   |                                                            ^^^^^^^^^^^
 help: consider changing the trait object's explicit `'static` bound to lifetime `'a`
    |
 LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
diff --git a/src/test/ui/issues/issue-16922.stderr b/src/test/ui/issues/issue-16922.stderr
index 6c0b26a86b6..a254343cd1b 100644
--- a/src/test/ui/issues/issue-16922.stderr
+++ b/src/test/ui/issues/issue-16922.stderr
@@ -4,13 +4,8 @@ error: cannot infer an appropriate lifetime
 LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> {
    |                       -- this data with the anonymous lifetime `'_`...
 LL |     Box::new(value) as Box<dyn Any>
-   |              ^^^^^ ...is captured here...
+   |              ^^^^^ ...is captured here with a `'static` requirement
    |
-note: ...and required to be `'static` by this
-  --> $DIR/issue-16922.rs:4:5
-   |
-LL |     Box::new(value) as Box<dyn Any>
-   |     ^^^^^^^^^^^^^^^
 help: to permit non-static references in a trait object value, you can add an explicit bound for the anonymous lifetime `'_`
    |
 LL | fn foo<T: Any>(value: &T) -> Box<dyn Any + '_> {
diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr
index b333c314c57..97d1f3579fc 100644
--- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr
+++ b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr
@@ -4,13 +4,8 @@ error: cannot infer an appropriate lifetime
 LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
    |         ----- this data with the anonymous lifetime `'_`...
 LL |     let x: Box<dyn Foo + 'static> = Box::new(v);
-   |                                              ^ ...is captured here...
+   |                                              ^ ...is captured here with a `'static` requirement
    |
-note: ...and required to be `'static` by this
-  --> $DIR/region-object-lifetime-in-coercion.rs:8:37
-   |
-LL |     let x: Box<dyn Foo + 'static> = Box::new(v);
-   |                                     ^^^^^^^^^^^
 help: consider changing the trait object's explicit `'static` bound to the anonymous lifetime `'_`
    |
 LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
@@ -26,13 +21,8 @@ error: cannot infer an appropriate lifetime
 LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
    |         ----- this data with the anonymous lifetime `'_`...
 LL |     Box::new(v)
-   |              ^ ...is captured here...
+   |              ^ ...is captured here with a `'static` requirement
    |
-note: ...and required to be `'static` by this
-  --> $DIR/region-object-lifetime-in-coercion.rs:13:5
-   |
-LL |     Box::new(v)
-   |     ^^^^^^^^^^^
 help: consider changing the trait object's explicit `'static` bound to the anonymous lifetime `'_`
    |
 LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
@@ -49,13 +39,8 @@ LL | fn c(v: &[u8]) -> Box<dyn Foo> {
    |         ----- this data with the anonymous lifetime `'_`...
 ...
 LL |     Box::new(v)
-   |              ^ ...is captured here...
-   |
-note: ...and required to be `'static` by this
-  --> $DIR/region-object-lifetime-in-coercion.rs:19:5
+   |              ^ ...is captured here with a `'static` requirement
    |
-LL |     Box::new(v)
-   |     ^^^^^^^^^^^
 help: to permit non-static references in a trait object value, you can add an explicit bound for the anonymous lifetime `'_`
    |
 LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> {
diff --git a/src/test/ui/regions/regions-close-object-into-object-2.stderr b/src/test/ui/regions/regions-close-object-into-object-2.stderr
index 3127ae65ace..3d707f2d999 100644
--- a/src/test/ui/regions/regions-close-object-into-object-2.stderr
+++ b/src/test/ui/regions/regions-close-object-into-object-2.stderr
@@ -4,13 +4,8 @@ error: cannot infer an appropriate lifetime
 LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
    |                         ------------------ this data with lifetime `'a`...
 LL |     box B(&*v) as Box<dyn X>
-   |           ^^^ ...is captured here...
+   |           ^^^ ...is captured here with a `'static` requirement
    |
-note: ...and required to be `'static` by this
-  --> $DIR/regions-close-object-into-object-2.rs:10:5
-   |
-LL |     box B(&*v) as Box<dyn X>
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
 help: consider changing the trait object's explicit `'static` bound to lifetime `'a`
    |
 LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'a> {
diff --git a/src/test/ui/regions/regions-close-object-into-object-4.stderr b/src/test/ui/regions/regions-close-object-into-object-4.stderr
index b18c61f1376..70282c8cbdb 100644
--- a/src/test/ui/regions/regions-close-object-into-object-4.stderr
+++ b/src/test/ui/regions/regions-close-object-into-object-4.stderr
@@ -4,13 +4,8 @@ error: cannot infer an appropriate lifetime
 LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
    |                   ---------------- this data with lifetime `'a`...
 LL |     box B(&*v) as Box<dyn X>
-   |           ^^^ ...is captured here...
+   |           ^^^ ...is captured here with a `'static` requirement
    |
-note: ...and required to be `'static` by this
-  --> $DIR/regions-close-object-into-object-4.rs:10:5
-   |
-LL |     box B(&*v) as Box<dyn X>
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
 help: consider changing the trait object's explicit `'static` bound to lifetime `'a`
    |
 LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'a> {
diff --git a/src/test/ui/regions/regions-proc-bound-capture.stderr b/src/test/ui/regions/regions-proc-bound-capture.stderr
index 5cb9506afd3..8f93fad7fe9 100644
--- a/src/test/ui/regions/regions-proc-bound-capture.stderr
+++ b/src/test/ui/regions/regions-proc-bound-capture.stderr
@@ -5,13 +5,8 @@ LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + 'static> {
    |                   ------ this data with the anonymous lifetime `'_`...
 LL |     // This is illegal, because the region bound on `proc` is 'static.
 LL |     Box::new(move || { *x })
-   |              ^^^^^^^^^^^^^^ ...is captured here...
+   |              ^^^^^^^^^^^^^^ ...is captured here with a `'static` requirement
    |
-note: ...and required to be `'static` by this
-  --> $DIR/regions-proc-bound-capture.rs:9:5
-   |
-LL |     Box::new(move || { *x })
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
 help: consider changing the trait object's explicit `'static` bound to the anonymous lifetime `'_`
    |
 LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> {