2024-05-07 14:35:25 -05:00
|
|
|
//@ run-rustfix
|
|
|
|
#![allow(non_snake_case, dead_code)]
|
|
|
|
|
|
|
|
use std::pin::Pin;
|
|
|
|
|
2024-05-07 14:45:51 -05:00
|
|
|
struct Struct<'a> {
|
|
|
|
data: &'a u32,
|
|
|
|
}
|
2024-05-07 14:35:25 -05:00
|
|
|
|
|
|
|
impl<'a> Struct<'a> {
|
|
|
|
// Test using `&self` sugar:
|
|
|
|
|
2024-05-07 14:54:16 -05:00
|
|
|
fn ref_self<'b>(&self, f: &'b u32) -> &'b u32 {
|
2024-05-07 14:35:25 -05:00
|
|
|
f
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test using `&Self` explicitly:
|
|
|
|
|
2024-05-07 14:54:16 -05:00
|
|
|
fn ref_Self<'b>(self: &Self, f: &'b u32) -> &'b u32 {
|
2024-05-07 14:35:25 -05:00
|
|
|
f
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
}
|
|
|
|
|
2024-05-07 14:54:16 -05:00
|
|
|
fn box_ref_Self<'b>(self: Box<&Self>, f: &'b u32) -> &'b u32 {
|
2024-05-07 14:35:25 -05:00
|
|
|
f
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
}
|
|
|
|
|
2024-05-07 14:54:16 -05:00
|
|
|
fn pin_ref_Self<'b>(self: Pin<&Self>, f: &'b u32) -> &'b u32 {
|
2024-05-07 14:35:25 -05:00
|
|
|
f
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
}
|
|
|
|
|
2024-05-07 14:54:16 -05:00
|
|
|
fn box_box_ref_Self<'b>(self: Box<Box<&Self>>, f: &'b u32) -> &'b u32 {
|
2024-05-07 14:35:25 -05:00
|
|
|
f
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
}
|
|
|
|
|
2024-05-07 14:54:16 -05:00
|
|
|
fn box_pin_Self<'b>(self: Box<Pin<&Self>>, f: &'b u32) -> &'b u32 {
|
2024-05-07 14:35:25 -05:00
|
|
|
f
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-07 14:45:51 -05:00
|
|
|
fn main() {}
|