diff options
Diffstat (limited to 'third_party/rust/pin-project/tests/ui/cfg')
12 files changed, 143 insertions, 0 deletions
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs new file mode 100644 index 0000000000..e36cc9593a --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs @@ -0,0 +1,11 @@ +use std::pin::Pin; + +#[cfg_attr(any(), pin_project::pin_project)] +struct Foo<T> { + f: T, +} + +fn main() { + let mut x = Foo { f: 0_u8 }; + let _ = Pin::new(&mut x).project(); //~ ERROR E0599 +} diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr new file mode 100644 index 0000000000..0393c143fe --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr @@ -0,0 +1,5 @@ +error[E0599]: no method named `project` found for struct `Pin<&mut Foo<u8>>` in the current scope + --> tests/ui/cfg/cfg_attr-resolve.rs:10:30 + | +10 | let _ = Pin::new(&mut x).project(); //~ ERROR E0599 + | ^^^^^^^ method not found in `Pin<&mut Foo<u8>>` diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs new file mode 100644 index 0000000000..1b9664b544 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs @@ -0,0 +1,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 +} diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr new file mode 100644 index 0000000000..366d9c74cb --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> tests/ui/cfg/cfg_attr-type-mismatch.rs:20:27 + | +20 | let _: Pin<&mut u8> = x.f; //~ ERROR E0308 + | ------------ ^^^ expected struct `Pin`, found `&mut u8` + | | + | expected due to this + | + = note: expected struct `Pin<&mut u8>` + found mutable reference `&mut u8` + +error[E0308]: mismatched types + --> tests/ui/cfg/cfg_attr-type-mismatch.rs:24:22 + | +24 | let _: &mut u8 = x.f; //~ ERROR E0308 + | ------- ^^^ + | | | + | | expected `&mut u8`, found struct `Pin` + | | help: consider mutably borrowing here: `&mut x.f` + | expected due to this + | + = note: expected mutable reference `&mut u8` + found struct `Pin<&mut u8>` diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs new file mode 100644 index 0000000000..7e19952b6d --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs @@ -0,0 +1,15 @@ +use auxiliary_macro::hidden_repr; +use pin_project::pin_project; + +#[pin_project] +#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types +struct S { + #[cfg(not(any()))] + #[pin] + f: u32, + #[cfg(any())] + #[pin] + f: u8, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr new file mode 100644 index 0000000000..4f3acc3494 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr @@ -0,0 +1,5 @@ +error: #[pin_project] attribute may not be used on #[repr(packed)] types + --> tests/ui/cfg/packed_sneaky-span-issue-1.rs:5:15 + | +5 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types + | ^^^^^^ diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs new file mode 100644 index 0000000000..fcea76bab8 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs @@ -0,0 +1,15 @@ +use auxiliary_macro::hidden_repr; +use pin_project::pin_project; + +#[pin_project] +#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types +struct S { + #[cfg(any())] + #[pin] + f: u32, + #[cfg(not(any()))] + #[pin] + f: u8, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr new file mode 100644 index 0000000000..cc2795ac68 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr @@ -0,0 +1,5 @@ +error: #[pin_project] attribute may not be used on #[repr(packed)] types + --> tests/ui/cfg/packed_sneaky-span-issue-2.rs:5:15 + | +5 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types + | ^^^^^^ diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs new file mode 100644 index 0000000000..0b01dc90e2 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs @@ -0,0 +1,12 @@ +use auxiliary_macro::hidden_repr_cfg_not_any; +use pin_project::pin_project; + +// `#[hidden_repr_cfg_not_any(packed)]` generates `#[cfg_attr(not(any()), repr(packed))]`. +#[pin_project] +#[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types +struct S { + #[pin] + f: u32, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr new file mode 100644 index 0000000000..a54c2ec2d2 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr @@ -0,0 +1,5 @@ +error: #[pin_project] attribute may not be used on #[repr(packed)] types + --> tests/ui/cfg/packed_sneaky.rs:6:27 + | +6 | #[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types + | ^^^^^^ diff --git a/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs b/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs new file mode 100644 index 0000000000..b950d4b828 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs @@ -0,0 +1,11 @@ +use pin_project::pin_project; + +#[pin_project] +struct S { + //~^ ERROR may not be used on structs with zero fields + #[cfg(any())] + #[pin] + f: u8, +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr b/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr new file mode 100644 index 0000000000..e1c871c011 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr @@ -0,0 +1,11 @@ +error: #[pin_project] attribute may not be used on structs with zero fields + --> tests/ui/cfg/unsupported.rs:4:10 + | +4 | struct S { + | __________^ +5 | | //~^ ERROR may not be used on structs with zero fields +6 | | #[cfg(any())] +7 | | #[pin] +8 | | f: u8, +9 | | } + | |_^ |