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 {}
|
2024-05-07 14:35:25 -05:00
|
|
|
|
|
|
|
impl Struct {
|
|
|
|
// Test using `&mut self` sugar:
|
|
|
|
|
2024-05-07 14:54:16 -05:00
|
|
|
fn ref_self<'a>(&mut self, f: &'a u32) -> &'a u32 {
|
2024-05-07 14:35:25 -05:00
|
|
|
f
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test using `&mut Self` explicitly:
|
|
|
|
|
2024-05-07 14:54:16 -05:00
|
|
|
fn ref_Self<'a>(self: &mut Self, f: &'a u32) -> &'a 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<'a>(self: Box<&mut Self>, f: &'a u32) -> &'a 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<'a>(self: Pin<&mut Self>, f: &'a u32) -> &'a 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<'a>(self: Box<Box<&mut Self>>, f: &'a u32) -> &'a 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_ref_Self<'a>(self: Box<Pin<&mut Self>>, f: &'a u32) -> &'a 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() {}
|