- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-derive_coerce_pointeeFeature: RFC 3621's oft-renamed implementationFeature: RFC 3621's oft-renamed implementationT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Define a proc macro that strips the #[repr(transparent)].
#[proc_macro_attribute]
pub fn untransparent(_: TokenStream, item: TokenStream) -> TokenStream {
    let mut i = item.into_iter();
    drop(i.next());
    drop(i.next());
    i.collect()
}use it
#![feature(derive_coerce_pointee)]
use std::marker::CoercePointee;
use …:untransparent;
#[derive(CoercePointee)]
#[untransparent]
#[repr(transparent)]
struct Foo<T: ?Sized>(Box<T>);compiles successfully, expands to
#![feature(prelude_import)]
#![feature(derive_coerce_pointee)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
use std::marker::CoercePointee;
use …::untransparent;
struct Foo<T: ?Sized>(Box<T>);
#[automatically_derived]
impl<
    T: ?Sized + ::core::marker::Unsize<__S>,
    __S: ?Sized,
> ::core::ops::DispatchFromDyn<Foo<__S>> for Foo<T> {}
#[automatically_derived]
impl<
    T: ?Sized + ::core::marker::Unsize<__S>,
    __S: ?Sized,
> ::core::ops::CoerceUnsized<Foo<__S>> for Foo<T> {}As far as I understand the RFC and intent, the intended stabilization should only stabilize allowing these (CoerceUnsized & DispatchFromDyn impls) to be generated for #[repr(transparent)] types.
@rustbot label F-derive_coerce_pointee
dingxiangfei2009
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-derive_coerce_pointeeFeature: RFC 3621's oft-renamed implementationFeature: RFC 3621's oft-renamed implementationT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.