about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-06-02 16:05:48 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-06-15 09:06:58 -0700
commite31367de6b5ed3878711cdd1761828587b9639fb (patch)
tree224c608363536f67a2cc99546f77d3f0290b1872 /src
parent34d8692262a8299025379e5178041d0d52a0329e (diff)
downloadrust-e31367de6b5ed3878711cdd1761828587b9639fb.tar.gz
rust-e31367de6b5ed3878711cdd1761828587b9639fb.zip
small tweaks
Diffstat (limited to 'src')
-rw-r--r--src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs20
-rw-r--r--src/test/ui/async-await/issues/issue-62097.stderr6
-rw-r--r--src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr10
-rw-r--r--src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr2
-rw-r--r--src/test/ui/regions/region-object-lifetime-in-coercion.stderr4
-rw-r--r--src/test/ui/regions/regions-close-object-into-object-2.stderr2
-rw-r--r--src/test/ui/regions/regions-close-object-into-object-4.stderr2
-rw-r--r--src/test/ui/regions/regions-proc-bound-capture.stderr2
-rw-r--r--src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr11
-rw-r--r--src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr2
10 files changed, 30 insertions, 31 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 74267a8dec0..5ad76e39640 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
@@ -79,15 +79,22 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
                             );
                         } else {
                             err.span_label(sup_origin.span(), "...is captured here...");
-                            err.span_note(
-                                return_sp,
-                                "...and is required to live as long as `'static` here",
-                            );
+                            if return_sp < sup_origin.span() {
+                                err.span_note(
+                                    return_sp,
+                                    "...and is required to live as long as `'static` here",
+                                );
+                            } else {
+                                err.span_label(
+                                    return_sp,
+                                    "...and is required to live as long as `'static` here",
+                                );
+                            }
                         }
                     } else {
                         err.span_label(
                             return_sp,
-                            "...is captured and required live as long as `'static` here",
+                            "...is captured and required to live as long as `'static` here",
                         );
                     }
 
@@ -104,7 +111,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
                         };
                         let explicit =
                             format!("you can add an explicit `{}` lifetime bound", lifetime_name);
-                        let explicit_static = format!("explicit `'static` bound to {}", arg);
+                        let explicit_static =
+                            format!("explicit `'static` bound to the lifetime of {}", arg);
                         let captures = format!("captures data from {}", arg);
                         let add_static_bound =
                             "alternatively, add an explicit `'static` bound to this reference";
diff --git a/src/test/ui/async-await/issues/issue-62097.stderr b/src/test/ui/async-await/issues/issue-62097.stderr
index b3754cce408..aa443b9d2fc 100644
--- a/src/test/ui/async-await/issues/issue-62097.stderr
+++ b/src/test/ui/async-await/issues/issue-62097.stderr
@@ -6,12 +6,8 @@ LL |     pub async fn run_dummy_fn(&self) {
    |                               |
    |                               this data with an anonymous lifetime `'_`...
    |                               ...is captured here...
-   |
-note: ...and is required to live as long as `'static` here
-  --> $DIR/issue-62097.rs:13:9
-   |
 LL |         foo(|| self.bar()).await;
-   |         ^^^
+   |         --- ...and is required to live as long as `'static` here
 
 error: aborting due to previous error
 
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 5ab450a85d9..baed43783a1 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
@@ -47,7 +47,7 @@ note: ...and is required to live as long as `'static` here
    |
 LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
    |                        ^^^^^^^^^^^^^^^^^^^
-help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
+help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
    |
 LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
    |                                    ^^
@@ -69,7 +69,7 @@ note: ...and is required to live as long as `'static` here
    |
 LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
    |                                 ^^^^^^^^^^^^^^^^^^^
-help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
+help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
    |
 LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x }
    |                                             ^^
@@ -97,7 +97,7 @@ note: ...and is required to live as long as `'static` here
    |
 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
+help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
    |
 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x }
    |                                                           ^^
@@ -157,7 +157,7 @@ LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
    |               |
    |               this data with an anonymous lifetime `'_`...
    |
-help: consider changing the trait object's explicit `'static` bound to argument `x`
+help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
    |
 LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
    |                                        ^^
@@ -172,7 +172,7 @@ error[E0758]: cannot infer an appropriate lifetime
 LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
    |                     ------- this data with lifetime `'a`...         ^ ...is captured here, requiring it to live as long as `'static`
    |
-help: consider changing the trait object's explicit `'static` bound to argument `x`
+help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
    |
 LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
    |                                                 ^^
diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr
index ac7502e004c..d461001adea 100644
--- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr
+++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr
@@ -5,7 +5,7 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> {
    |             --------------- this data with an anonymous lifetime `'_`...
 ...
 LL |     ss.r
-   |     ^^^^ ...is captured and required live as long as `'static` here
+   |     ^^^^ ...is captured and required to live as long as `'static` here
    |
 help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound
    |
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 fe191e9b695..c684373c67e 100644
--- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr
+++ b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr
@@ -6,7 +6,7 @@ LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
 LL |     let x: Box<dyn Foo + 'static> = Box::new(v);
    |                                              ^ ...is captured here, requiring it to live as long as `'static`
    |
-help: consider changing the trait object's explicit `'static` bound to argument `v`
+help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
    |
 LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
    |                                 ^^
@@ -23,7 +23,7 @@ LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
 LL |     Box::new(v)
    |              ^ ...is captured here, requiring it to live as long as `'static`
    |
-help: consider changing the trait object's explicit `'static` bound to argument `v`
+help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
    |
 LL | fn b(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 2ea970afced..c4ba3951798 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
@@ -6,7 +6,7 @@ LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
 LL |     box B(&*v) as Box<dyn X>
    |           ^^^ ...is captured here, requiring it to live as long as `'static`
    |
-help: consider changing the trait object's explicit `'static` bound to argument `v`
+help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
    |
 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 493b7a1df99..e45930bd957 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
@@ -6,7 +6,7 @@ LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
 LL |     box B(&*v) as Box<dyn X>
    |           ^^^ ...is captured here, requiring it to live as long as `'static`
    |
-help: consider changing the trait object's explicit `'static` bound to argument `v`
+help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
    |
 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 c10b9850a4e..69c7256364d 100644
--- a/src/test/ui/regions/regions-proc-bound-capture.stderr
+++ b/src/test/ui/regions/regions-proc-bound-capture.stderr
@@ -7,7 +7,7 @@ LL |     // This is illegal, because the region bound on `proc` is 'static.
 LL |     Box::new(move || { *x })
    |              ^^^^^^^^^^^^^^ ...is captured here, requiring it to live as long as `'static`
    |
-help: consider changing the trait object's explicit `'static` bound to argument `x`
+help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
    |
 LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> {
    |                                                           ^^
diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr
index 69022607bd1..9b04069136b 100644
--- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr
+++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr
@@ -2,15 +2,10 @@ error[E0758]: cannot infer an appropriate lifetime
   --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:16
    |
 LL |     async fn f(self: Pin<&Self>) -> impl Clone { self }
-   |                ^^^^  ---------- this data with an anonymous lifetime `'_`...
-   |                |
+   |                ^^^^  ----------     ---------- ...and is required to live as long as `'static` here
+   |                |     |
+   |                |     this data with an anonymous lifetime `'_`...
    |                ...is captured here...
-   |
-note: ...and is required to live as long as `'static` here
-  --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:37
-   |
-LL |     async fn f(self: Pin<&Self>) -> impl Clone { self }
-   |                                     ^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
index e768d7c8ab9..fc4c8019495 100644
--- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
+++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
@@ -5,7 +5,7 @@ LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
    |                ---- this data with an anonymous lifetime `'_`...
 LL |     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
 LL |     Box::new(items.iter())
-   |     ---------------^^^^--- ...is captured and required live as long as `'static` here
+   |     ---------------^^^^--- ...is captured and required to live as long as `'static` here
    |
 help: to declare that the trait object captures data from argument `items`, you can add an explicit `'_` lifetime bound
    |