2021-11-13 16:43:43 +11:00
error[E0597]: `foo` does not live long enough
2022-04-01 13:13:25 -04:00
--> $DIR/issue-90600-expected-return-static-indirect.rs:7:32
2021-11-13 16:43:43 +11:00
|
2023-01-15 03:06:44 +00:00
LL | fn inner(mut foo: &[u8]) {
| ------- binding `foo` declared here
2021-11-13 16:43:43 +11:00
LL | let refcell = RefCell::new(&mut foo);
| ^^^^^^^^ borrowed value does not live long enough
...
2024-12-04 03:19:03 -08:00
LL | read_thing(read);
| ---------------- argument requires that `foo` is borrowed for `'static`
LL |
2021-11-13 16:43:43 +11:00
LL | }
2023-05-21 01:31:17 -07:00
| - `foo` dropped here while still borrowed
2021-11-13 16:43:43 +11:00
2024-12-04 03:19:03 -08:00
error[E0521]: borrowed data escapes outside of function
--> $DIR/issue-90600-expected-return-static-indirect.rs:11:5
2021-11-13 16:43:43 +11:00
|
LL | fn inner(mut foo: &[u8]) {
2024-12-04 03:19:03 -08:00
| ------- - let's call the lifetime of this reference `'1`
| |
| `foo` is a reference that is only valid in the function body
2021-11-13 16:43:43 +11:00
...
2024-12-04 03:19:03 -08:00
LL | read_thing(read);
| ^^^^^^^^^^^^^^^^
| |
| `foo` escapes the function body here
| argument requires that `'1` must outlive `'static`
|
= note: requirement occurs because of the type `RefCell<(dyn std::io::Read + 'static)>`, which makes the generic argument `(dyn std::io::Read + 'static)` invariant
= note: the struct `RefCell<T>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
2021-11-13 16:43:43 +11:00
error: aborting due to 2 previous errors
2024-12-04 03:19:03 -08:00
Some errors have detailed explanations: E0521, E0597.
For more information about an error, try `rustc --explain E0521`.