diff options
| author | Josh Stone <jistone@redhat.com> | 2022-06-27 10:05:55 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2022-06-27 10:05:55 -0700 |
| commit | e67e1655854b8f2c94dff80f4da2e595bd1ceaa8 (patch) | |
| tree | 6ae5fbdbf49550cfa0b7fff0d99a49ca97a7aa92 /library/alloc/tests | |
| parent | bd2e51a338e36372b200a22f3e0e22189a1063e6 (diff) | |
| download | rust-e67e1655854b8f2c94dff80f4da2e595bd1ceaa8.tar.gz rust-e67e1655854b8f2c94dff80f4da2e595bd1ceaa8.zip | |
Make `ThinBox<T>` covariant in `T`
Just like `Box<T>`, we want `ThinBox<T>` to be covariant in `T`, but the projection in `WithHeader<<T as Pointee>::Metadata>` was making it invariant. This is now hidden as `WithOpaqueHeader`, which we type-cast whenever the real `WithHeader<H>` type is needed.
Diffstat (limited to 'library/alloc/tests')
| -rw-r--r-- | library/alloc/tests/thin_box.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/library/alloc/tests/thin_box.rs b/library/alloc/tests/thin_box.rs index 70d1db8b457..368aa564f94 100644 --- a/library/alloc/tests/thin_box.rs +++ b/library/alloc/tests/thin_box.rs @@ -26,6 +26,13 @@ fn want_thin() { assert!(is_thin::<i32>()); } +#[allow(dead_code)] +fn assert_covariance() { + fn thin_box<'new>(b: ThinBox<[&'static str]>) -> ThinBox<[&'new str]> { + b + } +} + #[track_caller] fn verify_aligned<T>(ptr: *const T) { // Use `black_box` to attempt to obscure the fact that we're calling this |
