|
| 1 | +error[E0478]: lifetime bound not satisfied |
| 2 | + --> $DIR/static-impl-obligation.rs:222:10 |
| 3 | + | |
| 4 | +LL | impl MyTrait for dyn ObjectTrait + '_ {} |
| 5 | + | ^^^^^^^ |
| 6 | + | |
| 7 | +note: lifetime parameter instantiated with the anonymous lifetime as defined here |
| 8 | + --> $DIR/static-impl-obligation.rs:222:40 |
| 9 | + | |
| 10 | +LL | impl MyTrait for dyn ObjectTrait + '_ {} |
| 11 | + | ^^ |
| 12 | + = note: but lifetime parameter must outlive the static lifetime |
| 13 | +note: `'static` requirement introduced here |
| 14 | + --> $DIR/static-impl-obligation.rs:215:31 |
| 15 | + | |
| 16 | +LL | trait MyTrait where Self: 'static { |
| 17 | + | ^^^^^^^ |
| 18 | + |
| 19 | +error[E0521]: borrowed data escapes outside of function |
| 20 | + --> $DIR/static-impl-obligation.rs:225:9 |
| 21 | + | |
| 22 | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { |
| 23 | + | -- --- `val` is a reference that is only valid in the function body |
| 24 | + | | |
| 25 | + | lifetime `'a` defined here |
| 26 | +LL | val.use_self() |
| 27 | + | ^^^^^^^^^^^^^^ |
| 28 | + | | |
| 29 | + | `val` escapes the function body here |
| 30 | + | argument requires that `'a` must outlive `'static` |
| 31 | + |
| 32 | +error[E0521]: borrowed data escapes outside of function |
| 33 | + --> $DIR/static-impl-obligation.rs:243:9 |
| 34 | + | |
| 35 | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { |
| 36 | + | -- --- `val` is a reference that is only valid in the function body |
| 37 | + | | |
| 38 | + | lifetime `'a` defined here |
| 39 | +LL | val.use_self() |
| 40 | + | ^^^^^^^^^^^^^^ |
| 41 | + | | |
| 42 | + | `val` escapes the function body here |
| 43 | + | argument requires that `'a` must outlive `'static` |
| 44 | + |
| 45 | +error[E0521]: borrowed data escapes outside of function |
| 46 | + --> $DIR/static-impl-obligation.rs:261:9 |
| 47 | + | |
| 48 | +LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { |
| 49 | + | -- --- `val` is a reference that is only valid in the function body |
| 50 | + | | |
| 51 | + | lifetime `'a` defined here |
| 52 | +LL | val.use_self() |
| 53 | + | ^^^^^^^^^^^^^^ |
| 54 | + | | |
| 55 | + | `val` escapes the function body here |
| 56 | + | argument requires that `'a` must outlive `'static` |
| 57 | + | |
| 58 | +note: the used `impl` has a `'static` requirement |
| 59 | + --> $DIR/static-impl-obligation.rs:258:26 |
| 60 | + | |
| 61 | +LL | fn use_self(&'static self) -> &() { panic!() } |
| 62 | + | -------- calling this method introduces the `impl`'s `'static` requirement |
| 63 | +... |
| 64 | +LL | impl MyTrait for dyn ObjectTrait {} |
| 65 | + | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement |
| 66 | +note: the `impl` on `(dyn v::ObjectTrait + 'static)` has `'static` lifetime requirements |
| 67 | + --> $DIR/static-impl-obligation.rs:252:21 |
| 68 | + | |
| 69 | +LL | fn use_self(&'static self) -> &() { panic!() } |
| 70 | + | ^^^^^^^^^^^^^ |
| 71 | +... |
| 72 | +LL | impl MyTrait for dyn ObjectTrait {} |
| 73 | + | ^^^^^^^^^^^^^^^ |
| 74 | + |
| 75 | +error[E0478]: lifetime bound not satisfied |
| 76 | + --> $DIR/static-impl-obligation.rs:270:10 |
| 77 | + | |
| 78 | +LL | impl Trait for dyn Foo + '_ { |
| 79 | + | ^^^^^ |
| 80 | + | |
| 81 | +note: lifetime parameter instantiated with the anonymous lifetime as defined here |
| 82 | + --> $DIR/static-impl-obligation.rs:270:30 |
| 83 | + | |
| 84 | +LL | impl Trait for dyn Foo + '_ { |
| 85 | + | ^^ |
| 86 | + = note: but lifetime parameter must outlive the static lifetime |
| 87 | +note: `'static` requirement introduced here |
| 88 | + --> $DIR/static-impl-obligation.rs:268:29 |
| 89 | + | |
| 90 | +LL | trait Trait where Self: 'static { fn hello(&self) {} } |
| 91 | + | ^^^^^^^ |
| 92 | + |
1 | 93 | error: lifetime may not live long enough
|
2 | 94 | --> $DIR/static-impl-obligation.rs:9:9
|
3 | 95 | |
|
@@ -329,6 +421,15 @@ help: consider relaxing the implicit `'static` requirement on the impl
|
329 | 421 | LL | impl Trait for dyn Foo + '_ {
|
330 | 422 | | ++++
|
331 | 423 |
|
332 |
| -error: aborting due to 19 previous errors |
| 424 | +error: lifetime may not live long enough |
| 425 | + --> $DIR/static-impl-obligation.rs:275:27 |
| 426 | + | |
| 427 | +LL | fn convert<'a>(x: &'a &'a u32) { |
| 428 | + | -- lifetime `'a` defined here |
| 429 | +LL | let y: &dyn Foo = x; |
| 430 | + | ^ cast requires that `'a` must outlive `'static` |
| 431 | + |
| 432 | +error: aborting due to 25 previous errors |
333 | 433 |
|
334 |
| -For more information about this error, try `rustc --explain E0521`. |
| 434 | +Some errors have detailed explanations: E0478, E0521. |
| 435 | +For more information about an error, try `rustc --explain E0478`. |
0 commit comments