2021-11-12 23:43:43 -06:00
|
|
|
error[E0597]: `foo` does not live long enough
|
2022-04-01 12:13:25 -05:00
|
|
|
--> $DIR/issue-90600-expected-return-static-indirect.rs:7:32
|
2021-11-12 23:43:43 -06:00
|
|
|
|
|
2023-01-14 21:06:44 -06:00
|
|
|
LL | fn inner(mut foo: &[u8]) {
|
|
|
|
| ------- binding `foo` declared here
|
2021-11-12 23:43:43 -06:00
|
|
|
LL | let refcell = RefCell::new(&mut foo);
|
|
|
|
| ^^^^^^^^ borrowed value does not live long enough
|
2022-04-01 12:13:25 -05:00
|
|
|
LL |
|
2021-11-12 23:43:43 -06:00
|
|
|
LL | let read = &refcell as &RefCell<dyn Read>;
|
|
|
|
| -------- cast requires that `foo` is borrowed for `'static`
|
|
|
|
...
|
|
|
|
LL | }
|
2023-05-21 03:31:17 -05:00
|
|
|
| - `foo` dropped here while still borrowed
|
2021-11-12 23:43:43 -06:00
|
|
|
|
|
|
|
error: lifetime may not live long enough
|
2022-04-01 12:13:25 -05:00
|
|
|
--> $DIR/issue-90600-expected-return-static-indirect.rs:9:16
|
2021-11-12 23:43:43 -06:00
|
|
|
|
|
|
|
|
LL | fn inner(mut foo: &[u8]) {
|
|
|
|
| - let's call the lifetime of this reference `'1`
|
|
|
|
...
|
|
|
|
LL | let read = &refcell as &RefCell<dyn Read>;
|
|
|
|
| ^^^^^^^^ cast requires that `'1` must outlive `'static`
|
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0597`.
|