Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d83b461

Browse files
committedOct 9, 2024··
s/SmartPointer/CoerceReferent/g
move derive_smart_pointer into removed set
1 parent a1eceec commit d83b461

24 files changed

+257
-237
lines changed
 

‎compiler/rustc_builtin_macros/src/deriving/smart_ptr.rs renamed to ‎compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ macro_rules! path {
1919
($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] }
2020
}
2121

22-
pub(crate) fn expand_deriving_smart_ptr(
22+
pub(crate) fn expand_deriving_coerce_pointee(
2323
cx: &ExtCtxt<'_>,
2424
span: Span,
2525
_mitem: &MetaItem,
@@ -41,7 +41,7 @@ pub(crate) fn expand_deriving_smart_ptr(
4141
cx.dcx()
4242
.struct_span_err(
4343
span,
44-
"`SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`",
44+
"`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`",
4545
)
4646
.emit();
4747
return;
@@ -54,7 +54,7 @@ pub(crate) fn expand_deriving_smart_ptr(
5454
cx.dcx()
5555
.struct_span_err(
5656
span,
57-
"`SmartPointer` can only be derived on `struct`s with at least one field",
57+
"`CoercePointee` can only be derived on `struct`s with at least one field",
5858
)
5959
.emit();
6060
return;
@@ -64,7 +64,7 @@ pub(crate) fn expand_deriving_smart_ptr(
6464
cx.dcx()
6565
.struct_span_err(
6666
span,
67-
"`SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`",
67+
"`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`",
6868
)
6969
.emit();
7070
return;
@@ -94,10 +94,10 @@ pub(crate) fn expand_deriving_smart_ptr(
9494
.collect();
9595

9696
let pointee_param_idx = if type_params.is_empty() {
97-
// `#[derive(SmartPointer)]` requires at least one generic type on the target `struct`
97+
// `#[derive(CoercePointee)]` requires at least one generic type on the target `struct`
9898
cx.dcx().struct_span_err(
9999
span,
100-
"`SmartPointer` can only be derived on `struct`s that are generic over at least one type",
100+
"`CoercePointee` can only be derived on `struct`s that are generic over at least one type",
101101
).emit();
102102
return;
103103
} else if type_params.len() == 1 {
@@ -113,15 +113,15 @@ pub(crate) fn expand_deriving_smart_ptr(
113113
(None, _) => {
114114
cx.dcx().struct_span_err(
115115
span,
116-
"exactly one generic type parameter must be marked as #[pointee] to derive SmartPointer traits",
116+
"exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits",
117117
).emit();
118118
return;
119119
}
120120
(Some((_, one)), Some((_, another))) => {
121121
cx.dcx()
122122
.struct_span_err(
123123
vec![one, another],
124-
"only one type parameter can be marked as `#[pointee]` when deriving SmartPointer traits",
124+
"only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits",
125125
)
126126
.emit();
127127
return;
@@ -185,7 +185,7 @@ pub(crate) fn expand_deriving_smart_ptr(
185185
.struct_span_err(
186186
pointee_ty_ident.span,
187187
format!(
188-
"`derive(SmartPointer)` requires {} to be marked `?Sized`",
188+
"`derive(CoercePointee)` requires {} to be marked `?Sized`",
189189
pointee_ty_ident.name
190190
),
191191
)
@@ -195,7 +195,7 @@ pub(crate) fn expand_deriving_smart_ptr(
195195
let arg = GenericArg::Type(s_ty.clone());
196196
let unsize = cx.path_all(span, true, path!(span, core::marker::Unsize), vec![arg]);
197197
pointee.bounds.push(cx.trait_bound(unsize, false));
198-
// Drop `#[pointee]` attribute since it should not be recognized outside `derive(SmartPointer)`
198+
// Drop `#[pointee]` attribute since it should not be recognized outside `derive(CoercePointee)`
199199
pointee.attrs.retain(|attr| !attr.has_name(sym::pointee));
200200
}
201201

‎compiler/rustc_builtin_macros/src/deriving/mod.rs

Lines changed: 1 addition & 1 deletion
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_pointee;
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/lib.rs

Lines changed: 1 addition & 1 deletion
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+
CoercePointee: coerce_pointee::expand_deriving_coerce_pointee,
134134
}
135135

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

‎compiler/rustc_feature/src/removed.rs

Lines changed: 2 additions & 0 deletions
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 `CoercePointee`")),
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

Lines changed: 2 additions & 2 deletions
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 `CoercePointee` specification
436+
(unstable, derive_coerce_pointee, "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

Lines changed: 1 addition & 1 deletion
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::pointee // FIXME(derive_coerce_pointee)
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ symbols! {
174174
Center,
175175
Cleanup,
176176
Clone,
177+
CoercePointee,
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_pointee,
740741
derive_const,
741742
derive_default_enum,
742743
derive_smart_pointer,

‎library/core/src/marker.rs

Lines changed: 4 additions & 3 deletions
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(CoercePointee, attributes(pointee))]
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_pointee", issue = "123430")]
1068+
#[cfg(not(bootstrap))]
1069+
pub macro CoercePointee($item:item) {
10691070
/* compiler built-in */
10701071
}
10711072

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
extern crate proc_macro;
88

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

1111
#[proc_macro_derive(AnotherMacro, attributes(pointee))]
1212
pub fn derive(_input: TokenStream) -> TokenStream {
@@ -25,7 +25,7 @@ pub fn pointee(
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
//@ aux-build: another-proc-macro.rs
33
//@ compile-flags: -Zunpretty=expanded
44

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

77
#[macro_use]
88
extern crate another_proc_macro;
99

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

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

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

Lines changed: 3 additions & 3 deletions
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_pointee)]
88
#[prelude_import]
99
use ::std::prelude::rust_2015::*;
1010
#[macro_use]
@@ -13,7 +13,7 @@ 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, pointee};
1717

1818
#[repr(transparent)]
1919
pub struct Ptr<'a, #[pointee] T: ?Sized> {
@@ -32,7 +32,7 @@ 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
};
3737
#[pointee]
3838
struct MyStruct;

‎tests/ui/deriving/smart-pointer-bounds-issue-127647.rs renamed to ‎tests/ui/deriving/coerce-pointee-bounds-issue-127647.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//@ check-pass
22

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

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

16-
#[derive(core::marker::SmartPointer)]
16+
#[derive(core::marker::CoercePointee)]
1717
#[repr(transparent)]
1818
pub struct Ptr2<'a, #[pointee] T: ?Sized, X>
1919
where
@@ -25,7 +25,7 @@ where
2525

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

28-
#[derive(core::marker::SmartPointer)]
28+
#[derive(core::marker::CoercePointee)]
2929
#[repr(transparent)]
3030
pub struct Ptr3<'a, #[pointee] T: ?Sized, X>
3131
where
@@ -35,14 +35,14 @@ where
3535
x: core::marker::PhantomData<X>,
3636
}
3737

38-
#[derive(core::marker::SmartPointer)]
38+
#[derive(core::marker::CoercePointee)]
3939
#[repr(transparent)]
4040
pub struct Ptr4<'a, #[pointee] 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::CoercePointee)]
4646
#[repr(transparent)]
4747
pub struct Ptr5<'a, #[pointee] T: ?Sized, X>
4848
where
@@ -56,7 +56,7 @@ 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::CoercePointee)]
6060
#[repr(transparent)]
6161
pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize = 0> {
6262
data: &'a mut T,
@@ -65,7 +65,7 @@ pub struct Ptr6<'a, #[pointee] T: ?Sized, X: MyTrait<T> = (), const PARAM: usize
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)]
68+
#[derive(core::marker::CoercePointee)]
6969
pub struct ListArc<#[pointee] T, const ID: u64 = 0>
7070
where
7171
T: ListArcSafe<ID> + ?Sized,

‎tests/ui/deriving/deriving-smart-pointer-expanded.rs renamed to ‎tests/ui/deriving/deriving-coerce-pointee-expanded.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
//@ check-pass
22
//@ compile-flags: -Zunpretty=expanded
3-
#![feature(derive_smart_pointer)]
4-
use std::marker::SmartPointer;
3+
#![feature(derive_coerce_pointee)]
4+
use std::marker::CoercePointee;
55

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

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

14-
#[derive(core::marker::SmartPointer)]
14+
#[derive(core::marker::CoercePointee)]
1515
#[repr(transparent)]
1616
pub struct MyPointer2<'a, Y, Z: MyTrait<T>, #[pointee] T: ?Sized + MyTrait<T>, X: MyTrait<T> = ()>
1717
where
@@ -21,7 +21,7 @@ where
2121
x: core::marker::PhantomData<X>,
2222
}
2323

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

‎tests/ui/deriving/deriving-smart-pointer-expanded.stdout renamed to ‎tests/ui/deriving/deriving-coerce-pointee-expanded.stdout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#![no_std]
33
//@ check-pass
44
//@ compile-flags: -Zunpretty=expanded
5-
#![feature(derive_smart_pointer)]
5+
#![feature(derive_coerce_pointee)]
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::CoercePointee;
1111

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

‎tests/ui/deriving/deriving-smart-pointer-neg.rs renamed to ‎tests/ui/deriving/deriving-coerce-pointee-neg.rs

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,131 @@
1-
#![feature(derive_smart_pointer, arbitrary_self_types)]
1+
#![feature(derive_coerce_pointee, arbitrary_self_types)]
22

33
extern crate core;
4-
use std::marker::SmartPointer;
4+
use std::marker::CoercePointee;
55

6-
#[derive(SmartPointer)]
7-
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`
6+
#[derive(CoercePointee)]
7+
//~^ ERROR: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
88
enum NotStruct<'a, T: ?Sized> {
99
Variant(&'a T),
1010
}
1111

12-
#[derive(SmartPointer)]
13-
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with at least one field
12+
#[derive(CoercePointee)]
13+
//~^ ERROR: `CoercePointee` can only be derived on `struct`s with at least one field
1414
#[repr(transparent)]
1515
struct NoField<'a, #[pointee] T: ?Sized> {}
1616
//~^ ERROR: lifetime parameter `'a` is never used
1717
//~| ERROR: type parameter `T` is never used
1818

19-
#[derive(SmartPointer)]
20-
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with at least one field
19+
#[derive(CoercePointee)]
20+
//~^ ERROR: `CoercePointee` can only be derived on `struct`s with at least one field
2121
#[repr(transparent)]
2222
struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
2323
//~^ ERROR: lifetime parameter `'a` is never used
2424
//~| ERROR: type parameter `T` is never used
2525

26-
#[derive(SmartPointer)]
27-
//~^ ERROR: `SmartPointer` can only be derived on `struct`s that are generic over at least one type
26+
#[derive(CoercePointee)]
27+
//~^ ERROR: `CoercePointee` can only be derived on `struct`s that are generic over at least one type
2828
#[repr(transparent)]
2929
struct NoGeneric<'a>(&'a u8);
3030

31-
#[derive(SmartPointer)]
32-
//~^ ERROR: exactly one generic type parameter must be marked as #[pointee] to derive SmartPointer traits
31+
#[derive(CoercePointee)]
32+
//~^ ERROR: exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits
3333
#[repr(transparent)]
3434
struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> {
3535
a: (&'a T1, &'a T2),
3636
}
3737

38-
#[derive(SmartPointer)]
38+
#[derive(CoercePointee)]
3939
#[repr(transparent)]
4040
struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B));
41-
//~^ ERROR: only one type parameter can be marked as `#[pointee]` when deriving SmartPointer traits
41+
//~^ ERROR: only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits
4242

43-
#[derive(SmartPointer)]
44-
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`
43+
#[derive(CoercePointee)]
44+
//~^ ERROR: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
4545
struct NotTransparent<'a, #[pointee] T: ?Sized> {
4646
ptr: &'a T,
4747
}
4848

49-
#[derive(SmartPointer)]
49+
#[derive(CoercePointee)]
5050
#[repr(transparent)]
5151
struct NoMaybeSized<'a, #[pointee] T> {
52-
//~^ ERROR: `derive(SmartPointer)` requires T to be marked `?Sized`
52+
//~^ ERROR: `derive(CoercePointee)` requires T to be marked `?Sized`
5353
ptr: &'a T,
5454
}
5555

56-
#[derive(SmartPointer)]
56+
#[derive(CoercePointee)]
5757
#[repr(transparent)]
5858
struct PointeeOnField<'a, #[pointee] T: ?Sized> {
5959
#[pointee]
6060
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
61-
ptr: &'a T
61+
ptr: &'a T,
6262
}
6363

64-
#[derive(SmartPointer)]
64+
#[derive(CoercePointee)]
6565
#[repr(transparent)]
66-
struct PointeeInTypeConstBlock<'a, T: ?Sized = [u32; const { struct UhOh<#[pointee] T>(T); 10 }]> {
67-
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
66+
struct PointeeInTypeConstBlock<
67+
'a,
68+
T: ?Sized = [u32; const {
69+
struct UhOh<#[pointee] T>(T);
70+
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
71+
10
72+
}],
73+
> {
6874
ptr: &'a T,
6975
}
7076

71-
#[derive(SmartPointer)]
77+
#[derive(CoercePointee)]
7278
#[repr(transparent)]
7379
struct PointeeInConstConstBlock<
7480
'a,
7581
T: ?Sized,
76-
const V: u32 = { struct UhOh<#[pointee] T>(T); 10 }>
77-
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
78-
{
82+
const V: u32 = {
83+
struct UhOh<#[pointee] T>(T);
84+
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
85+
10
86+
},
87+
> {
7988
ptr: &'a T,
8089
}
8190

82-
#[derive(SmartPointer)]
91+
#[derive(CoercePointee)]
8392
#[repr(transparent)]
8493
struct PointeeInAnotherTypeConstBlock<'a, #[pointee] T: ?Sized> {
85-
ptr: PointeeInConstConstBlock<'a, T, { struct UhOh<#[pointee] T>(T); 0 }>
86-
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
94+
ptr: PointeeInConstConstBlock<
95+
'a,
96+
T,
97+
{
98+
struct UhOh<#[pointee] T>(T);
99+
//~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters
100+
0
101+
},
102+
>,
87103
}
88104

89105
// However, reordering attributes should work nevertheless.
90106
#[repr(transparent)]
91-
#[derive(SmartPointer)]
92-
struct ThisIsAPossibleSmartPointer<'a, #[pointee] T: ?Sized> {
107+
#[derive(CoercePointee)]
108+
struct ThisIsAPossibleCoercePointee<'a, #[pointee] T: ?Sized> {
93109
ptr: &'a T,
94110
}
95111

96112
// Also, these paths to Sized should work
97-
#[derive(SmartPointer)]
113+
#[derive(CoercePointee)]
98114
#[repr(transparent)]
99115
struct StdSized<'a, #[pointee] T: ?std::marker::Sized> {
100116
ptr: &'a T,
101117
}
102-
#[derive(SmartPointer)]
118+
#[derive(CoercePointee)]
103119
#[repr(transparent)]
104120
struct CoreSized<'a, #[pointee] T: ?core::marker::Sized> {
105121
ptr: &'a T,
106122
}
107-
#[derive(SmartPointer)]
123+
#[derive(CoercePointee)]
108124
#[repr(transparent)]
109125
struct GlobalStdSized<'a, #[pointee] T: ?::std::marker::Sized> {
110126
ptr: &'a T,
111127
}
112-
#[derive(SmartPointer)]
128+
#[derive(CoercePointee)]
113129
#[repr(transparent)]
114130
struct GlobalCoreSized<'a, #[pointee] T: ?::core::marker::Sized> {
115131
ptr: &'a T,
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
error: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
2+
--> $DIR/deriving-coerce-pointee-neg.rs:6:10
3+
|
4+
LL | #[derive(CoercePointee)]
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error: `CoercePointee` can only be derived on `struct`s with at least one field
10+
--> $DIR/deriving-coerce-pointee-neg.rs:12:10
11+
|
12+
LL | #[derive(CoercePointee)]
13+
| ^^^^^^^^^^^^^
14+
|
15+
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
16+
17+
error: `CoercePointee` can only be derived on `struct`s with at least one field
18+
--> $DIR/deriving-coerce-pointee-neg.rs:19:10
19+
|
20+
LL | #[derive(CoercePointee)]
21+
| ^^^^^^^^^^^^^
22+
|
23+
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
24+
25+
error: `CoercePointee` can only be derived on `struct`s that are generic over at least one type
26+
--> $DIR/deriving-coerce-pointee-neg.rs:26:10
27+
|
28+
LL | #[derive(CoercePointee)]
29+
| ^^^^^^^^^^^^^
30+
|
31+
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
32+
33+
error: exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits
34+
--> $DIR/deriving-coerce-pointee-neg.rs:31:10
35+
|
36+
LL | #[derive(CoercePointee)]
37+
| ^^^^^^^^^^^^^
38+
|
39+
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
40+
41+
error: only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits
42+
--> $DIR/deriving-coerce-pointee-neg.rs:40:39
43+
|
44+
LL | struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B));
45+
| ^ ^
46+
47+
error: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
48+
--> $DIR/deriving-coerce-pointee-neg.rs:43:10
49+
|
50+
LL | #[derive(CoercePointee)]
51+
| ^^^^^^^^^^^^^
52+
|
53+
= note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info)
54+
55+
error: `derive(CoercePointee)` requires T to be marked `?Sized`
56+
--> $DIR/deriving-coerce-pointee-neg.rs:51:36
57+
|
58+
LL | struct NoMaybeSized<'a, #[pointee] T> {
59+
| ^
60+
61+
error: the `#[pointee]` attribute may only be used on generic parameters
62+
--> $DIR/deriving-coerce-pointee-neg.rs:59:5
63+
|
64+
LL | #[pointee]
65+
| ^^^^^^^^^^
66+
67+
error: the `#[pointee]` attribute may only be used on generic parameters
68+
--> $DIR/deriving-coerce-pointee-neg.rs:69:33
69+
|
70+
LL | struct UhOh<#[pointee] T>(T);
71+
| ^^^^^^^^^^
72+
73+
error: the `#[pointee]` attribute may only be used on generic parameters
74+
--> $DIR/deriving-coerce-pointee-neg.rs:83:21
75+
|
76+
LL | struct UhOh<#[pointee] T>(T);
77+
| ^^^^^^^^^^
78+
79+
error: the `#[pointee]` attribute may only be used on generic parameters
80+
--> $DIR/deriving-coerce-pointee-neg.rs:98:25
81+
|
82+
LL | struct UhOh<#[pointee] T>(T);
83+
| ^^^^^^^^^^
84+
85+
error[E0392]: lifetime parameter `'a` is never used
86+
--> $DIR/deriving-coerce-pointee-neg.rs:15:16
87+
|
88+
LL | struct NoField<'a, #[pointee] T: ?Sized> {}
89+
| ^^ unused lifetime parameter
90+
|
91+
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
92+
93+
error[E0392]: type parameter `T` is never used
94+
--> $DIR/deriving-coerce-pointee-neg.rs:15:31
95+
|
96+
LL | struct NoField<'a, #[pointee] T: ?Sized> {}
97+
| ^ unused type parameter
98+
|
99+
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
100+
101+
error[E0392]: lifetime parameter `'a` is never used
102+
--> $DIR/deriving-coerce-pointee-neg.rs:22:20
103+
|
104+
LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
105+
| ^^ unused lifetime parameter
106+
|
107+
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
108+
109+
error[E0392]: type parameter `T` is never used
110+
--> $DIR/deriving-coerce-pointee-neg.rs:22:35
111+
|
112+
LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
113+
| ^ unused type parameter
114+
|
115+
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
116+
117+
error: aborting due to 16 previous errors
118+
119+
For more information about this error, try `rustc --explain E0392`.

‎tests/ui/deriving/deriving-smart-pointer.rs renamed to ‎tests/ui/deriving/deriving-coerce-pointee.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//@ run-pass
2-
#![feature(derive_smart_pointer, arbitrary_self_types)]
2+
#![feature(derive_coerce_pointee, arbitrary_self_types)]
33

4-
use std::marker::SmartPointer;
4+
use std::marker::CoercePointee;
55

6-
#[derive(SmartPointer)]
6+
#[derive(CoercePointee)]
77
#[repr(transparent)]
88
struct MyPointer<'a, #[pointee] T: ?Sized> {
99
ptr: &'a T,

‎tests/ui/deriving/deriving-smart-pointer-neg.stderr

Lines changed: 0 additions & 119 deletions
This file was deleted.

‎tests/ui/deriving/proc-macro-attribute-mixing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This test certify that we can mix attribute macros from Rust and external proc-macros.
2-
// For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(SmartPointer)]` uses
2+
// For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(CoercePointee)]` uses
33
// `#[pointee]`.
44
// The scoping rule should allow the use of the said two attributes when external proc-macros
55
// are in scope.
@@ -8,7 +8,7 @@
88
//@ aux-build: another-proc-macro.rs
99
//@ compile-flags: -Zunpretty=expanded
1010

11-
#![feature(derive_smart_pointer)]
11+
#![feature(derive_coerce_pointee)]
1212

1313
#[macro_use]
1414
extern crate another_proc_macro;

‎tests/ui/deriving/proc-macro-attribute-mixing.stdout

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(prelude_import)]
22
#![no_std]
33
// This test certify that we can mix attribute macros from Rust and external proc-macros.
4-
// For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(SmartPointer)]` uses
4+
// For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(CoercePointee)]` uses
55
// `#[pointee]`.
66
// The scoping rule should allow the use of the said two attributes when external proc-macros
77
// are in scope.
@@ -10,7 +10,7 @@
1010
//@ aux-build: another-proc-macro.rs
1111
//@ compile-flags: -Zunpretty=expanded
1212

13-
#![feature(derive_smart_pointer)]
13+
#![feature(derive_coerce_pointee)]
1414
#[prelude_import]
1515
use ::std::prelude::rust_2015::*;
1616
#[macro_use]
@@ -22,7 +22,7 @@ extern crate another_proc_macro;
2222

2323
const _: () =
2424
{
25-
const POINTEE_MACRO_ATTR_DERIVED: () = ();
25+
const REFERENT_MACRO_ATTR_DERIVED: () = ();
2626
};
2727
const _: () =
2828
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use std::marker::CoercePointee; //~ ERROR use of unstable library feature 'derive_coerce_pointee'
2+
3+
#[derive(CoercePointee)] //~ ERROR use of unstable library feature 'derive_coerce_pointee'
4+
#[repr(transparent)]
5+
struct MyPointer<'a, #[pointee] T: ?Sized> {
6+
ptr: &'a T,
7+
}
8+
9+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0658]: use of unstable library feature 'derive_coerce_pointee'
2+
--> $DIR/feature-gate-derive-coerce-pointee.rs:3:10
3+
|
4+
LL | #[derive(CoercePointee)]
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information
8+
= help: add `#![feature(derive_coerce_pointee)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: use of unstable library feature 'derive_coerce_pointee'
12+
--> $DIR/feature-gate-derive-coerce-pointee.rs:1:5
13+
|
14+
LL | use std::marker::CoercePointee;
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
|
17+
= note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information
18+
= help: add `#![feature(derive_coerce_pointee)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error: aborting due to 2 previous errors
22+
23+
For more information about this error, try `rustc --explain E0658`.

‎tests/ui/feature-gates/feature-gate-derive-smart-pointer.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎tests/ui/feature-gates/feature-gate-derive-smart-pointer.stderr

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.