aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-07-10 20:23:30 -0700
committerChih-Hung Hsieh <chh@google.com>2020-07-13 22:26:50 -0700
commitd58366dc4a1a1ec807bb02dfc7928051799130ac (patch)
tree99470e8e8e4787e90b156f71bafac98438d6c39a /tests
parent09ba014483c2506939704e0b993a728958553e25 (diff)
downloadpin-project-d58366dc4a1a1ec807bb02dfc7928051799130ac.tar.gz
Upgrade rust/crates/pin-project to 0.4.22android-r-beta-3android-r-beta-2
* Keep local change in src/lib.rs Test: make Change-Id: I63ca4a3f247df2028bcb6cb849823b296865f444
Diffstat (limited to 'tests')
-rw-r--r--tests/cfg.rs16
-rw-r--r--tests/compiletest.rs2
-rw-r--r--tests/forbid_unsafe.rs108
-rw-r--r--tests/include/basic-safe-part.rs136
-rw-r--r--tests/include/basic.rs14
-rw-r--r--tests/lint.rs135
-rw-r--r--tests/lint.txt139
-rw-r--r--tests/lints.rs126
-rw-r--r--tests/overwriting_core_crate.rs116
-rw-r--r--tests/pin_project.rs214
-rw-r--r--tests/pinned_drop.rs230
-rw-r--r--tests/project.rs7
-rw-r--r--tests/project_if_attr.rs.in5
-rw-r--r--tests/project_ref.rs3
-rw-r--r--tests/project_replace.rs9
-rw-r--r--tests/repr_packed.rs1
-rw-r--r--tests/ui/cfg/cfg_attr-unpin.stderr4
-rw-r--r--tests/ui/cfg/proper_unpin.stderr4
-rw-r--r--tests/ui/not_unpin/conflict-unpin.stderr12
-rw-r--r--tests/ui/pin_project/add-attr-to-struct.rs (renamed from tests/ui/pin_project/add-pin-attr-to-struct.rs)0
-rw-r--r--tests/ui/pin_project/add-attr-to-struct.stderr (renamed from tests/ui/pin_project/add-pin-attr-to-struct.stderr)4
-rw-r--r--tests/ui/pin_project/add-pinned-field.stderr8
-rw-r--r--tests/ui/pin_project/conflict-drop.stderr2
-rw-r--r--tests/ui/pin_project/conflict-naming.rs6
-rw-r--r--tests/ui/pin_project/conflict-naming.stderr21
-rw-r--r--tests/ui/pin_project/invalid.rs64
-rw-r--r--tests/ui/pin_project/invalid.stderr244
-rw-r--r--tests/ui/pin_project/overlapping_unpin_struct.stderr4
-rw-r--r--tests/ui/pin_project/project_replace_unsized.rs11
-rw-r--r--tests/ui/pin_project/project_replace_unsized.stderr77
-rw-r--r--tests/ui/pin_project/project_replace_unsized_locals.rs13
-rw-r--r--tests/ui/pin_project/project_replace_unsized_locals.stderr64
-rw-r--r--tests/ui/pin_project/proper_unpin.stderr12
-rw-r--r--tests/ui/pin_project/remove-attr-from-field.rs16
-rw-r--r--tests/ui/pin_project/remove-attr-from-struct.rs36
-rw-r--r--tests/ui/pin_project/remove-attr-from-struct.stderr56
-rw-r--r--tests/ui/pin_project/visibility.rs6
-rw-r--r--tests/ui/pinned_drop/invalid.rs22
-rw-r--r--tests/ui/pinned_drop/invalid.stderr18
-rw-r--r--tests/ui/pinned_drop/self.rs46
-rw-r--r--tests/ui/pinned_drop/self.stderr47
-rw-r--r--tests/ui/project/ambiguous-let.rs2
-rw-r--r--tests/ui/project/ambiguous-let.stderr4
-rw-r--r--tests/ui/project/deprecated.rs8
-rw-r--r--tests/ui/project/deprecated.stderr23
-rw-r--r--tests/ui/project/invalid.rs4
-rw-r--r--tests/ui/project/invalid.stderr116
-rw-r--r--tests/ui/project/type-mismatch.rs6
-rw-r--r--tests/ui/project/type-mismatch.stderr19
-rw-r--r--tests/ui/project/use-public.rs2
-rw-r--r--tests/ui/project/use-public.stderr4
-rw-r--r--tests/ui/project/use.rs2
-rw-r--r--tests/ui/project/use.stderr8
-rw-r--r--tests/ui/unsafe_unpin/conflict-unpin.stderr15
-rw-r--r--tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs1
-rw-r--r--tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs2
-rw-r--r--tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr16
57 files changed, 1450 insertions, 840 deletions
diff --git a/tests/cfg.rs b/tests/cfg.rs
index 20b8472..4133517 100644
--- a/tests/cfg.rs
+++ b/tests/cfg.rs
@@ -21,7 +21,7 @@ struct Any(PhantomPinned);
fn cfg() {
// structs
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct SameName {
#[cfg(target_os = "linux")]
#[pin]
@@ -41,7 +41,7 @@ fn cfg() {
#[cfg(not(target_os = "linux"))]
let _x = SameName { inner: Other };
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct DifferentName {
#[cfg(target_os = "linux")]
#[pin]
@@ -61,7 +61,7 @@ fn cfg() {
#[cfg(not(target_os = "linux"))]
let _x = DifferentName { o: Other };
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct TupleStruct(
#[cfg(target_os = "linux")]
#[pin]
@@ -83,7 +83,7 @@ fn cfg() {
// enums
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Variant {
#[cfg(target_os = "linux")]
Inner(#[pin] Linux),
@@ -110,7 +110,7 @@ fn cfg() {
#[cfg(not(target_os = "linux"))]
let _x = Variant::Other(Other);
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Field {
SameName {
#[cfg(target_os = "linux")]
@@ -167,7 +167,7 @@ fn cfg() {
#[test]
fn cfg_attr() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct SameCfg {
#[cfg(target_os = "linux")]
#[cfg_attr(target_os = "linux", pin)]
@@ -193,7 +193,7 @@ fn cfg_attr() {
#[cfg(not(target_os = "linux"))]
let _: Pin<&mut Other> = x.inner;
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct DifferentCfg {
#[cfg(target_os = "linux")]
#[cfg_attr(target_os = "linux", pin)]
@@ -233,7 +233,7 @@ fn cfg_attr() {
#[test]
fn cfg_attr_any_packed() {
// Since `cfg(any())` can never be true, it is okay for this to pass.
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
#[cfg_attr(any(), repr(packed))]
struct Struct {
#[pin]
diff --git a/tests/compiletest.rs b/tests/compiletest.rs
index 078abaa..e78b3dc 100644
--- a/tests/compiletest.rs
+++ b/tests/compiletest.rs
@@ -1,6 +1,6 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
-#[ignore]
+#[rustversion::attr(not(nightly), ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
diff --git a/tests/forbid_unsafe.rs b/tests/forbid_unsafe.rs
deleted file mode 100644
index 4b2e248..0000000
--- a/tests/forbid_unsafe.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-#![forbid(unsafe_code)]
-#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![allow(dead_code)]
-
-// default #[pin_project], PinnedDrop, Replace, and !Unpin are completely safe.
-
-use pin_project::{pin_project, pinned_drop};
-use std::pin::Pin;
-
-#[pin_project]
-pub struct StructDefault<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project(PinnedDrop)]
-pub struct StructPinnedDrop<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pinned_drop]
-impl<T, U> PinnedDrop for StructPinnedDrop<T, U> {
- fn drop(self: Pin<&mut Self>) {}
-}
-
-#[pin_project(Replace)]
-pub struct StructReplace<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-// UnsafeUnpin without UnsafeUnpin impl is also safe
-#[pin_project(UnsafeUnpin)]
-pub struct StructUnsafeUnpin<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project(!Unpin)]
-pub struct StructNotUnpin<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project]
-pub enum EnumDefault<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pin_project(PinnedDrop)]
-pub enum EnumPinnedDrop<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pinned_drop]
-impl<T, U> PinnedDrop for EnumPinnedDrop<T, U> {
- fn drop(self: Pin<&mut Self>) {}
-}
-
-#[pin_project(Replace)]
-pub enum EnumReplace<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-// UnsafeUnpin without UnsafeUnpin impl is also safe
-#[pin_project(UnsafeUnpin)]
-pub enum EnumUnsafeUnpin<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pin_project(!Unpin)]
-pub enum EnumNotUnpin<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[test]
-fn test() {}
diff --git a/tests/include/basic-safe-part.rs b/tests/include/basic-safe-part.rs
new file mode 100644
index 0000000..fefc924
--- /dev/null
+++ b/tests/include/basic-safe-part.rs
@@ -0,0 +1,136 @@
+// default #[pin_project], PinnedDrop, project_replace, !Unpin, and UnsafeUnpin without UnsafeUnpin impl are completely safe.
+
+#[::pin_project::pin_project]
+#[derive(Debug)]
+pub struct DefaultStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project]
+#[derive(Debug)]
+pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project]
+#[derive(Debug)]
+pub enum DefaultEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[::pin_project::pin_project(PinnedDrop)]
+#[derive(Debug)]
+pub struct PinnedDropStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pinned_drop]
+impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+}
+
+#[::pin_project::pin_project(PinnedDrop)]
+#[derive(Debug)]
+pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pinned_drop]
+impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+}
+
+#[::pin_project::pin_project(PinnedDrop)]
+#[derive(Debug)]
+pub enum PinnedDropEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[::pin_project::pinned_drop]
+impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+}
+
+#[::pin_project::pin_project(project_replace)]
+#[derive(Debug)]
+pub struct ReplaceStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project(project_replace)]
+#[derive(Debug)]
+pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(project_replace)]
+#[derive(Debug)]
+pub enum ReplaceEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[::pin_project::pin_project(UnsafeUnpin)]
+#[derive(Debug)]
+pub struct UnsafeUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project(UnsafeUnpin)]
+#[derive(Debug)]
+pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(UnsafeUnpin)]
+#[derive(Debug)]
+pub enum UnsafeUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[::pin_project::pin_project(!Unpin)]
+#[derive(Debug)]
+pub struct NotUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project(!Unpin)]
+#[derive(Debug)]
+pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(!Unpin)]
+#[derive(Debug)]
+pub enum NotUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
diff --git a/tests/include/basic.rs b/tests/include/basic.rs
new file mode 100644
index 0000000..f862c63
--- /dev/null
+++ b/tests/include/basic.rs
@@ -0,0 +1,14 @@
+include!("basic-safe-part.rs");
+
+unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinStruct<T, U>
+{
+}
+unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct<T, U>
+{
+}
+unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinEnum<T, U>
+{
+}
diff --git a/tests/lint.rs b/tests/lint.rs
new file mode 100644
index 0000000..25cb649
--- /dev/null
+++ b/tests/lint.rs
@@ -0,0 +1,135 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+#![warn(future_incompatible, nonstandard_style, rust_2018_compatibility, unused)]
+#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
+
+#[allow(unknown_lints)] // for old compilers
+#[warn(
+ absolute_paths_not_starting_with_crate,
+ anonymous_parameters,
+ box_pointers,
+ confusable_idents,
+ deprecated_in_future,
+ elided_lifetimes_in_paths,
+ explicit_outlives_requirements,
+ indirect_structural_match,
+ keyword_idents,
+ macro_use_extern_crate,
+ meta_variable_misuse,
+ missing_copy_implementations,
+ missing_crate_level_docs,
+ missing_debug_implementations,
+ missing_docs,
+ missing_doc_code_examples,
+ non_ascii_idents,
+ private_doc_tests,
+ single_use_lifetimes,
+ trivial_casts,
+ trivial_numeric_casts,
+ unaligned_references,
+ unreachable_pub,
+ unstable_features,
+ unused_extern_crates,
+ unused_import_braces,
+ unused_lifetimes,
+ unused_qualifications,
+ unused_results,
+ variant_size_differences
+)]
+// unused_crate_dependencies: unrelated
+// unsafe_code: checked in forbid_unsafe module
+// unsafe_block_in_unsafe_fn: unstable
+pub mod basic {
+ include!("include/basic.rs");
+}
+
+pub mod forbid_unsafe {
+ #![forbid(unsafe_code)]
+
+ include!("include/basic-safe-part.rs");
+}
+
+pub mod clippy {
+ use pin_project::pin_project;
+
+ #[pin_project(project_replace)]
+ pub struct MutMutStruct<'a, T, U> {
+ #[pin]
+ pub pinned: &'a mut T,
+ pub unpinned: &'a mut U,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct MutMutTupleStruct<'a, T, U>(#[pin] &'a mut T, &'a mut U);
+
+ #[pin_project(project_replace)]
+ pub enum MutMutEnum<'a, T, U> {
+ Struct {
+ #[pin]
+ pinned: &'a mut T,
+ unpinned: &'a mut U,
+ },
+ Tuple(#[pin] &'a mut T, &'a mut U),
+ Unit,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct TypeRepetitionInBoundsStruct<T, U>
+ where
+ Self: Sized,
+ {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct TypeRepetitionInBoundsTupleStruct<T, U>(#[pin] T, U)
+ where
+ Self: Sized;
+
+ #[pin_project(project_replace)]
+ pub enum TypeRepetitionInBoundsEnum<T, U>
+ where
+ Self: Sized,
+ {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct UsedUnderscoreBindingStruct<T, U> {
+ #[pin]
+ pub _pinned: T,
+ pub _unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ pub enum UsedUnderscoreBindingEnum<T, U> {
+ Struct {
+ #[pin]
+ _pinned: T,
+ _unpinned: U,
+ },
+ }
+}
+
+#[rustversion::attr(not(since(2020-06-12)), ignore)]
+#[test]
+fn check_lint_list() {
+ use std::{env, process::Command, str};
+
+ (|| -> Result<(), Box<dyn std::error::Error>> {
+ let current = include_str!("lint.txt");
+ let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
+ let output = Command::new(rustc).args(&["-W", "help"]).output()?;
+ let new = str::from_utf8(&output.stdout)?;
+ assert_eq!(current, new);
+ Ok(())
+ })()
+ .unwrap_or_else(|e| panic!("{}", e));
+}
diff --git a/tests/lint.txt b/tests/lint.txt
new file mode 100644
index 0000000..5110d4b
--- /dev/null
+++ b/tests/lint.txt
@@ -0,0 +1,139 @@
+
+Available lint options:
+ -W <foo> Warn about <foo>
+ -A <foo> Allow <foo>
+ -D <foo> Deny <foo>
+ -F <foo> Forbid <foo> (deny <foo> and all attempts to override)
+
+
+Lint checks provided by rustc:
+
+ name default meaning
+ ---- ------- -------
+ absolute-paths-not-starting-with-crate allow fully qualified paths that start with a module name instead of `crate`, `self`, or an extern crate name
+ anonymous-parameters allow detects anonymous parameters
+ box-pointers allow use of owned (Box type) heap memory
+ confusable-idents allow detects visually confusable pairs between identifiers
+ deprecated-in-future allow detects use of items that will be deprecated in a future version
+ elided-lifetimes-in-paths allow hidden lifetime parameters in types are deprecated
+ explicit-outlives-requirements allow outlives requirements can be inferred
+ indirect-structural-match allow pattern with const indirectly referencing non-structural-match type
+ keyword-idents allow detects edition keywords being used as an identifier
+ macro-use-extern-crate allow the `#[macro_use]` attribute is now deprecated in favor of using macros via the module system
+ meta-variable-misuse allow possible meta-variable misuse at macro definition
+ missing-copy-implementations allow detects potentially-forgotten implementations of `Copy`
+ missing-crate-level-docs allow detects crates with no crate-level documentation
+ missing-debug-implementations allow detects missing implementations of Debug
+ missing-docs allow detects missing documentation for public members
+ missing-doc-code-examples allow detects publicly-exported items without code samples in their documentation
+ non-ascii-idents allow detects non-ASCII identifiers
+ private-doc-tests allow detects code samples in docs of private items not documented by rustdoc
+ single-use-lifetimes allow detects lifetime parameters that are only used once
+ trivial-casts allow detects trivial casts which could be removed
+ trivial-numeric-casts allow detects trivial casts of numeric types which could be removed
+ unaligned-references allow detects unaligned references to fields of packed structs
+ unreachable-pub allow `pub` items not reachable from crate root
+ unsafe-code allow usage of `unsafe` code
+ unsafe-op-in-unsafe-fn allow unsafe operations in unsafe functions without an explicit unsafe block are deprecated
+ unstable-features allow enabling unstable features (deprecated. do not use)
+ unused-crate-dependencies allow crate dependencies that are never used
+ unused-extern-crates allow extern crates that are never used
+ unused-import-braces allow unnecessary braces around an imported item
+ unused-lifetimes allow detects lifetime parameters that are never used
+ unused-qualifications allow detects unnecessarily qualified names
+ unused-results allow unused result of an expression in a statement
+ variant-size-differences allow detects enums with widely varying variant sizes
+ array-into-iter warn detects calling `into_iter` on arrays
+ asm-sub-register warn using only a subset of a register for inline asm inputs
+ bare-trait-objects warn suggest using `dyn Trait` for trait objects
+ bindings-with-variant-name warn detects pattern bindings with the same name as one of the matched variants
+ coherence-leak-check warn distinct impls distinguished only by the leak-check code
+ dead-code warn detect unused, unexported items
+ deprecated warn detects use of deprecated items
+ ellipsis-inclusive-range-patterns warn `...` range patterns are deprecated
+ exported-private-dependencies warn public interface leaks type from a private dependency
+ illegal-floating-point-literal-pattern warn floating-point literals cannot be used in patterns
+ improper-ctypes warn proper use of libc types in foreign modules
+ incomplete-features warn incomplete features that may function improperly in some or all cases
+ inline-no-sanitize warn detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`
+ intra-doc-link-resolution-failure warn failures in resolving intra-doc link targets
+ invalid-codeblock-attribute warn codeblock attribute looks a lot like a known one
+ invalid-value warn an invalid value is being created (such as a NULL reference)
+ irrefutable-let-patterns warn detects irrefutable patterns in if-let and while-let statements
+ late-bound-lifetime-arguments warn detects generic lifetime arguments in path segments with late bound lifetime parameters
+ mutable-borrow-reservation-conflict warn reservation of a two-phased borrow conflicts with other shared borrows
+ non-camel-case-types warn types, variants, traits and type parameters should have camel case names
+ non-shorthand-field-patterns warn using `Struct { x: x }` instead of `Struct { x }` in a pattern
+ non-snake-case warn variables, methods, functions, lifetime parameters and modules should have snake case names
+ non-upper-case-globals warn static constants should have uppercase identifiers
+ no-mangle-generic-items warn generic items must be mangled
+ overlapping-patterns warn detects overlapping patterns
+ path-statements warn path statements with no effect
+ private-in-public warn detect private items in public interfaces not caught by the old implementation
+ proc-macro-derive-resolution-fallback warn detects proc macro derives using inaccessible names from parent modules
+ redundant-semicolons warn detects unnecessary trailing semicolons
+ renamed-and-removed-lints warn lints that have been renamed or removed
+ safe-packed-borrows warn safe borrows of fields of packed structs were erroneously allowed
+ stable-features warn stable features found in `#[feature]` directive
+ trivial-bounds warn these bounds don't depend on an type parameters
+ type-alias-bounds warn bounds in type aliases are not enforced
+ tyvar-behind-raw-pointer warn raw pointer to an inference variable
+ uncommon-codepoints warn detects uncommon Unicode codepoints in identifiers
+ unconditional-recursion warn functions that cannot return without calling themselves
+ unknown-lints warn unrecognized lint attribute
+ unnameable-test-items warn detects an item that cannot be named being marked as `#[test_case]`
+ unreachable-code warn detects unreachable code paths
+ unreachable-patterns warn detects unreachable patterns
+ unstable-name-collisions warn detects name collision with an existing but unstable method
+ unused-allocation warn detects unnecessary allocations that can be eliminated
+ unused-assignments warn detect assignments that will never be read
+ unused-attributes warn detects attributes that were not used by the compiler
+ unused-braces warn unnecessary braces around an expression
+ unused-comparisons warn comparisons made useless by limits of the types involved
+ unused-doc-comments warn detects doc comments that aren't used by rustdoc
+ unused-features warn unused features found in crate-level `#[feature]` directives
+ unused-imports warn imports that are never used
+ unused-labels warn detects labels that are never used
+ unused-macros warn detects macros that were not used
+ unused-must-use warn unused result of a type flagged as `#[must_use]`
+ unused-mut warn detect mut variables which don't need to be mutable
+ unused-parens warn `if`, `match`, `while` and `return` do not need parentheses
+ unused-unsafe warn unnecessary use of an `unsafe` block
+ unused-variables warn detect variables which are not used in any way
+ warnings warn mass-change the level for lints which produce warnings
+ where-clauses-object-safety warn checks the object safety of where clauses
+ while-true warn suggest using `loop { }` instead of `while true { }`
+ ambiguous-associated-items deny ambiguous associated items
+ arithmetic-overflow deny arithmetic operation overflows
+ conflicting-repr-hints deny conflicts between `#[repr(..)]` hints that were previously accepted and used in practice
+ const-err deny constant evaluation detected erroneous expression
+ ill-formed-attribute-input deny ill-formed attribute inputs that were previously accepted and used in practice
+ incomplete-include deny trailing content in included file
+ invalid-type-param-default deny type parameter default erroneously allowed in invalid location
+ macro-expanded-macro-exports-accessed-by-absolute-paths deny macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
+ missing-fragment-specifier deny detects missing fragment specifiers in unused `macro_rules!` patterns
+ mutable-transmutes deny mutating transmuted &mut T from &T may cause undefined behavior
+ no-mangle-const-items deny const items will not have their symbols exported
+ order-dependent-trait-objects deny trait-object types were treated as different depending on marker-trait order
+ overflowing-literals deny literal out of range for its type
+ patterns-in-fns-without-body deny patterns in functions without body were erroneously allowed
+ pub-use-of-private-extern-crate deny detect public re-exports of private extern crates
+ soft-unstable deny a feature gate that doesn't break dependent crates
+ unconditional-panic deny operation will cause a panic at runtime
+ unknown-crate-types deny unknown crate type found in `#[crate_type]` directive
+
+
+Lint groups provided by rustc:
+
+ name sub-lints
+ ---- ---------
+ warnings all lints that are set to issue warnings
+ future-incompatible keyword-idents, anonymous-parameters, illegal-floating-point-literal-pattern, private-in-public, pub-use-of-private-extern-crate, invalid-type-param-default, safe-packed-borrows, patterns-in-fns-without-body, missing-fragment-specifier, late-bound-lifetime-arguments, order-dependent-trait-objects, coherence-leak-check, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate, unstable-name-collisions, where-clauses-object-safety, proc-macro-derive-resolution-fallback, macro-expanded-macro-exports-accessed-by-absolute-paths, ill-formed-attribute-input, conflicting-repr-hints, ambiguous-associated-items, mutable-borrow-reservation-conflict, indirect-structural-match, soft-unstable, array-into-iter
+ nonstandard-style non-camel-case-types, non-snake-case, non-upper-case-globals
+ rust-2018-compatibility keyword-idents, anonymous-parameters, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate
+ rust-2018-idioms bare-trait-objects, unused-extern-crates, ellipsis-inclusive-range-patterns, elided-lifetimes-in-paths, explicit-outlives-requirements
+ rustdoc intra-doc-link-resolution-failure, invalid-codeblock-attribute, missing-doc-code-examples, private-doc-tests
+ unused unused-imports, unused-variables, unused-assignments, dead-code, unused-mut, unreachable-code, unreachable-patterns, overlapping-patterns, unused-must-use, unused-unsafe, path-statements, unused-attributes, unused-macros, unused-allocation, unused-doc-comments, unused-extern-crates, unused-features, unused-labels, unused-parens, unused-braces, redundant-semicolons
+
+
+Compiler plugins can provide additional lints and lint groups. To see a listing of these, re-run `rustc -W help` with a crate filename.
diff --git a/tests/lints.rs b/tests/lints.rs
deleted file mode 100644
index 4009f55..0000000
--- a/tests/lints.rs
+++ /dev/null
@@ -1,126 +0,0 @@
-#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![warn(unused, future_incompatible)]
-#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
-
-use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
-use std::pin::Pin;
-
-#[pin_project]
-pub struct StructDefault<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project(PinnedDrop)]
-pub struct StructPinnedDrop<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pinned_drop]
-impl<T, U> PinnedDrop for StructPinnedDrop<T, U> {
- fn drop(self: Pin<&mut Self>) {}
-}
-
-#[pin_project(Replace)]
-pub struct StructReplace<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project(UnsafeUnpin)]
-pub struct StructUnsafeUnpin<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-unsafe impl<T: Unpin, U> UnsafeUnpin for StructUnsafeUnpin<T, U> {}
-
-#[pin_project(!Unpin)]
-pub struct StructNotUnpin<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project]
-pub struct StructMutMut<'a, T, U> {
- #[pin]
- pub pinned: &'a mut T,
- pub unpinned: &'a mut U,
-}
-
-#[pin_project]
-pub enum EnumDefault<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pin_project(PinnedDrop)]
-pub enum EnumPinnedDrop<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pinned_drop]
-impl<T, U> PinnedDrop for EnumPinnedDrop<T, U> {
- fn drop(self: Pin<&mut Self>) {}
-}
-
-#[pin_project(Replace)]
-pub enum EnumReplace<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pin_project(UnsafeUnpin)]
-pub enum EnumUnsafeUnpin<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-unsafe impl<T: Unpin, U> UnsafeUnpin for EnumUnsafeUnpin<T, U> {}
-
-#[pin_project(!Unpin)]
-pub enum EnumNotUnpin<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pin_project]
-pub enum EnumMutMut<'a, T, U> {
- Struct {
- #[pin]
- pinned: &'a mut T,
- unpinned: &'a mut U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[allow(clippy::missing_const_for_fn)]
-#[test]
-fn test() {}
diff --git a/tests/overwriting_core_crate.rs b/tests/overwriting_core_crate.rs
deleted file mode 100644
index 121104c..0000000
--- a/tests/overwriting_core_crate.rs
+++ /dev/null
@@ -1,116 +0,0 @@
-#![warn(rust_2018_idioms, single_use_lifetimes)]
-
-// See https://github.com/rust-lang/pin-utils/pull/26#discussion_r344491597
-//
-// Note: If the proc-macro does not depend on its own items, it may be preferable not to
-// support overwriting the name of core/std crate for compatibility with reexport.
-#[allow(unused_extern_crates)]
-extern crate pin_project as core;
-
-// Dummy module to check that the expansion refers to the crate.
-mod pin_project {}
-
-use ::pin_project::{pin_project, pinned_drop, UnsafeUnpin};
-use std::pin::Pin;
-
-#[pin_project]
-pub struct StructDefault<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project(PinnedDrop)]
-pub struct StructPinnedDrop<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pinned_drop]
-impl<T, U> PinnedDrop for StructPinnedDrop<T, U> {
- fn drop(self: Pin<&mut Self>) {}
-}
-
-#[pin_project(Replace)]
-pub struct StructReplace<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project(UnsafeUnpin)]
-pub struct StructUnsafeUnpin<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-unsafe impl<T: Unpin, U> UnsafeUnpin for StructUnsafeUnpin<T, U> {}
-
-#[pin_project(!Unpin)]
-pub struct StructNotUnpin<T, U> {
- #[pin]
- pub pinned: T,
- pub unpinned: U,
-}
-
-#[pin_project]
-pub enum EnumDefault<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pin_project(PinnedDrop)]
-pub enum EnumPinnedDrop<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pinned_drop]
-impl<T, U> PinnedDrop for EnumPinnedDrop<T, U> {
- fn drop(self: Pin<&mut Self>) {}
-}
-
-#[pin_project(Replace)]
-pub enum EnumReplace<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[pin_project(UnsafeUnpin)]
-pub enum EnumUnsafeUnpin<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-unsafe impl<T: Unpin, U> UnsafeUnpin for EnumUnsafeUnpin<T, U> {}
-
-#[pin_project(!Unpin)]
-pub enum EnumNotUnpin<T, U> {
- Struct {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- Tuple(#[pin] T, U),
-}
-
-#[test]
-fn test() {}
diff --git a/tests/pin_project.rs b/tests/pin_project.rs
index 72bcd15..766887f 100644
--- a/tests/pin_project.rs
+++ b/tests/pin_project.rs
@@ -1,16 +1,15 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
-use core::{
+use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
+use std::{
marker::{PhantomData, PhantomPinned},
pin::Pin,
};
-use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
#[test]
fn projection() {
#[pin_project(
- Replace,
project = StructProj,
project_ref = StructProjRef,
project_replace = StructProjOwn,
@@ -53,7 +52,7 @@ fn projection() {
assert_eq!(s.field1, 3);
assert_eq!(s.field2, 4);
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct TupleStruct<T, U>(#[pin] T, U);
let mut s = TupleStruct(1, 2);
@@ -65,7 +64,7 @@ fn projection() {
let y: &mut i32 = s.1;
assert_eq!(*y, 2);
- #[pin_project(Replace, project = EnumProj)]
+ #[pin_project(project_replace, project = EnumProj)]
#[derive(Eq, PartialEq, Debug)]
enum Enum<A, B, C, D> {
Variant1(#[pin] A, B),
@@ -127,7 +126,7 @@ fn projection() {
#[test]
fn enum_project_set() {
- #[pin_project(Replace, project = EnumProj)]
+ #[pin_project(project_replace, project = EnumProj)]
#[derive(Eq, PartialEq, Debug)]
enum Enum {
Variant1(#[pin] u8),
@@ -175,7 +174,7 @@ fn where_clause() {
#[test]
fn where_clause_and_associated_type_field() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct1<I>
where
I: Iterator,
@@ -185,7 +184,7 @@ fn where_clause_and_associated_type_field() {
field2: I::Item,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct2<I, J>
where
I: Iterator<Item = J>,
@@ -195,7 +194,7 @@ fn where_clause_and_associated_type_field() {
field2: J,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct3<T>
where
T: 'static,
@@ -207,12 +206,12 @@ fn where_clause_and_associated_type_field() {
impl<T> Static for Struct3<T> {}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct TupleStruct<I>(#[pin] I, I::Item)
where
I: Iterator;
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Enum<I>
where
I: Iterator,
@@ -224,7 +223,7 @@ fn where_clause_and_associated_type_field() {
#[test]
fn derive_copy() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
#[derive(Clone, Copy)]
struct Struct<T> {
val: T,
@@ -239,7 +238,7 @@ fn derive_copy() {
fn move_out() {
struct NotCopy;
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct {
val: NotCopy,
}
@@ -247,7 +246,7 @@ fn move_out() {
let x = Struct { val: NotCopy };
let _val: NotCopy = x.val;
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Enum {
Variant(NotCopy),
}
@@ -261,39 +260,39 @@ fn move_out() {
#[test]
fn trait_bounds_on_type_generics() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct1<'a, T: ?Sized> {
field: &'a mut T,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct2<'a, T: ::core::fmt::Debug> {
field: &'a mut T,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct3<'a, T: core::fmt::Debug> {
field: &'a mut T,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct4<'a, T: core::fmt::Debug + core::fmt::Display> {
field: &'a mut T,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct5<'a, T: core::fmt::Debug + ?Sized> {
field: &'a mut T,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct6<'a, T: core::fmt::Debug = [u8; 16]> {
field: &'a mut T,
}
let _: Struct6<'_> = Struct6 { field: &mut [0u8; 16] };
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct7<T: 'static> {
field: T,
}
@@ -302,16 +301,16 @@ fn trait_bounds_on_type_generics() {
impl<T> Static for Struct7<T> {}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct8<'a, 'b: 'a> {
field1: &'a u8,
field2: &'b u8,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct TupleStruct<'a, T: ?Sized>(&'a mut T);
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Enum<'a, T: ?Sized> {
Variant(&'a mut T),
}
@@ -319,13 +318,13 @@ fn trait_bounds_on_type_generics() {
#[test]
fn overlapping_lifetime_names() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct1<'pin, T> {
#[pin]
field: &'pin mut T,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Struct2<'pin, 'pin_, 'pin__> {
#[pin]
field: &'pin &'pin_ &'pin__ (),
@@ -334,7 +333,7 @@ fn overlapping_lifetime_names() {
pub trait A<'a> {}
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct HRTB<'pin___, T>
where
for<'pin> &'pin T: Unpin,
@@ -349,39 +348,39 @@ fn overlapping_lifetime_names() {
#[test]
fn combine() {
#[pin_project(PinnedDrop, UnsafeUnpin)]
- pub struct Struct1<T> {
+ pub struct PinnedDropWithUnsafeUnpin<T> {
#[pin]
field: T,
}
#[pinned_drop]
- impl<T> PinnedDrop for Struct1<T> {
+ impl<T> PinnedDrop for PinnedDropWithUnsafeUnpin<T> {
fn drop(self: Pin<&mut Self>) {}
}
- unsafe impl<T: Unpin> UnsafeUnpin for Struct1<T> {}
+ unsafe impl<T: Unpin> UnsafeUnpin for PinnedDropWithUnsafeUnpin<T> {}
- #[pin_project(UnsafeUnpin, Replace)]
- pub struct Struct2<T> {
+ #[pin_project(PinnedDrop, !Unpin)]
+ pub struct PinnedDropWithNotUnpin<T> {
#[pin]
field: T,
}
- unsafe impl<T: Unpin> UnsafeUnpin for Struct2<T> {}
+ #[pinned_drop]
+ impl<T> PinnedDrop for PinnedDropWithNotUnpin<T> {
+ fn drop(self: Pin<&mut Self>) {}
+ }
- #[pin_project(PinnedDrop, !Unpin)]
- pub struct Struct3<T> {
+ #[pin_project(UnsafeUnpin, project_replace)]
+ pub struct UnsafeUnpinWithReplace<T> {
#[pin]
field: T,
}
- #[pinned_drop]
- impl<T> PinnedDrop for Struct3<T> {
- fn drop(self: Pin<&mut Self>) {}
- }
+ unsafe impl<T: Unpin> UnsafeUnpin for UnsafeUnpinWithReplace<T> {}
- #[pin_project(!Unpin, Replace)]
- pub struct Struct4<T> {
+ #[pin_project(!Unpin, project_replace)]
+ pub struct NotUnpinWithReplace<T> {
#[pin]
field: T,
}
@@ -389,7 +388,7 @@ fn combine() {
#[test]
fn private_type_in_public_type() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct PublicStruct<T> {
#[pin]
inner: PrivateStruct<T>,
@@ -400,21 +399,21 @@ fn private_type_in_public_type() {
#[test]
fn lifetime_project() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct1<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct2<'a, T, U> {
#[pin]
pinned: &'a mut T,
unpinned: U,
}
- #[pin_project(Replace, project = EnumProj, project_ref = EnumProjRef)]
+ #[pin_project(project_replace, project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Variant {
#[pin]
@@ -458,21 +457,21 @@ fn lifetime_project() {
#[rustversion::since(1.36)] // https://github.com/rust-lang/rust/pull/61207
#[test]
fn lifetime_project_elided() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct1<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct2<'a, T, U> {
#[pin]
pinned: &'a mut T,
unpinned: U,
}
- #[pin_project(Replace, project = EnumProj, project_ref = EnumProjRef)]
+ #[pin_project(project_replace, project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Variant {
#[pin]
@@ -516,7 +515,7 @@ fn lifetime_project_elided() {
mod visibility {
use pin_project::pin_project;
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub(crate) struct A {
pub b: u8,
}
@@ -534,7 +533,7 @@ fn visibility() {
#[test]
fn trivial_bounds() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct NoGenerics {
#[pin]
field: PhantomPinned,
@@ -709,34 +708,102 @@ fn dyn_type() {
}
#[test]
-fn self_in_where_clause() {
- pub trait Trait1 {}
+fn parse_self() {
+ macro_rules! mac {
+ ($($tt:tt)*) => {
+ $($tt)*
+ };
+ }
+
+ pub trait Trait {
+ type Assoc;
+ }
- #[pin_project(Replace)]
- pub struct Struct1<T>
+ #[pin_project(project_replace)]
+ pub struct Generics<T: Trait<Assoc = Self>>
where
- Self: Trait1,
+ Self: Trait<Assoc = Self>,
+ <Self as Trait>::Assoc: Sized,
+ mac!(Self): Trait<Assoc = mac!(Self)>,
{
- x: T,
+ _f: T,
}
- impl<T> Trait1 for Struct1<T> {}
+ impl<T: Trait<Assoc = Self>> Trait for Generics<T> {
+ type Assoc = Self;
+ }
- pub trait Trait2 {
- type Assoc;
+ #[pin_project(project_replace)]
+ pub struct Struct {
+ _f1: Box<Self>,
+ _f2: Box<<Self as Trait>::Assoc>,
+ _f3: Box<mac!(Self)>,
+ _f4: [(); Self::ASSOC],
+ _f5: [(); Self::assoc()],
+ _f6: [(); mac!(Self::assoc())],
}
- #[pin_project(Replace)]
- pub struct Struct2<T>
- where
- Self: Trait2<Assoc = Struct1<T>>,
- <Self as Trait2>::Assoc: Trait1,
- {
- x: T,
+ impl Struct {
+ const ASSOC: usize = 1;
+ const fn assoc() -> usize {
+ 0
+ }
+ }
+
+ impl Trait for Struct {
+ type Assoc = Self;
+ }
+
+ #[pin_project(project_replace)]
+ struct Tuple(
+ Box<Self>,
+ Box<<Self as Trait>::Assoc>,
+ Box<mac!(Self)>,
+ [(); Self::ASSOC],
+ [(); Self::assoc()],
+ [(); mac!(Self::assoc())],
+ );
+
+ impl Tuple {
+ const ASSOC: usize = 1;
+ const fn assoc() -> usize {
+ 0
+ }
+ }
+
+ impl Trait for Tuple {
+ type Assoc = Self;
+ }
+
+ #[pin_project(project_replace)]
+ enum Enum {
+ Struct {
+ _f1: Box<Self>,
+ _f2: Box<<Self as Trait>::Assoc>,
+ _f3: Box<mac!(Self)>,
+ _f4: [(); Self::ASSOC],
+ _f5: [(); Self::assoc()],
+ _f6: [(); mac!(Self::assoc())],
+ },
+ Tuple(
+ Box<Self>,
+ Box<<Self as Trait>::Assoc>,
+ Box<mac!(Self)>,
+ [(); Self::ASSOC],
+ [(); Self::assoc()],
+ [(); mac!(Self::assoc())],
+ ),
+ }
+
+ impl Enum {
+ const ASSOC: usize = 1;
+ const fn assoc() -> usize {
+ 0
+ }
}
- impl<T> Trait2 for Struct2<T> {
- type Assoc = Struct1<T>;
+ impl Trait for Enum {
+ type Assoc = Self;
}
}
@@ -752,7 +819,7 @@ fn no_infer_outlives() {
type Y = Option<T>;
}
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Foo<A, B> {
_x: <Example<A> as Bar<B>>::Y,
}
@@ -760,11 +827,12 @@ fn no_infer_outlives() {
// https://github.com/rust-lang/rust/issues/47949
// https://github.com/taiki-e/pin-project/pull/194#discussion_r419098111
+#[allow(clippy::many_single_char_names)]
#[test]
fn project_replace_panic() {
use std::panic;
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct S<T, U> {
#[pin]
pinned: T,
@@ -786,7 +854,8 @@ fn project_replace_panic() {
let mut x = S { pinned: D(&mut a, true), unpinned: D(&mut b, false) };
let _y = Pin::new(&mut x)
.project_replace(S { pinned: D(&mut c, false), unpinned: D(&mut d, false) });
- // Previous `x.pinned` was dropped and panicked when `project_replace` is called, so this is unreachable.
+ // Previous `x.pinned` was dropped and panicked when `project_replace` is
+ // called, so this is unreachable.
unreachable!();
}));
assert!(res.is_err());
@@ -801,7 +870,8 @@ fn project_replace_panic() {
{
let _y = Pin::new(&mut x)
.project_replace(S { pinned: D(&mut c, false), unpinned: D(&mut d, false) });
- // `_y` (previous `x.unpinned`) live to the end of this scope, so this is not unreachable,
+ // `_y` (previous `x.unpinned`) live to the end of this scope, so
+ // this is not unreachable.
// unreachable!();
}
unreachable!();
diff --git a/tests/pinned_drop.rs b/tests/pinned_drop.rs
index b0677e2..e257758 100644
--- a/tests/pinned_drop.rs
+++ b/tests/pinned_drop.rs
@@ -1,5 +1,4 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![allow(dead_code)]
use pin_project::{pin_project, pinned_drop};
use std::pin::Pin;
@@ -26,66 +25,61 @@ fn safe_project() {
}
#[test]
-fn mut_self_argument() {
- #[pin_project(PinnedDrop)]
- struct Struct {
- data: usize,
- }
-
- #[pinned_drop]
- impl PinnedDrop for Struct {
- fn drop(mut self: Pin<&mut Self>) {
- let _: &mut _ = &mut self.data;
- }
- }
-}
+fn self_argument_in_macro() {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
-#[test]
-fn self_in_vec() {
#[pin_project(PinnedDrop)]
struct Struct {
- data: usize,
+ x: (),
}
#[pinned_drop]
impl PinnedDrop for Struct {
fn drop(self: Pin<&mut Self>) {
- let _: Vec<_> = vec![self.data];
+ let _: Vec<_> = vec![self.x];
}
}
}
#[test]
fn self_in_macro_containing_fn() {
- #[pin_project(PinnedDrop)]
- pub struct Struct {
- data: usize,
- }
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
- macro_rules! emit {
+ macro_rules! mac {
($($tt:tt)*) => {
$($tt)*
};
}
+ #[pin_project(PinnedDrop)]
+ pub struct Struct {
+ _x: (),
+ }
+
#[pinned_drop]
impl PinnedDrop for Struct {
fn drop(self: Pin<&mut Self>) {
- let _ = emit!({
+ let _ = mac!({
impl Struct {
- pub fn f(self) {}
+ pub fn _f(self) -> Self {
+ self
+ }
}
});
- let _ = self.data;
}
}
}
#[test]
fn self_call() {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
+
#[pin_project(PinnedDrop)]
- pub struct Struct {
- data: usize,
+ pub struct Struct<T> {
+ _x: T,
}
trait Trait {
@@ -96,10 +90,10 @@ fn self_call() {
fn assoc_fn(_this: Pin<&mut Self>) {}
}
- impl Trait for Struct {}
+ impl<T> Trait for Struct<T> {}
#[pinned_drop]
- impl PinnedDrop for Struct {
+ impl<T> PinnedDrop for Struct<T> {
fn drop(mut self: Pin<&mut Self>) {
self.self_ref();
self.as_ref().self_pin_ref();
@@ -112,53 +106,13 @@ fn self_call() {
}
#[test]
-fn self_expr() {
- #[pin_project(PinnedDrop)]
- pub struct Struct {
- x: usize,
- }
-
- #[pinned_drop]
- impl PinnedDrop for Struct {
- fn drop(mut self: Pin<&mut Self>) {
- let _: Self = Self { x: 0 };
- }
- }
-
- #[pin_project(PinnedDrop)]
- pub struct TupleStruct(usize);
-
- #[pinned_drop]
- impl PinnedDrop for TupleStruct {
- fn drop(mut self: Pin<&mut Self>) {
- let _: Self = Self(0);
- }
- }
-}
-
-#[rustversion::since(1.37)]
-#[test]
-fn self_expr_enum() {
- #[pin_project(PinnedDrop)]
- pub enum Enum {
- StructVariant { x: usize },
- TupleVariant(usize),
- }
-
- #[pinned_drop]
- impl PinnedDrop for Enum {
- fn drop(mut self: Pin<&mut Self>) {
- let _: Self = Self::StructVariant { x: 0 };
- let _: Self = Self::TupleVariant(0);
- }
- }
-}
+fn self_struct() {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
-#[test]
-fn self_pat() {
#[pin_project(PinnedDrop)]
pub struct Struct {
- x: usize,
+ pub x: (),
}
#[pinned_drop]
@@ -166,6 +120,10 @@ fn self_pat() {
#[allow(irrefutable_let_patterns)]
#[allow(clippy::match_single_binding)]
fn drop(mut self: Pin<&mut Self>) {
+ // expr
+ let _: Self = Self { x: () };
+
+ // pat
match *self {
Self { x: _ } => {}
}
@@ -175,12 +133,16 @@ fn self_pat() {
}
#[pin_project(PinnedDrop)]
- pub struct TupleStruct(usize);
+ pub struct TupleStruct(());
#[pinned_drop]
impl PinnedDrop for TupleStruct {
#[allow(irrefutable_let_patterns)]
fn drop(mut self: Pin<&mut Self>) {
+ // expr
+ let _: Self = Self(());
+
+ // pat
match *self {
Self(_) => {}
}
@@ -190,24 +152,32 @@ fn self_pat() {
}
}
-#[rustversion::since(1.37)]
+#[rustversion::since(1.37)] // type_alias_enum_variants requires Rust 1.37
#[test]
-fn self_pat_enum() {
+fn self_enum() {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
+
#[pin_project(PinnedDrop)]
pub enum Enum {
- StructVariant { x: usize },
- TupleVariant(usize),
+ Struct { x: () },
+ Tuple(()),
}
#[pinned_drop]
impl PinnedDrop for Enum {
fn drop(mut self: Pin<&mut Self>) {
+ // expr
+ let _: Self = Self::Struct { x: () };
+ let _: Self = Self::Tuple(());
+
+ // pat
match *self {
- Self::StructVariant { x: _ } => {}
- Self::TupleVariant(_) => {}
+ Self::Struct { x: _ } => {}
+ Self::Tuple(_) => {}
}
- if let Self::StructVariant { x: _ } = *self {}
- if let Self::TupleVariant(_) = *self {}
+ if let Self::Struct { x: _ } = *self {}
+ if let Self::Tuple(_) = *self {}
}
}
}
@@ -216,20 +186,108 @@ fn self_pat_enum() {
#[rustversion::since(1.40)] // https://github.com/rust-lang/rust/pull/64690
#[test]
fn self_in_macro_def() {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
+
#[pin_project(PinnedDrop)]
pub struct Struct {
- x: usize,
+ _x: (),
}
#[pinned_drop]
impl PinnedDrop for Struct {
fn drop(self: Pin<&mut Self>) {
- macro_rules! t {
+ macro_rules! mac {
() => {{
let _ = self;
}};
}
- t!();
+ mac!();
+ }
+ }
+}
+
+#[test]
+fn self_inside_macro() {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
+
+ macro_rules! mac {
+ ($($tt:tt)*) => {
+ $($tt)*
+ };
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub struct Struct<T: Send>
+ where
+ mac!(Self): Send,
+ {
+ _x: T,
+ }
+
+ impl<T: Send> Struct<T> {
+ const ASSOCIATED1: &'static str = "1";
+ fn associated1() {}
+ }
+
+ trait Trait {
+ type Associated2;
+ const ASSOCIATED2: &'static str;
+ fn associated2();
+ }
+
+ impl<T: Send> Trait for Struct<T> {
+ type Associated2 = ();
+ const ASSOCIATED2: &'static str = "2";
+ fn associated2() {}
+ }
+
+ #[pinned_drop]
+ impl<T: Send> PinnedDrop for Struct<T>
+ where
+ mac!(Self): Send,
+ {
+ #[allow(path_statements)]
+ #[allow(clippy::no_effect)]
+ fn drop(self: Pin<&mut Self>) {
+ // inherent items
+ mac!(Self::ASSOCIATED1;);
+ mac!(<Self>::ASSOCIATED1;);
+ mac!(Self::associated1(););
+ mac!(<Self>::associated1(););
+
+ // trait items
+ mac!(let _: <Self as Trait>::Associated2;);
+ mac!(Self::ASSOCIATED2;);
+ mac!(<Self>::ASSOCIATED2;);
+ mac!(<Self as Trait>::ASSOCIATED2;);
+ mac!(Self::associated2(););
+ mac!(<Self>::associated2(););
+ mac!(<Self as Trait>::associated2(););
}
}
}
+
+#[test]
+fn inside_macro() {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
+
+ #[pin_project(PinnedDrop)]
+ struct Struct(());
+
+ macro_rules! mac {
+ ($expr:expr) => {
+ #[pinned_drop]
+ impl PinnedDrop for Struct {
+ #[allow(clippy::no_effect)]
+ fn drop(self: Pin<&mut Self>) {
+ $expr;
+ }
+ }
+ };
+ }
+
+ mac!(1);
+}
diff --git a/tests/project.rs b/tests/project.rs
index a0f8b07..78a9261 100644
--- a/tests/project.rs
+++ b/tests/project.rs
@@ -1,5 +1,6 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
+#![allow(deprecated)]
// Ceurrently, `#[attr] if true {}` doesn't even *parse* on MSRV,
// which means that it will error even behind a `#[rustversion::since(..)]`
@@ -160,8 +161,8 @@ struct A {
mod project_use_1 {
use crate::A;
- use core::pin::Pin;
use pin_project::project;
+ use std::pin::Pin;
#[project]
use crate::A;
@@ -242,7 +243,7 @@ fn issue_206() {
#[project]
#[test]
fn combine() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Enum<A> {
V1(#[pin] A),
V2,
@@ -272,7 +273,7 @@ fn combine() {
#[project_replace]
#[test]
fn combine_compat() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Enum<A> {
V1(#[pin] A),
V2,
diff --git a/tests/project_if_attr.rs.in b/tests/project_if_attr.rs.in
index a8ceeac..7bc236d 100644
--- a/tests/project_if_attr.rs.in
+++ b/tests/project_if_attr.rs.in
@@ -6,8 +6,9 @@ fn project_if_let() {
Variant1(#[pin] A),
Variant2(u8),
Variant3 {
- #[pin] field: B
- }
+ #[pin]
+ field: B,
+ },
}
let mut x: Foo<bool, f32> = Foo::Variant1(true);
diff --git a/tests/project_ref.rs b/tests/project_ref.rs
index e38ef83..0e8ebd9 100644
--- a/tests/project_ref.rs
+++ b/tests/project_ref.rs
@@ -1,5 +1,6 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
+#![allow(deprecated)]
use pin_project::{pin_project, project_ref};
use std::pin::Pin;
@@ -149,7 +150,7 @@ fn project_impl() {
#[project_ref]
#[test]
fn combine() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Enum<A> {
V1(#[pin] A),
V2,
diff --git a/tests/project_replace.rs b/tests/project_replace.rs
index 9c8a5ab..a97e3af 100644
--- a/tests/project_replace.rs
+++ b/tests/project_replace.rs
@@ -1,5 +1,6 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
+#![allow(deprecated)]
use pin_project::{pin_project, project_replace};
use std::{marker::PhantomData, pin::Pin};
@@ -7,7 +8,7 @@ use std::{marker::PhantomData, pin::Pin};
#[project_replace] // Nightly does not need a dummy attribute to the function.
#[test]
fn project_replace_stmt_expr() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct Struct<T, U> {
#[pin]
field1: T,
@@ -27,7 +28,7 @@ fn project_replace_stmt_expr() {
// tuple struct
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct TupleStruct<T, U>(#[pin] T, U);
let mut s = TupleStruct(1, 2);
@@ -39,7 +40,7 @@ fn project_replace_stmt_expr() {
let y: i32 = y;
assert_eq!(y, 2);
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Enum<A, B, C, D> {
Variant1(#[pin] A, B),
Variant2 {
@@ -73,7 +74,7 @@ fn project_replace_stmt_expr() {
#[project_replace]
#[test]
fn combine() {
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
enum Enum<A> {
V1(#[pin] A),
V2,
diff --git a/tests/repr_packed.rs b/tests/repr_packed.rs
index ca56959..73fc45c 100644
--- a/tests/repr_packed.rs
+++ b/tests/repr_packed.rs
@@ -1,5 +1,4 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![allow(dead_code)]
#![deny(safe_packed_borrows)]
use std::cell::Cell;
diff --git a/tests/ui/cfg/cfg_attr-unpin.stderr b/tests/ui/cfg/cfg_attr-unpin.stderr
index ce31c24..45789ff 100644
--- a/tests/ui/cfg/cfg_attr-unpin.stderr
+++ b/tests/ui/cfg/cfg_attr-unpin.stderr
@@ -16,7 +16,7 @@ error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
| ----- required by this bound in `is_unpin`
...
20 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__SCOPE_Bar::__Bar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Bar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `__SCOPE_Bar::__Bar<'_, std::marker::PhantomPinned>`
+ = note: required because it appears within the type `_::__Bar<'_, std::marker::PhantomPinned>`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<std::marker::PhantomPinned>`
diff --git a/tests/ui/cfg/proper_unpin.stderr b/tests/ui/cfg/proper_unpin.stderr
index 407d900..f1fff34 100644
--- a/tests/ui/cfg/proper_unpin.stderr
+++ b/tests/ui/cfg/proper_unpin.stderr
@@ -5,7 +5,7 @@ error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
| ----- required by this bound in `is_unpin`
...
27 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__SCOPE_Bar::__Bar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Bar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `__SCOPE_Bar::__Bar<'_, std::marker::PhantomPinned>`
+ = note: required because it appears within the type `_::__Bar<'_, std::marker::PhantomPinned>`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<std::marker::PhantomPinned>`
diff --git a/tests/ui/not_unpin/conflict-unpin.stderr b/tests/ui/not_unpin/conflict-unpin.stderr
index 7407bdf..e90a574 100644
--- a/tests/ui/not_unpin/conflict-unpin.stderr
+++ b/tests/ui/not_unpin/conflict-unpin.stderr
@@ -1,26 +1,26 @@
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`:
- --> $DIR/conflict-unpin.rs:3:16
+ --> $DIR/conflict-unpin.rs:3:15
|
3 | #[pin_project(!Unpin)] //~ ERROR E0119
- | ^^^^^ conflicting implementation for `Foo<_, _>`
+ | ^^^^^^ conflicting implementation for `Foo<_, _>`
...
10 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
| --------------------------------------------- first implementation here
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`:
- --> $DIR/conflict-unpin.rs:12:16
+ --> $DIR/conflict-unpin.rs:12:15
|
12 | #[pin_project(!Unpin)] //~ ERROR E0119
- | ^^^^^ conflicting implementation for `Bar<_, _>`
+ | ^^^^^^ conflicting implementation for `Bar<_, _>`
...
19 | impl<T, U> Unpin for Bar<T, U> {}
| ------------------------------ first implementation here
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`:
- --> $DIR/conflict-unpin.rs:21:16
+ --> $DIR/conflict-unpin.rs:21:15
|
21 | #[pin_project(!Unpin)] //~ ERROR E0119
- | ^^^^^ conflicting implementation for `Baz<_, _>`
+ | ^^^^^^ conflicting implementation for `Baz<_, _>`
...
28 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
| -------------------------------------------- first implementation here
diff --git a/tests/ui/pin_project/add-pin-attr-to-struct.rs b/tests/ui/pin_project/add-attr-to-struct.rs
index f5364fc..f5364fc 100644
--- a/tests/ui/pin_project/add-pin-attr-to-struct.rs
+++ b/tests/ui/pin_project/add-attr-to-struct.rs
diff --git a/tests/ui/pin_project/add-pin-attr-to-struct.stderr b/tests/ui/pin_project/add-attr-to-struct.stderr
index c2adaea..27656d6 100644
--- a/tests/ui/pin_project/add-pin-attr-to-struct.stderr
+++ b/tests/ui/pin_project/add-attr-to-struct.stderr
@@ -1,5 +1,5 @@
error: duplicate #[pin] attribute
- --> $DIR/add-pin-attr-to-struct.rs:6:1
+ --> $DIR/add-attr-to-struct.rs:6:1
|
6 | #[add_pin_attr(struct)] //~ ERROR duplicate #[pin] attribute
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -7,7 +7,7 @@ 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-pin-attr-to-struct.rs:12:1
+ --> $DIR/add-attr-to-struct.rs:12:1
|
12 | #[add_pin_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants
| ^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/pin_project/add-pinned-field.stderr b/tests/ui/pin_project/add-pinned-field.stderr
index db07a74..d6a1dcd 100644
--- a/tests/ui/pin_project/add-pinned-field.stderr
+++ b/tests/ui/pin_project/add-pinned-field.stderr
@@ -5,9 +5,9 @@ error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
| ----- required by this bound in `is_unpin`
...
21 | is_unpin::<Foo>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^ within `__SCOPE_Foo::__Foo<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^ within `_::__Foo<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `__SCOPE_Foo::__Foo<'_>`
+ = note: required because it appears within the type `_::__Foo<'_>`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo`
error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
@@ -17,7 +17,7 @@ error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
| ----- required by this bound in `is_unpin`
...
22 | is_unpin::<Bar>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^ within `__SCOPE_Bar::__Bar<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^ within `_::__Bar<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `__SCOPE_Bar::__Bar<'_>`
+ = note: required because it appears within the type `_::__Bar<'_>`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar`
diff --git a/tests/ui/pin_project/conflict-drop.stderr b/tests/ui/pin_project/conflict-drop.stderr
index f97d060..d5ca7b3 100644
--- a/tests/ui/pin_project/conflict-drop.stderr
+++ b/tests/ui/pin_project/conflict-drop.stderr
@@ -1,4 +1,4 @@
-error[E0119]: conflicting implementations of trait `__SCOPE_Foo::FooMustNotImplDrop` for type `Foo<_, _>`:
+error[E0119]: conflicting implementations of trait `_::FooMustNotImplDrop` for type `Foo<_, _>`:
--> $DIR/conflict-drop.rs:4:1
|
4 | #[pin_project] //~ ERROR E0119
diff --git a/tests/ui/pin_project/conflict-naming.rs b/tests/ui/pin_project/conflict-naming.rs
deleted file mode 100644
index 1cb50b4..0000000
--- a/tests/ui/pin_project/conflict-naming.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-use pin_project::pin_project;
-
-#[pin_project(project = A, project_ref = A)] //~ ERROR E0428,E0308
-struct Struct(#[pin] ());
-
-fn main() {}
diff --git a/tests/ui/pin_project/conflict-naming.stderr b/tests/ui/pin_project/conflict-naming.stderr
deleted file mode 100644
index bbac1eb..0000000
--- a/tests/ui/pin_project/conflict-naming.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0428]: the name `A` is defined multiple times
- --> $DIR/conflict-naming.rs:3:1
- |
-3 | #[pin_project(project = A, project_ref = A)] //~ ERROR E0428,E0308
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | `A` redefined here
- | previous definition of the type `A` here
- |
- = note: `A` must be defined only once in the type namespace of this module
- = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error[E0308]: mismatched types
- --> $DIR/conflict-naming.rs:3:1
- |
-3 | #[pin_project(project = A, project_ref = A)] //~ ERROR E0428,E0308
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability
- |
- = note: expected mutable reference `&mut ()`
- found reference `&()`
- = 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/invalid.rs b/tests/ui/pin_project/invalid.rs
index d7911df..9c51bec 100644
--- a/tests/ui/pin_project/invalid.rs
+++ b/tests/ui/pin_project/invalid.rs
@@ -100,6 +100,9 @@ mod pin_project_argument {
#[pin_project()] // Ok
struct Unexpected4(#[pin] ());
+ #[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
+ struct Unexpected5(#[pin] ());
+
#[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
struct DuplicatePinnedDrop(#[pin] ());
@@ -121,13 +124,22 @@ mod pin_project_argument {
#[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
struct DuplicateProject(#[pin] ());
+ #[pin_project(project = A, project_ref = A, project = B)] //~ ERROR duplicate `project` argument
+ struct DuplicateProject2(#[pin] ());
+
#[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
struct DuplicateProjectRef(#[pin] ());
#[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
- struct DuplicateProjectReplace(#[pin] ());
+ struct DuplicateProjectReplace1(#[pin] ());
+
+ #[pin_project(project_replace, project_replace = B)] //~ ERROR duplicate `project_replace` argument
+ struct DuplicateProjectReplace2(#[pin] ());
- #[pin_project(project_replace = A)] //~ ERROR `project_replace` argument can only be used together with `Replace` argument
+ #[pin_project(project_replace = A, project_replace)] //~ ERROR duplicate `project_replace` argument
+ struct DuplicateProjectReplace3(#[pin] ());
+
+ #[pin_project(project_replace = A)] // Ok
struct ProjectReplaceWithoutReplace(#[pin] ());
#[pin_project(PinnedDrop, Replace)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
@@ -136,35 +148,69 @@ mod pin_project_argument {
#[pin_project(Replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
struct PinnedDropWithReplace2(#[pin] ());
+ #[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ struct PinnedDropWithProjectReplace1(#[pin] ());
+
+ #[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ struct PinnedDropWithProjectReplace2(#[pin] ());
+
+ #[pin_project(project_replace, Replace)] // Ok
+ struct ProjectReplaceWithReplace1(#[pin] ());
+
+ #[pin_project(project_replace = B, Replace)] // Ok
+ struct ProjectReplaceWithReplace2(#[pin] ());
+
#[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
struct UnsafeUnpinWithNotUnpin1(#[pin] ());
#[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
struct UnsafeUnpinWithNotUnpin2(#[pin] ());
- #[pin_project(!)] //~ ERROR unexpected end of input, expected `Unpin`
+ #[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
struct NotUnpin1(#[pin] ());
#[pin_project(Unpin)] //~ ERROR unexpected argument
struct NotUnpin2(#[pin] ());
- #[pin_project(project)] //~ ERROR expected `=`
+ #[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
struct Project1(#[pin] ());
- #[pin_project(project = )] //~ ERROR unexpected end of input, expected identifier
+ #[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
struct Project2(#[pin] ());
- #[pin_project(project_ref)] //~ ERROR expected `=`
+ #[pin_project(project = !)] //~ ERROR expected identifier
+ struct Project3(#[pin] ());
+
+ #[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
struct ProjectRef1(#[pin] ());
- #[pin_project(project_ref = )] //~ ERROR unexpected end of input, expected identifier
+ #[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
struct ProjectRef2(#[pin] ());
- #[pin_project(project_replace)] //~ ERROR expected `=`
+ #[pin_project(project_ref = !)] //~ ERROR expected identifier
+ struct ProjectRef3(#[pin] ());
+
+ #[pin_project(project_replace)] // Ok
struct ProjectReplace1(#[pin] ());
- #[pin_project(project_replace = )] //~ ERROR unexpected end of input, expected identifier
+ #[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
struct ProjectReplace2(#[pin] ());
+
+ #[pin_project(project_replace = !)] //~ ERROR expected identifier
+ struct ProjectReplace3(#[pin] ());
+}
+
+mod pin_project_conflict_naming {
+ use pin_project::pin_project;
+
+ #[pin_project(project = A, project_ref = A)] //~ ERROR name `A` is already specified by `project` argument
+ struct ProjAndProjRef(#[pin] ());
+
+ #[pin_project(project = A, project_replace = A)] //~ ERROR name `A` is already specified by `project` argument
+ struct ProjAndProjOwn(#[pin] ());
+
+ #[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
+ struct ProjRefAndProjOwn(#[pin] ());
}
mod pin_project_attribute {
diff --git a/tests/ui/pin_project/invalid.stderr b/tests/ui/pin_project/invalid.stderr
index 82026aa..3c6af57 100644
--- a/tests/ui/pin_project/invalid.stderr
+++ b/tests/ui/pin_project/invalid.stderr
@@ -82,219 +82,265 @@ error: expected identifier
97 | #[pin_project(,UnsafeUnpin)] //~ ERROR expected identifier
| ^
+error: expected `,`
+ --> $DIR/invalid.rs:103:30
+ |
+103 | #[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
+ | ^^^^^^^^^^
+
error: duplicate `PinnedDrop` argument
- --> $DIR/invalid.rs:103:31
+ --> $DIR/invalid.rs:106:31
|
-103 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
+106 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
| ^^^^^^^^^^
error: duplicate `Replace` argument
- --> $DIR/invalid.rs:106:28
+ --> $DIR/invalid.rs:109:28
|
-106 | #[pin_project(Replace, Replace)] //~ ERROR duplicate `Replace` argument
+109 | #[pin_project(Replace, Replace)] //~ ERROR duplicate `Replace` argument
| ^^^^^^^
error: duplicate `UnsafeUnpin` argument
- --> $DIR/invalid.rs:109:32
+ --> $DIR/invalid.rs:112:32
|
-109 | #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+112 | #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
| ^^^^^^^^^^^
error: duplicate `!Unpin` argument
- --> $DIR/invalid.rs:112:27
+ --> $DIR/invalid.rs:115:27
|
-112 | #[pin_project(!Unpin, !Unpin)] //~ ERROR duplicate `!Unpin` argument
+115 | #[pin_project(!Unpin, !Unpin)] //~ ERROR duplicate `!Unpin` argument
| ^^^^^^
error: duplicate `UnsafeUnpin` argument
- --> $DIR/invalid.rs:115:44
+ --> $DIR/invalid.rs:118:44
|
-115 | #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+118 | #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
| ^^^^^^^^^^^
error: duplicate `PinnedDrop` argument
- --> $DIR/invalid.rs:118:44
+ --> $DIR/invalid.rs:121:44
|
-118 | #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, UnsafeUnpin)] //~ ERROR duplicate `PinnedDrop` argument
+121 | #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, UnsafeUnpin)] //~ ERROR duplicate `PinnedDrop` argument
| ^^^^^^^^^^
error: duplicate `project` argument
- --> $DIR/invalid.rs:121:32
+ --> $DIR/invalid.rs:124:32
+ |
+124 | #[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
+ | ^^^^^^^^^^^
+
+error: duplicate `project` argument
+ --> $DIR/invalid.rs:127:49
|
-121 | #[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
- | ^^^^^^^
+127 | #[pin_project(project = A, project_ref = A, project = B)] //~ ERROR duplicate `project` argument
+ | ^^^^^^^^^^^
error: duplicate `project_ref` argument
- --> $DIR/invalid.rs:124:36
+ --> $DIR/invalid.rs:130:36
|
-124 | #[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
- | ^^^^^^^^^^^
+130 | #[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
+ | ^^^^^^^^^^^^^^^
error: duplicate `project_replace` argument
- --> $DIR/invalid.rs:127:40
+ --> $DIR/invalid.rs:133:40
|
-127 | #[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
- | ^^^^^^^^^^^^^^^
+133 | #[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
+ | ^^^^^^^^^^^^^^^^^^^
-error: `project_replace` argument can only be used together with `Replace` argument
- --> $DIR/invalid.rs:130:19
+error: duplicate `project_replace` argument
+ --> $DIR/invalid.rs:136:36
|
-130 | #[pin_project(project_replace = A)] //~ ERROR `project_replace` argument can only be used together with `Replace` argument
- | ^^^^^^^^^^^^^^^
+136 | #[pin_project(project_replace, project_replace = B)] //~ ERROR duplicate `project_replace` argument
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: duplicate `project_replace` argument
+ --> $DIR/invalid.rs:139:40
+ |
+139 | #[pin_project(project_replace = A, project_replace)] //~ ERROR duplicate `project_replace` argument
+ | ^^^^^^^^^^^^^^^
error: arguments `PinnedDrop` and `Replace` are mutually exclusive
- --> $DIR/invalid.rs:133:19
+ --> $DIR/invalid.rs:145:19
|
-133 | #[pin_project(PinnedDrop, Replace)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
+145 | #[pin_project(PinnedDrop, Replace)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
| ^^^^^^^^^^
error: arguments `PinnedDrop` and `Replace` are mutually exclusive
- --> $DIR/invalid.rs:136:41
+ --> $DIR/invalid.rs:148:41
|
-136 | #[pin_project(Replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
+148 | #[pin_project(Replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
| ^^^^^^^^^^
+error: arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ --> $DIR/invalid.rs:151:19
+ |
+151 | #[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ | ^^^^^^^^^^
+
+error: arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ --> $DIR/invalid.rs:154:49
+ |
+154 | #[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ | ^^^^^^^^^^
+
error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
- --> $DIR/invalid.rs:139:19
+ --> $DIR/invalid.rs:163:19
|
-139 | #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+163 | #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
| ^^^^^^^^^^^
error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
- --> $DIR/invalid.rs:142:39
+ --> $DIR/invalid.rs:166:39
|
-142 | #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+166 | #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
| ^^^^^^^^^^^
-error: unexpected end of input, expected `Unpin`
- --> $DIR/invalid.rs:145:5
+error: expected `!Unpin`, found `!`
+ --> $DIR/invalid.rs:169:19
|
-145 | #[pin_project(!)] //~ ERROR unexpected end of input, expected `Unpin`
- | ^^^^^^^^^^^^^^^^^
- |
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+169 | #[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
+ | ^
error: unexpected argument: Unpin
- --> $DIR/invalid.rs:148:19
+ --> $DIR/invalid.rs:172:19
|
-148 | #[pin_project(Unpin)] //~ ERROR unexpected argument
+172 | #[pin_project(Unpin)] //~ ERROR unexpected argument
| ^^^^^
-error: expected `=`
- --> $DIR/invalid.rs:151:5
- |
-151 | #[pin_project(project)] //~ ERROR expected `=`
- | ^^^^^^^^^^^^^^^^^^^^^^^
+error: expected `project = <identifier>`, found `project`
+ --> $DIR/invalid.rs:175:19
|
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+175 | #[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
+ | ^^^^^^^
-error: unexpected end of input, expected identifier
- --> $DIR/invalid.rs:154:5
+error: expected `project = <identifier>`, found `project =`
+ --> $DIR/invalid.rs:178:19
|
-154 | #[pin_project(project = )] //~ ERROR unexpected end of input, expected identifier
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+178 | #[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
+ | ^^^^^^^^^
+
+error: expected identifier
+ --> $DIR/invalid.rs:181:29
|
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+181 | #[pin_project(project = !)] //~ ERROR expected identifier
+ | ^
-error: expected `=`
- --> $DIR/invalid.rs:157:5
+error: expected `project_ref = <identifier>`, found `project_ref`
+ --> $DIR/invalid.rs:184:19
|
-157 | #[pin_project(project_ref)] //~ ERROR expected `=`
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+184 | #[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
+ | ^^^^^^^^^^^
+
+error: expected `project_ref = <identifier>`, found `project_ref =`
+ --> $DIR/invalid.rs:187:19
|
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+187 | #[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
+ | ^^^^^^^^^^^^^
-error: unexpected end of input, expected identifier
- --> $DIR/invalid.rs:160:5
+error: expected identifier
+ --> $DIR/invalid.rs:190:33
|
-160 | #[pin_project(project_ref = )] //~ ERROR unexpected end of input, expected identifier
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+190 | #[pin_project(project_ref = !)] //~ ERROR expected identifier
+ | ^
+
+error: expected `project_replace = <identifier>`, found `project_replace =`
+ --> $DIR/invalid.rs:196:19
|
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+196 | #[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
+ | ^^^^^^^^^^^^^^^^^
-error: expected `=`
- --> $DIR/invalid.rs:163:5
+error: expected identifier
+ --> $DIR/invalid.rs:199:37
|
-163 | #[pin_project(project_replace)] //~ ERROR expected `=`
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+199 | #[pin_project(project_replace = !)] //~ ERROR expected identifier
+ | ^
+
+error: name `A` is already specified by `project` argument
+ --> $DIR/invalid.rs:206:46
|
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+206 | #[pin_project(project = A, project_ref = A)] //~ ERROR name `A` is already specified by `project` argument
+ | ^
-error: unexpected end of input, expected identifier
- --> $DIR/invalid.rs:166:5
+error: name `A` is already specified by `project` argument
+ --> $DIR/invalid.rs:209:50
|
-166 | #[pin_project(project_replace = )] //~ ERROR unexpected end of input, expected identifier
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+209 | #[pin_project(project = A, project_replace = A)] //~ ERROR name `A` is already specified by `project` argument
+ | ^
+
+error: name `A` is already specified by `project_ref` argument
+ --> $DIR/invalid.rs:212:54
|
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+212 | #[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
+ | ^
error: duplicate #[pin_project] attribute
- --> $DIR/invalid.rs:174:5
+ --> $DIR/invalid.rs:220:5
|
-174 | #[pin_project] //~ ERROR duplicate #[pin_project] attribute
+220 | #[pin_project] //~ ERROR duplicate #[pin_project] attribute
| ^^^^^^^^^^^^^^
error: #[pin_project] attribute may not be used on structs with zero fields
- --> $DIR/invalid.rs:182:19
+ --> $DIR/invalid.rs:228:19
|
-182 | struct Struct {} //~ ERROR may not be used on structs with zero fields
+228 | struct Struct {} //~ ERROR may not be used on structs with zero fields
| ^^
error: #[pin_project] attribute may not be used on structs with zero fields
- --> $DIR/invalid.rs:185:23
+ --> $DIR/invalid.rs:231:23
|
-185 | struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
+231 | struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
| ^^
error: #[pin_project] attribute may not be used on structs with zero fields
- --> $DIR/invalid.rs:188:12
+ --> $DIR/invalid.rs:234:12
|
-188 | struct UnitStruct; //~ ERROR may not be used on structs with zero fields
+234 | struct UnitStruct; //~ ERROR may not be used on structs with zero fields
| ^^^^^^^^^^
error: #[pin_project] attribute may not be used on enums without variants
- --> $DIR/invalid.rs:191:20
+ --> $DIR/invalid.rs:237:20
|
-191 | enum EnumEmpty {} //~ ERROR may not be used on enums without variants
+237 | enum EnumEmpty {} //~ ERROR may not be used on enums without variants
| ^^
error: #[pin_project] attribute may not be used on enums with discriminants
- --> $DIR/invalid.rs:195:13
+ --> $DIR/invalid.rs:241:13
|
-195 | V = 2, //~ ERROR may not be used on enums with discriminants
+241 | V = 2, //~ ERROR may not be used on enums with discriminants
| ^
error: #[pin_project] attribute may not be used on enums with zero fields
- --> $DIR/invalid.rs:200:9
+ --> $DIR/invalid.rs:246:9
|
-200 | / Unit, //~ ERROR may not be used on enums with zero fields
-201 | | Tuple(),
-202 | | Struct {},
+246 | / Unit, //~ ERROR may not be used on enums with zero fields
+247 | | Tuple(),
+248 | | Struct {},
| |__________________^
error: #[pin_project] attribute may only be used on structs or enums
- --> $DIR/invalid.rs:206:5
+ --> $DIR/invalid.rs:252:5
|
-206 | / union Union {
-207 | | //~^ ERROR may only be used on structs or enums
-208 | | f: (),
-209 | | }
+252 | / union Union {
+253 | | //~^ ERROR may only be used on structs or enums
+254 | | f: (),
+255 | | }
| |_____^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/invalid.rs:217:12
+ --> $DIR/invalid.rs:263:12
|
-217 | #[repr(packed)]
+263 | #[repr(packed)]
| ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/invalid.rs:221:12
+ --> $DIR/invalid.rs:267:12
|
-221 | #[repr(packed)]
+267 | #[repr(packed)]
| ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/invalid.rs:225:12
+ --> $DIR/invalid.rs:271:12
|
-225 | #[repr(packed)]
+271 | #[repr(packed)]
| ^^^^^^
diff --git a/tests/ui/pin_project/overlapping_unpin_struct.stderr b/tests/ui/pin_project/overlapping_unpin_struct.stderr
index d0fd4a9..96a9f51 100644
--- a/tests/ui/pin_project/overlapping_unpin_struct.stderr
+++ b/tests/ui/pin_project/overlapping_unpin_struct.stderr
@@ -5,7 +5,7 @@ error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
| ----- required by this bound in `is_unpin`
...
17 | is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__SCOPE_Foo::__Foo<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Foo<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `__SCOPE_Foo::__Foo<'_, std::marker::PhantomPinned>`
+ = note: required because it appears within the type `_::__Foo<'_, std::marker::PhantomPinned>`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned>`
diff --git a/tests/ui/pin_project/project_replace_unsized.rs b/tests/ui/pin_project/project_replace_unsized.rs
new file mode 100644
index 0000000..706a0c1
--- /dev/null
+++ b/tests/ui/pin_project/project_replace_unsized.rs
@@ -0,0 +1,11 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace)] //~ ERROR E0277
+struct Struct<T: ?Sized> {
+ x: T,
+}
+
+#[pin_project(project_replace)] //~ ERROR E0277
+struct TupleStruct<T: ?Sized>(T);
+
+fn main() {}
diff --git a/tests/ui/pin_project/project_replace_unsized.stderr b/tests/ui/pin_project/project_replace_unsized.stderr
new file mode 100644
index 0000000..c3a3be7
--- /dev/null
+++ b/tests/ui/pin_project/project_replace_unsized.stderr
@@ -0,0 +1,77 @@
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized.rs:3:15
+ |
+3 | #[pin_project(project_replace)] //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+4 | struct Struct<T: ?Sized> {
+ | - this type parameter needs to be `std::marker::Sized`
+ |
+ = help: within `Struct<T>`, the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = note: required because it appears within the type `Struct<T>`
+ = note: all local variables must have a statically known size
+ = help: unsized locals are gated as an unstable feature
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized.rs:5:5
+ |
+4 | struct Struct<T: ?Sized> {
+ | - this type parameter needs to be `std::marker::Sized`
+5 | x: T,
+ | ^ doesn't have a size known at compile-time
+ |
+ = help: the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized.rs:3:1
+ |
+3 | #[pin_project(project_replace)] //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+4 | struct Struct<T: ?Sized> {
+ | - this type parameter needs to be `std::marker::Sized`
+ |
+ = help: within `__StructProjectionOwned<T>`, the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = note: required because it appears within the type `__StructProjectionOwned<T>`
+ = note: structs must have a statically known size to be initialized
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized.rs:8:15
+ |
+8 | #[pin_project(project_replace)] //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+9 | struct TupleStruct<T: ?Sized>(T);
+ | - this type parameter needs to be `std::marker::Sized`
+ |
+ = help: within `TupleStruct<T>`, the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = note: required because it appears within the type `TupleStruct<T>`
+ = note: all local variables must have a statically known size
+ = help: unsized locals are gated as an unstable feature
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized.rs:8:1
+ |
+8 | #[pin_project(project_replace)] //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+9 | struct TupleStruct<T: ?Sized>(T);
+ | - this type parameter needs to be `std::marker::Sized`
+ |
+ = help: the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized.rs:9:8
+ |
+9 | struct TupleStruct<T: ?Sized>(T);
+ | ^^^^^^^^^^^ - this type parameter needs to be `std::marker::Sized`
+ | |
+ | doesn't have a size known at compile-time
+ |
+ = help: the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = note: all function arguments must have a statically known size
+ = help: unsized locals are gated as an unstable feature
diff --git a/tests/ui/pin_project/project_replace_unsized_locals.rs b/tests/ui/pin_project/project_replace_unsized_locals.rs
new file mode 100644
index 0000000..2546041
--- /dev/null
+++ b/tests/ui/pin_project/project_replace_unsized_locals.rs
@@ -0,0 +1,13 @@
+#![feature(unsized_locals)]
+
+use pin_project::pin_project;
+
+#[pin_project(project_replace)] //~ ERROR E0277
+struct Struct<T: ?Sized> {
+ x: T,
+}
+
+#[pin_project(project_replace)] //~ ERROR E0277
+struct TupleStruct<T: ?Sized>(T);
+
+fn main() {}
diff --git a/tests/ui/pin_project/project_replace_unsized_locals.stderr b/tests/ui/pin_project/project_replace_unsized_locals.stderr
new file mode 100644
index 0000000..1616904
--- /dev/null
+++ b/tests/ui/pin_project/project_replace_unsized_locals.stderr
@@ -0,0 +1,64 @@
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized_locals.rs:6:8
+ |
+6 | struct Struct<T: ?Sized> {
+ | ^^^^^^^-^^^^^^^^^
+ | | |
+ | | this type parameter needs to be `std::marker::Sized`
+ | doesn't have a size known at compile-time
+ |
+ = help: within `__StructProjectionOwned<T>`, the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = note: required because it appears within the type `__StructProjectionOwned<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
+ --> $DIR/project_replace_unsized_locals.rs:7:5
+ |
+6 | struct Struct<T: ?Sized> {
+ | - this type parameter needs to be `std::marker::Sized`
+7 | x: T,
+ | ^ doesn't have a size known at compile-time
+ |
+ = help: the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized_locals.rs:5:1
+ |
+5 | #[pin_project(project_replace)] //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+6 | struct Struct<T: ?Sized> {
+ | - this type parameter needs to be `std::marker::Sized`
+ |
+ = help: within `__StructProjectionOwned<T>`, the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = note: required because it appears within the type `__StructProjectionOwned<T>`
+ = note: structs must have a statically known size to be initialized
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> $DIR/project_replace_unsized_locals.rs:11:8
+ |
+11 | struct TupleStruct<T: ?Sized>(T);
+ | ^^^^^^^^^^^^-^^^^^^^^^
+ | | |
+ | | this type parameter needs to be `std::marker::Sized`
+ | doesn't have a size known at compile-time
+ |
+ = help: within `__TupleStructProjectionOwned<T>`, the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = note: required because it appears within the type `__TupleStructProjectionOwned<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
+ --> $DIR/project_replace_unsized_locals.rs:10:1
+ |
+10 | #[pin_project(project_replace)] //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+11 | struct TupleStruct<T: ?Sized>(T);
+ | - this type parameter needs to be `std::marker::Sized`
+ |
+ = help: the trait `std::marker::Sized` is not implemented for `T`
+ = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+ = 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/proper_unpin.stderr b/tests/ui/pin_project/proper_unpin.stderr
index 9142887..7562597 100644
--- a/tests/ui/pin_project/proper_unpin.stderr
+++ b/tests/ui/pin_project/proper_unpin.stderr
@@ -5,10 +5,10 @@ error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
| ----- required by this bound in `is_unpin`
...
31 | is_unpin::<Foo<PhantomPinned, ()>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__SCOPE_Foo::__Foo<'_, std::marker::PhantomPinned, ()>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Foo<'_, std::marker::PhantomPinned, ()>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
= note: required because it appears within the type `Inner<std::marker::PhantomPinned>`
- = note: required because it appears within the type `__SCOPE_Foo::__Foo<'_, std::marker::PhantomPinned, ()>`
+ = note: required because it appears within the type `_::__Foo<'_, std::marker::PhantomPinned, ()>`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, ()>`
error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
@@ -18,10 +18,10 @@ error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
| ----- required by this bound in `is_unpin`
...
33 | is_unpin::<Foo<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__SCOPE_Foo::__Foo<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Foo<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
= note: required because it appears within the type `Inner<std::marker::PhantomPinned>`
- = note: required because it appears within the type `__SCOPE_Foo::__Foo<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`
+ = note: required because it appears within the type `_::__Foo<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, std::marker::PhantomPinned>`
error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
@@ -31,7 +31,7 @@ error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
| ----- required by this bound in `is_unpin`
...
35 | is_unpin::<TrivialBounds>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `__SCOPE_TrivialBounds::__TrivialBounds<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__TrivialBounds<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `__SCOPE_TrivialBounds::__TrivialBounds<'_>`
+ = note: required because it appears within the type `_::__TrivialBounds<'_>`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `TrivialBounds`
diff --git a/tests/ui/pin_project/remove-attr-from-field.rs b/tests/ui/pin_project/remove-attr-from-field.rs
index eebd3cd..1ecd56f 100644
--- a/tests/ui/pin_project/remove-attr-from-field.rs
+++ b/tests/ui/pin_project/remove-attr-from-field.rs
@@ -5,28 +5,28 @@ use std::{marker::PhantomPinned, pin::Pin};
fn is_unpin<T: Unpin>() {}
#[pin_project]
-#[remove_attr(field)]
-struct Foo {
+#[remove_attr(field_all)]
+struct A {
#[pin]
field: PhantomPinned,
}
-#[remove_attr(field)]
+#[remove_attr(field_all)]
#[pin_project]
-struct Bar {
+struct B {
#[pin]
field: PhantomPinned,
}
fn main() {
- is_unpin::<Foo>();
- is_unpin::<Bar>();
+ is_unpin::<A>();
+ is_unpin::<B>();
- let mut x = Foo { field: PhantomPinned };
+ let mut x = A { field: PhantomPinned };
let x = Pin::new(&mut x).project();
let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
- let mut x = Bar { field: PhantomPinned };
+ let mut x = B { field: PhantomPinned };
let x = Pin::new(&mut x).project();
let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
}
diff --git a/tests/ui/pin_project/remove-attr-from-struct.rs b/tests/ui/pin_project/remove-attr-from-struct.rs
index b395a42..0c7af63 100644
--- a/tests/ui/pin_project/remove-attr-from-struct.rs
+++ b/tests/ui/pin_project/remove-attr-from-struct.rs
@@ -5,26 +5,42 @@ use std::{marker::PhantomPinned, pin::Pin};
fn is_unpin<T: Unpin>() {}
#[pin_project]
-#[remove_attr(struct)]
-struct Foo {
+#[remove_attr(struct_all)]
+struct A {
#[pin] //~ ERROR cannot find attribute `pin` in this scope
field: PhantomPinned,
}
-#[remove_attr(struct)]
+#[remove_attr(struct_all)]
#[pin_project]
-struct Bar {
+struct B {
#[pin] //~ ERROR cannot find attribute `pin` in this scope
field: PhantomPinned,
}
+#[pin_project] //~ ERROR has been removed
+#[remove_attr(struct_pin)]
+struct C {
+ field: PhantomPinned,
+}
+
+#[remove_attr(struct_pin)]
+#[pin_project] // Ok
+struct D {
+ field: PhantomPinned,
+}
+
fn main() {
- is_unpin::<Foo>(); //~ ERROR E0277
- is_unpin::<Bar>(); //~ ERROR E0277
+ is_unpin::<A>(); //~ ERROR E0277
+ is_unpin::<B>(); //~ ERROR E0277
+ is_unpin::<D>(); // Ok
+
+ let mut x = A { field: PhantomPinned };
+ let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- let mut x = Foo { field: PhantomPinned };
- let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ let mut x = B { field: PhantomPinned };
+ let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- let mut x = Bar { field: PhantomPinned };
- let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ let mut x = D { field: PhantomPinned };
+ let _ = Pin::new(&mut x).project(); //~ Ok
}
diff --git a/tests/ui/pin_project/remove-attr-from-struct.stderr b/tests/ui/pin_project/remove-attr-from-struct.stderr
index 3173248..112584e 100644
--- a/tests/ui/pin_project/remove-attr-from-struct.stderr
+++ b/tests/ui/pin_project/remove-attr-from-struct.stderr
@@ -1,3 +1,11 @@
+error: #[pin_project] attribute has been removed
+ --> $DIR/remove-attr-from-struct.rs:21:1
+ |
+21 | #[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:10:7
|
@@ -11,53 +19,53 @@ error: cannot find attribute `pin` in this scope
| ^^^
error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/remove-attr-from-struct.rs:22:5
+ --> $DIR/remove-attr-from-struct.rs:34:5
|
5 | fn is_unpin<T: Unpin>() {}
| ----- required by this bound in `is_unpin`
...
-22 | is_unpin::<Foo>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^ within `Foo`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+34 | is_unpin::<A>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^ within `A`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `Foo`
+ = note: required because it appears within the type `A`
error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/remove-attr-from-struct.rs:23:5
+ --> $DIR/remove-attr-from-struct.rs:35:5
|
5 | fn is_unpin<T: Unpin>() {}
| ----- required by this bound in `is_unpin`
...
-23 | is_unpin::<Bar>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^ within `Bar`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+35 | is_unpin::<B>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^ within `B`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `Bar`
+ = note: required because it appears within the type `B`
error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/remove-attr-from-struct.rs:26:14
+ --> $DIR/remove-attr-from-struct.rs:39:13
|
-26 | let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- | ^^^^^^^^ within `Foo`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+39 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^^ within `A`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `Foo`
+ = note: required because it appears within the type `A`
= note: required by `std::pin::Pin::<P>::new`
-error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut Foo>` in the current scope
- --> $DIR/remove-attr-from-struct.rs:26:31
+error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut A>` in the current scope
+ --> $DIR/remove-attr-from-struct.rs:39:30
|
-26 | let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- | ^^^^^^^ method not found in `std::pin::Pin<&mut Foo>`
+39 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^ method not found in `std::pin::Pin<&mut A>`
error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/remove-attr-from-struct.rs:29:14
+ --> $DIR/remove-attr-from-struct.rs:42:13
|
-29 | let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- | ^^^^^^^^ within `Bar`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+42 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^^ within `B`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
- = note: required because it appears within the type `Bar`
+ = note: required because it appears within the type `B`
= note: required by `std::pin::Pin::<P>::new`
-error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut Bar>` in the current scope
- --> $DIR/remove-attr-from-struct.rs:29:31
+error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut B>` in the current scope
+ --> $DIR/remove-attr-from-struct.rs:42:30
|
-29 | let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- | ^^^^^^^ method not found in `std::pin::Pin<&mut Bar>`
+42 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^ method not found in `std::pin::Pin<&mut B>`
diff --git a/tests/ui/pin_project/visibility.rs b/tests/ui/pin_project/visibility.rs
index 7dce6ab..01c0831 100644
--- a/tests/ui/pin_project/visibility.rs
+++ b/tests/ui/pin_project/visibility.rs
@@ -4,7 +4,7 @@ mod pub_ {
#[pin_project]
pub struct Default(());
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub struct Replace(());
}
pub mod pub_use {
@@ -37,7 +37,7 @@ mod pub_crate {
#[pin_project]
pub(crate) struct Default(());
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
pub(crate) struct Replace(());
}
pub mod pub_crate_use {
@@ -55,7 +55,7 @@ mod pub_renamed {
#[pin_project(project = DProj, project_ref = DProjRef)]
pub struct Default(());
- #[pin_project(Replace, project = RProj, project_ref = RProjRef, project_replace = RProjOwn)]
+ #[pin_project(project = RProj, project_ref = RProjRef, project_replace = RProjOwn)]
pub struct Replace(());
}
pub mod pub_renamed_use {
diff --git a/tests/ui/pinned_drop/invalid.rs b/tests/ui/pinned_drop/invalid.rs
index 9ff5de2..7065ec9 100644
--- a/tests/ui/pinned_drop/invalid.rs
+++ b/tests/ui/pinned_drop/invalid.rs
@@ -204,4 +204,26 @@ mod method {
}
}
+mod self_ty {
+ use pin_project::pinned_drop;
+
+ #[pinned_drop]
+ impl PinnedDrop for () {
+ //~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for &mut A {
+ //~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for [A] {
+ //~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
+ fn drop(self: Pin<&mut Self>) {}
+ }
+}
+
fn main() {}
diff --git a/tests/ui/pinned_drop/invalid.stderr b/tests/ui/pinned_drop/invalid.stderr
index 8046903..65ef9ff 100644
--- a/tests/ui/pinned_drop/invalid.stderr
+++ b/tests/ui/pinned_drop/invalid.stderr
@@ -123,3 +123,21 @@ error: method `pinned_drop` is not a member of trait `PinnedDrop
|
203 | fn pinned_drop(&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
+ |
+211 | impl PinnedDrop for () {
+ | ^^
+
+error: implementing the trait `PinnedDrop` on this type is unsupported
+ --> $DIR/invalid.rs:217:25
+ |
+217 | impl PinnedDrop for &mut A {
+ | ^^^^^^
+
+error: implementing the trait `PinnedDrop` on this type is unsupported
+ --> $DIR/invalid.rs:223:25
+ |
+223 | impl PinnedDrop for [A] {
+ | ^^^
diff --git a/tests/ui/pinned_drop/self.rs b/tests/ui/pinned_drop/self.rs
index cd53b04..9176066 100644
--- a/tests/ui/pinned_drop/self.rs
+++ b/tests/ui/pinned_drop/self.rs
@@ -1,10 +1,10 @@
-use pin_project::{pin_project, pinned_drop};
-use std::pin::Pin;
+pub mod self_in_macro_def {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
-fn self_in_macro_def() {
#[pin_project(PinnedDrop)]
pub struct Struct {
- x: usize,
+ x: (),
}
#[pinned_drop]
@@ -12,12 +12,9 @@ fn self_in_macro_def() {
fn drop(self: Pin<&mut Self>) {
macro_rules! t {
() => {{
- let _ = self; //~ ERROR can't capture dynamic environment in a fn item
+ let _ = self; //~ ERROR E0434
- fn f(self: ()) {
- //~^ ERROR `self` parameter is only allowed in associated functions
- let _ = self;
- }
+ fn f(self: ()) {} //~ ERROR `self` parameter is only allowed in associated functions
}};
}
t!();
@@ -25,4 +22,35 @@ fn self_in_macro_def() {
}
}
+pub mod self_span {
+ use pin_project::{pin_project, pinned_drop};
+ use std::pin::Pin;
+
+ #[pin_project(PinnedDrop)]
+ pub struct S {
+ x: (),
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for S {
+ fn drop(self: Pin<&mut Self>) {
+ let _: () = self; //~ ERROR E0308
+ let _: Self = Self; //~ ERROR E0423
+ }
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub enum E {
+ V { x: () },
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for E {
+ fn drop(self: Pin<&mut Self>) {
+ let _: () = self; //~ ERROR E0308
+ let _: Self = Self::V; //~ ERROR E0533
+ }
+ }
+}
+
fn main() {}
diff --git a/tests/ui/pinned_drop/self.stderr b/tests/ui/pinned_drop/self.stderr
index 3ba333b..2a71b0a 100644
--- a/tests/ui/pinned_drop/self.stderr
+++ b/tests/ui/pinned_drop/self.stderr
@@ -1,10 +1,10 @@
error: `self` parameter is only allowed in associated functions
--> $DIR/self.rs:17:26
|
-17 | fn f(self: ()) {
+17 | fn f(self: ()) {} //~ ERROR `self` parameter is only allowed in associated functions
| ^^^^ not semantically valid as function parameter
...
-23 | t!();
+20 | t!();
| ----- in this macro invocation
|
= note: associated functions are those in `impl` or `trait` definitions
@@ -13,11 +13,50 @@ error: `self` parameter is only allowed in associated functions
error[E0434]: can't capture dynamic environment in a fn item
--> $DIR/self.rs:15:29
|
-15 | let _ = self; //~ ERROR can't capture dynamic environment in a fn item
+15 | let _ = self; //~ ERROR E0434
| ^^^^
...
-23 | t!();
+20 | 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
+ |
+30 | / pub struct S {
+31 | | x: (),
+32 | | }
+ | |_____- `S` defined here
+...
+38 | let _: Self = Self; //~ ERROR E0423
+ | ^^^^ did you mean `S { /* fields */ }`?
+
+error[E0308]: mismatched types
+ --> $DIR/self.rs:37:25
+ |
+37 | let _: () = self; //~ ERROR E0308
+ | -- ^^^^ expected `()`, found struct `std::pin::Pin`
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found struct `std::pin::Pin<&mut self_span::S>`
+
+error[E0308]: mismatched types
+ --> $DIR/self.rs:50:25
+ |
+50 | let _: () = self; //~ ERROR E0308
+ | -- ^^^^ expected `()`, found struct `std::pin::Pin`
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found struct `std::pin::Pin<&mut self_span::E>`
+
+error[E0533]: expected unit struct, unit variant or constant, found struct variant `Self::V`
+ --> $DIR/self.rs:51:27
+ |
+51 | let _: Self = Self::V; //~ ERROR E0533
+ | ^^^^^^^
diff --git a/tests/ui/project/ambiguous-let.rs b/tests/ui/project/ambiguous-let.rs
index a706749..bbb3a2c 100644
--- a/tests/ui/project/ambiguous-let.rs
+++ b/tests/ui/project/ambiguous-let.rs
@@ -1,3 +1,5 @@
+#![allow(deprecated)]
+
use pin_project::{pin_project, project};
#[pin_project]
diff --git a/tests/ui/project/ambiguous-let.stderr b/tests/ui/project/ambiguous-let.stderr
index e6552c8..2e66484 100644
--- a/tests/ui/project/ambiguous-let.stderr
+++ b/tests/ui/project/ambiguous-let.stderr
@@ -1,5 +1,5 @@
error: Both initializer expression and pattern are replaceable, you need to split the initializer expression into separate let bindings to avoid ambiguity
- --> $DIR/ambiguous-let.rs:16:9
+ --> $DIR/ambiguous-let.rs:18:9
|
-16 | let Struct(x) = match Pin::new(&mut foo).project() {
+18 | let Struct(x) = match Pin::new(&mut foo).project() {
| ^^^^^^^^^
diff --git a/tests/ui/project/deprecated.rs b/tests/ui/project/deprecated.rs
new file mode 100644
index 0000000..78d593d
--- /dev/null
+++ b/tests/ui/project/deprecated.rs
@@ -0,0 +1,8 @@
+#![deny(deprecated)]
+
+use pin_project::{project, project_ref, project_replace};
+
+#[project]
+#[project_ref]
+#[project_replace]
+fn main() {}
diff --git a/tests/ui/project/deprecated.stderr b/tests/ui/project/deprecated.stderr
new file mode 100644
index 0000000..015b8df
--- /dev/null
+++ b/tests/ui/project/deprecated.stderr
@@ -0,0 +1,23 @@
+error: use of deprecated item 'project': consider naming projected type by passing `project` argument to #[pin_project] attribute instead, see release note <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> for details
+ --> $DIR/deprecated.rs:5:3
+ |
+5 | #[project]
+ | ^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/deprecated.rs:1:9
+ |
+1 | #![deny(deprecated)]
+ | ^^^^^^^^^^
+
+error: use of deprecated item 'project_ref': consider naming projected type by passing `project_ref` argument to #[pin_project] attribute instead, see release note <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> for details
+ --> $DIR/deprecated.rs:6:3
+ |
+6 | #[project_ref]
+ | ^^^^^^^^^^^
+
+error: use of deprecated item 'project_replace': consider naming projected type by passing `project_replace` argument to #[pin_project] attribute instead, see release note <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> for details
+ --> $DIR/deprecated.rs:7:3
+ |
+7 | #[project_replace]
+ | ^^^^^^^^^^^^^^^
diff --git a/tests/ui/project/invalid.rs b/tests/ui/project/invalid.rs
index 07e9970..e72f84c 100644
--- a/tests/ui/project/invalid.rs
+++ b/tests/ui/project/invalid.rs
@@ -1,3 +1,5 @@
+#![allow(deprecated)]
+
mod argument {
use pin_project::{pin_project, project};
@@ -46,7 +48,7 @@ mod argument {
mod attribute {
use pin_project::{pin_project, project, project_ref, project_replace};
- #[pin_project(Replace)]
+ #[pin_project(project_replace)]
struct A(#[pin] ());
#[project]
diff --git a/tests/ui/project/invalid.stderr b/tests/ui/project/invalid.stderr
index 287cac8..e1dc388 100644
--- a/tests/ui/project/invalid.stderr
+++ b/tests/ui/project/invalid.stderr
@@ -1,155 +1,155 @@
error: unexpected token: ()
- --> $DIR/invalid.rs:10:18
+ --> $DIR/invalid.rs:12:18
|
-10 | #[project()] //~ ERROR unexpected token
+12 | #[project()] //~ ERROR unexpected token
| ^^
error: unexpected token: (foo)
- --> $DIR/invalid.rs:17:18
+ --> $DIR/invalid.rs:19:18
|
-17 | #[project(foo)] //~ ERROR unexpected token
+19 | #[project(foo)] //~ ERROR unexpected token
| ^^^^^
error: unexpected token: ()
- --> $DIR/invalid.rs:24:18
+ --> $DIR/invalid.rs:26:18
|
-24 | #[project()] //~ ERROR unexpected token
+26 | #[project()] //~ ERROR unexpected token
| ^^
error: unexpected token: (foo)
- --> $DIR/invalid.rs:33:18
+ --> $DIR/invalid.rs:35:18
|
-33 | #[project(foo)] //~ ERROR unexpected token
+35 | #[project(foo)] //~ ERROR unexpected token
| ^^^^^
error: unexpected token: foo
- --> $DIR/invalid.rs:42:15
+ --> $DIR/invalid.rs:44:15
|
-42 | #[project(foo)] //~ ERROR unexpected token
+44 | #[project(foo)] //~ ERROR unexpected token
| ^^^
error: duplicate #[project] attribute
- --> $DIR/invalid.rs:56:9
+ --> $DIR/invalid.rs:58:9
|
-56 | #[project] //~ ERROR duplicate #[project] attribute
+58 | #[project] //~ ERROR duplicate #[project] attribute
| ^^^^^^^^^^
error: duplicate #[project_ref] attribute
- --> $DIR/invalid.rs:64:9
+ --> $DIR/invalid.rs:66:9
|
-64 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
+66 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
| ^^^^^^^^^^^^^^
error: duplicate #[project_replace] attribute
- --> $DIR/invalid.rs:72:9
+ --> $DIR/invalid.rs:74:9
|
-72 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
+74 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
| ^^^^^^^^^^^^^^^^^^
-error: attributes `project_ref` and `project` are mutually exclusive
- --> $DIR/invalid.rs:79:9
+error: attributes `project` and `project_ref` are mutually exclusive
+ --> $DIR/invalid.rs:82:9
|
-79 | #[project]
- | ^^^^^^^^^^
+82 | #[project_ref] //~ ERROR are mutually exclusive
+ | ^^^^^^^^^^^^^^
error: attributes `project` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:88:9
+ --> $DIR/invalid.rs:90:9
|
-88 | #[project_replace] //~ ERROR are mutually exclusive
+90 | #[project_replace] //~ ERROR are mutually exclusive
| ^^^^^^^^^^^^^^^^^^
error: attributes `project_ref` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:96:9
+ --> $DIR/invalid.rs:98:9
|
-96 | #[project_replace] //~ ERROR are mutually exclusive
+98 | #[project_replace] //~ ERROR are mutually exclusive
| ^^^^^^^^^^^^^^^^^^
-error: attributes `project_ref` and `project` are mutually exclusive
- --> $DIR/invalid.rs:103:9
+error: attributes `project` and `project_ref` are mutually exclusive
+ --> $DIR/invalid.rs:106:9
|
-103 | #[project]
- | ^^^^^^^^^^
+106 | #[project_ref] //~ ERROR are mutually exclusive
+ | ^^^^^^^^^^^^^^
error: attributes `project` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:112:9
+ --> $DIR/invalid.rs:114:9
|
-112 | #[project_replace] //~ ERROR are mutually exclusive
+114 | #[project_replace] //~ ERROR are mutually exclusive
| ^^^^^^^^^^^^^^^^^^
error: attributes `project_ref` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:120:9
+ --> $DIR/invalid.rs:122:9
|
-120 | #[project_replace] //~ ERROR are mutually exclusive
+122 | #[project_replace] //~ ERROR are mutually exclusive
| ^^^^^^^^^^^^^^^^^^
-error: attributes `project_ref` and `project` are mutually exclusive
- --> $DIR/invalid.rs:127:9
+error: attributes `project` and `project_ref` are mutually exclusive
+ --> $DIR/invalid.rs:130:9
|
-127 | #[project]
- | ^^^^^^^^^^
+130 | #[project_ref] //~ ERROR are mutually exclusive
+ | ^^^^^^^^^^^^^^
error: attributes `project` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:136:9
+ --> $DIR/invalid.rs:138:9
|
-136 | #[project_replace] //~ ERROR are mutually exclusive
+138 | #[project_replace] //~ ERROR are mutually exclusive
| ^^^^^^^^^^^^^^^^^^
error: attributes `project_ref` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:144:9
+ --> $DIR/invalid.rs:146:9
|
-144 | #[project_replace] //~ ERROR are mutually exclusive
+146 | #[project_replace] //~ ERROR are mutually exclusive
| ^^^^^^^^^^^^^^^^^^
error: duplicate #[project] attribute
- --> $DIR/invalid.rs:149:5
+ --> $DIR/invalid.rs:151:5
|
-149 | #[project] //~ ERROR duplicate #[project] attribute
+151 | #[project] //~ ERROR duplicate #[project] attribute
| ^^^^^^^^^^
error: duplicate #[project_ref] attribute
- --> $DIR/invalid.rs:153:5
+ --> $DIR/invalid.rs:155:5
|
-153 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
+155 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
| ^^^^^^^^^^^^^^
error: duplicate #[project_replace] attribute
- --> $DIR/invalid.rs:157:5
+ --> $DIR/invalid.rs:159:5
|
-157 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
+159 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
| ^^^^^^^^^^^^^^^^^^
error: duplicate #[project] attribute
- --> $DIR/invalid.rs:161:5
+ --> $DIR/invalid.rs:163:5
|
-161 | #[project] //~ ERROR duplicate #[project] attribute
+163 | #[project] //~ ERROR duplicate #[project] attribute
| ^^^^^^^^^^
error: duplicate #[project_ref] attribute
- --> $DIR/invalid.rs:165:5
+ --> $DIR/invalid.rs:167:5
|
-165 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
+167 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
| ^^^^^^^^^^^^^^
error: duplicate #[project_replace] attribute
- --> $DIR/invalid.rs:169:5
+ --> $DIR/invalid.rs:171:5
|
-169 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
+171 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
| ^^^^^^^^^^^^^^^^^^
error: duplicate #[project] attribute
- --> $DIR/invalid.rs:177:9
+ --> $DIR/invalid.rs:179:9
|
-177 | #[project] //~ ERROR duplicate #[project] attribute
+179 | #[project] //~ ERROR duplicate #[project] attribute
| ^^^^^^^^^^
error: duplicate #[project_ref] attribute
- --> $DIR/invalid.rs:181:9
+ --> $DIR/invalid.rs:183:9
|
-181 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
+183 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
| ^^^^^^^^^^^^^^
error: duplicate #[project_replace] attribute
- --> $DIR/invalid.rs:185:9
+ --> $DIR/invalid.rs:187:9
|
-185 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
+187 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
| ^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/project/type-mismatch.rs b/tests/ui/project/type-mismatch.rs
index 41a70eb..0e40c83 100644
--- a/tests/ui/project/type-mismatch.rs
+++ b/tests/ui/project/type-mismatch.rs
@@ -1,3 +1,4 @@
+#![allow(deprecated)]
#![feature(proc_macro_hygiene, stmt_expr_attributes)]
use pin_project::{pin_project, project};
@@ -36,9 +37,6 @@ fn type_mismatch() {
}
}
-//~ ERROR mismatched types
-// span is lost.
-// Refs: https://github.com/rust-lang/rust/issues/43081
fn type_mismatch_span_issue() {
#[pin_project]
enum Enum<A, B, C, D> {
@@ -67,7 +65,7 @@ fn type_mismatch_span_issue() {
let _x: &mut Pin<&mut i32> = field1;
let _y: &mut &mut i32 = field2;
}
- None => {}
+ None => {} //~ ERROR mismatched types
}
}
diff --git a/tests/ui/project/type-mismatch.stderr b/tests/ui/project/type-mismatch.stderr
index b4c97d5..4199c17 100644
--- a/tests/ui/project/type-mismatch.stderr
+++ b/tests/ui/project/type-mismatch.stderr
@@ -1,16 +1,23 @@
error[E0308]: mismatched types
- --> $DIR/type-mismatch.rs:35:9
+ --> $DIR/type-mismatch.rs:36:9
|
-23 | match &mut foo {
+24 | match &mut foo {
| -------- this expression has type `&mut type_mismatch::__EnumProjection<'_, {integer}, {integer}, _, _>`
...
-35 | None => {} //~ ERROR mismatched types
+36 | None => {} //~ ERROR mismatched types
| ^^^^ expected enum `type_mismatch::__EnumProjection`, found enum `std::option::Option`
|
= note: expected enum `type_mismatch::__EnumProjection<'_, {integer}, {integer}, _, _>`
found enum `std::option::Option<_>`
error[E0308]: mismatched types
- |
- = note: expected enum `type_mismatch_span_issue::__EnumProjection<'_, {integer}, {integer}, _, _>`
- found enum `std::option::Option<_>`
+ --> $DIR/type-mismatch.rs:68:9
+ |
+56 | match &mut foo {
+ | -------- this expression has type `&mut type_mismatch_span_issue::__EnumProjection<'_, {integer}, {integer}, _, _>`
+...
+68 | None => {} //~ ERROR mismatched types
+ | ^^^^ expected enum `type_mismatch_span_issue::__EnumProjection`, found enum `std::option::Option`
+ |
+ = note: expected enum `type_mismatch_span_issue::__EnumProjection<'_, {integer}, {integer}, _, _>`
+ found enum `std::option::Option<_>`
diff --git a/tests/ui/project/use-public.rs b/tests/ui/project/use-public.rs
index 23c9b89..aa82a95 100644
--- a/tests/ui/project/use-public.rs
+++ b/tests/ui/project/use-public.rs
@@ -1,3 +1,5 @@
+#![allow(deprecated)]
+
use pin_project::pin_project;
#[pin_project]
diff --git a/tests/ui/project/use-public.stderr b/tests/ui/project/use-public.stderr
index 7919d65..6956656 100644
--- a/tests/ui/project/use-public.stderr
+++ b/tests/ui/project/use-public.stderr
@@ -1,7 +1,7 @@
error[E0365]: `__AProjection` is private, and cannot be re-exported
- --> $DIR/use-public.rs:12:13
+ --> $DIR/use-public.rs:14:13
|
-12 | pub use crate::A; //~ ERROR E0365
+14 | pub use crate::A; //~ ERROR E0365
| ^^^^^^^^ re-export of private `__AProjection`
|
= note: consider declaring type or module `__AProjection` with `pub`
diff --git a/tests/ui/project/use.rs b/tests/ui/project/use.rs
index d4b02c1..ba56382 100644
--- a/tests/ui/project/use.rs
+++ b/tests/ui/project/use.rs
@@ -1,3 +1,5 @@
+#![allow(deprecated)]
+
use pin_project::pin_project;
#[pin_project]
diff --git a/tests/ui/project/use.stderr b/tests/ui/project/use.stderr
index 07d0241..daddb16 100644
--- a/tests/ui/project/use.stderr
+++ b/tests/ui/project/use.stderr
@@ -1,11 +1,11 @@
error: #[project] attribute may not be used on renamed imports
- --> $DIR/use.rs:12:16
+ --> $DIR/use.rs:14:16
|
-12 | use crate::A as B; //~ ERROR #[project] attribute may not be used on renamed imports
+14 | use crate::A as B; //~ ERROR #[project] attribute may not be used on renamed imports
| ^^^^^^
error: #[project] attribute may not be used on glob imports
- --> $DIR/use.rs:14:16
+ --> $DIR/use.rs:16:16
|
-14 | use crate::*; //~ ERROR #[project] attribute may not be used on glob imports
+16 | use crate::*; //~ ERROR #[project] attribute may not be used on glob imports
| ^
diff --git a/tests/ui/unsafe_unpin/conflict-unpin.stderr b/tests/ui/unsafe_unpin/conflict-unpin.stderr
index 62de016..916c3f2 100644
--- a/tests/ui/unsafe_unpin/conflict-unpin.stderr
+++ b/tests/ui/unsafe_unpin/conflict-unpin.stderr
@@ -1,35 +1,32 @@
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`:
- --> $DIR/conflict-unpin.rs:3:1
+ --> $DIR/conflict-unpin.rs:3:15
|
3 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
+ | ^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
...
10 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
| --------------------------------------------- first implementation here
|
= note: upstream crates may add a new impl of trait `pin_project::UnsafeUnpin` for type `pin_project::__private::Wrapper<'_, Foo<_, _>>` in future versions
- = 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<_, _>`:
- --> $DIR/conflict-unpin.rs:12:1
+ --> $DIR/conflict-unpin.rs:12:15
|
12 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
+ | ^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
...
19 | impl<T, U> Unpin for Bar<T, U> {}
| ------------------------------ first implementation here
|
= note: upstream crates may add a new impl of trait `pin_project::UnsafeUnpin` for type `pin_project::__private::Wrapper<'_, Bar<_, _>>` in future versions
- = 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<_, _>`:
- --> $DIR/conflict-unpin.rs:21:1
+ --> $DIR/conflict-unpin.rs:21:15
|
21 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
+ | ^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
...
28 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
| -------------------------------------------- first implementation here
|
= note: upstream crates may add a new impl of trait `pin_project::UnsafeUnpin` for type `pin_project::__private::Wrapper<'_, Baz<_, _>>` in future versions
- = 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/run-pass/stmt_expr_attributes.rs b/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs
index 8ad8e41..2b6377a 100644
--- a/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs
+++ b/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs
@@ -1,5 +1,6 @@
// NB: If you change this test, change 'stmt_expr_attributes-feature-gate.rs' at the same time.
+#![allow(deprecated)]
// proc_macro_hygiene
// Tracking issue: https://github.com/rust-lang/rust/issues/54727
#![feature(proc_macro_hygiene)]
diff --git a/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs b/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs
index 8226723..5dbe523 100644
--- a/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs
+++ b/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs
@@ -1,5 +1,7 @@
// NB: If you change this test, change 'stmt_expr_attributes.rs' at the same time.
+#![allow(deprecated)]
+
use pin_project::{pin_project, project};
use std::pin::Pin;
diff --git a/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr b/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr
index 6510ec7..3c0501a 100644
--- a/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr
+++ b/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr
@@ -1,34 +1,34 @@
error[E0658]: attributes on expressions are experimental
- --> $DIR/stmt_expr_attributes-feature-gate.rs:22:5
+ --> $DIR/stmt_expr_attributes-feature-gate.rs:24:5
|
-22 | #[project] //~ ERROR E0658
+24 | #[project] //~ ERROR E0658
| ^^^^^^^^^^
|
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
error[E0658]: attributes on expressions are experimental
- --> $DIR/stmt_expr_attributes-feature-gate.rs:38:14
+ --> $DIR/stmt_expr_attributes-feature-gate.rs:40:14
|
-38 | let () = #[project] //~ ERROR E0658
+40 | let () = #[project] //~ ERROR E0658
| ^^^^^^^^^^
|
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
error[E0658]: custom attributes cannot be applied to expressions
- --> $DIR/stmt_expr_attributes-feature-gate.rs:22:5
+ --> $DIR/stmt_expr_attributes-feature-gate.rs:24:5
|
-22 | #[project] //~ ERROR E0658
+24 | #[project] //~ ERROR E0658
| ^^^^^^^^^^
|
= note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
= help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
error[E0658]: custom attributes cannot be applied to expressions
- --> $DIR/stmt_expr_attributes-feature-gate.rs:38:14
+ --> $DIR/stmt_expr_attributes-feature-gate.rs:40:14
|
-38 | let () = #[project] //~ ERROR E0658
+40 | let () = #[project] //~ ERROR E0658
| ^^^^^^^^^^
|
= note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information