Enforce opaque Rust types are unpin for now

This commit is contained in:
David Tolnay 2020-11-15 17:34:05 -08:00
parent c90897fb2f
commit 20fa62bf71
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 15 additions and 1 deletions

View File

@ -489,10 +489,14 @@ fn expand_rust_type_assert_sized(ety: &ExternType) -> TokenStream {
let sized = quote_spanned! {ety.semi_token.span=>
#begin_span std::marker::Sized
};
let unpin = quote_spanned! {ety.semi_token.span=>
#begin_span std::marker::Unpin
};
quote_spanned! {ident.span()=>
let _ = {
fn __AssertSized<T: ?#sized + #sized>() {}
__AssertSized::<#ident>
fn __AssertUnpin<T: #unpin>() {}
(__AssertSized::<#ident>, __AssertUnpin::<#ident>)
};
}
}

View File

@ -0,0 +1,10 @@
error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/rust_pinned.rs:6:14
|
6 | type Pinned;
| -----^^^^^^-
| | |
| | within `Pinned`, the trait `Unpin` is not implemented for `PhantomPinned`
| required by this bound in `__AssertUnpin`
|
= note: required because it appears within the type `Pinned`