Skip to content

Commit 6e7d624

Browse files
s/SmartPointer/CoerceReferent/g
move derive_smart_pointer into removed set
1 parent a1eceec commit 6e7d624

27 files changed

+417
-397
lines changed

compiler/rustc_builtin_macros/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ builtin_macros_non_exhaustive_default = default variant must be exhaustive
235235
.label = declared `#[non_exhaustive]` here
236236
.help = consider a manual implementation of `Default`
237237
238-
builtin_macros_non_generic_pointee = the `#[pointee]` attribute may only be used on generic parameters
238+
builtin_macros_non_generic_referent = the `#[referent]` attribute may only be used on generic parameters
239239
240240
builtin_macros_non_unit_default = the `#[default]` attribute may only be used on unit enum variants
241241
.help = consider a manual implementation of `Default`

compiler/rustc_builtin_macros/src/deriving/smart_ptr.rs compiler/rustc_builtin_macros/src/deriving/coerce_referent.rs

+61-61
Large diffs are not rendered by default.

compiler/rustc_builtin_macros/src/deriving/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ macro path_std($($x:tt)*) {
2222

2323
pub(crate) mod bounds;
2424
pub(crate) mod clone;
25+
pub(crate) mod coerce_referent;
2526
pub(crate) mod debug;
2627
pub(crate) mod decodable;
2728
pub(crate) mod default;
2829
pub(crate) mod encodable;
2930
pub(crate) mod hash;
30-
pub(crate) mod smart_ptr;
3131

3232
#[path = "cmp/eq.rs"]
3333
pub(crate) mod eq;

compiler/rustc_builtin_macros/src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ pub(crate) struct NakedFunctionTestingAttribute {
942942
}
943943

944944
#[derive(Diagnostic)]
945-
#[diag(builtin_macros_non_generic_pointee)]
946-
pub(crate) struct NonGenericPointee {
945+
#[diag(builtin_macros_non_generic_referent)]
946+
pub(crate) struct NonGenericReferent {
947947
#[primary_span]
948948
pub span: Span,
949949
}

compiler/rustc_builtin_macros/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
130130
PartialOrd: partial_ord::expand_deriving_partial_ord,
131131
RustcDecodable: decodable::expand_deriving_rustc_decodable,
132132
RustcEncodable: encodable::expand_deriving_rustc_encodable,
133-
SmartPointer: smart_ptr::expand_deriving_smart_ptr,
133+
CoerceReferent: coerce_referent::expand_deriving_coerce_referent,
134134
}
135135

136136
let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);

compiler/rustc_feature/src/removed.rs

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ declare_features! (
8585
/// Allows default type parameters to influence type inference.
8686
(removed, default_type_parameter_fallback, "1.82.0", Some(27336),
8787
Some("never properly implemented; requires significant design work")),
88+
/// Allows deriving traits as per `SmartPointer` specification
89+
(removed, derive_smart_pointer, "1.79.0", Some(123430), Some("replaced by `CoerceReferent`")),
8890
/// Allows using `#[doc(keyword = "...")]`.
8991
(removed, doc_keyword, "1.28.0", Some(51315),
9092
Some("merged into `#![feature(rustdoc_internals)]`")),

compiler/rustc_feature/src/unstable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ declare_features! (
432432
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
433433
/// Allows deref patterns.
434434
(incomplete, deref_patterns, "1.79.0", Some(87121)),
435-
/// Allows deriving `SmartPointer` traits
436-
(unstable, derive_smart_pointer, "1.79.0", Some(123430)),
435+
/// Allows deriving traits as per `CoerceReferent` specification
436+
(unstable, derive_coerce_referent, "1.79.0", Some(123430)),
437437
/// Controls errors in trait implementations.
438438
(unstable, do_not_recommend, "1.67.0", Some(51992)),
439439
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.

compiler/rustc_passes/src/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
259259
| sym::cfg_attr
260260
// need to be fixed
261261
| sym::cfi_encoding // FIXME(cfi_encoding)
262-
| sym::pointee // FIXME(derive_smart_pointer)
262+
| sym::referent // FIXME(derive_coerce_referent)
263263
| sym::omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
264264
| sym::used // handled elsewhere to restrict to static items
265265
| sym::repr // handled elsewhere to restrict to type decls items

compiler/rustc_span/src/symbol.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ symbols! {
174174
Center,
175175
Cleanup,
176176
Clone,
177+
CoerceReferent,
177178
CoerceUnsized,
178179
Command,
179180
ConstParamTy,
@@ -315,7 +316,6 @@ symbols! {
315316
Sized,
316317
SliceIndex,
317318
SliceIter,
318-
SmartPointer,
319319
Some,
320320
SpanCtxt,
321321
String,
@@ -737,6 +737,7 @@ symbols! {
737737
deref_pure,
738738
deref_target,
739739
derive,
740+
derive_coerce_referent,
740741
derive_const,
741742
derive_default_enum,
742743
derive_smart_pointer,
@@ -1460,7 +1461,6 @@ symbols! {
14601461
plugin,
14611462
plugin_registrar,
14621463
plugins,
1463-
pointee,
14641464
pointee_trait,
14651465
pointer,
14661466
pointer_like,
@@ -1571,6 +1571,7 @@ symbols! {
15711571
ref_pat_everywhere,
15721572
ref_unwind_safe_trait,
15731573
reference,
1574+
referent,
15741575
reflect,
15751576
reg,
15761577
reg16,

library/core/src/marker.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1062,10 +1062,11 @@ pub trait FnPtr: Copy + Clone {
10621062
}
10631063

10641064
/// Derive macro generating impls of traits related to smart pointers.
1065-
#[rustc_builtin_macro(SmartPointer, attributes(pointee))]
1065+
#[rustc_builtin_macro(CoerceReferent, attributes(referent))]
10661066
#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)]
1067-
#[unstable(feature = "derive_smart_pointer", issue = "123430")]
1068-
pub macro SmartPointer($item:item) {
1067+
#[unstable(feature = "derive_coerce_referent", issue = "123430")]
1068+
#[cfg(not(bootstrap))]
1069+
pub macro CoerceReferent($item:item) {
10691070
/* compiler built-in */
10701071
}
10711072

tests/ui/deriving/auxiliary/another-proc-macro.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
extern crate proc_macro;
88

9-
use proc_macro::{quote, TokenStream};
9+
use proc_macro::{TokenStream, quote};
1010

11-
#[proc_macro_derive(AnotherMacro, attributes(pointee))]
11+
#[proc_macro_derive(AnotherMacro, attributes(referent))]
1212
pub fn derive(_input: TokenStream) -> TokenStream {
1313
quote! {
1414
const _: () = {
@@ -19,13 +19,13 @@ pub fn derive(_input: TokenStream) -> TokenStream {
1919
}
2020

2121
#[proc_macro_attribute]
22-
pub fn pointee(
22+
pub fn referent(
2323
_attr: proc_macro::TokenStream,
2424
_item: proc_macro::TokenStream,
2525
) -> proc_macro::TokenStream {
2626
quote! {
2727
const _: () = {
28-
const POINTEE_MACRO_ATTR_DERIVED: () = ();
28+
const REFERENT_MACRO_ATTR_DERIVED: () = ();
2929
};
3030
}
3131
.into()

tests/ui/deriving/built-in-proc-macro-scope.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
//@ aux-build: another-proc-macro.rs
33
//@ compile-flags: -Zunpretty=expanded
44

5-
#![feature(derive_smart_pointer)]
5+
#![feature(derive_coerce_referent)]
66

77
#[macro_use]
88
extern crate another_proc_macro;
99

10-
use another_proc_macro::{pointee, AnotherMacro};
10+
use another_proc_macro::{AnotherMacro, referent};
1111

12-
#[derive(core::marker::SmartPointer)]
12+
#[derive(core::marker::CoerceReferent)]
1313
#[repr(transparent)]
14-
pub struct Ptr<'a, #[pointee] T: ?Sized> {
14+
pub struct Ptr<'a, #[referent] T: ?Sized> {
1515
data: &'a mut T,
1616
}
1717

18-
#[pointee]
18+
#[referent]
1919
fn f() {}
2020

2121
#[derive(AnotherMacro)]
22-
#[pointee]
22+
#[referent]
2323
struct MyStruct;
2424

2525
fn main() {}

tests/ui/deriving/built-in-proc-macro-scope.stdout

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@ aux-build: another-proc-macro.rs
55
//@ compile-flags: -Zunpretty=expanded
66

7-
#![feature(derive_smart_pointer)]
7+
#![feature(derive_coerce_referent)]
88
#[prelude_import]
99
use ::std::prelude::rust_2015::*;
1010
#[macro_use]
@@ -13,10 +13,10 @@ extern crate std;
1313
#[macro_use]
1414
extern crate another_proc_macro;
1515

16-
use another_proc_macro::{pointee, AnotherMacro};
16+
use another_proc_macro::{AnotherMacro, referent};
1717

1818
#[repr(transparent)]
19-
pub struct Ptr<'a, #[pointee] T: ?Sized> {
19+
pub struct Ptr<'a, #[referent] T: ?Sized> {
2020
data: &'a mut T,
2121
}
2222
#[automatically_derived]
@@ -32,9 +32,9 @@ impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized>
3232

3333
const _: () =
3434
{
35-
const POINTEE_MACRO_ATTR_DERIVED: () = ();
35+
const REFERENT_MACRO_ATTR_DERIVED: () = ();
3636
};
37-
#[pointee]
37+
#[referent]
3838
struct MyStruct;
3939
const _: () =
4040
{

tests/ui/deriving/smart-pointer-bounds-issue-127647.rs tests/ui/deriving/coerce-referent-bounds-issue-127647.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//@ check-pass
22

3-
#![feature(derive_smart_pointer)]
3+
#![feature(derive_coerce_referent)]
44

5-
#[derive(core::marker::SmartPointer)]
5+
#[derive(core::marker::CoerceReferent)]
66
#[repr(transparent)]
7-
pub struct Ptr<'a, #[pointee] T: OnDrop + ?Sized, X> {
7+
pub struct Ptr<'a, #[referent] T: OnDrop + ?Sized, X> {
88
data: &'a mut T,
99
x: core::marker::PhantomData<X>,
1010
}
@@ -13,9 +13,9 @@ pub trait OnDrop {
1313
fn on_drop(&mut self);
1414
}
1515

16-
#[derive(core::marker::SmartPointer)]
16+
#[derive(core::marker::CoerceReferent)]
1717
#[repr(transparent)]
18-
pub struct Ptr2<'a, #[pointee] T: ?Sized, X>
18+
pub struct Ptr2<'a, #[referent] T: ?Sized, X>
1919
where
2020
T: OnDrop,
2121
{
@@ -25,26 +25,26 @@ where
2525

2626
pub trait MyTrait<T: ?Sized> {}
2727

28-
#[derive(core::marker::SmartPointer)]
28+
#[derive(core::marker::CoerceReferent)]
2929
#[repr(transparent)]
30-
pub struct Ptr3<'a, #[pointee] T: ?Sized, X>
30+
pub struct Ptr3<'a, #[referent] T: ?Sized, X>
3131
where
3232
T: MyTrait<T>,
3333
{
3434
data: &'a mut T,
3535
x: core::marker::PhantomData<X>,
3636
}
3737

38-
#[derive(core::marker::SmartPointer)]
38+
#[derive(core::marker::CoerceReferent)]
3939
#[repr(transparent)]
40-
pub struct Ptr4<'a, #[pointee] T: MyTrait<T> + ?Sized, X> {
40+
pub struct Ptr4<'a, #[referent] T: MyTrait<T> + ?Sized, X> {
4141
data: &'a mut T,
4242
x: core::marker::PhantomData<X>,
4343
}
4444

45-
#[derive(core::marker::SmartPointer)]
45+
#[derive(core::marker::CoerceReferent)]
4646
#[repr(transparent)]
47-
pub struct Ptr5<'a, #[pointee] T: ?Sized, X>
47+
pub struct Ptr5<'a, #[referent] T: ?Sized, X>
4848
where
4949
Ptr5Companion<T>: MyTrait<T>,
5050
Ptr5Companion2: MyTrait<T>,
@@ -56,17 +56,17 @@ where
5656
pub struct Ptr5Companion<T: ?Sized>(core::marker::PhantomData<T>);
5757
pub struct Ptr5Companion2;
5858

59-
#[derive(core::marker::SmartPointer)]
59+
#[derive(core::marker::CoerceReferent)]
6060
#[repr(transparent)]
61-
pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize = 0> {
61+
pub struct Ptr6<'a, #[referent] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize = 0> {
6262
data: &'a mut T,
6363
x: core::marker::PhantomData<X>,
6464
}
6565

6666
// a reduced example from https://lore.kernel.org/all/20240402-linked-list-v1-1-b1c59ba7ae3b@google.com/
6767
#[repr(transparent)]
68-
#[derive(core::marker::SmartPointer)]
69-
pub struct ListArc<#[pointee] T, const ID: u64 = 0>
68+
#[derive(core::marker::CoerceReferent)]
69+
pub struct ListArc<#[referent] T, const ID: u64 = 0>
7070
where
7171
T: ListArcSafe<ID> + ?Sized,
7272
{

tests/ui/deriving/deriving-smart-pointer-expanded.rs tests/ui/deriving/deriving-coerce-referent-expanded.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
//@ check-pass
22
//@ compile-flags: -Zunpretty=expanded
3-
#![feature(derive_smart_pointer)]
4-
use std::marker::SmartPointer;
3+
#![feature(derive_coerce_referent)]
4+
use std::marker::CoerceReferent;
55

66
pub trait MyTrait<T: ?Sized> {}
77

8-
#[derive(SmartPointer)]
8+
#[derive(CoerceReferent)]
99
#[repr(transparent)]
10-
struct MyPointer<'a, #[pointee] T: ?Sized> {
10+
struct MyPointer<'a, #[referent] T: ?Sized> {
1111
ptr: &'a T,
1212
}
1313

14-
#[derive(core::marker::SmartPointer)]
14+
#[derive(core::marker::CoerceReferent)]
1515
#[repr(transparent)]
16-
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, X: MyTrait<T> = ()>
16+
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[referent] T: ?Sized + MyTrait<T>, X: MyTrait<T> = ()>
1717
where
1818
Y: MyTrait<T>,
1919
{
2020
data: &'a mut T,
2121
x: core::marker::PhantomData<X>,
2222
}
2323

24-
#[derive(SmartPointer)]
24+
#[derive(CoerceReferent)]
2525
#[repr(transparent)]
2626
struct MyPointerWithoutPointee<'a, T: ?Sized> {
2727
ptr: &'a T,

tests/ui/deriving/deriving-smart-pointer-expanded.stdout tests/ui/deriving/deriving-coerce-referent-expanded.stdout

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
#![no_std]
33
//@ check-pass
44
//@ compile-flags: -Zunpretty=expanded
5-
#![feature(derive_smart_pointer)]
5+
#![feature(derive_coerce_referent)]
66
#[prelude_import]
77
use ::std::prelude::rust_2015::*;
88
#[macro_use]
99
extern crate std;
10-
use std::marker::SmartPointer;
10+
use std::marker::CoerceReferent;
1111

1212
pub trait MyTrait<T: ?Sized> {}
1313

1414
#[repr(transparent)]
15-
struct MyPointer<'a, #[pointee] T: ?Sized> {
15+
struct MyPointer<'a, #[referent] T: ?Sized> {
1616
ptr: &'a T,
1717
}
1818
#[automatically_derived]
@@ -25,8 +25,8 @@ impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized>
2525
}
2626

2727
#[repr(transparent)]
28-
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>,
29-
X: MyTrait<T> = ()> where Y: MyTrait<T> {
28+
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[referent] T: ?Sized +
29+
MyTrait<T>, X: MyTrait<T> = ()> where Y: MyTrait<T> {
3030
data: &'a mut T,
3131
x: core::marker::PhantomData<X>,
3232
}

0 commit comments

Comments
 (0)