aboutsummaryrefslogtreecommitdiff
path: root/tests/ui/pin_project/remove-attr-from-field.rs
blob: fd14da37c1545cedaf220649c490ba07edd4aab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::{marker::PhantomPinned, pin::Pin};

use auxiliary_macro::remove_attr;
use pin_project::pin_project;

fn is_unpin<T: Unpin>() {}

#[pin_project]
#[remove_attr(field_all)]
struct A {
    #[pin]
    f: PhantomPinned,
}

#[remove_attr(field_all)]
#[pin_project]
struct B {
    #[pin]
    f: PhantomPinned,
}

fn main() {
    is_unpin::<A>();
    is_unpin::<B>();

    let mut x = A { f: PhantomPinned };
    let x = Pin::new(&mut x).project();
    let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308

    let mut x = B { f: PhantomPinned };
    let x = Pin::new(&mut x).project();
    let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
}