]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / suggestions / impl-on-dyn-trait-with-implicit-static-bound.stderr
index ed094c1365caa6a72de2ca9b6580b1ed59c317c5..679ebd61ead1ab76d55e8bd53392b1ce81799d0a 100644 (file)
@@ -1,13 +1,18 @@
-error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:13
+error[E0521]: borrowed data escapes outside of function
+  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:21:9
    |
 LL |     fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
-   |                           ---------------------- this data with lifetime `'a`...
+   |               --     --- `val` is a reference that is only valid in the function body
+   |               |
+   |               lifetime `'a` defined here
 LL |         val.use_self::<T>()
-   |             ^^^^^^^^ ...is used and required to live as long as `'static` here
+   |         ^^^^^^^^^^^^^^^^^^^
+   |         |
+   |         `val` escapes the function body here
+   |         argument requires that `'a` must outlive `'static`
    |
 note: the used `impl` has a `'static` requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32
+  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:15:32
    |
 LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> {
    |                                ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
@@ -18,16 +23,21 @@ help: consider relaxing the implicit `'static` requirement
 LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
    |                                               ++++
 
-error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:13
+error[E0521]: borrowed data escapes outside of function
+  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:70:9
    |
 LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
-   |                        ------------------- this data with lifetime `'a`...
+   |               --  --- `val` is a reference that is only valid in the function body
+   |               |
+   |               lifetime `'a` defined here
 LL |         val.use_self()
-   |             ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl`
+   |         ^^^^^^^^^^^^^^
+   |         |
+   |         `val` escapes the function body here
+   |         argument requires that `'a` must outlive `'static`
    |
 note: the used `impl` has a `'static` requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14
+  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:65:14
    |
 LL |     impl dyn ObjectTrait {
    |              ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
@@ -38,16 +48,21 @@ help: consider relaxing the implicit `'static` requirement
 LL |     impl dyn ObjectTrait + '_ {
    |                          ++++
 
-error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:13
+error[E0521]: borrowed data escapes outside of function
+  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:90:9
    |
 LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
-   |                        ------------------- this data with lifetime `'a`...
+   |               --  --- `val` is a reference that is only valid in the function body
+   |               |
+   |               lifetime `'a` defined here
 LL |         val.use_self()
-   |             ^^^^^^^^ ...is used and required to live as long as `'static` here
+   |         ^^^^^^^^^^^^^^
+   |         |
+   |         `val` escapes the function body here
+   |         argument requires that `'a` must outlive `'static`
    |
 note: the used `impl` has a `'static` requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85:26
+  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:87:26
    |
 LL |         fn use_self(&self) -> &() { panic!() }
    |            -------- calling this method introduces the `impl`'s 'static` requirement
@@ -58,26 +73,22 @@ help: consider relaxing the implicit `'static` requirement
    |
 LL |     impl MyTrait for dyn ObjectTrait + '_ {}
    |                                      ++++
-help: to declare that the `impl Trait` captures data from argument `val`, you can add an explicit `'a` lifetime bound
-   |
-LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
-   |                                                                    ++++
 
-error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:27
+error[E0521]: borrowed data escapes outside of function
+  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:110:9
    |
 LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
-   |                        ------------------- this data with lifetime `'a`...
+   |               --  --- `val` is a reference that is only valid in the function body
+   |               |
+   |               lifetime `'a` defined here
 LL |         MyTrait::use_self(val)
-   |                           ^^^ ...is used here...
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+   |         |
+   |         `val` escapes the function body here
+   |         argument requires that `'a` must outlive `'static`
    |
-note: ...and is required to live as long as `'static` here
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9
-   |
-LL |         MyTrait::use_self(val)
-   |         ^^^^^^^^^^^^^^^^^
 note: the used `impl` has a `'static` requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:104:26
+  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:106:26
    |
 LL |         fn use_self(&self) -> &() { panic!() }
    |            -------- calling this method introduces the `impl`'s 'static` requirement
@@ -89,47 +100,6 @@ help: consider relaxing the implicit `'static` requirement
 LL |     impl MyTrait for dyn ObjectTrait + '_ {}
    |                                      ++++
 
-error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:37:13
-   |
-LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
-   |                        ------------------- this data with lifetime `'a`...
-LL |         val.use_self()
-   |             ^^^^^^^^ ...is used and required to live as long as `'static` here
-   |
-note: the used `impl` has a `'static` requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26
-   |
-LL |     impl MyTrait for dyn ObjectTrait {
-   |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
-LL |         fn use_self(&self) -> &() { panic!() }
-   |            -------- calling this method introduces the `impl`'s 'static` requirement
-help: consider relaxing the implicit `'static` requirement
-   |
-LL |     impl MyTrait for dyn ObjectTrait + '_ {
-   |                                      ++++
-
-error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:54:13
-   |
-LL |     fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
-   |                        ----------------------------- this data with lifetime `'a`...
-LL |         val.use_self()
-   |             ^^^^^^^^ ...is used and required to live as long as `'static` here
-   |
-note: the used `impl` has a `'static` requirement
-  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30
-   |
-LL |     impl MyTrait for Box<dyn ObjectTrait> {
-   |                              ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
-LL |         fn use_self(&self) -> &() { panic!() }
-   |            -------- calling this method introduces the `impl`'s 'static` requirement
-help: consider relaxing the implicit `'static` requirement
-   |
-LL |     impl MyTrait for Box<dyn ObjectTrait + '_> {
-   |                                          ++++
-
-error: aborting due to 6 previous errors
+error: aborting due to 4 previous errors
 
-Some errors have detailed explanations: E0759, E0772.
-For more information about an error, try `rustc --explain E0759`.
+For more information about this error, try `rustc --explain E0521`.