File: issue-90600-expected-return-static-indirect.stderr

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (26 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
error[E0597]: `foo` does not live long enough
  --> $DIR/issue-90600-expected-return-static-indirect.rs:7:32
   |
LL | fn inner(mut foo: &[u8]) {
   |          ------- binding `foo` declared here
LL |     let refcell = RefCell::new(&mut foo);
   |                                ^^^^^^^^ borrowed value does not live long enough
LL |
LL |     let read = &refcell as &RefCell<dyn Read>;
   |                ------------------------------ cast requires that `foo` is borrowed for `'static`
...
LL | }
   |  - `foo` dropped here while still borrowed

error: lifetime may not live long enough
  --> $DIR/issue-90600-expected-return-static-indirect.rs:9:16
   |
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`.