diff options
Diffstat (limited to 'third_party/rust/pin-project/tests/ui/unstable-features')
15 files changed, 366 insertions, 0 deletions
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/README.md b/third_party/rust/pin-project/tests/ui/unstable-features/README.md new file mode 100644 index 0000000000..96f370ca77 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/README.md @@ -0,0 +1,7 @@ +# UI tests for unstable features + +These tests check how the guarantees and features provided by pin-project +interact with unstable language features. + +The names of the files contained in this directory need to begin with the name +of the feature. diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs new file mode 100644 index 0000000000..542250bd90 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs @@ -0,0 +1,20 @@ +// Note: If you change this test, change 'marker_trait_attr.rs' at the same time. + +use std::marker::PhantomPinned; + +use pin_project::pin_project; + +#[pin_project] //~ ERROR E0119 +struct Struct<T> { + #[pin] + f: T, +} + +// unsound Unpin impl +impl<T> Unpin for Struct<T> {} + +fn is_unpin<T: Unpin>() {} + +fn main() { + is_unpin::<Struct<PhantomPinned>>() +} diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr new file mode 100644 index 0000000000..3412f2e224 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr @@ -0,0 +1,10 @@ +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>` + --> tests/ui/unstable-features/marker_trait_attr-feature-gate.rs:7:1 + | +7 | #[pin_project] //~ ERROR E0119 + | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>` +... +14 | impl<T> Unpin for Struct<T> {} + | --------------------------- first implementation here + | + = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs new file mode 100644 index 0000000000..9c8e6643e0 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs @@ -0,0 +1,26 @@ +// Note: If you change this test, change 'marker_trait_attr-feature-gate.rs' at the same time. + +// marker_trait_attr +// Tracking issue: https://github.com/rust-lang/rust/issues/29864 +#![feature(marker_trait_attr)] + +// See https://github.com/taiki-e/pin-project/issues/105#issuecomment-535355974 + +use std::marker::PhantomPinned; + +use pin_project::pin_project; + +#[pin_project] //~ ERROR E0119 +struct Struct<T> { + #[pin] + f: T, +} + +// unsound Unpin impl +impl<T> Unpin for Struct<T> {} + +fn is_unpin<T: Unpin>() {} + +fn main() { + is_unpin::<Struct<PhantomPinned>>() +} diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr new file mode 100644 index 0000000000..2b68c80ffb --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr @@ -0,0 +1,10 @@ +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>` + --> tests/ui/unstable-features/marker_trait_attr.rs:13:1 + | +13 | #[pin_project] //~ ERROR E0119 + | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>` +... +20 | impl<T> Unpin for Struct<T> {} + | --------------------------- first implementation here + | + = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.rs b/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.rs new file mode 100644 index 0000000000..96056423a0 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.rs @@ -0,0 +1,23 @@ +#![feature(negative_impls)] +#![deny(suspicious_auto_trait_impls)] + +// https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/design.20meeting.3A.20backlog.20bonanza/near/269471299 +// https://github.com/taiki-e/pin-project/issues/340 + +#[pin_project::pin_project] +struct Foo<Pinned, Unpinned> { + #[pin] + pinned: Pinned, + + unpinned: Unpinned, +} + +struct MyPhantomPinned {} +impl !Unpin for MyPhantomPinned {} +impl Unpin for Foo<MyPhantomPinned, ()> {} + +fn is_unpin<T: Unpin>() {} + +fn main() { + is_unpin::<Foo<MyPhantomPinned, ()>>() +} diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.stderr new file mode 100644 index 0000000000..0d99e2bf69 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.stderr @@ -0,0 +1,19 @@ +error: cross-crate traits with a default impl, like `Unpin`, should not be specialized + --> tests/ui/unstable-features/negative_impls.rs:17:1 + | +17 | impl Unpin for Foo<MyPhantomPinned, ()> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> tests/ui/unstable-features/negative_impls.rs:2:9 + | +2 | #![deny(suspicious_auto_trait_impls)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `MyPhantomPinned` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> tests/ui/unstable-features/negative_impls.rs:8:1 + | +8 | struct Foo<Pinned, Unpinned> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs new file mode 100644 index 0000000000..012c8709bd --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs @@ -0,0 +1,20 @@ +// Note: If you change this test, change 'overlapping_marker_traits.rs' at the same time. + +use std::marker::PhantomPinned; + +use pin_project::pin_project; + +#[pin_project] //~ ERROR E0119 +struct Struct<T> { + #[pin] + f: T, +} + +// unsound Unpin impl +impl<T> Unpin for Struct<T> {} + +fn is_unpin<T: Unpin>() {} + +fn main() { + is_unpin::<Struct<PhantomPinned>>() +} diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr new file mode 100644 index 0000000000..918d804d0e --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr @@ -0,0 +1,10 @@ +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>` + --> tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs:7:1 + | +7 | #[pin_project] //~ ERROR E0119 + | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>` +... +14 | impl<T> Unpin for Struct<T> {} + | --------------------------- first implementation here + | + = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs new file mode 100644 index 0000000000..8dc27c1dba --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs @@ -0,0 +1,30 @@ +// Note: If you change this test, change 'overlapping_marker_traits-feature-gate.rs' at the same time. + +// This feature could break the guarantee for Unpin provided by pin-project, +// but was removed in https://github.com/rust-lang/rust/pull/68544 (nightly-2020-02-06). +// Refs: +// - https://github.com/rust-lang/rust/issues/29864#issuecomment-515780867 +// - https://github.com/taiki-e/pin-project/issues/105 + +// overlapping_marker_traits +// Tracking issue: https://github.com/rust-lang/rust/issues/29864 +#![feature(overlapping_marker_traits)] + +use std::marker::PhantomPinned; + +use pin_project::pin_project; + +#[pin_project] +struct Struct<T> { + #[pin] + f: T, +} + +// unsound Unpin impl +impl<T> Unpin for Struct<T> {} + +fn is_unpin<T: Unpin>() {} + +fn main() { + is_unpin::<Struct<PhantomPinned>>() +} diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr new file mode 100644 index 0000000000..3e8411d4b0 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr @@ -0,0 +1,18 @@ +error[E0557]: feature has been removed + --> tests/ui/unstable-features/overlapping_marker_traits.rs:11:12 + | +11 | #![feature(overlapping_marker_traits)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed + | + = note: removed in favor of `#![feature(marker_trait_attr)]` + +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>` + --> tests/ui/unstable-features/overlapping_marker_traits.rs:17:1 + | +17 | #[pin_project] + | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>` +... +24 | impl<T> Unpin for Struct<T> {} + | --------------------------- first implementation here + | + = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs new file mode 100644 index 0000000000..f8467b082e --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs @@ -0,0 +1,53 @@ +// Note: If you change this test, change 'trivial_bounds.rs' at the same time. + +mod phantom_pinned { + use std::marker::{PhantomData, PhantomPinned}; + + struct A(PhantomPinned); + + impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277 + + struct Wrapper<T>(T); + + impl<T> Unpin for Wrapper<T> where T: Unpin {} + + struct B(PhantomPinned); + + impl Unpin for B where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277 + + struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T); + + impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {} + + struct C(PhantomPinned); + + impl<'a> Unpin for C where WrapperWithLifetime<'a, PhantomPinned>: Unpin {} // Ok +} + +mod inner { + use std::marker::{PhantomData, PhantomPinned}; + + struct Inner(PhantomPinned); + + struct A(Inner); + + impl Unpin for A where Inner: Unpin {} //~ ERROR E0277 + + struct Wrapper<T>(T); + + impl<T> Unpin for Wrapper<T> where T: Unpin {} + + struct B(Inner); + + impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277 + + struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T); + + impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {} + + struct C(Inner); + + impl<'a> Unpin for C where WrapperWithLifetime<'a, Inner>: Unpin {} // Ok +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr new file mode 100644 index 0000000000..2e316585ed --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr @@ -0,0 +1,59 @@ +error[E0277]: `PhantomPinned` cannot be unpinned + --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:8:28 + | +8 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `PhantomPinned` + | + = note: consider using `Box::pin` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: `PhantomPinned` cannot be unpinned + --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:16:28 + | +16 | impl Unpin for B where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `PhantomPinned` + | + = note: consider using `Box::pin` +note: required because of the requirements on the impl of `Unpin` for `phantom_pinned::Wrapper<PhantomPinned>` + --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:12:13 + | +12 | impl<T> Unpin for Wrapper<T> where T: Unpin {} + | ^^^^^ ^^^^^^^^^^ + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: `PhantomPinned` cannot be unpinned + --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:34:28 + | +34 | impl Unpin for A where Inner: Unpin {} //~ ERROR E0277 + | ^^^^^^^^^^^^ within `Inner`, the trait `Unpin` is not implemented for `PhantomPinned` + | + = note: consider using `Box::pin` +note: required because it appears within the type `Inner` + --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:30:12 + | +30 | struct Inner(PhantomPinned); + | ^^^^^ + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: `PhantomPinned` cannot be unpinned + --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:42:28 + | +42 | impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^^ within `Inner`, the trait `Unpin` is not implemented for `PhantomPinned` + | + = note: consider using `Box::pin` +note: required because it appears within the type `Inner` + --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:30:12 + | +30 | struct Inner(PhantomPinned); + | ^^^^^ +note: required because of the requirements on the impl of `Unpin` for `inner::Wrapper<Inner>` + --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:38:13 + | +38 | impl<T> Unpin for Wrapper<T> where T: Unpin {} + | ^^^^^ ^^^^^^^^^^ + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs new file mode 100644 index 0000000000..41f885d4e7 --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs @@ -0,0 +1,38 @@ +// Note: If you change this test, change 'trivial_bounds-feature-gate.rs' at the same time. + +// trivial_bounds +// Tracking issue: https://github.com/rust-lang/rust/issues/48214 +#![feature(trivial_bounds)] +#![deny(trivial_bounds)] + +use std::marker::{PhantomData, PhantomPinned}; + +fn inner() { + struct Inner(PhantomPinned); + + struct A(PhantomPinned); + + impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters + + struct B(Inner); + + impl Unpin for B where Inner: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters + + struct Wrapper<T>(T); + + impl<T> Unpin for Wrapper<T> where T: Unpin {} + + struct C(Inner); + + impl Unpin for C where Wrapper<Inner>: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters + + struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T); + + impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {} + + struct D(Inner); + + impl<'a> Unpin for D where WrapperWithLifetime<'a, Inner>: Unpin {} // Ok +} + +fn main() {} diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr new file mode 100644 index 0000000000..23f45c738d --- /dev/null +++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr @@ -0,0 +1,23 @@ +error: trait bound PhantomPinned: Unpin does not depend on any type or lifetime parameters + --> tests/ui/unstable-features/trivial_bounds.rs:15:43 + | +15 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters + | ^^^^^ + | +note: the lint level is defined here + --> tests/ui/unstable-features/trivial_bounds.rs:6:9 + | +6 | #![deny(trivial_bounds)] + | ^^^^^^^^^^^^^^ + +error: trait bound Inner: Unpin does not depend on any type or lifetime parameters + --> tests/ui/unstable-features/trivial_bounds.rs:19:35 + | +19 | impl Unpin for B where Inner: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters + | ^^^^^ + +error: trait bound Wrapper<Inner>: Unpin does not depend on any type or lifetime parameters + --> tests/ui/unstable-features/trivial_bounds.rs:27:44 + | +27 | impl Unpin for C where Wrapper<Inner>: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters + | ^^^^^ |