pin-project icon indicating copy to clipboard operation
pin-project copied to clipboard

#![feature(negative_impls)] breaks the guarantee for Unpin provided by pin-project

Open taiki-e opened this issue 3 years ago • 1 comments

pin-project provides an appropriate Unpin implementation by default. Since overlapping implementations are prohibited, this ensures that users cannot add inappropriate Unpin implementations.

However, currently, this guarantee can be broken by using #[feature(negative_impls)]: playground

Thanks @danielhenrymantilla for pointing out the interaction with this feature.

taiki-e avatar Jan 30 '22 01:01 taiki-e

It seems that a warning that catches this has been implemented.

error: cross-crate traits with a default impl, like `Unpin`, should not be specialized
  --> tests/run-pass/negative_impls.rs:16:1
   |
16 | impl Unpin for Foo<MyPhantomPinned, ()> {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `-D suspicious-auto-trait-impls` implied by `-D warnings`
   = warning: this will change its meaning in a future release!
   = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
   = note: `MyPhantomPinned` is not a generic parameter

taiki-e avatar Jun 30 '22 02:06 taiki-e