I think annotating these self references is overly restrictive. Suppose I am parsing a &'static [u8] and call (e.g.) as_tagged within a function. Then 'a will get narrowed to the lifetime of the current function. This makes it impossible to return anything borrowed from the return of as_tagged from the function.
More concretely, the following compiles after merging this PR...
error[E0515]: cannot return value referencing local variable `obj`
--> src/foo.rs:3:5
|
| Ok((rem, obj.as_tagged()?.2.as_slice()?))
| ^^^^^^^^^---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | `obj` is borrowed here
| returns a value referencing data owned by the current function
I think annotating these
self
references is overly restrictive. Suppose I am parsing a&'static [u8]
and call (e.g.)as_tagged
within a function. Then'a
will get narrowed to the lifetime of the current function. This makes it impossible to return anything borrowed from the return ofas_tagged
from the function.More concretely, the following compiles after merging this PR...
...but fails to compile under
master
...