]> git.lizzy.rs Git - rust.git/blob - src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr
Rollup merge of #97516 - RalfJung:atomics, r=joshtriplett
[rust.git] / src / test / ui / object-lifetime / object-lifetime-default-from-box-error.stderr
1 error: lifetime may not live long enough
2   --> $DIR/object-lifetime-default-from-box-error.rs:18:5
3    |
4 LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> {
5    |         -- has type `&mut SomeStruct<'1>`
6 ...
7 LL |     ss.r
8    |     ^^^^ returning this value requires that `'1` must outlive `'static`
9    |
10 help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound
11    |
12 LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait + '_> {
13    |                                                   ++++
14
15 error[E0507]: cannot move out of `ss.r` which is behind a mutable reference
16   --> $DIR/object-lifetime-default-from-box-error.rs:18:5
17    |
18 LL |     ss.r
19    |     ^^^^ move occurs because `ss.r` has type `Box<dyn SomeTrait>`, which does not implement the `Copy` trait
20
21 error[E0621]: explicit lifetime required in the type of `ss`
22   --> $DIR/object-lifetime-default-from-box-error.rs:33:5
23    |
24 LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) {
25    |                   --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>`
26 ...
27 LL |     ss.r = b;
28    |     ^^^^ lifetime `'b` required
29
30 error: aborting due to 3 previous errors
31
32 Some errors have detailed explanations: E0507, E0621.
33 For more information about an error, try `rustc --explain E0507`.