Closed
Description
I mentioned this on the RFC recently, but since this is being hit by futures
0.3 I thought it's worth having an issue for the current implementation in case it's an easy fix.
#![feature(arbitrary_self_types)]
struct Foo;
struct Bar<'a>(&'a Foo);
impl std::ops::Deref for Bar<'_> {
type Target = Foo;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl Foo {
fn a(&self) -> Bar<'_> {
Bar(self)
}
fn b(c: &Self) -> Bar<'_> {
Bar(c)
}
fn c(self: Bar<'_>) -> Bar<'_> {
self
}
fn d(e: Bar<'_>) -> Bar<'_> {
e
}
}
fn main() {
let foo = Foo;
{ foo.a() };
{ Foo::b(&foo) };
{ Bar(&foo).c() };
{ Foo::d(Bar(&foo)) };
}
error[E0106]: missing lifetime specifier
--> src/main.rs:15:32
|
15 | fn c(self: Bar<'_>) -> Bar<'_> {
| ^^ expected lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
= help: consider giving it a 'static lifetime