fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

1.40.0
765 B21 linesraw
1error: lifetime may not live long enough
2  --> $DIR/object-lifetime-default-mybox.rs:27:5
3   |
4LL | fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>,
5   |          -- -- lifetime `'b` defined here
6   |          |
7   |          lifetime `'a` defined here
8...
9LL |     a
10   |     ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
11
12error[E0521]: borrowed data escapes outside of function
13  --> $DIR/object-lifetime-default-mybox.rs:31:5
14   |
15LL | fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> {
16   |              -- `ss` is a reference that is only valid in the function body
17LL |     load0(ss)
18   |     ^^^^^^^^^ `ss` escapes the function body here
19
20error: aborting due to 2 previous errors
21