-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rename macro SmartPointer
to CoercePointee
#131284
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -425,8 +425,8 @@ declare_features! ( | |||||
(unstable, deprecated_suggestion, "1.61.0", Some(94785)), | ||||||
/// Allows deref patterns. | ||||||
(incomplete, deref_patterns, "1.79.0", Some(87121)), | ||||||
/// Allows deriving `SmartPointer` traits | ||||||
(unstable, derive_smart_pointer, "1.79.0", Some(123430)), | ||||||
/// Allows deriving traits as per `CoercePointee` specification | ||||||
(unstable, derive_coerce_pointee, "1.79.0", Some(123430)), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
per @compiler-errors's comment |
||||||
/// Controls errors in trait implementations. | ||||||
(unstable, do_not_recommend, "1.67.0", Some(51992)), | ||||||
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1063,10 +1063,11 @@ pub trait FnPtr: Copy + Clone { | |
} | ||
|
||
/// Derive macro generating impls of traits related to smart pointers. | ||
#[rustc_builtin_macro(SmartPointer, attributes(pointee))] | ||
#[rustc_builtin_macro(CoercePointee, attributes(pointee))] | ||
#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)] | ||
#[unstable(feature = "derive_smart_pointer", issue = "123430")] | ||
pub macro SmartPointer($item:item) { | ||
#[unstable(feature = "derive_coerce_pointee", issue = "123430")] | ||
#[cfg(not(bootstrap))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will remove this in the next beta release. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to remove it; it'll get removed by the release team member doing the beta release. |
||
pub macro CoercePointee($item:item) { | ||
/* compiler built-in */ | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
//@ check-pass | ||
|
||
#![feature(derive_smart_pointer)] | ||
#![feature(derive_coerce_pointee)] | ||
|
||
#[derive(core::marker::SmartPointer)] | ||
#[derive(core::marker::CoercePointee)] | ||
#[repr(transparent)] | ||
pub struct Ptr<'a, #[pointee] T: OnDrop + ?Sized, X> { | ||
data: &'a mut T, | ||
|
@@ -13,7 +13,7 @@ pub trait OnDrop { | |
fn on_drop(&mut self); | ||
} | ||
|
||
#[derive(core::marker::SmartPointer)] | ||
#[derive(core::marker::CoercePointee)] | ||
#[repr(transparent)] | ||
pub struct Ptr2<'a, #[pointee] T: ?Sized, X> | ||
where | ||
|
@@ -25,7 +25,7 @@ where | |
|
||
pub trait MyTrait<T: ?Sized> {} | ||
|
||
#[derive(core::marker::SmartPointer)] | ||
#[derive(core::marker::CoercePointee)] | ||
#[repr(transparent)] | ||
pub struct Ptr3<'a, #[pointee] T: ?Sized, X> | ||
where | ||
|
@@ -35,14 +35,14 @@ where | |
x: core::marker::PhantomData<X>, | ||
} | ||
|
||
#[derive(core::marker::SmartPointer)] | ||
#[derive(core::marker::CoercePointee)] | ||
#[repr(transparent)] | ||
pub struct Ptr4<'a, #[pointee] T: MyTrait<T> + ?Sized, X> { | ||
data: &'a mut T, | ||
x: core::marker::PhantomData<X>, | ||
} | ||
|
||
#[derive(core::marker::SmartPointer)] | ||
#[derive(core::marker::CoercePointee)] | ||
#[repr(transparent)] | ||
pub struct Ptr5<'a, #[pointee] T: ?Sized, X> | ||
where | ||
|
@@ -56,7 +56,7 @@ where | |
pub struct Ptr5Companion<T: ?Sized>(core::marker::PhantomData<T>); | ||
pub struct Ptr5Companion2; | ||
|
||
#[derive(core::marker::SmartPointer)] | ||
#[derive(core::marker::CoercePointee)] | ||
#[repr(transparent)] | ||
pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize = 0> { | ||
data: &'a mut T, | ||
|
@@ -65,7 +65,7 @@ pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize | |
|
||
// a reduced example from https://lore.kernel.org/all/[email protected]/ | ||
#[repr(transparent)] | ||
#[derive(core::marker::SmartPointer)] | ||
#[derive(core::marker::CoercePointee)] | ||
pub struct ListArc<#[pointee] T, const ID: u64 = 0> | ||
where | ||
T: ListArcSafe<ID> + ?Sized, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a lang feature at all? The feature gating should be a library feature, since all this gates is a macro, and no behavior in the compiler.
I believe that you can remove this.