aboutsummaryrefslogtreecommitdiff
path: root/tests/ui/cfg/cfg_attr-type-mismatch.rs
blob: 1b9664b5447e858845dc0f05d2cec9371fecb54e (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
use std::pin::Pin;

use pin_project::pin_project;

#[cfg_attr(not(any()), pin_project)]
struct Foo<T> {
    #[cfg_attr(any(), pin)]
    f: T,
}

#[cfg_attr(not(any()), pin_project)]
struct Bar<T> {
    #[cfg_attr(not(any()), pin)]
    f: T,
}

fn main() {
    let mut x = Foo { f: 0_u8 };
    let x = Pin::new(&mut x).project();
    let _: Pin<&mut u8> = x.f; //~ ERROR E0308

    let mut x = Bar { f: 0_u8 };
    let x = Pin::new(&mut x).project();
    let _: &mut u8 = x.f; //~ ERROR E0308
}