From c95dc516440636acb2e9f0b61e3a4595a90c4d2e Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Wed, 19 May 2021 16:12:52 -0700 Subject: Upgrade rust/crates/pin-project to 1.0.7 Test: make Change-Id: I9cb8c4f9c94d68c5775ee9a360f4e882a836e186 --- tests/expand/default/struct.expanded.rs | 2 +- tests/expand/default/tuple_struct.expanded.rs | 2 +- tests/expand/multifields/struct.expanded.rs | 2 +- tests/expand/multifields/tuple_struct.expanded.rs | 2 +- tests/expand/naming/struct-all.expanded.rs | 2 +- tests/expand/naming/struct-mut.expanded.rs | 2 +- tests/expand/naming/struct-none.expanded.rs | 2 +- tests/expand/naming/struct-own.expanded.rs | 2 +- tests/expand/naming/struct-ref.expanded.rs | 2 +- tests/expand/naming/tuple_struct-all.expanded.rs | 2 +- tests/expand/naming/tuple_struct-mut.expanded.rs | 2 +- tests/expand/naming/tuple_struct-none.expanded.rs | 2 +- tests/expand/naming/tuple_struct-own.expanded.rs | 2 +- tests/expand/naming/tuple_struct-ref.expanded.rs | 2 +- tests/expand/not_unpin/struct.expanded.rs | 2 +- tests/expand/not_unpin/tuple_struct.expanded.rs | 2 +- tests/expand/pinned_drop/enum.expanded.rs | 3 +- tests/expand/pinned_drop/enum.rs | 3 +- tests/expand/pinned_drop/struct.expanded.rs | 5 +- tests/expand/pinned_drop/struct.rs | 3 +- tests/expand/pinned_drop/tuple_struct.expanded.rs | 5 +- tests/expand/pinned_drop/tuple_struct.rs | 3 +- tests/expand/project_replace/struct.expanded.rs | 2 +- .../project_replace/tuple_struct.expanded.rs | 2 +- tests/expand/pub/struct.expanded.rs | 2 +- tests/expand/pub/tuple_struct.expanded.rs | 2 +- tests/expand/unsafe_unpin/struct.expanded.rs | 2 +- tests/expand/unsafe_unpin/tuple_struct.expanded.rs | 2 +- tests/expandtest.rs | 8 +- tests/lint.rs | 2 +- tests/pinned_drop.rs | 20 +++++ tests/repr_packed.rs | 5 +- tests/ui/cfg/cfg_attr-type-mismatch.rs | 3 +- tests/ui/cfg/cfg_attr-type-mismatch.stderr | 8 +- tests/ui/cfg/packed_sneaky-span-issue-1.rs | 3 +- tests/ui/cfg/packed_sneaky-span-issue-1.stderr | 14 +-- tests/ui/cfg/packed_sneaky-span-issue-2.rs | 3 +- tests/ui/cfg/packed_sneaky-span-issue-2.stderr | 14 +-- tests/ui/cfg/unsupported.stderr | 5 +- tests/ui/not_unpin/conflict-unpin.stderr | 6 +- tests/ui/not_unpin/impl-unsafe-unpin.stderr | 6 +- tests/ui/pin_project/add-attr-to-struct.rs | 3 +- tests/ui/pin_project/add-attr-to-struct.stderr | 8 +- tests/ui/pin_project/add-pinned-field.stderr | 14 ++- tests/ui/pin_project/conflict-drop.rs | 3 +- tests/ui/pin_project/conflict-drop.stderr | 14 +-- tests/ui/pin_project/conflict-unpin.stderr | 6 +- tests/ui/pin_project/impl-unsafe-unpin.stderr | 6 +- tests/ui/pin_project/overlapping_unpin_struct.rs | 3 +- .../ui/pin_project/overlapping_unpin_struct.stderr | 13 ++- tests/ui/pin_project/packed-enum.rs | 4 + tests/ui/pin_project/packed-enum.stderr | 50 +++++++---- tests/ui/pin_project/packed-name-value.rs | 19 ++-- tests/ui/pin_project/packed-name-value.stderr | 22 ++--- tests/ui/pin_project/packed.rs | 14 ++- tests/ui/pin_project/packed.stderr | 6 ++ tests/ui/pin_project/packed_sneaky-1.rs | 3 +- tests/ui/pin_project/packed_sneaky-1.stderr | 12 +-- .../ui/pin_project/project_replace_unsized.stderr | 36 +++++--- .../project_replace_unsized_fn_params.stderr | 34 +++++-- tests/ui/pin_project/remove-attr-from-field.rs | 3 +- tests/ui/pin_project/remove-attr-from-field.stderr | 8 +- tests/ui/pin_project/remove-attr-from-struct.rs | 3 +- .../ui/pin_project/remove-attr-from-struct.stderr | 68 +++++++++----- tests/ui/pin_project/safe_packed_borrows.rs | 23 +++-- tests/ui/pin_project/safe_packed_borrows.stderr | 33 +++---- tests/ui/pin_project/unaligned_references.rs | 23 +++++ tests/ui/pin_project/unaligned_references.stderr | 44 +++++++++ tests/ui/pinned_drop/call-drop-inner.rs | 3 +- tests/ui/pinned_drop/call-drop-inner.stderr | 8 +- tests/ui/pinned_drop/conditional-drop-impl.rs | 3 +- tests/ui/pinned_drop/conditional-drop-impl.stderr | 27 +++--- tests/ui/pinned_drop/invalid.rs | 6 +- tests/ui/pinned_drop/invalid.stderr | 100 ++++++++++----------- tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs | 3 +- .../ui/pinned_drop/pinned-drop-no-attr-arg.stderr | 8 +- tests/ui/pinned_drop/self.rs | 6 +- tests/ui/pinned_drop/self.stderr | 34 +++---- tests/ui/pinned_drop/unsafe-call.rs | 3 +- tests/ui/pinned_drop/unsafe-call.stderr | 4 +- tests/ui/unsafe_unpin/conflict-unpin.stderr | 6 +- .../marker_trait_attr-feature-gate.rs | 3 +- .../marker_trait_attr-feature-gate.stderr | 8 +- tests/ui/unstable-features/marker_trait_attr.rs | 3 +- .../ui/unstable-features/marker_trait_attr.stderr | 8 +- .../overlapping_marker_traits-feature-gate.rs | 3 +- .../overlapping_marker_traits-feature-gate.stderr | 8 +- .../unstable-features/overlapping_marker_traits.rs | 7 +- .../overlapping_marker_traits.stderr | 8 +- .../ui/unstable-features/trivial_bounds-bug.stderr | 2 + .../trivial_bounds-feature-gate.stderr | 18 +++- 91 files changed, 567 insertions(+), 350 deletions(-) create mode 100644 tests/ui/pin_project/unaligned_references.rs create mode 100644 tests/ui/pin_project/unaligned_references.stderr (limited to 'tests') diff --git a/tests/expand/default/struct.expanded.rs b/tests/expand/default/struct.expanded.rs index 2528ece..70f04ef 100644 --- a/tests/expand/default/struct.expanded.rs +++ b/tests/expand/default/struct.expanded.rs @@ -77,7 +77,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/default/tuple_struct.expanded.rs b/tests/expand/default/tuple_struct.expanded.rs index 3e8e306..1322d22 100644 --- a/tests/expand/default/tuple_struct.expanded.rs +++ b/tests/expand/default/tuple_struct.expanded.rs @@ -65,7 +65,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/multifields/struct.expanded.rs b/tests/expand/multifields/struct.expanded.rs index 17dab6a..1f7dfdd 100644 --- a/tests/expand/multifields/struct.expanded.rs +++ b/tests/expand/multifields/struct.expanded.rs @@ -142,7 +142,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned1; let _ = &this.pinned2; diff --git a/tests/expand/multifields/tuple_struct.expanded.rs b/tests/expand/multifields/tuple_struct.expanded.rs index 28e7fd8..aef8f8d 100644 --- a/tests/expand/multifields/tuple_struct.expanded.rs +++ b/tests/expand/multifields/tuple_struct.expanded.rs @@ -118,7 +118,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/naming/struct-all.expanded.rs b/tests/expand/naming/struct-all.expanded.rs index 6506928..88e024c 100644 --- a/tests/expand/naming/struct-all.expanded.rs +++ b/tests/expand/naming/struct-all.expanded.rs @@ -109,7 +109,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/naming/struct-mut.expanded.rs b/tests/expand/naming/struct-mut.expanded.rs index 53c5212..1365b23 100644 --- a/tests/expand/naming/struct-mut.expanded.rs +++ b/tests/expand/naming/struct-mut.expanded.rs @@ -75,7 +75,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/naming/struct-none.expanded.rs b/tests/expand/naming/struct-none.expanded.rs index 2528ece..70f04ef 100644 --- a/tests/expand/naming/struct-none.expanded.rs +++ b/tests/expand/naming/struct-none.expanded.rs @@ -77,7 +77,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/naming/struct-own.expanded.rs b/tests/expand/naming/struct-own.expanded.rs index 0c1fc76..899166f 100644 --- a/tests/expand/naming/struct-own.expanded.rs +++ b/tests/expand/naming/struct-own.expanded.rs @@ -111,7 +111,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/naming/struct-ref.expanded.rs b/tests/expand/naming/struct-ref.expanded.rs index 3f52ac5..f636f10 100644 --- a/tests/expand/naming/struct-ref.expanded.rs +++ b/tests/expand/naming/struct-ref.expanded.rs @@ -77,7 +77,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/naming/tuple_struct-all.expanded.rs b/tests/expand/naming/tuple_struct-all.expanded.rs index 325b9db..e4032be 100644 --- a/tests/expand/naming/tuple_struct-all.expanded.rs +++ b/tests/expand/naming/tuple_struct-all.expanded.rs @@ -88,7 +88,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/naming/tuple_struct-mut.expanded.rs b/tests/expand/naming/tuple_struct-mut.expanded.rs index 8cbb11f..076e4a0 100644 --- a/tests/expand/naming/tuple_struct-mut.expanded.rs +++ b/tests/expand/naming/tuple_struct-mut.expanded.rs @@ -60,7 +60,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/naming/tuple_struct-none.expanded.rs b/tests/expand/naming/tuple_struct-none.expanded.rs index 3e8e306..1322d22 100644 --- a/tests/expand/naming/tuple_struct-none.expanded.rs +++ b/tests/expand/naming/tuple_struct-none.expanded.rs @@ -65,7 +65,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/naming/tuple_struct-own.expanded.rs b/tests/expand/naming/tuple_struct-own.expanded.rs index 84bc14b..eda8267 100644 --- a/tests/expand/naming/tuple_struct-own.expanded.rs +++ b/tests/expand/naming/tuple_struct-own.expanded.rs @@ -96,7 +96,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/naming/tuple_struct-ref.expanded.rs b/tests/expand/naming/tuple_struct-ref.expanded.rs index 587d741..3c2618f 100644 --- a/tests/expand/naming/tuple_struct-ref.expanded.rs +++ b/tests/expand/naming/tuple_struct-ref.expanded.rs @@ -62,7 +62,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/not_unpin/struct.expanded.rs b/tests/expand/not_unpin/struct.expanded.rs index efa660f..680fb03 100644 --- a/tests/expand/not_unpin/struct.expanded.rs +++ b/tests/expand/not_unpin/struct.expanded.rs @@ -77,7 +77,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/not_unpin/tuple_struct.expanded.rs b/tests/expand/not_unpin/tuple_struct.expanded.rs index 89a257e..8bc6bbc 100644 --- a/tests/expand/not_unpin/tuple_struct.expanded.rs +++ b/tests/expand/not_unpin/tuple_struct.expanded.rs @@ -65,7 +65,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/pinned_drop/enum.expanded.rs b/tests/expand/pinned_drop/enum.expanded.rs index c8eb0e4..6e6ed54 100644 --- a/tests/expand/pinned_drop/enum.expanded.rs +++ b/tests/expand/pinned_drop/enum.expanded.rs @@ -1,5 +1,5 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; # [pin (__private (PinnedDrop , project = EnumProj , project_ref = EnumProjRef))] enum Enum { Struct { @@ -130,6 +130,7 @@ const _: () = { } } }; +#[doc(hidden)] impl ::pin_project::__private::PinnedDrop for Enum { unsafe fn drop(self: Pin<&mut Self>) { #[allow(clippy::needless_pass_by_value)] diff --git a/tests/expand/pinned_drop/enum.rs b/tests/expand/pinned_drop/enum.rs index f5b8aa4..c162ef6 100644 --- a/tests/expand/pinned_drop/enum.rs +++ b/tests/expand/pinned_drop/enum.rs @@ -1,6 +1,7 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop, project = EnumProj, project_ref = EnumProjRef)] enum Enum { Struct { diff --git a/tests/expand/pinned_drop/struct.expanded.rs b/tests/expand/pinned_drop/struct.expanded.rs index 9d7f489..10ca8c1 100644 --- a/tests/expand/pinned_drop/struct.expanded.rs +++ b/tests/expand/pinned_drop/struct.expanded.rs @@ -1,5 +1,5 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; #[pin(__private(PinnedDrop))] struct Struct { #[pin] @@ -78,7 +78,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; @@ -112,6 +112,7 @@ const _: () = { } } }; +#[doc(hidden)] impl ::pin_project::__private::PinnedDrop for Struct { unsafe fn drop(self: Pin<&mut Self>) { #[allow(clippy::needless_pass_by_value)] diff --git a/tests/expand/pinned_drop/struct.rs b/tests/expand/pinned_drop/struct.rs index 948e6cc..691d3cb 100644 --- a/tests/expand/pinned_drop/struct.rs +++ b/tests/expand/pinned_drop/struct.rs @@ -1,6 +1,7 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop)] struct Struct { #[pin] diff --git a/tests/expand/pinned_drop/tuple_struct.expanded.rs b/tests/expand/pinned_drop/tuple_struct.expanded.rs index b30ee66..506726c 100644 --- a/tests/expand/pinned_drop/tuple_struct.expanded.rs +++ b/tests/expand/pinned_drop/tuple_struct.expanded.rs @@ -1,5 +1,5 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; #[pin(__private(PinnedDrop))] struct TupleStruct(#[pin] T, U); #[allow(box_pointers)] @@ -66,7 +66,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; @@ -100,6 +100,7 @@ const _: () = { } } }; +#[doc(hidden)] impl ::pin_project::__private::PinnedDrop for TupleStruct { unsafe fn drop(self: Pin<&mut Self>) { #[allow(clippy::needless_pass_by_value)] diff --git a/tests/expand/pinned_drop/tuple_struct.rs b/tests/expand/pinned_drop/tuple_struct.rs index a536039..1f4917c 100644 --- a/tests/expand/pinned_drop/tuple_struct.rs +++ b/tests/expand/pinned_drop/tuple_struct.rs @@ -1,6 +1,7 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop)] struct TupleStruct(#[pin] T, U); diff --git a/tests/expand/project_replace/struct.expanded.rs b/tests/expand/project_replace/struct.expanded.rs index 476c0ab..d3ed9e4 100644 --- a/tests/expand/project_replace/struct.expanded.rs +++ b/tests/expand/project_replace/struct.expanded.rs @@ -111,7 +111,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/project_replace/tuple_struct.expanded.rs b/tests/expand/project_replace/tuple_struct.expanded.rs index 0026a9f..91077f3 100644 --- a/tests/expand/project_replace/tuple_struct.expanded.rs +++ b/tests/expand/project_replace/tuple_struct.expanded.rs @@ -96,7 +96,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/pub/struct.expanded.rs b/tests/expand/pub/struct.expanded.rs index 246d9b6..7e6b975 100644 --- a/tests/expand/pub/struct.expanded.rs +++ b/tests/expand/pub/struct.expanded.rs @@ -77,7 +77,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/pub/tuple_struct.expanded.rs b/tests/expand/pub/tuple_struct.expanded.rs index 033fbaf..48355e3 100644 --- a/tests/expand/pub/tuple_struct.expanded.rs +++ b/tests/expand/pub/tuple_struct.expanded.rs @@ -65,7 +65,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expand/unsafe_unpin/struct.expanded.rs b/tests/expand/unsafe_unpin/struct.expanded.rs index 4066d49..76f4e52 100644 --- a/tests/expand/unsafe_unpin/struct.expanded.rs +++ b/tests/expand/unsafe_unpin/struct.expanded.rs @@ -77,7 +77,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &Struct) { let _ = &this.pinned; let _ = &this.unpinned; diff --git a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs index 59a40da..a0a52a8 100644 --- a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs +++ b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs @@ -65,7 +65,7 @@ const _: () = { } } } - #[forbid(safe_packed_borrows)] + #[forbid(unaligned_references, safe_packed_borrows)] fn __assert_not_repr_packed(this: &TupleStruct) { let _ = &this.0; let _ = &this.1; diff --git a/tests/expandtest.rs b/tests/expandtest.rs index adf8dde..4e08040 100644 --- a/tests/expandtest.rs +++ b/tests/expandtest.rs @@ -6,6 +6,8 @@ use std::{ process::{Command, ExitStatus, Stdio}, }; +const PATH: &str = "tests/expand/**/*.rs"; + #[rustversion::attr(not(nightly), ignore)] #[test] fn expandtest() { @@ -18,12 +20,12 @@ fn expandtest() { return; } - let path = "tests/expand/*/*.rs"; + let args = &["--all-features"]; if is_ci { - macrotest::expand_without_refresh(path); + macrotest::expand_without_refresh_args(PATH, args); } else { env::set_var("MACROTEST", "overwrite"); - macrotest::expand(path); + macrotest::expand_args(PATH, args); } } diff --git a/tests/lint.rs b/tests/lint.rs index e7aee5a..4820816 100644 --- a/tests/lint.rs +++ b/tests/lint.rs @@ -17,10 +17,10 @@ missing_docs, non_ascii_idents, noop_method_call, + or_patterns_back_compat, single_use_lifetimes, trivial_casts, trivial_numeric_casts, - unaligned_references, unreachable_pub, unused_extern_crates, unused_import_braces, diff --git a/tests/pinned_drop.rs b/tests/pinned_drop.rs index 9e7287d..785cea3 100644 --- a/tests/pinned_drop.rs +++ b/tests/pinned_drop.rs @@ -262,3 +262,23 @@ fn inside_macro() { mac!(1); } + +pub mod self_path { + use super::*; + + #[pin_project(PinnedDrop)] + pub struct S(T); + + fn f() {} + + #[pinned_drop] + impl PinnedDrop for self::S { + fn drop(mut self: Pin<&mut Self>) { + self::f(); + let _: self::S<()> = self::S(()); + let _: self::S> = self::S(self.as_mut()); + let self::S(()) = self::S(()); + let self::S(&mut Self(_)) = self::S(&mut *self); + } + } +} diff --git a/tests/repr_packed.rs b/tests/repr_packed.rs index a0d8bdc..e87aabf 100644 --- a/tests/repr_packed.rs +++ b/tests/repr_packed.rs @@ -1,5 +1,8 @@ #![warn(rust_2018_idioms, single_use_lifetimes)] -#![forbid(safe_packed_borrows)] +// unaligned_references did not exist in older compilers and safe_packed_borrows was removed in the latest compilers. +// https://github.com/rust-lang/rust/pull/82525 +#![allow(unknown_lints, renamed_and_removed_lints)] +#![forbid(unaligned_references, safe_packed_borrows)] use std::cell::Cell; diff --git a/tests/ui/cfg/cfg_attr-type-mismatch.rs b/tests/ui/cfg/cfg_attr-type-mismatch.rs index b075af9..1b9664b 100644 --- a/tests/ui/cfg/cfg_attr-type-mismatch.rs +++ b/tests/ui/cfg/cfg_attr-type-mismatch.rs @@ -1,6 +1,7 @@ -use pin_project::pin_project; use std::pin::Pin; +use pin_project::pin_project; + #[cfg_attr(not(any()), pin_project)] struct Foo { #[cfg_attr(any(), pin)] diff --git a/tests/ui/cfg/cfg_attr-type-mismatch.stderr b/tests/ui/cfg/cfg_attr-type-mismatch.stderr index 89172a2..576a08c 100644 --- a/tests/ui/cfg/cfg_attr-type-mismatch.stderr +++ b/tests/ui/cfg/cfg_attr-type-mismatch.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types - --> $DIR/cfg_attr-type-mismatch.rs:19:27 + --> $DIR/cfg_attr-type-mismatch.rs:20:27 | -19 | let _: Pin<&mut u8> = x.f; //~ ERROR E0308 +20 | let _: Pin<&mut u8> = x.f; //~ ERROR E0308 | ------------ ^^^ expected struct `Pin`, found `&mut u8` | | | expected due to this @@ -10,9 +10,9 @@ error[E0308]: mismatched types found mutable reference `&mut u8` error[E0308]: mismatched types - --> $DIR/cfg_attr-type-mismatch.rs:23:22 + --> $DIR/cfg_attr-type-mismatch.rs:24:22 | -23 | let _: &mut u8 = x.f; //~ ERROR E0308 +24 | let _: &mut u8 = x.f; //~ ERROR E0308 | ------- ^^^ | | | | | expected `&mut u8`, found struct `Pin` diff --git a/tests/ui/cfg/packed_sneaky-span-issue-1.rs b/tests/ui/cfg/packed_sneaky-span-issue-1.rs index 42f57b5..7e19952 100644 --- a/tests/ui/cfg/packed_sneaky-span-issue-1.rs +++ b/tests/ui/cfg/packed_sneaky-span-issue-1.rs @@ -2,9 +2,8 @@ use auxiliary_macro::hidden_repr; use pin_project::pin_project; #[pin_project] -#[hidden_repr(packed)] +#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types struct S { - //~^ ERROR may not be used on #[repr(packed)] types #[cfg(not(any()))] #[pin] f: u32, diff --git a/tests/ui/cfg/packed_sneaky-span-issue-1.stderr b/tests/ui/cfg/packed_sneaky-span-issue-1.stderr index abe3ecd..c98d3ee 100644 --- a/tests/ui/cfg/packed_sneaky-span-issue-1.stderr +++ b/tests/ui/cfg/packed_sneaky-span-issue-1.stderr @@ -1,11 +1,5 @@ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> $DIR/packed_sneaky-span-issue-1.rs:6:1 - | -6 | / struct S { -7 | | //~^ ERROR may not be used on #[repr(packed)] types -8 | | #[cfg(not(any()))] -9 | | #[pin] -... | -13 | | f: u8, -14 | | } - | |_^ + --> $DIR/packed_sneaky-span-issue-1.rs:5:15 + | +5 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types + | ^^^^^^ diff --git a/tests/ui/cfg/packed_sneaky-span-issue-2.rs b/tests/ui/cfg/packed_sneaky-span-issue-2.rs index 948d72c..fcea76b 100644 --- a/tests/ui/cfg/packed_sneaky-span-issue-2.rs +++ b/tests/ui/cfg/packed_sneaky-span-issue-2.rs @@ -2,9 +2,8 @@ use auxiliary_macro::hidden_repr; use pin_project::pin_project; #[pin_project] -#[hidden_repr(packed)] +#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types struct S { - //~^ ERROR may not be used on #[repr(packed)] types #[cfg(any())] #[pin] f: u32, diff --git a/tests/ui/cfg/packed_sneaky-span-issue-2.stderr b/tests/ui/cfg/packed_sneaky-span-issue-2.stderr index a957ceb..25b9cdc 100644 --- a/tests/ui/cfg/packed_sneaky-span-issue-2.stderr +++ b/tests/ui/cfg/packed_sneaky-span-issue-2.stderr @@ -1,11 +1,5 @@ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> $DIR/packed_sneaky-span-issue-2.rs:6:1 - | -6 | / struct S { -7 | | //~^ ERROR may not be used on #[repr(packed)] types -8 | | #[cfg(any())] -9 | | #[pin] -... | -13 | | f: u8, -14 | | } - | |_^ + --> $DIR/packed_sneaky-span-issue-2.rs:5:15 + | +5 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types + | ^^^^^^ diff --git a/tests/ui/cfg/unsupported.stderr b/tests/ui/cfg/unsupported.stderr index b3bd1ae..7ad20d1 100644 --- a/tests/ui/cfg/unsupported.stderr +++ b/tests/ui/cfg/unsupported.stderr @@ -1,7 +1,8 @@ error: #[pin_project] attribute may not be used on structs with zero fields - --> $DIR/unsupported.rs:4:1 + --> $DIR/unsupported.rs:4:10 | -4 | / struct S { +4 | struct S { + | __________^ 5 | | //~^ ERROR may not be used on structs with zero fields 6 | | #[cfg(any())] 7 | | #[pin] diff --git a/tests/ui/not_unpin/conflict-unpin.stderr b/tests/ui/not_unpin/conflict-unpin.stderr index e90a574..7b43b0f 100644 --- a/tests/ui/not_unpin/conflict-unpin.stderr +++ b/tests/ui/not_unpin/conflict-unpin.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>` --> $DIR/conflict-unpin.rs:3:15 | 3 | #[pin_project(!Unpin)] //~ ERROR E0119 @@ -7,7 +7,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type 10 | impl Unpin for Foo where T: Unpin {} | --------------------------------------------- first implementation here -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>` --> $DIR/conflict-unpin.rs:12:15 | 12 | #[pin_project(!Unpin)] //~ ERROR E0119 @@ -16,7 +16,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type 19 | impl Unpin for Bar {} | ------------------------------ first implementation here -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>` --> $DIR/conflict-unpin.rs:21:15 | 21 | #[pin_project(!Unpin)] //~ ERROR E0119 diff --git a/tests/ui/not_unpin/impl-unsafe-unpin.stderr b/tests/ui/not_unpin/impl-unsafe-unpin.stderr index ba80d5e..43cd4f1 100644 --- a/tests/ui/not_unpin/impl-unsafe-unpin.stderr +++ b/tests/ui/not_unpin/impl-unsafe-unpin.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Foo<_, _>`: +error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Foo<_, _>` --> $DIR/impl-unsafe-unpin.rs:3:1 | 3 | #[pin_project(!Unpin)] //~ ERROR E0119 @@ -9,7 +9,7 @@ error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` fo | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Bar<_, _>`: +error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Bar<_, _>` --> $DIR/impl-unsafe-unpin.rs:12:1 | 12 | #[pin_project(!Unpin)] //~ ERROR E0119 @@ -20,7 +20,7 @@ error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` fo | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Baz<_, _>`: +error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Baz<_, _>` --> $DIR/impl-unsafe-unpin.rs:21:1 | 21 | #[pin_project(!Unpin)] //~ ERROR E0119 diff --git a/tests/ui/pin_project/add-attr-to-struct.rs b/tests/ui/pin_project/add-attr-to-struct.rs index 55f1561..045e796 100644 --- a/tests/ui/pin_project/add-attr-to-struct.rs +++ b/tests/ui/pin_project/add-attr-to-struct.rs @@ -1,6 +1,7 @@ +use std::marker::PhantomPinned; + use auxiliary_macro::add_pin_attr; use pin_project::pin_project; -use std::marker::PhantomPinned; #[pin_project] #[add_pin_attr(struct)] //~ ERROR duplicate #[pin] attribute diff --git a/tests/ui/pin_project/add-attr-to-struct.stderr b/tests/ui/pin_project/add-attr-to-struct.stderr index 27656d6..f3ee9e4 100644 --- a/tests/ui/pin_project/add-attr-to-struct.stderr +++ b/tests/ui/pin_project/add-attr-to-struct.stderr @@ -1,15 +1,15 @@ error: duplicate #[pin] attribute - --> $DIR/add-attr-to-struct.rs:6:1 + --> $DIR/add-attr-to-struct.rs:7:1 | -6 | #[add_pin_attr(struct)] //~ ERROR duplicate #[pin] attribute +7 | #[add_pin_attr(struct)] //~ ERROR duplicate #[pin] attribute | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) error: #[pin] attribute may only be used on fields of structs or variants - --> $DIR/add-attr-to-struct.rs:12:1 + --> $DIR/add-attr-to-struct.rs:13:1 | -12 | #[add_pin_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants +13 | #[add_pin_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/add-pinned-field.stderr b/tests/ui/pin_project/add-pinned-field.stderr index a140694..a391f3b 100644 --- a/tests/ui/pin_project/add-pinned-field.stderr +++ b/tests/ui/pin_project/add-pinned-field.stderr @@ -7,7 +7,12 @@ error[E0277]: `PhantomPinned` cannot be unpinned 21 | is_unpin::(); //~ ERROR E0277 | ^^^^^^^^^^^^^^^ within `__Foo<'_>`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `__Foo<'_>` + = note: consider using `Box::pin` +note: required because it appears within the type `__Foo<'_>` + --> $DIR/add-pinned-field.rs:8:8 + | +8 | struct Foo { + | ^^^ = note: required because of the requirements on the impl of `Unpin` for `Foo` error[E0277]: `PhantomPinned` cannot be unpinned @@ -19,5 +24,10 @@ error[E0277]: `PhantomPinned` cannot be unpinned 22 | is_unpin::(); //~ ERROR E0277 | ^^^^^^^^^^^^^^^ within `__Bar<'_>`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `__Bar<'_>` + = note: consider using `Box::pin` +note: required because it appears within the type `__Bar<'_>` + --> $DIR/add-pinned-field.rs:15:8 + | +15 | struct Bar { + | ^^^ = note: required because of the requirements on the impl of `Unpin` for `Bar` diff --git a/tests/ui/pin_project/conflict-drop.rs b/tests/ui/pin_project/conflict-drop.rs index 908f5c0..4fdb118 100644 --- a/tests/ui/pin_project/conflict-drop.rs +++ b/tests/ui/pin_project/conflict-drop.rs @@ -1,6 +1,7 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; + #[pin_project] //~ ERROR E0119 struct Foo { #[pin] diff --git a/tests/ui/pin_project/conflict-drop.stderr b/tests/ui/pin_project/conflict-drop.stderr index d5ca7b3..ae51456 100644 --- a/tests/ui/pin_project/conflict-drop.stderr +++ b/tests/ui/pin_project/conflict-drop.stderr @@ -1,7 +1,7 @@ -error[E0119]: conflicting implementations of trait `_::FooMustNotImplDrop` for type `Foo<_, _>`: - --> $DIR/conflict-drop.rs:4:1 +error[E0119]: conflicting implementations of trait `_::FooMustNotImplDrop` for type `Foo<_, _>` + --> $DIR/conflict-drop.rs:5:1 | -4 | #[pin_project] //~ ERROR E0119 +5 | #[pin_project] //~ ERROR E0119 | ^^^^^^^^^^^^^^ | | | first implementation here @@ -9,11 +9,11 @@ error[E0119]: conflicting implementations of trait `_::FooMustNotImplDrop` for t | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `Bar<_, _>`: - --> $DIR/conflict-drop.rs:15:15 +error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `Bar<_, _>` + --> $DIR/conflict-drop.rs:16:15 | -15 | #[pin_project(PinnedDrop)] //~ ERROR E0119 +16 | #[pin_project(PinnedDrop)] //~ ERROR E0119 | ^^^^^^^^^^ conflicting implementation for `Bar<_, _>` ... -27 | impl Drop for Bar { +28 | impl Drop for Bar { | ----------------------------- first implementation here diff --git a/tests/ui/pin_project/conflict-unpin.stderr b/tests/ui/pin_project/conflict-unpin.stderr index 0d6f439..0401140 100644 --- a/tests/ui/pin_project/conflict-unpin.stderr +++ b/tests/ui/pin_project/conflict-unpin.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>` --> $DIR/conflict-unpin.rs:5:1 | 5 | #[pin_project] //~ ERROR E0119 @@ -9,7 +9,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>` --> $DIR/conflict-unpin.rs:17:1 | 17 | #[pin_project] //~ ERROR E0119 @@ -20,7 +20,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>` --> $DIR/conflict-unpin.rs:27:1 | 27 | #[pin_project] //~ ERROR E0119 diff --git a/tests/ui/pin_project/impl-unsafe-unpin.stderr b/tests/ui/pin_project/impl-unsafe-unpin.stderr index 78545c2..078baee 100644 --- a/tests/ui/pin_project/impl-unsafe-unpin.stderr +++ b/tests/ui/pin_project/impl-unsafe-unpin.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Foo<_, _>`: +error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Foo<_, _>` --> $DIR/impl-unsafe-unpin.rs:3:1 | 3 | #[pin_project] //~ ERROR E0119 @@ -9,7 +9,7 @@ error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` fo | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Bar<_, _>`: +error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Bar<_, _>` --> $DIR/impl-unsafe-unpin.rs:12:1 | 12 | #[pin_project] //~ ERROR E0119 @@ -20,7 +20,7 @@ error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` fo | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Baz<_, _>`: +error[E0119]: conflicting implementations of trait `pin_project::UnsafeUnpin` for type `Baz<_, _>` --> $DIR/impl-unsafe-unpin.rs:21:1 | 21 | #[pin_project] //~ ERROR E0119 diff --git a/tests/ui/pin_project/overlapping_unpin_struct.rs b/tests/ui/pin_project/overlapping_unpin_struct.rs index 8db0855..abfd5d1 100644 --- a/tests/ui/pin_project/overlapping_unpin_struct.rs +++ b/tests/ui/pin_project/overlapping_unpin_struct.rs @@ -1,6 +1,7 @@ -use pin_project::pin_project; use std::marker::PhantomPinned; +use pin_project::pin_project; + #[pin_project] struct S { #[pin] diff --git a/tests/ui/pin_project/overlapping_unpin_struct.stderr b/tests/ui/pin_project/overlapping_unpin_struct.stderr index 296b063..f49c736 100644 --- a/tests/ui/pin_project/overlapping_unpin_struct.stderr +++ b/tests/ui/pin_project/overlapping_unpin_struct.stderr @@ -1,11 +1,16 @@ error[E0277]: `PhantomPinned` cannot be unpinned - --> $DIR/overlapping_unpin_struct.rs:17:5 + --> $DIR/overlapping_unpin_struct.rs:18:5 | -14 | fn is_unpin() {} +15 | fn is_unpin() {} | ----- required by this bound in `is_unpin` ... -17 | is_unpin::>(); //~ ERROR E0277 +18 | is_unpin::>(); //~ ERROR E0277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__S<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `_::__S<'_, PhantomPinned>` + = note: consider using `Box::pin` +note: required because it appears within the type `_::__S<'_, PhantomPinned>` + --> $DIR/overlapping_unpin_struct.rs:6:8 + | +6 | struct S { + | ^ = note: required because of the requirements on the impl of `Unpin` for `S` diff --git a/tests/ui/pin_project/packed-enum.rs b/tests/ui/pin_project/packed-enum.rs index 9d4a4c3..023c08d 100644 --- a/tests/ui/pin_project/packed-enum.rs +++ b/tests/ui/pin_project/packed-enum.rs @@ -1,5 +1,9 @@ use pin_project::pin_project; +// #[repr(packed)] cannot be apply on enums and will be rejected by rustc. +// However, we should not rely on the behavior of rustc that rejects this. +// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001 + #[repr(packed)] //~ ERROR E0517 enum E1 { V(()), diff --git a/tests/ui/pin_project/packed-enum.stderr b/tests/ui/pin_project/packed-enum.stderr index afc8b30..0951944 100644 --- a/tests/ui/pin_project/packed-enum.stderr +++ b/tests/ui/pin_project/packed-enum.stderr @@ -1,30 +1,42 @@ +error: #[repr(packed)] attribute should be applied to a struct or union + --> $DIR/packed-enum.rs:13:8 + | +13 | #[repr(packed)] //~ ERROR E0517 + | ^^^^^^ + +error: #[repr(packed)] attribute should be applied to a struct or union + --> $DIR/packed-enum.rs:18:8 + | +18 | #[repr(packed)] //~ ERROR E0517 + | ^^^^^^ + error[E0517]: attribute should be applied to a struct or union - --> $DIR/packed-enum.rs:3:8 - | -3 | #[repr(packed)] //~ ERROR E0517 - | ^^^^^^ -4 | / enum E1 { -5 | | V(()), -6 | | } - | |_- not a struct or union + --> $DIR/packed-enum.rs:7:8 + | +7 | #[repr(packed)] //~ ERROR E0517 + | ^^^^^^ +8 | / enum E1 { +9 | | V(()), +10 | | } + | |_- not a struct or union error[E0517]: attribute should be applied to a struct or union - --> $DIR/packed-enum.rs:9:8 + --> $DIR/packed-enum.rs:13:8 | -9 | #[repr(packed)] //~ ERROR E0517 +13 | #[repr(packed)] //~ ERROR E0517 | ^^^^^^ -10 | / enum E2 { -11 | | V(()), -12 | | } +14 | / enum E2 { +15 | | V(()), +16 | | } | |_- not a struct or union error[E0517]: attribute should be applied to a struct or union - --> $DIR/packed-enum.rs:14:8 + --> $DIR/packed-enum.rs:18:8 | -14 | #[repr(packed)] //~ ERROR E0517 +18 | #[repr(packed)] //~ ERROR E0517 | ^^^^^^ -15 | #[pin_project] -16 | / enum E3 { -17 | | V(()), -18 | | } +19 | #[pin_project] +20 | / enum E3 { +21 | | V(()), +22 | | } | |_- not a struct or union diff --git a/tests/ui/pin_project/packed-name-value.rs b/tests/ui/pin_project/packed-name-value.rs index ed819ca..dedc403 100644 --- a/tests/ui/pin_project/packed-name-value.rs +++ b/tests/ui/pin_project/packed-name-value.rs @@ -1,17 +1,24 @@ use pin_project::pin_project; -#[repr(packed = "")] //~ ERROR E0552 -struct S1 { - f: (), -} +// #[repr(packed = "")] is not valid format of #[repr(packed)] and will be +// rejected by rustc. +// However, we should not rely on the behavior of rustc that rejects this. +// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001 + +// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001 +// https://github.com/rust-lang/rust/issues/83921 +// #[repr(packed = "")] //~ ERROR E0552 +// struct S1 { +// f: (), +// } #[pin_project] -#[repr(packed = "")] //~ ERROR E0552 +#[repr(packed = "")] //~ ERROR attribute should not be name-value pair struct S2 { f: (), } -#[repr(packed = "")] //~ ERROR E0552 +#[repr(packed = "")] //~ ERROR attribute should not be name-value pair #[pin_project] struct S3 { f: (), diff --git a/tests/ui/pin_project/packed-name-value.stderr b/tests/ui/pin_project/packed-name-value.stderr index a3e2571..51b82dd 100644 --- a/tests/ui/pin_project/packed-name-value.stderr +++ b/tests/ui/pin_project/packed-name-value.stderr @@ -1,17 +1,11 @@ -error[E0552]: unrecognized representation hint - --> $DIR/packed-name-value.rs:3:8 - | -3 | #[repr(packed = "")] //~ ERROR E0552 - | ^^^^^^^^^^^ - -error[E0552]: unrecognized representation hint - --> $DIR/packed-name-value.rs:9:8 - | -9 | #[repr(packed = "")] //~ ERROR E0552 - | ^^^^^^^^^^^ +error: #[repr(packed)] attribute should not be name-value pair + --> $DIR/packed-name-value.rs:16:8 + | +16 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair + | ^^^^^^^^^^^ -error[E0552]: unrecognized representation hint - --> $DIR/packed-name-value.rs:14:8 +error: #[repr(packed)] attribute should not be name-value pair + --> $DIR/packed-name-value.rs:21:8 | -14 | #[repr(packed = "")] //~ ERROR E0552 +21 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair | ^^^^^^^^^^^ diff --git a/tests/ui/pin_project/packed.rs b/tests/ui/pin_project/packed.rs index f756605..dd3ebfd 100644 --- a/tests/ui/pin_project/packed.rs +++ b/tests/ui/pin_project/packed.rs @@ -2,7 +2,7 @@ use pin_project::pin_project; #[pin_project] #[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types -struct A { +struct Packed1 { #[pin] f: u8, } @@ -10,14 +10,22 @@ struct A { // Test putting 'repr' before the 'pin_project' attribute #[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types #[pin_project] -struct B { +struct Packed2 { #[pin] f: u8, } #[pin_project] #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types -struct C { +struct PackedN1 { + #[pin] + f: u32, +} + +// Test putting 'repr' before the 'pin_project' attribute +#[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types +#[pin_project] +struct PackedN2 { #[pin] f: u32, } diff --git a/tests/ui/pin_project/packed.stderr b/tests/ui/pin_project/packed.stderr index 969faea..e5b9e55 100644 --- a/tests/ui/pin_project/packed.stderr +++ b/tests/ui/pin_project/packed.stderr @@ -15,3 +15,9 @@ error: #[pin_project] attribute may not be used on #[repr(packed)] types | 19 | #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types | ^^^^^^^^^ + +error: #[pin_project] attribute may not be used on #[repr(packed)] types + --> $DIR/packed.rs:26:8 + | +26 | #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types + | ^^^^^^^^^ diff --git a/tests/ui/pin_project/packed_sneaky-1.rs b/tests/ui/pin_project/packed_sneaky-1.rs index 38f6fe0..72d3d3e 100644 --- a/tests/ui/pin_project/packed_sneaky-1.rs +++ b/tests/ui/pin_project/packed_sneaky-1.rs @@ -1,6 +1,7 @@ +use std::pin::Pin; + use auxiliary_macro::hidden_repr; use pin_project::{pin_project, pinned_drop, UnsafeUnpin}; -use std::pin::Pin; #[pin_project] //~ ERROR may not be used on #[repr(packed)] types #[hidden_repr(packed)] diff --git a/tests/ui/pin_project/packed_sneaky-1.stderr b/tests/ui/pin_project/packed_sneaky-1.stderr index 510200e..67bcd1b 100644 --- a/tests/ui/pin_project/packed_sneaky-1.stderr +++ b/tests/ui/pin_project/packed_sneaky-1.stderr @@ -1,17 +1,17 @@ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> $DIR/packed_sneaky-1.rs:6:15 + --> $DIR/packed_sneaky-1.rs:7:15 | -6 | #[hidden_repr(packed)] +7 | #[hidden_repr(packed)] | ^^^^^^ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> $DIR/packed_sneaky-1.rs:13:15 + --> $DIR/packed_sneaky-1.rs:14:15 | -13 | #[hidden_repr(packed)] +14 | #[hidden_repr(packed)] | ^^^^^^ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> $DIR/packed_sneaky-1.rs:22:15 + --> $DIR/packed_sneaky-1.rs:23:15 | -22 | #[hidden_repr(packed)] +23 | #[hidden_repr(packed)] | ^^^^^^ diff --git a/tests/ui/pin_project/project_replace_unsized.stderr b/tests/ui/pin_project/project_replace_unsized.stderr index 26e416a..75a2666 100644 --- a/tests/ui/pin_project/project_replace_unsized.stderr +++ b/tests/ui/pin_project/project_replace_unsized.stderr @@ -4,9 +4,13 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 3 | #[pin_project(project_replace)] //~ ERROR E0277 | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time 4 | struct Struct { - | - this type parameter needs to be `Sized` + | - this type parameter needs to be `std::marker::Sized` | - = note: required because it appears within the type `Struct` +note: required because it appears within the type `Struct` + --> $DIR/project_replace_unsized.rs:4:8 + | +4 | struct Struct { + | ^^^^^^ = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | @@ -19,9 +23,13 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 3 | #[pin_project(project_replace)] //~ ERROR E0277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time 4 | struct Struct { - | - this type parameter needs to be `Sized` + | - this type parameter needs to be `std::marker::Sized` + | +note: required because it appears within the type `Struct` + --> $DIR/project_replace_unsized.rs:4:8 | - = note: required because it appears within the type `Struct` +4 | struct Struct { + | ^^^^^^ = note: required by `UnsafeOverwriteGuard` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) @@ -29,7 +37,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/project_replace_unsized.rs:5:5 | 4 | struct Struct { - | - this type parameter needs to be `Sized` + | - this type parameter needs to be `std::marker::Sized` 5 | f: T, | ^ doesn't have a size known at compile-time @@ -39,9 +47,13 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 8 | #[pin_project(project_replace)] //~ ERROR E0277 | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time 9 | struct TupleStruct(T); - | - this type parameter needs to be `Sized` + | - this type parameter needs to be `std::marker::Sized` + | +note: required because it appears within the type `TupleStruct` + --> $DIR/project_replace_unsized.rs:9:8 | - = note: required because it appears within the type `TupleStruct` +9 | struct TupleStruct(T); + | ^^^^^^^^^^^ = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | @@ -54,9 +66,13 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 8 | #[pin_project(project_replace)] //~ ERROR E0277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time 9 | struct TupleStruct(T); - | - this type parameter needs to be `Sized` + | - this type parameter needs to be `std::marker::Sized` | - = note: required because it appears within the type `TupleStruct` +note: required because it appears within the type `TupleStruct` + --> $DIR/project_replace_unsized.rs:9:8 + | +9 | struct TupleStruct(T); + | ^^^^^^^^^^^ = note: required by `UnsafeOverwriteGuard` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) @@ -64,7 +80,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/project_replace_unsized.rs:9:8 | 9 | struct TupleStruct(T); - | ^^^^^^^^^^^ - this type parameter needs to be `Sized` + | ^^^^^^^^^^^ - this type parameter needs to be `std::marker::Sized` | | | doesn't have a size known at compile-time | diff --git a/tests/ui/pin_project/project_replace_unsized_fn_params.stderr b/tests/ui/pin_project/project_replace_unsized_fn_params.stderr index f0f9573..f8cee98 100644 --- a/tests/ui/pin_project/project_replace_unsized_fn_params.stderr +++ b/tests/ui/pin_project/project_replace_unsized_fn_params.stderr @@ -4,10 +4,14 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 6 | struct Struct { | ^^^^^^^-^^^^^^^^^ | | | - | | this type parameter needs to be `Sized` + | | this type parameter needs to be `std::marker::Sized` | doesn't have a size known at compile-time | - = note: required because it appears within the type `__StructProjectionOwned` +note: required because it appears within the type `__StructProjectionOwned` + --> $DIR/project_replace_unsized_fn_params.rs:6:8 + | +6 | struct Struct { + | ^^^^^^ = note: the return type of a function must have a statically known size error[E0277]: the size for values of type `T` cannot be known at compilation time @@ -16,9 +20,13 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 5 | #[pin_project(project_replace)] //~ ERROR E0277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time 6 | struct Struct { - | - this type parameter needs to be `Sized` + | - this type parameter needs to be `std::marker::Sized` | - = note: required because it appears within the type `Struct` +note: required because it appears within the type `Struct` + --> $DIR/project_replace_unsized_fn_params.rs:6:8 + | +6 | struct Struct { + | ^^^^^^ = note: required by `UnsafeOverwriteGuard` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) @@ -26,7 +34,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/project_replace_unsized_fn_params.rs:7:5 | 6 | struct Struct { - | - this type parameter needs to be `Sized` + | - this type parameter needs to be `std::marker::Sized` 7 | f: T, | ^ doesn't have a size known at compile-time @@ -36,10 +44,14 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 11 | struct TupleStruct(T); | ^^^^^^^^^^^^-^^^^^^^^^ | | | - | | this type parameter needs to be `Sized` + | | this type parameter needs to be `std::marker::Sized` | doesn't have a size known at compile-time | - = note: required because it appears within the type `__TupleStructProjectionOwned` +note: required because it appears within the type `__TupleStructProjectionOwned` + --> $DIR/project_replace_unsized_fn_params.rs:11:8 + | +11 | struct TupleStruct(T); + | ^^^^^^^^^^^ = note: the return type of a function must have a statically known size error[E0277]: the size for values of type `T` cannot be known at compilation time @@ -48,8 +60,12 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 10 | #[pin_project(project_replace)] //~ ERROR E0277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time 11 | struct TupleStruct(T); - | - this type parameter needs to be `Sized` + | - this type parameter needs to be `std::marker::Sized` | - = note: required because it appears within the type `TupleStruct` +note: required because it appears within the type `TupleStruct` + --> $DIR/project_replace_unsized_fn_params.rs:11:8 + | +11 | struct TupleStruct(T); + | ^^^^^^^^^^^ = note: required by `UnsafeOverwriteGuard` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/remove-attr-from-field.rs b/tests/ui/pin_project/remove-attr-from-field.rs index bec8302..fd14da3 100644 --- a/tests/ui/pin_project/remove-attr-from-field.rs +++ b/tests/ui/pin_project/remove-attr-from-field.rs @@ -1,6 +1,7 @@ +use std::{marker::PhantomPinned, pin::Pin}; + use auxiliary_macro::remove_attr; use pin_project::pin_project; -use std::{marker::PhantomPinned, pin::Pin}; fn is_unpin() {} diff --git a/tests/ui/pin_project/remove-attr-from-field.stderr b/tests/ui/pin_project/remove-attr-from-field.stderr index 5d8caac..486bc00 100644 --- a/tests/ui/pin_project/remove-attr-from-field.stderr +++ b/tests/ui/pin_project/remove-attr-from-field.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types - --> $DIR/remove-attr-from-field.rs:27:38 + --> $DIR/remove-attr-from-field.rs:28:38 | -27 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308 +28 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308 | ----------------------- ^^^ expected struct `Pin`, found `&mut PhantomPinned` | | | expected due to this @@ -10,9 +10,9 @@ error[E0308]: mismatched types found mutable reference `&mut PhantomPinned` error[E0308]: mismatched types - --> $DIR/remove-attr-from-field.rs:31:38 + --> $DIR/remove-attr-from-field.rs:32:38 | -31 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308 +32 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308 | ----------------------- ^^^ expected struct `Pin`, found `&mut PhantomPinned` | | | expected due to this diff --git a/tests/ui/pin_project/remove-attr-from-struct.rs b/tests/ui/pin_project/remove-attr-from-struct.rs index 0086cf9..cbe5aba 100644 --- a/tests/ui/pin_project/remove-attr-from-struct.rs +++ b/tests/ui/pin_project/remove-attr-from-struct.rs @@ -1,6 +1,7 @@ +use std::{marker::PhantomPinned, pin::Pin}; + use auxiliary_macro::remove_attr; use pin_project::pin_project; -use std::{marker::PhantomPinned, pin::Pin}; fn is_unpin() {} diff --git a/tests/ui/pin_project/remove-attr-from-struct.stderr b/tests/ui/pin_project/remove-attr-from-struct.stderr index 4652b66..82fada5 100644 --- a/tests/ui/pin_project/remove-attr-from-struct.stderr +++ b/tests/ui/pin_project/remove-attr-from-struct.stderr @@ -1,71 +1,91 @@ error: #[pin_project] attribute has been removed - --> $DIR/remove-attr-from-struct.rs:21:1 + --> $DIR/remove-attr-from-struct.rs:22:1 | -21 | #[pin_project] //~ ERROR has been removed +22 | #[pin_project] //~ ERROR has been removed | ^^^^^^^^^^^^^^ | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find attribute `pin` in this scope - --> $DIR/remove-attr-from-struct.rs:17:7 + --> $DIR/remove-attr-from-struct.rs:18:7 | -17 | #[pin] //~ ERROR cannot find attribute `pin` in this scope +18 | #[pin] //~ ERROR cannot find attribute `pin` in this scope | ^^^ error: cannot find attribute `pin` in this scope - --> $DIR/remove-attr-from-struct.rs:10:7 + --> $DIR/remove-attr-from-struct.rs:11:7 | -10 | #[pin] //~ ERROR cannot find attribute `pin` in this scope +11 | #[pin] //~ ERROR cannot find attribute `pin` in this scope | ^^^ error[E0277]: `PhantomPinned` cannot be unpinned - --> $DIR/remove-attr-from-struct.rs:34:5 + --> $DIR/remove-attr-from-struct.rs:35:5 | -5 | fn is_unpin() {} +6 | fn is_unpin() {} | ----- required by this bound in `is_unpin` ... -34 | is_unpin::(); //~ ERROR E0277 +35 | is_unpin::(); //~ ERROR E0277 | ^^^^^^^^^^^^^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `A` + = note: consider using `Box::pin` +note: required because it appears within the type `A` + --> $DIR/remove-attr-from-struct.rs:10:8 + | +10 | struct A { + | ^ error[E0277]: `PhantomPinned` cannot be unpinned - --> $DIR/remove-attr-from-struct.rs:35:5 + --> $DIR/remove-attr-from-struct.rs:36:5 | -5 | fn is_unpin() {} +6 | fn is_unpin() {} | ----- required by this bound in `is_unpin` ... -35 | is_unpin::(); //~ ERROR E0277 +36 | is_unpin::(); //~ ERROR E0277 | ^^^^^^^^^^^^^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `B` + = note: consider using `Box::pin` +note: required because it appears within the type `B` + --> $DIR/remove-attr-from-struct.rs:17:8 + | +17 | struct B { + | ^ error[E0277]: `PhantomPinned` cannot be unpinned - --> $DIR/remove-attr-from-struct.rs:39:13 + --> $DIR/remove-attr-from-struct.rs:40:13 | -39 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599 +40 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599 | ^^^^^^^^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `A` + = note: consider using `Box::pin` +note: required because it appears within the type `A` + --> $DIR/remove-attr-from-struct.rs:10:8 + | +10 | struct A { + | ^ = note: required by `Pin::

::new` error[E0599]: no method named `project` found for struct `Pin<&mut A>` in the current scope - --> $DIR/remove-attr-from-struct.rs:39:30 + --> $DIR/remove-attr-from-struct.rs:40:30 | -39 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599 +40 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599 | ^^^^^^^ method not found in `Pin<&mut A>` error[E0277]: `PhantomPinned` cannot be unpinned - --> $DIR/remove-attr-from-struct.rs:42:13 + --> $DIR/remove-attr-from-struct.rs:43:13 | -42 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599 +43 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599 | ^^^^^^^^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `B` + = note: consider using `Box::pin` +note: required because it appears within the type `B` + --> $DIR/remove-attr-from-struct.rs:17:8 + | +17 | struct B { + | ^ = note: required by `Pin::

::new` error[E0599]: no method named `project` found for struct `Pin<&mut B>` in the current scope - --> $DIR/remove-attr-from-struct.rs:42:30 + --> $DIR/remove-attr-from-struct.rs:43:30 | -42 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599 +43 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599 | ^^^^^^^ method not found in `Pin<&mut B>` diff --git a/tests/ui/pin_project/safe_packed_borrows.rs b/tests/ui/pin_project/safe_packed_borrows.rs index db4ac2d..8f4f462 100644 --- a/tests/ui/pin_project/safe_packed_borrows.rs +++ b/tests/ui/pin_project/safe_packed_borrows.rs @@ -1,21 +1,28 @@ -#![forbid(safe_packed_borrows)] +#![deny(renamed_and_removed_lints)] +#![deny(safe_packed_borrows)] //~ ERROR has been renamed to `unaligned_references` +#![allow(unaligned_references)] -// Refs: https://github.com/rust-lang/rust/issues/46043 +// This lint was removed in https://github.com/rust-lang/rust/pull/82525 (nightly-2021-03-28). +// Refs: +// - https://github.com/rust-lang/rust/pull/82525 +// - https://github.com/rust-lang/rust/issues/46043 #[repr(packed)] -struct A { +struct Packed { f: u32, } #[repr(packed(2))] -struct B { +struct PackedN { f: u32, } fn main() { - let a = A { f: 1 }; - &a.f; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block + let a = Packed { f: 1 }; + &a.f; + let _ = &a.f; - let b = B { f: 1 }; - &b.f; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block + let b = PackedN { f: 1 }; + &b.f; + let _ = &b.f; } diff --git a/tests/ui/pin_project/safe_packed_borrows.stderr b/tests/ui/pin_project/safe_packed_borrows.stderr index c1f734a..4048eaa 100644 --- a/tests/ui/pin_project/safe_packed_borrows.stderr +++ b/tests/ui/pin_project/safe_packed_borrows.stderr @@ -1,24 +1,11 @@ -error: borrow of packed field is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe_packed_borrows.rs:17:5 - | -17 | &a.f; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block - | ^^^^ - | +error: lint `safe_packed_borrows` has been renamed to `unaligned_references` + --> $DIR/safe_packed_borrows.rs:2:9 + | +2 | #![deny(safe_packed_borrows)] //~ ERROR has been renamed to `unaligned_references` + | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `unaligned_references` + | note: the lint level is defined here - --> $DIR/safe_packed_borrows.rs:1:11 - | -1 | #![forbid(safe_packed_borrows)] - | ^^^^^^^^^^^^^^^^^^^ - = 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 #46043 - = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior - -error: borrow of packed field is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe_packed_borrows.rs:20:5 - | -20 | &b.f; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block - | ^^^^ - | - = 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 #46043 - = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior + --> $DIR/safe_packed_borrows.rs:1:9 + | +1 | #![deny(renamed_and_removed_lints)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pin_project/unaligned_references.rs b/tests/ui/pin_project/unaligned_references.rs new file mode 100644 index 0000000..23dd71d --- /dev/null +++ b/tests/ui/pin_project/unaligned_references.rs @@ -0,0 +1,23 @@ +#![forbid(unaligned_references)] + +// Refs: https://github.com/rust-lang/rust/issues/82523 + +#[repr(packed)] +struct Packed { + f: u32, +} + +#[repr(packed(2))] +struct PackedN { + f: u32, +} + +fn main() { + let a = Packed { f: 1 }; + &a.f; //~ ERROR reference to packed field is unaligned + let _ = &a.f; //~ ERROR reference to packed field is unaligned + + let b = PackedN { f: 1 }; + &b.f; //~ ERROR reference to packed field is unaligned + let _ = &b.f; //~ ERROR reference to packed field is unaligned +} diff --git a/tests/ui/pin_project/unaligned_references.stderr b/tests/ui/pin_project/unaligned_references.stderr new file mode 100644 index 0000000..17600de --- /dev/null +++ b/tests/ui/pin_project/unaligned_references.stderr @@ -0,0 +1,44 @@ +error: reference to packed field is unaligned + --> $DIR/unaligned_references.rs:17:5 + | +17 | &a.f; //~ ERROR reference to packed field is unaligned + | ^^^^ + | +note: the lint level is defined here + --> $DIR/unaligned_references.rs:1:11 + | +1 | #![forbid(unaligned_references)] + | ^^^^^^^^^^^^^^^^^^^^ + = 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 + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + +error: reference to packed field is unaligned + --> $DIR/unaligned_references.rs:18:13 + | +18 | let _ = &a.f; //~ ERROR reference to packed field is unaligned + | ^^^^ + | + = 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 + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + +error: reference to packed field is unaligned + --> $DIR/unaligned_references.rs:21:5 + | +21 | &b.f; //~ ERROR reference to packed field is unaligned + | ^^^^ + | + = 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 + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + +error: reference to packed field is unaligned + --> $DIR/unaligned_references.rs:22:13 + | +22 | let _ = &b.f; //~ ERROR reference to packed field is unaligned + | ^^^^ + | + = 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 + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) diff --git a/tests/ui/pinned_drop/call-drop-inner.rs b/tests/ui/pinned_drop/call-drop-inner.rs index 4171ed5..9f89942 100644 --- a/tests/ui/pinned_drop/call-drop-inner.rs +++ b/tests/ui/pinned_drop/call-drop-inner.rs @@ -1,6 +1,7 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop)] struct Struct { f: bool, diff --git a/tests/ui/pinned_drop/call-drop-inner.stderr b/tests/ui/pinned_drop/call-drop-inner.stderr index 53194b0..463e837 100644 --- a/tests/ui/pinned_drop/call-drop-inner.stderr +++ b/tests/ui/pinned_drop/call-drop-inner.stderr @@ -1,14 +1,14 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/call-drop-inner.rs:12:9 + --> $DIR/call-drop-inner.rs:13:9 | -12 | __drop_inner(__self); +13 | __drop_inner(__self); | ^^^^^^^^^^^^ ------ supplied 1 argument | | | expected 0 arguments | note: function defined here - --> $DIR/call-drop-inner.rs:9:1 + --> $DIR/call-drop-inner.rs:10:1 | -9 | #[pinned_drop] +10 | #[pinned_drop] | ^^^^^^^^^^^^^^ = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pinned_drop/conditional-drop-impl.rs b/tests/ui/pinned_drop/conditional-drop-impl.rs index fecfd50..23d756d 100644 --- a/tests/ui/pinned_drop/conditional-drop-impl.rs +++ b/tests/ui/pinned_drop/conditional-drop-impl.rs @@ -1,6 +1,7 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; + // In `Drop` impl, the implementor must specify the same requirement as type definition. struct DropImpl { diff --git a/tests/ui/pinned_drop/conditional-drop-impl.stderr b/tests/ui/pinned_drop/conditional-drop-impl.stderr index 6381a29..8ab2294 100644 --- a/tests/ui/pinned_drop/conditional-drop-impl.stderr +++ b/tests/ui/pinned_drop/conditional-drop-impl.stderr @@ -1,26 +1,31 @@ error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not - --> $DIR/conditional-drop-impl.rs:10:9 + --> $DIR/conditional-drop-impl.rs:11:9 | -10 | impl Drop for DropImpl { +11 | impl Drop for DropImpl { | ^^^^^ | note: the implementor must specify the same requirement - --> $DIR/conditional-drop-impl.rs:6:1 + --> $DIR/conditional-drop-impl.rs:7:1 | -6 | / struct DropImpl { -7 | | f: T, -8 | | } +7 | / struct DropImpl { +8 | | f: T, +9 | | } | |_^ error[E0277]: `T` cannot be unpinned - --> $DIR/conditional-drop-impl.rs:15:15 + --> $DIR/conditional-drop-impl.rs:16:15 | -15 | #[pin_project(PinnedDrop)] //~ ERROR E0277 +16 | #[pin_project(PinnedDrop)] //~ ERROR E0277 | ^^^^^^^^^^ the trait `Unpin` is not implemented for `T` | - = note: required because of the requirements on the impl of `PinnedDrop` for `PinnedDropImpl` + = note: consider using `Box::pin` +note: required because of the requirements on the impl of `PinnedDrop` for `PinnedDropImpl` + --> $DIR/conditional-drop-impl.rs:23:16 + | +23 | impl PinnedDrop for PinnedDropImpl { + | ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ = note: required by `pin_project::__private::PinnedDrop::drop` help: consider restricting type parameter `T` | -16 | struct PinnedDropImpl { - | ^^^^^^^ +17 | struct PinnedDropImpl { + | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pinned_drop/invalid.rs b/tests/ui/pinned_drop/invalid.rs index 7e36750..fdadf8a 100644 --- a/tests/ui/pinned_drop/invalid.rs +++ b/tests/ui/pinned_drop/invalid.rs @@ -1,7 +1,8 @@ mod argument { - use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; + use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop)] struct UnexpectedArg1(()); @@ -128,9 +129,10 @@ mod assoc_item { } mod method { - use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; + use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop)] struct RetUnit(()); diff --git a/tests/ui/pinned_drop/invalid.stderr b/tests/ui/pinned_drop/invalid.stderr index 277a2fa..499b0d9 100644 --- a/tests/ui/pinned_drop/invalid.stderr +++ b/tests/ui/pinned_drop/invalid.stderr @@ -1,143 +1,143 @@ error: unexpected token: foo - --> $DIR/invalid.rs:8:19 + --> $DIR/invalid.rs:9:19 | -8 | #[pinned_drop(foo)] //~ ERROR unexpected token +9 | #[pinned_drop(foo)] //~ ERROR unexpected token | ^^^ error: duplicate #[pinned_drop] attribute - --> $DIR/invalid.rs:29:5 + --> $DIR/invalid.rs:30:5 | -29 | #[pinned_drop] //~ ERROR duplicate #[pinned_drop] attribute +30 | #[pinned_drop] //~ ERROR duplicate #[pinned_drop] attribute | ^^^^^^^^^^^^^^ error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait - --> $DIR/invalid.rs:42:10 + --> $DIR/invalid.rs:43:10 | -42 | impl Drop for TraitImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait +43 | impl Drop for TraitImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait | ^^^^ error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait - --> $DIR/invalid.rs:48:10 + --> $DIR/invalid.rs:49:10 | -48 | impl InherentImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait +49 | impl InherentImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait | ^^^^^^^^^^^^ error: expected `impl` - --> $DIR/invalid.rs:51:5 + --> $DIR/invalid.rs:52:5 | -51 | fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl` +52 | fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl` | ^^ error: implementing the trait `PinnedDrop` is not unsafe - --> $DIR/invalid.rs:61:5 + --> $DIR/invalid.rs:62:5 | -61 | unsafe impl PinnedDrop for Impl { +62 | unsafe impl PinnedDrop for Impl { | ^^^^^^ error: implementing the method `drop` is not unsafe - --> $DIR/invalid.rs:71:9 + --> $DIR/invalid.rs:72:9 | -71 | unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe +72 | unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe | ^^^^^^ error: not all trait items implemented, missing: `drop` - --> $DIR/invalid.rs:82:5 + --> $DIR/invalid.rs:83:5 | -82 | impl PinnedDrop for Empty {} //~ ERROR not all trait items implemented, missing: `drop` +83 | impl PinnedDrop for Empty {} //~ ERROR not all trait items implemented, missing: `drop` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: const `A` is not a member of trait `PinnedDrop` - --> $DIR/invalid.rs:89:9 + --> $DIR/invalid.rs:90:9 | -89 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop` +90 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop` | ^^^^^^^^^^^^^^^^ error: const `A` is not a member of trait `PinnedDrop` - --> $DIR/invalid.rs:99:9 - | -99 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop` - | ^^^^^^^^^^^^^^^^ + --> $DIR/invalid.rs:100:9 + | +100 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop` + | ^^^^^^^^^^^^^^^^ error: type `A` is not a member of trait `PinnedDrop` - --> $DIR/invalid.rs:107:9 + --> $DIR/invalid.rs:108:9 | -107 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop` +108 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop` | ^^^^^^^^^^^^ error: type `A` is not a member of trait `PinnedDrop` - --> $DIR/invalid.rs:117:9 + --> $DIR/invalid.rs:118:9 | -117 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop` +118 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop` | ^^^^^^^^^^^^ error: duplicate definitions with name `drop` - --> $DIR/invalid.rs:126:9 + --> $DIR/invalid.rs:127:9 | -126 | fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop` +127 | fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: method `drop` must return the unit type - --> $DIR/invalid.rs:147:42 + --> $DIR/invalid.rs:149:42 | -147 | fn drop(self: Pin<&mut Self>) -> Self {} //~ ERROR method `drop` must return the unit type +149 | fn drop(self: Pin<&mut Self>) -> Self {} //~ ERROR method `drop` must return the unit type | ^^^^ error: method `drop` must take an argument `self: Pin<&mut Self>` - --> $DIR/invalid.rs:155:16 + --> $DIR/invalid.rs:157:16 | -155 | fn drop() {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` +157 | fn drop() {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` | ^^ error: method `drop` must take an argument `self: Pin<&mut Self>` - --> $DIR/invalid.rs:163:17 + --> $DIR/invalid.rs:165:17 | -163 | fn drop(self: Pin<&mut Self>, _: ()) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` +165 | fn drop(self: Pin<&mut Self>, _: ()) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: method `drop` must take an argument `self: Pin<&mut Self>` - --> $DIR/invalid.rs:171:17 + --> $DIR/invalid.rs:173:17 | -171 | fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` +173 | fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` | ^^^^^^^^^ error: method `drop` must take an argument `self: Pin<&mut Self>` - --> $DIR/invalid.rs:179:17 + --> $DIR/invalid.rs:181:17 | -179 | fn drop(_: Pin<&mut Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` +181 | fn drop(_: Pin<&mut Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` | ^^^^^^^^^^^^^^^^^ error: method `drop` must take an argument `self: Pin<&mut Self>` - --> $DIR/invalid.rs:187:17 + --> $DIR/invalid.rs:189:17 | -187 | fn drop(self: Pin<&Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` +189 | fn drop(self: Pin<&Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` | ^^^^^^^^^^^^^^^^ error: method `drop` must take an argument `self: Pin<&mut Self>` - --> $DIR/invalid.rs:195:17 + --> $DIR/invalid.rs:197:17 | -195 | fn drop(self: Pin<&mut ()>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` +197 | fn drop(self: Pin<&mut ()>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>` | ^^^^^^^^^^^^^^^^^^ error: method `pinned_drop` is not a member of trait `PinnedDrop - --> $DIR/invalid.rs:203:12 + --> $DIR/invalid.rs:205:12 | -203 | fn pinned_drop(self: Pin<&mut Self>) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop +205 | fn pinned_drop(self: Pin<&mut Self>) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop | ^^^^^^^^^^^ error: implementing the trait `PinnedDrop` on this type is unsupported - --> $DIR/invalid.rs:211:25 + --> $DIR/invalid.rs:213:25 | -211 | impl PinnedDrop for () { +213 | impl PinnedDrop for () { | ^^ error: implementing the trait `PinnedDrop` on this type is unsupported - --> $DIR/invalid.rs:217:25 + --> $DIR/invalid.rs:219:25 | -217 | impl PinnedDrop for &mut A { +219 | impl PinnedDrop for &mut A { | ^^^^^^ error: implementing the trait `PinnedDrop` on this type is unsupported - --> $DIR/invalid.rs:223:25 + --> $DIR/invalid.rs:225:25 | -223 | impl PinnedDrop for [A] { +225 | impl PinnedDrop for [A] { | ^^^ diff --git a/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs b/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs index f9db79c..391f290 100644 --- a/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs +++ b/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs @@ -1,6 +1,7 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; + #[pin_project] struct S { #[pin] diff --git a/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr b/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr index 6f868bf..9f32149 100644 --- a/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr +++ b/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr @@ -1,8 +1,8 @@ -error[E0119]: conflicting implementations of trait `pin_project::__private::PinnedDrop` for type `S`: - --> $DIR/pinned-drop-no-attr-arg.rs:11:1 +error[E0119]: conflicting implementations of trait `pin_project::__private::PinnedDrop` for type `S` + --> $DIR/pinned-drop-no-attr-arg.rs:12:1 | -4 | #[pin_project] +5 | #[pin_project] | -------------- first implementation here ... -11 | impl PinnedDrop for S { +12 | impl PinnedDrop for S { | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S` diff --git a/tests/ui/pinned_drop/self.rs b/tests/ui/pinned_drop/self.rs index 03825ca..ff63402 100644 --- a/tests/ui/pinned_drop/self.rs +++ b/tests/ui/pinned_drop/self.rs @@ -1,7 +1,8 @@ pub mod self_in_macro_def { - use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; + use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop)] pub struct S { f: (), @@ -23,9 +24,10 @@ pub mod self_in_macro_def { } pub mod self_span { - use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; + use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop)] pub struct S { f: (), diff --git a/tests/ui/pinned_drop/self.stderr b/tests/ui/pinned_drop/self.stderr index edab117..4ccbc41 100644 --- a/tests/ui/pinned_drop/self.stderr +++ b/tests/ui/pinned_drop/self.stderr @@ -1,42 +1,42 @@ error: `self` parameter is only allowed in associated functions - --> $DIR/self.rs:17:26 + --> $DIR/self.rs:18:26 | -17 | fn f(self: ()) {} //~ ERROR `self` parameter is only allowed in associated functions +18 | fn f(self: ()) {} //~ ERROR `self` parameter is only allowed in associated functions | ^^^^ not semantically valid as function parameter ... -20 | t!(); +21 | t!(); | ----- in this macro invocation | = note: associated functions are those in `impl` or `trait` definitions = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/self.rs:15:29 + --> $DIR/self.rs:16:29 | -15 | let _ = self; //~ ERROR E0434 +16 | let _ = self; //~ ERROR E0434 | ^^^^ ... -20 | t!(); +21 | t!(); | ----- in this macro invocation | = help: use the `|| { ... }` closure form instead = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0423]: expected value, found struct `S` - --> $DIR/self.rs:38:27 + --> $DIR/self.rs:40:27 | -30 | / pub struct S { -31 | | f: (), -32 | | } +32 | / pub struct S { +33 | | f: (), +34 | | } | |_____- `S` defined here ... -38 | let _: Self = Self; //~ ERROR E0423 +40 | let _: Self = Self; //~ ERROR E0423 | ^^^^ help: use struct literal syntax instead: `S { f: val }` error[E0308]: mismatched types - --> $DIR/self.rs:37:25 + --> $DIR/self.rs:39:25 | -37 | let _: () = self; //~ ERROR E0308 +39 | let _: () = self; //~ ERROR E0308 | -- ^^^^ expected `()`, found struct `Pin` | | | expected due to this @@ -45,9 +45,9 @@ error[E0308]: mismatched types found struct `Pin<&mut self_span::S>` error[E0308]: mismatched types - --> $DIR/self.rs:50:25 + --> $DIR/self.rs:52:25 | -50 | let _: () = self; //~ ERROR E0308 +52 | let _: () = self; //~ ERROR E0308 | -- ^^^^ expected `()`, found struct `Pin` | | | expected due to this @@ -56,7 +56,7 @@ error[E0308]: mismatched types found struct `Pin<&mut E>` error[E0533]: expected unit struct, unit variant or constant, found struct variant `Self::V` - --> $DIR/self.rs:51:27 + --> $DIR/self.rs:53:27 | -51 | let _: Self = Self::V; //~ ERROR E0533 +53 | let _: Self = Self::V; //~ ERROR E0533 | ^^^^^^^ diff --git a/tests/ui/pinned_drop/unsafe-call.rs b/tests/ui/pinned_drop/unsafe-call.rs index 7faf0fa..3ee2b56 100644 --- a/tests/ui/pinned_drop/unsafe-call.rs +++ b/tests/ui/pinned_drop/unsafe-call.rs @@ -1,6 +1,7 @@ -use pin_project::{pin_project, pinned_drop}; use std::pin::Pin; +use pin_project::{pin_project, pinned_drop}; + #[pin_project(PinnedDrop)] struct S { #[pin] diff --git a/tests/ui/pinned_drop/unsafe-call.stderr b/tests/ui/pinned_drop/unsafe-call.stderr index cd5e572..6216200 100644 --- a/tests/ui/pinned_drop/unsafe-call.stderr +++ b/tests/ui/pinned_drop/unsafe-call.stderr @@ -1,7 +1,7 @@ error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/unsafe-call.rs:13:9 + --> $DIR/unsafe-call.rs:14:9 | -13 | self.project().f.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133] +14 | self.project().f.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior diff --git a/tests/ui/unsafe_unpin/conflict-unpin.stderr b/tests/ui/unsafe_unpin/conflict-unpin.stderr index 916c3f2..078ac71 100644 --- a/tests/ui/unsafe_unpin/conflict-unpin.stderr +++ b/tests/ui/unsafe_unpin/conflict-unpin.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>` --> $DIR/conflict-unpin.rs:3:15 | 3 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119 @@ -9,7 +9,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | = note: upstream crates may add a new impl of trait `pin_project::UnsafeUnpin` for type `pin_project::__private::Wrapper<'_, Foo<_, _>>` in future versions -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>` --> $DIR/conflict-unpin.rs:12:15 | 12 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119 @@ -20,7 +20,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | = note: upstream crates may add a new impl of trait `pin_project::UnsafeUnpin` for type `pin_project::__private::Wrapper<'_, Bar<_, _>>` in future versions -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`: +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>` --> $DIR/conflict-unpin.rs:21:15 | 21 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119 diff --git a/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs b/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs index 127cd1a..542250b 100644 --- a/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs +++ b/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs @@ -1,8 +1,9 @@ // Note: If you change this test, change 'marker_trait_attr.rs' at the same time. -use pin_project::pin_project; use std::marker::PhantomPinned; +use pin_project::pin_project; + #[pin_project] //~ ERROR E0119 struct Struct { #[pin] diff --git a/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr b/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr index bab534b..44322ec 100644 --- a/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr +++ b/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`: - --> $DIR/marker_trait_attr-feature-gate.rs:6:1 +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>` + --> $DIR/marker_trait_attr-feature-gate.rs:7:1 | -6 | #[pin_project] //~ ERROR E0119 +7 | #[pin_project] //~ ERROR E0119 | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>` ... -13 | impl Unpin for Struct {} +14 | impl Unpin for Struct {} | --------------------------- first implementation here | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/unstable-features/marker_trait_attr.rs b/tests/ui/unstable-features/marker_trait_attr.rs index d6eab21..9c8e664 100644 --- a/tests/ui/unstable-features/marker_trait_attr.rs +++ b/tests/ui/unstable-features/marker_trait_attr.rs @@ -6,9 +6,10 @@ // See https://github.com/taiki-e/pin-project/issues/105#issuecomment-535355974 -use pin_project::pin_project; use std::marker::PhantomPinned; +use pin_project::pin_project; + #[pin_project] //~ ERROR E0119 struct Struct { #[pin] diff --git a/tests/ui/unstable-features/marker_trait_attr.stderr b/tests/ui/unstable-features/marker_trait_attr.stderr index 9b3ec57..8893fb2 100644 --- a/tests/ui/unstable-features/marker_trait_attr.stderr +++ b/tests/ui/unstable-features/marker_trait_attr.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`: - --> $DIR/marker_trait_attr.rs:12:1 +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>` + --> $DIR/marker_trait_attr.rs:13:1 | -12 | #[pin_project] //~ ERROR E0119 +13 | #[pin_project] //~ ERROR E0119 | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>` ... -19 | impl Unpin for Struct {} +20 | impl Unpin for Struct {} | --------------------------- first implementation here | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs b/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs index 9d1b8b8..012c870 100644 --- a/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs +++ b/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs @@ -1,8 +1,9 @@ // Note: If you change this test, change 'overlapping_marker_traits.rs' at the same time. -use pin_project::pin_project; use std::marker::PhantomPinned; +use pin_project::pin_project; + #[pin_project] //~ ERROR E0119 struct Struct { #[pin] diff --git a/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr b/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr index 4a8e238..64a0596 100644 --- a/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr +++ b/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`: - --> $DIR/overlapping_marker_traits-feature-gate.rs:6:1 +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>` + --> $DIR/overlapping_marker_traits-feature-gate.rs:7:1 | -6 | #[pin_project] //~ ERROR E0119 +7 | #[pin_project] //~ ERROR E0119 | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>` ... -13 | impl Unpin for Struct {} +14 | impl Unpin for Struct {} | --------------------------- first implementation here | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/unstable-features/overlapping_marker_traits.rs b/tests/ui/unstable-features/overlapping_marker_traits.rs index 0e0cddd..8dc27c1 100644 --- a/tests/ui/unstable-features/overlapping_marker_traits.rs +++ b/tests/ui/unstable-features/overlapping_marker_traits.rs @@ -3,16 +3,17 @@ // 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 +// - 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 pin_project::pin_project; use std::marker::PhantomPinned; +use pin_project::pin_project; + #[pin_project] struct Struct { #[pin] diff --git a/tests/ui/unstable-features/overlapping_marker_traits.stderr b/tests/ui/unstable-features/overlapping_marker_traits.stderr index 91aaf6c..ffa50c7 100644 --- a/tests/ui/unstable-features/overlapping_marker_traits.stderr +++ b/tests/ui/unstable-features/overlapping_marker_traits.stderr @@ -6,13 +6,13 @@ error[E0557]: 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<_>`: - --> $DIR/overlapping_marker_traits.rs:16:1 +error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>` + --> $DIR/overlapping_marker_traits.rs:17:1 | -16 | #[pin_project] +17 | #[pin_project] | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>` ... -23 | impl Unpin for Struct {} +24 | impl Unpin for Struct {} | --------------------------- first implementation here | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/unstable-features/trivial_bounds-bug.stderr b/tests/ui/unstable-features/trivial_bounds-bug.stderr index fff09f9..f2407d0 100644 --- a/tests/ui/unstable-features/trivial_bounds-bug.stderr +++ b/tests/ui/unstable-features/trivial_bounds-bug.stderr @@ -3,3 +3,5 @@ error[E0277]: `PhantomPinned` cannot be unpinned | 13 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277 | ^^^^^ the trait `Unpin` is not implemented for `PhantomPinned` + | + = note: consider using `Box::pin` diff --git a/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr b/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr index dd151b0..fa81083 100644 --- a/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr +++ b/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr @@ -4,6 +4,7 @@ error[E0277]: `PhantomPinned` cannot be unpinned 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 @@ -12,6 +13,8 @@ error[E0277]: `PhantomPinned` cannot be unpinned | 8 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277 | ^^^^^ the trait `Unpin` is not implemented for `PhantomPinned` + | + = note: consider using `Box::pin` error[E0277]: `PhantomPinned` cannot be unpinned --> $DIR/trivial_bounds-feature-gate.rs:16:5 @@ -19,6 +22,7 @@ error[E0277]: `PhantomPinned` cannot be unpinned 16 | impl Unpin for B where Wrapper: 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` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -29,7 +33,12 @@ error[E0277]: `PhantomPinned` cannot be unpinned 34 | impl Unpin for A where Inner: Unpin {} //~ ERROR E0277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Inner`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `Inner` + = note: consider using `Box::pin` +note: required because it appears within the type `Inner` + --> $DIR/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 @@ -39,7 +48,12 @@ error[E0277]: `PhantomPinned` cannot be unpinned 42 | impl Unpin for B where Wrapper: Unpin {} //~ ERROR E0277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Inner`, the trait `Unpin` is not implemented for `PhantomPinned` | - = note: required because it appears within the type `Inner` + = note: consider using `Box::pin` +note: required because it appears within the type `Inner` + --> $DIR/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` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable -- cgit v1.2.3