mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
e62599f856
This makes a small change as requested in code review, such that if there's ambiguity in the self lifetime, we avoid lifetime elision entirely instead of considering using lifetimes from any of the other parameters. For example, impl Something { fn method(self: &Box<&Self>, something_else: &u32) -> &u32 { ... } } in standard Rust would have assumed the return lifetime was that of &Self; with this PR prior to this commit would have chosen the lifetime of 'something_else', and after this commit would give an error message explaining that the lifetime is ambiguous.
30 lines
572 B
Rust
30 lines
572 B
Rust
#![feature(arbitrary_self_types)]
|
|
#![allow(non_snake_case)]
|
|
#![allow(unused)]
|
|
|
|
use std::marker::PhantomData;
|
|
use std::ops::Deref;
|
|
|
|
struct Struct { }
|
|
|
|
struct Wrap<T, P>(T, PhantomData<P>);
|
|
|
|
impl<T, P> Deref for Wrap<T, P> {
|
|
type Target = T;
|
|
fn deref(&self) -> &T { &self.0 }
|
|
}
|
|
|
|
impl Struct {
|
|
fn ref_box_ref_Self(self: &Box<&Self>, f: &u32) -> &u32 {
|
|
//~^ ERROR missing lifetime specifier
|
|
f
|
|
}
|
|
|
|
fn ref_wrap_ref_Self(self: &Wrap<&Self, u32>, f: &u32) -> &u32 {
|
|
//~^ ERROR missing lifetime specifier
|
|
f
|
|
}
|
|
}
|
|
|
|
fn main() { }
|