Skip to content

Commit f360584

Browse files
committed
Remove impl PinCoerceUnsized for Pin
1 parent e1b9081 commit f360584

File tree

5 files changed

+42
-16
lines changed

5 files changed

+42
-16
lines changed

library/core/src/pin.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,9 +1758,6 @@ unsafe impl<'a, T: ?Sized> PinCoerceUnsized for &'a T {}
17581758
#[stable(feature = "pin", since = "1.33.0")]
17591759
unsafe impl<'a, T: ?Sized> PinCoerceUnsized for &'a mut T {}
17601760

1761-
#[stable(feature = "pin", since = "1.33.0")]
1762-
unsafe impl<T: PinCoerceUnsized> PinCoerceUnsized for Pin<T> {}
1763-
17641761
#[stable(feature = "pin", since = "1.33.0")]
17651762
unsafe impl<T: ?Sized> PinCoerceUnsized for *const T {}
17661763

library/coretests/tests/pin.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,4 @@ mod pin_coerce_unsized {
7777
pub fn pin_non_null(arg: Pin<NonNull<String>>) -> Pin<NonNull<dyn MyTrait>> {
7878
arg
7979
}
80-
pub fn nesting_pins(arg: Pin<Pin<&String>>) -> Pin<Pin<&dyn MyTrait>> {
81-
arg
82-
}
8380
}

tests/ui/self/arbitrary_self_types_stdlib_pointers.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ trait Trait {
1313
fn by_arc(self: Arc<Self>) -> i64;
1414
fn by_pin_mut(self: Pin<&mut Self>) -> i64;
1515
fn by_pin_box(self: Pin<Box<Self>>) -> i64;
16-
fn by_pin_pin_pin_ref(self: Pin<Pin<Pin<&Self>>>) -> i64;
1716
}
1817

1918
impl Trait for i64 {
@@ -29,9 +28,6 @@ impl Trait for i64 {
2928
fn by_pin_box(self: Pin<Box<Self>>) -> i64 {
3029
*self
3130
}
32-
fn by_pin_pin_pin_ref(self: Pin<Pin<Pin<&Self>>>) -> i64 {
33-
*self
34-
}
3531
}
3632

3733
fn main() {
@@ -47,8 +43,4 @@ fn main() {
4743

4844
let pin_box = Into::<Pin<Box<i64>>>::into(Box::new(4i64)) as Pin<Box<dyn Trait>>;
4945
assert_eq!(4, pin_box.by_pin_box());
50-
51-
let value = 5i64;
52-
let pin_pin_pin_ref = Pin::new(Pin::new(Pin::new(&value))) as Pin<Pin<Pin<&dyn Trait>>>;
53-
assert_eq!(5, pin_pin_pin_ref.by_pin_pin_pin_ref());
5446
}

tests/ui/typeck/pin-unsound-issue-85099-derefmut.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//@ check-pass
2-
//@ known-bug: #85099
1+
//@ check-fail
32

43
// Should fail. Can coerce `Pin<T>` into `Pin<U>` where
54
// `T: Deref<Target: Unpin>` and `U: Deref<Target: !Unpin>`, using the
@@ -59,6 +58,8 @@ pub fn unsound_pin<Fut: Future<Output = ()>>(
5958
let s: &SomeLocalStruct<'_, Fut> = &SomeLocalStruct(&cell);
6059
let p: Pin<Pin<&SomeLocalStruct<'_, Fut>>> = Pin::new(Pin::new(s));
6160
let mut p: Pin<Pin<&dyn SomeTrait<'_, Fut>>> = p;
61+
//~^ ERROR: the trait bound `Pin<&SomeLocalStruct<'_, Fut>>: PinCoerceUnsized` is not satisfied [E0277]
62+
//~| ERROR: the trait bound `Pin<&dyn SomeTrait<'_, Fut>>: PinCoerceUnsized` is not satisfied [E0277]
6263
let r: Pin<&mut dyn SomeTrait<'_, Fut>> = p.as_mut();
6364
let f: Pin<&mut Fut> = r.downcast();
6465
callback(f);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0277]: the trait bound `Pin<&SomeLocalStruct<'_, Fut>>: PinCoerceUnsized` is not satisfied
2+
--> $DIR/pin-unsound-issue-85099-derefmut.rs:60:52
3+
|
4+
LL | let mut p: Pin<Pin<&dyn SomeTrait<'_, Fut>>> = p;
5+
| ^ the trait `PinCoerceUnsized` is not implemented for `Pin<&SomeLocalStruct<'_, Fut>>`
6+
|
7+
= help: the following other types implement trait `PinCoerceUnsized`:
8+
&'a T
9+
&'a mut T
10+
*const T
11+
*mut T
12+
Arc<T, A>
13+
Box<T, A>
14+
Cell<T>
15+
NonNull<T>
16+
and 11 others
17+
= note: required for the cast from `Pin<Pin<&SomeLocalStruct<'_, Fut>>>` to `Pin<Pin<&dyn SomeTrait<'_, Fut>>>`
18+
19+
error[E0277]: the trait bound `Pin<&dyn SomeTrait<'_, Fut>>: PinCoerceUnsized` is not satisfied
20+
--> $DIR/pin-unsound-issue-85099-derefmut.rs:60:52
21+
|
22+
LL | let mut p: Pin<Pin<&dyn SomeTrait<'_, Fut>>> = p;
23+
| ^ the trait `PinCoerceUnsized` is not implemented for `Pin<&dyn SomeTrait<'_, Fut>>`
24+
|
25+
= help: the following other types implement trait `PinCoerceUnsized`:
26+
&'a T
27+
&'a mut T
28+
*const T
29+
*mut T
30+
Arc<T, A>
31+
Box<T, A>
32+
Cell<T>
33+
NonNull<T>
34+
and 11 others
35+
= note: required for the cast from `Pin<Pin<&SomeLocalStruct<'_, Fut>>>` to `Pin<Pin<&dyn SomeTrait<'_, Fut>>>`
36+
37+
error: aborting due to 2 previous errors
38+
39+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)