Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lifetime from wrapper types and impl generics #358

Closed
wants to merge 1 commit into from
Closed

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Oct 24, 2024

Context: #357 (comment)
I'm not worried about the compiler making changes that break the current code in the future since the compiler depends on pin-project-lite, but I do like reducing the generated code by this.

-impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+impl<T, U> _pin_project::__private::Unpin for Struct<T, U>
     where
-        ::pin_project::__private::PinnedFieldsOf<
-            __Struct<'pin, T, U>,
+        for<'pin> ::pin_project::__private::PinnedFieldsOf<
+           __Struct<T, U>,
         >: _pin_project::__private::Unpin,
     {}

FYI @danielhenrymantilla

@taiki-e
Copy link
Owner Author

taiki-e commented Oct 24, 2024

Hmm, it seems lifetime in wrapper type in needed in old rustc.
https://github.com/taiki-e/pin-project-lite/actions/runs/11503119119/job/32019681641
https://github.com/taiki-e/pin-project-lite/actions/runs/11503253973/job/32020114753

error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied
   --> tests/lint/lib.rs:93:5
    |
93  | /     pin_project! {
94  | |         /// Testing enum.
95  | |         #[project = EnumProj]
96  | |         #[project_ref = EnumProjRef]
...   |
112 | |         }
113 | |     }
    | |_____^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
    |
    = help: the following implementations were found:
              <std::marker::PhantomPinned as std::marker::Unpin>
    = help: see issue #48214
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

@taiki-e taiki-e changed the title Remove lifetime from wrapper types and impl generics Remove lifetime from wrapper types and impl generics of Unpin impl Oct 24, 2024
@taiki-e taiki-e changed the title Remove lifetime from wrapper types and impl generics of Unpin impl Remove lifetime from impl generics of Unpin impl Oct 24, 2024
@taiki-e taiki-e changed the title Remove lifetime from impl generics of Unpin impl Remove lifetime from wrapper types and impl generics Oct 24, 2024
@taiki-e
Copy link
Owner Author

taiki-e commented Oct 24, 2024

Nah, for<'a> approach doesn't seem to work well with the old rustc in the first place.
https://github.com/taiki-e/pin-project-lite/actions/runs/11503435474/job/32020719422?pr=85
taiki-e/pin-project-lite#85

error[E0277]: the trait bound `for<'__pin> <pin_project_lite::__private::PinnedFieldsOfHelperStruct<default::_::__Origin<'__pin, (), ()>> as pin_project_lite::__private::PinnedFieldsOfHelperTrait>::Actual: std::marker::Unpin` is not satisfied
  --> tests/proper_unpin.rs:28:5
   |
28 |     assert_unpin!(Struct<(), ()>);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     the trait `for<'__pin> std::marker::Unpin` is not implemented for `<pin_project_lite::__private::PinnedFieldsOfHelperStruct<default::_::__Origin<'__pin, (), ()>> as pin_project_lite::__private::PinnedFieldsOfHelperTrait>::Actual`
   |     in this macro invocation
   |
   = help: the following implementations were found:
             <&'a T as std::marker::Unpin>
             <&'a mut T as std::marker::Unpin>
   = note: required because of the requirements on the impl of `std::marker::Unpin` for `default::Struct<(), ()>`
note: required by `default::_::{{closure}}#0::assert_impl_all`
  --> tests/proper_unpin.rs:28:5
   |
28 |     assert_unpin!(Struct<(), ()>);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

@taiki-e taiki-e closed this Oct 24, 2024
@taiki-e taiki-e deleted the lt branch October 24, 2024 16:35
@danielhenrymantilla
Copy link

Interesting, TIL. Thanks for trying it out anyways!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants