rust/tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.rs
2023-01-11 14:09:14 -08:00

29 lines
660 B
Rust

// edition:2018
use core::{
convert::identity,
marker::PhantomPinned,
mem::drop as stuff,
pin::pin,
};
fn function_call_stops_borrow_extension() {
let phantom_pinned = identity(pin!(PhantomPinned));
//~^ ERROR temporary value dropped while borrowed
stuff(phantom_pinned)
}
fn promotion_only_works_for_the_innermost_block() {
let phantom_pinned = {
let phantom_pinned = pin!(PhantomPinned);
//~^ ERROR temporary value dropped while borrowed
phantom_pinned
};
stuff(phantom_pinned)
}
fn main() {
function_call_stops_borrow_extension();
promotion_only_works_for_the_innermost_block();
}