diff options
author | David LeGare <legare@google.com> | 2022-03-03 17:02:12 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-03 17:02:12 +0000 |
commit | 97174d06e99fa6c8332d88be9224d612439b3e20 (patch) | |
tree | 7fcd35ff92b7d412fdee86b26ca803e64cf1df60 /tests | |
parent | c9e9198c875859f1c39364f957c689523f783d88 (diff) | |
parent | 5426daeae334e11c75767e4488430860b6d4711f (diff) | |
download | pin-project-lite-android13-qpr3-s13-release.tar.gz |
Update pin-project-lite to 0.2.8 am: 634c6e65a5 am: 74a8190a28 am: 5426daeae3t_frc_odp_330442040t_frc_odp_330442000t_frc_ase_330444010android-13.0.0_r83android-13.0.0_r82android-13.0.0_r81android-13.0.0_r80android-13.0.0_r79android-13.0.0_r78android-13.0.0_r77android-13.0.0_r76android-13.0.0_r75android-13.0.0_r74android-13.0.0_r73android-13.0.0_r72android-13.0.0_r71android-13.0.0_r70android-13.0.0_r69android-13.0.0_r68android-13.0.0_r67android-13.0.0_r66android-13.0.0_r65android-13.0.0_r64android-13.0.0_r63android-13.0.0_r62android-13.0.0_r61android-13.0.0_r60android-13.0.0_r59android-13.0.0_r58android-13.0.0_r57android-13.0.0_r56android-13.0.0_r55android-13.0.0_r54android-13.0.0_r53android-13.0.0_r52android-13.0.0_r51android-13.0.0_r50android-13.0.0_r49android-13.0.0_r48android-13.0.0_r47android-13.0.0_r46android-13.0.0_r45android-13.0.0_r44android-13.0.0_r43android-13.0.0_r42android-13.0.0_r41android-13.0.0_r40android-13.0.0_r39android-13.0.0_r38android-13.0.0_r37android-13.0.0_r36android-13.0.0_r35android-13.0.0_r34android-13.0.0_r33android-13.0.0_r32android-13.0.0_r30android-13.0.0_r29android-13.0.0_r28android-13.0.0_r27android-13.0.0_r24android-13.0.0_r23android-13.0.0_r22android-13.0.0_r21android-13.0.0_r20android-13.0.0_r19android-13.0.0_r18android-13.0.0_r17android-13.0.0_r16aml_go_odp_330912000aml_go_ads_330915100aml_go_ads_330915000aml_go_ads_330913000android13-qpr3-s9-releaseandroid13-qpr3-s8-releaseandroid13-qpr3-s7-releaseandroid13-qpr3-s6-releaseandroid13-qpr3-s5-releaseandroid13-qpr3-s4-releaseandroid13-qpr3-s3-releaseandroid13-qpr3-s2-releaseandroid13-qpr3-s14-releaseandroid13-qpr3-s13-releaseandroid13-qpr3-s12-releaseandroid13-qpr3-s11-releaseandroid13-qpr3-s10-releaseandroid13-qpr3-s1-releaseandroid13-qpr3-releaseandroid13-qpr3-c-s8-releaseandroid13-qpr3-c-s7-releaseandroid13-qpr3-c-s6-releaseandroid13-qpr3-c-s5-releaseandroid13-qpr3-c-s4-releaseandroid13-qpr3-c-s3-releaseandroid13-qpr3-c-s2-releaseandroid13-qpr3-c-s12-releaseandroid13-qpr3-c-s11-releaseandroid13-qpr3-c-s10-releaseandroid13-qpr3-c-s1-releaseandroid13-qpr2-s9-releaseandroid13-qpr2-s8-releaseandroid13-qpr2-s7-releaseandroid13-qpr2-s6-releaseandroid13-qpr2-s5-releaseandroid13-qpr2-s3-releaseandroid13-qpr2-s2-releaseandroid13-qpr2-s12-releaseandroid13-qpr2-s11-releaseandroid13-qpr2-s10-releaseandroid13-qpr2-s1-releaseandroid13-qpr2-releaseandroid13-qpr2-b-s1-releaseandroid13-qpr1-s8-releaseandroid13-qpr1-s7-releaseandroid13-qpr1-s6-releaseandroid13-qpr1-s5-releaseandroid13-qpr1-s4-releaseandroid13-qpr1-s3-releaseandroid13-qpr1-s2-releaseandroid13-qpr1-s1-releaseandroid13-qpr1-releaseandroid13-mainline-go-adservices-releaseandroid13-frc-odp-releaseandroid13-devandroid13-d4-s2-releaseandroid13-d4-s1-releaseandroid13-d4-releaseandroid13-d3-s1-releaseandroid13-d2-release
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/pin-project-lite/+/2004420
Change-Id: I1513867af507f498af6f998a664bf2f0eabe8656
Diffstat (limited to 'tests')
21 files changed, 286 insertions, 171 deletions
diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..4721616 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,46 @@ +# Tests + +Many of the tests in this repository are based on [pin-project's tests](https://github.com/taiki-e/pin-project/tree/HEAD/tests). + +To run all tests, run the following command: + +```sh +cargo +nightly test --all +``` + +## UI tests (`ui`, `compiletest.rs`) + +This checks errors detected by the macro or the Rust compiler in the resulting +expanded code. + +To run this test, run the following command: + +```sh +cargo +nightly test --test compiletest +``` + +Locally, this test updates the files in the `ui` directory if there are +changes to the generated code. If there are any changes to the files in the +`ui` directory after running the test, please commit them. + +See also [`trybuild` documentation](https://docs.rs/trybuild). + +## Expansion tests (`expand`, `expandtest.rs`) + +Similar to ui tests, but instead of checking the compiler output, this checks +the code generated by macros. + +See pin-project's [examples](https://github.com/taiki-e/pin-project/tree/HEAD/examples) +for descriptions of what the generated code does, and why it needs to be generated. + +To run this test, run the following command: + +```sh +cargo +nightly test --test expandtest +``` + +Locally, this test updates the files in the `expand` directory if there are +changes to the generated code. If there are any changes to the files in the +`expand` directory after running the test, please commit them. + +See also [`macrotest` documentation](https://docs.rs/macrotest). diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 8970215..70d2358 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -3,7 +3,7 @@ use std::env; -#[rustversion::attr(before(2021-05-15), ignore)] // Note: This date is commit-date and the day before the toolchain date. +#[rustversion::attr(not(nightly), ignore)] #[test] fn ui() { if env::var_os("CI").is_none() { @@ -11,5 +11,5 @@ fn ui() { } let t = trybuild::TestCases::new(); - t.compile_fail("tests/ui/*/*.rs"); + t.compile_fail("tests/ui/**/*.rs"); } diff --git a/tests/expand/README.md b/tests/expand/README.md deleted file mode 100644 index 1f7dcfb..0000000 --- a/tests/expand/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Expansion tests - -Similar to ui tests, but instead of checking the compiler output, this checks -the code generated by macros. - -See [examples](https://github.com/taiki-e/pin-project/tree/HEAD/examples) for -descriptions of what the generated code does, and why it needs to be generated. - -To run this test, run the following command: - -```sh -cargo +nightly test --test expandtest -``` - -Locally, this test updates the files in the `expand` directory if there are -changes to the generated code. If there are any changes to the files in the -`expand` directory after running the test, please commit them. diff --git a/tests/expand/default/enum.expanded.rs b/tests/expand/default/enum.expanded.rs index df005ad..eae0aac 100644 --- a/tests/expand/default/enum.expanded.rs +++ b/tests/expand/default/enum.expanded.rs @@ -86,10 +86,10 @@ const _: () = { ) -> EnumProjReplace<T, U> { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard { - target: __self_ptr, - value: ::pin_project_lite::__private::ManuallyDrop::new(replacement), - }; + let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new( + __self_ptr, + replacement, + ); match &mut *__self_ptr { Self::Struct { pinned, unpinned } => { let result = EnumProjReplace::Struct { @@ -98,7 +98,7 @@ const _: () = { }; { ( - ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned), + ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned), (), ); } diff --git a/tests/expand/multifields/enum.expanded.rs b/tests/expand/multifields/enum.expanded.rs index a0b17cb..fca0feb 100644 --- a/tests/expand/multifields/enum.expanded.rs +++ b/tests/expand/multifields/enum.expanded.rs @@ -33,10 +33,10 @@ const _: () = { ) -> EnumProjReplace<T, U> { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard { - target: __self_ptr, - value: ::pin_project_lite::__private::ManuallyDrop::new(replacement), - }; + let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new( + __self_ptr, + replacement, + ); match &mut *__self_ptr { Self::Struct { pinned1, @@ -52,8 +52,8 @@ const _: () = { }; { ( - ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned1), - ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned2), + ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned1), + ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned2), (), (), ); diff --git a/tests/expand/multifields/struct.expanded.rs b/tests/expand/multifields/struct.expanded.rs index 638bf56..4320f68 100644 --- a/tests/expand/multifields/struct.expanded.rs +++ b/tests/expand/multifields/struct.expanded.rs @@ -97,10 +97,10 @@ const _: () = { ) -> StructProjReplace<T, U> { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard { - target: __self_ptr, - value: ::pin_project_lite::__private::ManuallyDrop::new(replacement), - }; + let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new( + __self_ptr, + replacement, + ); let Self { pinned1, pinned2, @@ -115,8 +115,8 @@ const _: () = { }; { ( - ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned1), - ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned2), + ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned1), + ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned2), (), (), ); diff --git a/tests/expand/naming/enum-all.expanded.rs b/tests/expand/naming/enum-all.expanded.rs index df005ad..eae0aac 100644 --- a/tests/expand/naming/enum-all.expanded.rs +++ b/tests/expand/naming/enum-all.expanded.rs @@ -86,10 +86,10 @@ const _: () = { ) -> EnumProjReplace<T, U> { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard { - target: __self_ptr, - value: ::pin_project_lite::__private::ManuallyDrop::new(replacement), - }; + let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new( + __self_ptr, + replacement, + ); match &mut *__self_ptr { Self::Struct { pinned, unpinned } => { let result = EnumProjReplace::Struct { @@ -98,7 +98,7 @@ const _: () = { }; { ( - ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned), + ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned), (), ); } diff --git a/tests/expand/naming/struct-all.expanded.rs b/tests/expand/naming/struct-all.expanded.rs index 5d2f135..b91c24e 100644 --- a/tests/expand/naming/struct-all.expanded.rs +++ b/tests/expand/naming/struct-all.expanded.rs @@ -75,10 +75,10 @@ const _: () = { ) -> StructProjReplace<T, U> { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard { - target: __self_ptr, - value: ::pin_project_lite::__private::ManuallyDrop::new(replacement), - }; + let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new( + __self_ptr, + replacement, + ); let Self { pinned, unpinned } = &mut *__self_ptr; let result = StructProjReplace { pinned: ::pin_project_lite::__private::PhantomData, @@ -86,7 +86,7 @@ const _: () = { }; { ( - ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned), + ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned), (), ); } diff --git a/tests/lint.rs b/tests/lint.rs index 2324cd5..792adce 100644 --- a/tests/lint.rs +++ b/tests/lint.rs @@ -1,15 +1,22 @@ // Check interoperability with rustc and clippy lints. +#![forbid(unsafe_code)] +// for old compilers +#![allow(unknown_lints)] #![warn(nonstandard_style, rust_2018_idioms, unused)] // Note: This does not guarantee compatibility with forbidding these lints in the future. // If rustc adds a new lint, we may not be able to keep this. -#![forbid(future_incompatible)] -#![allow(unknown_lints)] // for old compilers -#![forbid(unsafe_code)] +#![forbid(future_incompatible, rust_2018_compatibility, rust_2021_compatibility)] +// lints forbidden as a part of future_incompatible, rust_2018_compatibility, and rust_2021_compatibility are not included in the list below. +// elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: as a part of rust_2018_idioms +// unsafe_block_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn. +// non_exhaustive_omitted_patterns: unstable +// unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features +// unused_crate_dependencies: unrelated +// unsafe_code: checked in forbid_unsafe module #![warn( box_pointers, deprecated_in_future, - disjoint_capture_migration, macro_use_extern_crate, meta_variable_misuse, missing_abi, @@ -28,14 +35,7 @@ unused_results, variant_size_differences )] -// rust_2018_compatibility, rust_2021_compatibility, absolute_paths_not_starting_with_crate, etc.: forbidden as a part of future_incompatible -// elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: warned as a part of rust_2018_idioms -// unsafe_block_in_unsafe_fn: unsafe_block_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn. -// unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features -// unused_crate_dependencies: unrelated -// unsafe_code: forbidden -#![warn(clippy::all, clippy::pedantic, clippy::nursery)] -#![warn(clippy::restriction)] +#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::restriction)] #![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally. #![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)] // TODO @@ -161,7 +161,6 @@ mod clippy_redundant_pub_crate { } } - #[allow(dead_code)] pin_project! { #[project = EnumProj] #[project_ref = EnumProjRef] @@ -177,6 +176,7 @@ mod clippy_redundant_pub_crate { } } +#[allow(clippy::use_self)] pub mod clippy_type_repetition_in_bounds { use pin_project_lite::pin_project; diff --git a/tests/test.rs b/tests/test.rs index 162fc20..ed9b75c 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -665,4 +665,31 @@ fn pinned_drop() { } } } + + trait Service<Request> { + type Error; + } + + pin_project! { + struct Struct3<'a, T, Request> + where + T: Service<Request>, + T::Error: std::error::Error, + { + was_dropped: &'a mut bool, + #[pin] + field: T, + req: Request, + } + + impl<T, Request> PinnedDrop for Struct3<'_, T, Request> + where + T: Service<Request>, + T::Error: std::error::Error, + { + fn drop(mut this: Pin<&mut Self>) { + **this.as_mut().project().was_dropped = true; + } + } + } } diff --git a/tests/ui/pin_project/conflict-drop.stderr b/tests/ui/pin_project/conflict-drop.stderr index bbfc910..8531d08 100644 --- a/tests/ui/pin_project/conflict-drop.stderr +++ b/tests/ui/pin_project/conflict-drop.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `_::MustNotImplDrop` for type `Foo<_, _>` - --> $DIR/conflict-drop.rs:3:1 + --> tests/ui/pin_project/conflict-drop.rs:3:1 | 3 | / pin_project! { //~ ERROR E0119 4 | | struct Foo<T, U> { diff --git a/tests/ui/pin_project/conflict-unpin.stderr b/tests/ui/pin_project/conflict-unpin.stderr index 18bdd92..0c3141c 100644 --- a/tests/ui/pin_project/conflict-unpin.stderr +++ b/tests/ui/pin_project/conflict-unpin.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>` - --> $DIR/conflict-unpin.rs:5:1 + --> tests/ui/pin_project/conflict-unpin.rs:5:1 | 5 | / pin_project! { //~ ERROR E0119 6 | | struct Foo<T, U> { @@ -16,7 +16,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>` - --> $DIR/conflict-unpin.rs:18:1 + --> tests/ui/pin_project/conflict-unpin.rs:18:1 | 18 | / pin_project! { //~ ERROR E0119 19 | | struct Bar<T, U> { @@ -33,7 +33,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>` - --> $DIR/conflict-unpin.rs:29:1 + --> tests/ui/pin_project/conflict-unpin.rs:29:1 | 29 | / pin_project! { //~ ERROR E0119 30 | | struct Baz<T, U> { diff --git a/tests/ui/pin_project/invalid-bounds.stderr b/tests/ui/pin_project/invalid-bounds.stderr index b276989..e179565 100644 --- a/tests/ui/pin_project/invalid-bounds.stderr +++ b/tests/ui/pin_project/invalid-bounds.stderr @@ -1,5 +1,5 @@ error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:3:1 + --> tests/ui/pin_project/invalid-bounds.rs:3:1 | 3 | / pin_project! { 4 | | struct Generics1<T: 'static : Sized> { //~ ERROR no rules expected the token `:` @@ -8,10 +8,10 @@ error: no rules expected the token `[` 7 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:9:1 + --> tests/ui/pin_project/invalid-bounds.rs:9:1 | 9 | / pin_project! { 10 | | struct Generics2<T: 'static : ?Sized> { //~ ERROR no rules expected the token `:` @@ -20,10 +20,10 @@ error: no rules expected the token `[` 13 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected one of `+`, `,`, `=`, or `>`, found `:` - --> $DIR/invalid-bounds.rs:15:1 + --> tests/ui/pin_project/invalid-bounds.rs:15:1 | 15 | / pin_project! { 16 | | struct Generics3<T: Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:` @@ -39,7 +39,22 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:` = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected one of `+`, `,`, `=`, or `>`, found `:` - --> $DIR/invalid-bounds.rs:21:1 + --> tests/ui/pin_project/invalid-bounds.rs:15:1 + | +15 | / pin_project! { +16 | | struct Generics3<T: Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:` +17 | | field: T, +18 | | } +19 | | } + | | ^ + | | | + | |_expected one of `+`, `,`, `=`, or `>` + | unexpected token + | + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected one of `+`, `,`, `=`, or `>`, found `:` + --> tests/ui/pin_project/invalid-bounds.rs:21:1 | 21 | / pin_project! { 22 | | struct Generics4<T: ?Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:` @@ -55,7 +70,22 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:` = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected one of `+`, `,`, `=`, or `>`, found `:` - --> $DIR/invalid-bounds.rs:27:1 + --> tests/ui/pin_project/invalid-bounds.rs:21:1 + | +21 | / pin_project! { +22 | | struct Generics4<T: ?Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:` +23 | | field: T, +24 | | } +25 | | } + | | ^ + | | | + | |_expected one of `+`, `,`, `=`, or `>` + | unexpected token + | + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected one of `+`, `,`, `=`, or `>`, found `:` + --> tests/ui/pin_project/invalid-bounds.rs:27:1 | 27 | / pin_project! { 28 | | struct Generics5<T: Sized : ?Sized> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:` @@ -70,8 +100,23 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:` | = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) +error: expected one of `+`, `,`, `=`, or `>`, found `:` + --> tests/ui/pin_project/invalid-bounds.rs:27:1 + | +27 | / pin_project! { +28 | | struct Generics5<T: Sized : ?Sized> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:` +29 | | field: T, +30 | | } +31 | | } + | | ^ + | | | + | |_expected one of `+`, `,`, `=`, or `>` + | unexpected token + | + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) + error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:33:1 + --> tests/ui/pin_project/invalid-bounds.rs:33:1 | 33 | / pin_project! { 34 | | struct Generics6<T: ?Sized : Sized> { //~ ERROR no rules expected the token `Sized` @@ -80,10 +125,10 @@ error: no rules expected the token `[` 37 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:39:1 + --> tests/ui/pin_project/invalid-bounds.rs:39:1 | 39 | / pin_project! { 40 | | struct WhereClause1<T> @@ -94,10 +139,10 @@ error: no rules expected the token `[` 46 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:48:1 + --> tests/ui/pin_project/invalid-bounds.rs:48:1 | 48 | / pin_project! { 49 | | struct WhereClause2<T> @@ -108,10 +153,10 @@ error: no rules expected the token `[` 55 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected `where`, or `{` after struct name, found `:` - --> $DIR/invalid-bounds.rs:57:1 + --> tests/ui/pin_project/invalid-bounds.rs:57:1 | 57 | / pin_project! { 58 | | struct WhereClause3<T> @@ -127,8 +172,25 @@ error: expected `where`, or `{` after struct name, found `:` | = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) +error: expected one of `+`, `,`, or `{`, found `:` + --> tests/ui/pin_project/invalid-bounds.rs:57:1 + | +57 | / pin_project! { +58 | | struct WhereClause3<T> +59 | | where +60 | | T: Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:` +... | +63 | | } +64 | | } + | | ^ + | | | + | |_expected one of `+`, `,`, or `{` + | unexpected token + | + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) + error: expected `where`, or `{` after struct name, found `:` - --> $DIR/invalid-bounds.rs:66:1 + --> tests/ui/pin_project/invalid-bounds.rs:66:1 | 66 | / pin_project! { 67 | | struct WhereClause4<T> @@ -144,8 +206,25 @@ error: expected `where`, or `{` after struct name, found `:` | = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) +error: expected one of `+`, `,`, or `{`, found `:` + --> tests/ui/pin_project/invalid-bounds.rs:66:1 + | +66 | / pin_project! { +67 | | struct WhereClause4<T> +68 | | where +69 | | T: ?Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:` +... | +72 | | } +73 | | } + | | ^ + | | | + | |_expected one of `+`, `,`, or `{` + | unexpected token + | + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) + error: expected `where`, or `{` after struct name, found `:` - --> $DIR/invalid-bounds.rs:75:1 + --> tests/ui/pin_project/invalid-bounds.rs:75:1 | 75 | / pin_project! { 76 | | struct WhereClause5<T> @@ -161,8 +240,25 @@ error: expected `where`, or `{` after struct name, found `:` | = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) +error: expected one of `+`, `,`, or `{`, found `:` + --> tests/ui/pin_project/invalid-bounds.rs:75:1 + | +75 | / pin_project! { +76 | | struct WhereClause5<T> +77 | | where +78 | | T: Sized : ?Sized //~ ERROR expected `where`, or `{` after struct name, found `:` +... | +81 | | } +82 | | } + | | ^ + | | | + | |_expected one of `+`, `,`, or `{` + | unexpected token + | + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) + error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:84:1 + --> tests/ui/pin_project/invalid-bounds.rs:84:1 | 84 | / pin_project! { 85 | | struct WhereClause6<T> @@ -173,4 +269,4 @@ error: no rules expected the token `[` 91 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/invalid.stderr b/tests/ui/pin_project/invalid.stderr index 38df517..1e363d7 100644 --- a/tests/ui/pin_project/invalid.stderr +++ b/tests/ui/pin_project/invalid.stderr @@ -1,5 +1,5 @@ -error: no rules expected the token `[` - --> $DIR/invalid.rs:3:1 +error: no rules expected the token `struct` + --> tests/ui/pin_project/invalid.rs:3:1 | 3 | / pin_project! { 4 | | struct A<T> { @@ -9,10 +9,10 @@ error: no rules expected the token `[` 8 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) -error: no rules expected the token `[` - --> $DIR/invalid.rs:17:1 +error: no rules expected the token `struct` + --> tests/ui/pin_project/invalid.rs:17:1 | 17 | / pin_project! { 18 | | struct C<T> { @@ -23,10 +23,10 @@ error: no rules expected the token `[` 23 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find attribute `pin` in this scope - --> $DIR/invalid.rs:11:7 + --> tests/ui/pin_project/invalid.rs:11:7 | 11 | #[pin] //~ ERROR cannot find attribute `pin` in this scope | ^^^ diff --git a/tests/ui/pin_project/overlapping_lifetime_names.stderr b/tests/ui/pin_project/overlapping_lifetime_names.stderr index f87875d..dfd4235 100644 --- a/tests/ui/pin_project/overlapping_lifetime_names.stderr +++ b/tests/ui/pin_project/overlapping_lifetime_names.stderr @@ -1,5 +1,5 @@ error[E0263]: lifetime name `'__pin` declared twice in the same scope - --> $DIR/overlapping_lifetime_names.rs:4:20 + --> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20 | 3 | / pin_project! { //~ ERROR E0263,E0496 4 | | pub struct Foo<'__pin, T> { @@ -10,46 +10,8 @@ error[E0263]: lifetime name `'__pin` declared twice in the same scope 8 | | } | |_- previous declaration here -error[E0263]: lifetime name `'__pin` declared twice in the same scope - --> $DIR/overlapping_lifetime_names.rs:4:20 - | -3 | / pin_project! { //~ ERROR E0263,E0496 -4 | | pub struct Foo<'__pin, T> { - | | ^^^^^^ declared twice -5 | | #[pin] -6 | | field: &'__pin mut T, -7 | | } -8 | | } - | |_- previous declaration here - -error[E0263]: lifetime name `'__pin` declared twice in the same scope - --> $DIR/overlapping_lifetime_names.rs:4:20 - | -3 | / pin_project! { //~ ERROR E0263,E0496 -4 | | pub struct Foo<'__pin, T> { - | | ^^^^^^ declared twice -5 | | #[pin] -6 | | field: &'__pin mut T, -7 | | } -8 | | } - | |_- previous declaration here - -error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in scope - --> $DIR/overlapping_lifetime_names.rs:3:1 - | -3 | / pin_project! { //~ ERROR E0263,E0496 -4 | | pub struct Foo<'__pin, T> { - | | ------ first declared here -5 | | #[pin] -6 | | field: &'__pin mut T, -7 | | } -8 | | } - | |_^ lifetime `'__pin` already in scope - | - = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in scope - --> $DIR/overlapping_lifetime_names.rs:3:1 + --> tests/ui/pin_project/overlapping_lifetime_names.rs:3:1 | 3 | / pin_project! { //~ ERROR E0263,E0496 4 | | pub struct Foo<'__pin, T> { @@ -61,15 +23,3 @@ error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in | |_^ lifetime `'__pin` already in scope | = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0263]: lifetime name `'__pin` declared twice in the same scope - --> $DIR/overlapping_lifetime_names.rs:4:20 - | -3 | / pin_project! { //~ ERROR E0263,E0496 -4 | | pub struct Foo<'__pin, T> { - | | ^^^^^^ declared twice -5 | | #[pin] -6 | | field: &'__pin mut T, -7 | | } -8 | | } - | |_- previous declaration here diff --git a/tests/ui/pin_project/overlapping_unpin_struct.stderr b/tests/ui/pin_project/overlapping_unpin_struct.stderr index 9486f9d..1049879 100644 --- a/tests/ui/pin_project/overlapping_unpin_struct.stderr +++ b/tests/ui/pin_project/overlapping_unpin_struct.stderr @@ -1,15 +1,12 @@ error[E0277]: `PhantomPinned` cannot be unpinned - --> $DIR/overlapping_unpin_struct.rs:19:5 + --> tests/ui/pin_project/overlapping_unpin_struct.rs:19:5 | -16 | fn is_unpin<T: Unpin>() {} - | ----- required by this bound in `is_unpin` -... 19 | is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Origin<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned` | = note: consider using `Box::pin` note: required because it appears within the type `_::__Origin<'_, PhantomPinned>` - --> $DIR/overlapping_unpin_struct.rs:5:1 + --> tests/ui/pin_project/overlapping_unpin_struct.rs:5:1 | 5 | / pin_project! { 6 | | struct Foo<T> { @@ -18,5 +15,19 @@ note: required because it appears within the type `_::__Origin<'_, PhantomPinned 9 | | } 10 | | } | |_^ - = note: required because of the requirements on the impl of `Unpin` for `Foo<PhantomPinned>` +note: required because of the requirements on the impl of `Unpin` for `Foo<PhantomPinned>` + --> tests/ui/pin_project/overlapping_unpin_struct.rs:5:1 + | +5 | / pin_project! { +6 | | struct Foo<T> { +7 | | #[pin] +8 | | inner: T, +9 | | } +10 | | } + | |_^ +note: required by a bound in `is_unpin` + --> tests/ui/pin_project/overlapping_unpin_struct.rs:16:16 + | +16 | fn is_unpin<T: Unpin>() {} + | ^^^^^ required by this bound in `is_unpin` = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/packed.stderr b/tests/ui/pin_project/packed.stderr index 85f84c2..40a955e 100644 --- a/tests/ui/pin_project/packed.stderr +++ b/tests/ui/pin_project/packed.stderr @@ -1,5 +1,5 @@ error: reference to packed field is unaligned - --> $DIR/packed.rs:5:1 + --> tests/ui/pin_project/packed.rs:5:1 | 5 | / pin_project! { //~ ERROR reference to packed field is unaligned 6 | | #[repr(packed, C)] @@ -11,7 +11,7 @@ error: reference to packed field is unaligned | |_^ | note: the lint level is defined here - --> $DIR/packed.rs:5:1 + --> tests/ui/pin_project/packed.rs:5:1 | 5 | / pin_project! { //~ ERROR reference to packed field is unaligned 6 | | #[repr(packed, C)] @@ -24,10 +24,11 @@ note: the lint level is defined here = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: reference to packed field is unaligned - --> $DIR/packed.rs:13:1 + --> tests/ui/pin_project/packed.rs:13:1 | 13 | / pin_project! { //~ ERROR reference to packed field is unaligned 14 | | #[repr(packed(2))] @@ -39,7 +40,7 @@ error: reference to packed field is unaligned | |_^ | note: the lint level is defined here - --> $DIR/packed.rs:13:1 + --> tests/ui/pin_project/packed.rs:13:1 | 13 | / pin_project! { //~ ERROR reference to packed field is unaligned 14 | | #[repr(packed(2))] @@ -52,4 +53,5 @@ note: the lint level is defined here = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/unpin_sneaky.stderr b/tests/ui/pin_project/unpin_sneaky.stderr index 39a7745..4eb6eff 100644 --- a/tests/ui/pin_project/unpin_sneaky.stderr +++ b/tests/ui/pin_project/unpin_sneaky.stderr @@ -1,11 +1,11 @@ error[E0412]: cannot find type `__Origin` in this scope - --> $DIR/unpin_sneaky.rs:10:16 + --> tests/ui/pin_project/unpin_sneaky.rs:10:16 | 10 | impl Unpin for __Origin {} //~ ERROR E0412,E0321 | ^^^^^^^^ not found in this scope error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `[type error]` - --> $DIR/unpin_sneaky.rs:10:1 + --> tests/ui/pin_project/unpin_sneaky.rs:10:1 | 10 | impl Unpin for __Origin {} //~ ERROR E0412,E0321 | ^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type diff --git a/tests/ui/pin_project/unsupported.stderr b/tests/ui/pin_project/unsupported.stderr index 892e57c..d95f455 100644 --- a/tests/ui/pin_project/unsupported.stderr +++ b/tests/ui/pin_project/unsupported.stderr @@ -1,35 +1,35 @@ -error: no rules expected the token `[` - --> $DIR/unsupported.rs:3:1 +error: no rules expected the token `}` + --> tests/ui/pin_project/unsupported.rs:3:1 | 3 | / pin_project! { 4 | | struct Struct1 {} //~ ERROR no rules expected the token `}` 5 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected the token `[` - --> $DIR/unsupported.rs:7:1 + --> tests/ui/pin_project/unsupported.rs:7:1 | 7 | / pin_project! { 8 | | struct Struct2(); //~ ERROR no rules expected the token `(` 9 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected the token `[` - --> $DIR/unsupported.rs:11:1 + --> tests/ui/pin_project/unsupported.rs:11:1 | 11 | / pin_project! { 12 | | struct Struct3; //~ ERROR no rules expected the token `;` 13 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) -error: no rules expected the token `[` - --> $DIR/unsupported.rs:15:1 +error: no rules expected the token `enum` + --> tests/ui/pin_project/unsupported.rs:15:1 | 15 | / pin_project! { 16 | | enum Enum { //~ ERROR no rules expected the token `enum` @@ -38,10 +38,10 @@ error: no rules expected the token `[` 19 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) -error: no rules expected the token `[` - --> $DIR/unsupported.rs:21:1 +error: no rules expected the token `union` + --> tests/ui/pin_project/unsupported.rs:21:1 | 21 | / pin_project! { 22 | | union Union { //~ ERROR no rules expected the token `union` @@ -50,4 +50,4 @@ error: no rules expected the token `[` 25 | | } | |_^ no rules expected this token in macro call | - = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pinned_drop/call-drop-inner.stderr b/tests/ui/pinned_drop/call-drop-inner.stderr index 576e417..5bcb728 100644 --- a/tests/ui/pinned_drop/call-drop-inner.stderr +++ b/tests/ui/pinned_drop/call-drop-inner.stderr @@ -1,5 +1,5 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/call-drop-inner.rs:10:13 + --> tests/ui/pinned_drop/call-drop-inner.rs:10:13 | 10 | __drop_inner(this); | ^^^^^^^^^^^^ ---- supplied 1 argument @@ -7,7 +7,7 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied | expected 0 arguments | note: function defined here - --> $DIR/call-drop-inner.rs:3:1 + --> tests/ui/pinned_drop/call-drop-inner.rs:3:1 | 3 | / pin_project! { 4 | | pub struct S { diff --git a/tests/ui/pinned_drop/conditional-drop-impl.stderr b/tests/ui/pinned_drop/conditional-drop-impl.stderr index a67bc8d..f6c2075 100644 --- a/tests/ui/pinned_drop/conditional-drop-impl.stderr +++ b/tests/ui/pinned_drop/conditional-drop-impl.stderr @@ -1,11 +1,11 @@ error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not - --> $DIR/conditional-drop-impl.rs:9:9 + --> tests/ui/pinned_drop/conditional-drop-impl.rs:9:9 | 9 | impl<T: Unpin> Drop for DropImpl<T> { | ^^^^^ | note: the implementor must specify the same requirement - --> $DIR/conditional-drop-impl.rs:5:1 + --> tests/ui/pinned_drop/conditional-drop-impl.rs:5:1 | 5 | / struct DropImpl<T> { 6 | | f: T, @@ -13,7 +13,7 @@ note: the implementor must specify the same requirement | |_^ error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not - --> $DIR/conditional-drop-impl.rs:14:1 + --> tests/ui/pinned_drop/conditional-drop-impl.rs:14:1 | 14 | / pin_project! { 15 | | //~^ ERROR E0367 @@ -25,7 +25,7 @@ error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented f | |_^ | note: the implementor must specify the same requirement - --> $DIR/conditional-drop-impl.rs:14:1 + --> tests/ui/pinned_drop/conditional-drop-impl.rs:14:1 | 14 | / pin_project! { 15 | | //~^ ERROR E0367 |