Skip to content

Remove impl PinCoerceUnsized for Pin #144896

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,9 +1758,6 @@ unsafe impl<'a, T: ?Sized> PinCoerceUnsized for &'a T {}
#[stable(feature = "pin", since = "1.33.0")]
unsafe impl<'a, T: ?Sized> PinCoerceUnsized for &'a mut T {}

#[stable(feature = "pin", since = "1.33.0")]
unsafe impl<T: PinCoerceUnsized> PinCoerceUnsized for Pin<T> {}

#[stable(feature = "pin", since = "1.33.0")]
unsafe impl<T: ?Sized> PinCoerceUnsized for *const T {}

Expand Down
3 changes: 0 additions & 3 deletions library/coretests/tests/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,4 @@ mod pin_coerce_unsized {
pub fn pin_non_null(arg: Pin<NonNull<String>>) -> Pin<NonNull<dyn MyTrait>> {
arg
}
pub fn nesting_pins(arg: Pin<Pin<&String>>) -> Pin<Pin<&dyn MyTrait>> {
arg
}
}
8 changes: 0 additions & 8 deletions tests/ui/self/arbitrary_self_types_stdlib_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ trait Trait {
fn by_arc(self: Arc<Self>) -> i64;
fn by_pin_mut(self: Pin<&mut Self>) -> i64;
fn by_pin_box(self: Pin<Box<Self>>) -> i64;
fn by_pin_pin_pin_ref(self: Pin<Pin<Pin<&Self>>>) -> i64;
}

impl Trait for i64 {
Expand All @@ -29,9 +28,6 @@ impl Trait for i64 {
fn by_pin_box(self: Pin<Box<Self>>) -> i64 {
*self
}
fn by_pin_pin_pin_ref(self: Pin<Pin<Pin<&Self>>>) -> i64 {
*self
}
}

fn main() {
Expand All @@ -47,8 +43,4 @@ fn main() {

let pin_box = Into::<Pin<Box<i64>>>::into(Box::new(4i64)) as Pin<Box<dyn Trait>>;
assert_eq!(4, pin_box.by_pin_box());

let value = 5i64;
let pin_pin_pin_ref = Pin::new(Pin::new(Pin::new(&value))) as Pin<Pin<Pin<&dyn Trait>>>;
assert_eq!(5, pin_pin_pin_ref.by_pin_pin_pin_ref());
}
5 changes: 3 additions & 2 deletions tests/ui/typeck/pin-unsound-issue-85099-derefmut.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ check-pass
//@ known-bug: #85099
//@ check-fail

// Should fail. Can coerce `Pin<T>` into `Pin<U>` where
// `T: Deref<Target: Unpin>` and `U: Deref<Target: !Unpin>`, using the
Expand Down Expand Up @@ -59,6 +58,8 @@ pub fn unsound_pin<Fut: Future<Output = ()>>(
let s: &SomeLocalStruct<'_, Fut> = &SomeLocalStruct(&cell);
let p: Pin<Pin<&SomeLocalStruct<'_, Fut>>> = Pin::new(Pin::new(s));
let mut p: Pin<Pin<&dyn SomeTrait<'_, Fut>>> = p;
//~^ ERROR: the trait bound `Pin<&SomeLocalStruct<'_, Fut>>: PinCoerceUnsized` is not satisfied [E0277]
//~| ERROR: the trait bound `Pin<&dyn SomeTrait<'_, Fut>>: PinCoerceUnsized` is not satisfied [E0277]
let r: Pin<&mut dyn SomeTrait<'_, Fut>> = p.as_mut();
let f: Pin<&mut Fut> = r.downcast();
callback(f);
Expand Down
39 changes: 39 additions & 0 deletions tests/ui/typeck/pin-unsound-issue-85099-derefmut.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
error[E0277]: the trait bound `Pin<&SomeLocalStruct<'_, Fut>>: PinCoerceUnsized` is not satisfied
--> $DIR/pin-unsound-issue-85099-derefmut.rs:60:52
|
LL | let mut p: Pin<Pin<&dyn SomeTrait<'_, Fut>>> = p;
| ^ the trait `PinCoerceUnsized` is not implemented for `Pin<&SomeLocalStruct<'_, Fut>>`
|
= help: the following other types implement trait `PinCoerceUnsized`:
&'a T
&'a mut T
*const T
*mut T
Arc<T, A>
Box<T, A>
Cell<T>
NonNull<T>
and 11 others
= note: required for the cast from `Pin<Pin<&SomeLocalStruct<'_, Fut>>>` to `Pin<Pin<&dyn SomeTrait<'_, Fut>>>`

error[E0277]: the trait bound `Pin<&dyn SomeTrait<'_, Fut>>: PinCoerceUnsized` is not satisfied
--> $DIR/pin-unsound-issue-85099-derefmut.rs:60:52
|
LL | let mut p: Pin<Pin<&dyn SomeTrait<'_, Fut>>> = p;
| ^ the trait `PinCoerceUnsized` is not implemented for `Pin<&dyn SomeTrait<'_, Fut>>`
|
= help: the following other types implement trait `PinCoerceUnsized`:
&'a T
&'a mut T
*const T
*mut T
Arc<T, A>
Box<T, A>
Cell<T>
NonNull<T>
and 11 others
= note: required for the cast from `Pin<Pin<&SomeLocalStruct<'_, Fut>>>` to `Pin<Pin<&dyn SomeTrait<'_, Fut>>>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
Loading