File: ice-on-non-ref-sig-ty.stderr

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, 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 (36 lines) | stat: -rw-r--r-- 1,611 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
27
28
29
30
31
32
33
34
35
36
error[E0521]: borrowed data escapes outside of method
  --> $DIR/ice-on-non-ref-sig-ty.rs:13:9
   |
LL | impl<'a> W<'a> for &'static () {
   |      -- lifetime `'a` defined here
LL |     fn g<T>(self, x: &'a T) -> &'static T {
   |             ----  - `x` is a reference that is only valid in the method body
   |             |
   |             `self` declared here, outside of the method body
LL |         f(&self, x)
   |         ^^^^^^^^^^^
   |         |
   |         `x` escapes the method body here
   |         argument requires that `'a` must outlive `'static`

error[E0597]: `self` does not live long enough
  --> $DIR/ice-on-non-ref-sig-ty.rs:13:11
   |
LL | impl<'a> W<'a> for &'static () {
   |                     ------- has lifetime `'static`
LL |     fn g<T>(self, x: &'a T) -> &'static T {
   |                                 ------- also has lifetime `'static`
LL |         f(&self, x)
   |           ^^^^^ `self` would have to be valid for `'static`...
...
LL |     }
   |      - ...but `self` will be dropped here, when the function `g` returns
   |
   = help: use data from the highlighted arguments which match the `'static` lifetime of the return type
   = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
   = note: to learn more, visit <https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#dangling-references>

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0521, E0597.
For more information about an error, try `rustc --explain E0521`.