Auto merge of #131284 - dingxiangfei2009:rename-smart-ptr-to-coerce-r… · rust-lang/rust@81d6652 (original) (raw)

`@@ -19,7 +19,7 @@ macro_rules! path {

`

19

19

`($span:expr, (((part:ident)::) => { vec![$(Ident::new(sym::$part, $span),)] }

`

20

20

`}

`

21

21

``

22

``

`-

pub(crate) fn expand_deriving_smart_ptr(

`

``

22

`+

pub(crate) fn expand_deriving_coerce_pointee(

`

23

23

`cx: &ExtCtxt<'_>,

`

24

24

`span: Span,

`

25

25

`_mitem: &MetaItem,

`

`@@ -41,7 +41,7 @@ pub(crate) fn expand_deriving_smart_ptr(

`

41

41

` cx.dcx()

`

42

42

`.struct_span_err(

`

43

43

` span,

`

44

``

`` -

"SmartPointer can only be derived on structs with #[repr(transparent)]",

``

``

44

`` +

"CoercePointee can only be derived on structs with #[repr(transparent)]",

``

45

45

`)

`

46

46

`.emit();

`

47

47

`return;

`

`@@ -54,7 +54,7 @@ pub(crate) fn expand_deriving_smart_ptr(

`

54

54

` cx.dcx()

`

55

55

`.struct_span_err(

`

56

56

` span,

`

57

``

`` -

"SmartPointer can only be derived on structs with at least one field",

``

``

57

`` +

"CoercePointee can only be derived on structs with at least one field",

``

58

58

`)

`

59

59

`.emit();

`

60

60

`return;

`

`@@ -64,7 +64,7 @@ pub(crate) fn expand_deriving_smart_ptr(

`

64

64

` cx.dcx()

`

65

65

`.struct_span_err(

`

66

66

` span,

`

67

``

`` -

"SmartPointer can only be derived on structs with #[repr(transparent)]",

``

``

67

`` +

"CoercePointee can only be derived on structs with #[repr(transparent)]",

``

68

68

`)

`

69

69

`.emit();

`

70

70

`return;

`

`@@ -94,10 +94,10 @@ pub(crate) fn expand_deriving_smart_ptr(

`

94

94

`.collect();

`

95

95

``

96

96

`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

``

98

98

` cx.dcx().struct_span_err(

`

99

99

` span,

`

100

``

`` -

"SmartPointer can only be derived on structs that are generic over at least one type",

``

``

100

`` +

"CoercePointee can only be derived on structs that are generic over at least one type",

``

101

101

`).emit();

`

102

102

`return;

`

103

103

`} else if type_params.len() == 1 {

`

`@@ -113,15 +113,15 @@ pub(crate) fn expand_deriving_smart_ptr(

`

113

113

`(None, _) => {

`

114

114

` cx.dcx().struct_span_err(

`

115

115

` 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",

`

117

117

`).emit();

`

118

118

`return;

`

119

119

`}

`

120

120

`(Some((, one)), Some((, another))) => {

`

121

121

` cx.dcx()

`

122

122

`.struct_span_err(

`

123

123

`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",

``

125

125

`)

`

126

126

`.emit();

`

127

127

`return;

`

`@@ -185,7 +185,7 @@ pub(crate) fn expand_deriving_smart_ptr(

`

185

185

`.struct_span_err(

`

186

186

` pointee_ty_ident.span,

`

187

187

`format!(

`

188

``

`` -

"derive(SmartPointer) requires {} to be marked ?Sized",

``

``

188

`` +

"derive(CoercePointee) requires {} to be marked ?Sized",

``

189

189

` pointee_ty_ident.name

`

190

190

`),

`

191

191

`)

`

`@@ -195,7 +195,7 @@ pub(crate) fn expand_deriving_smart_ptr(

`

195

195

`let arg = GenericArg::Type(s_ty.clone());

`

196

196

`let unsize = cx.path_all(span, true, path!(span, core:📑:Unsize), vec![arg]);

`

197

197

` 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)

``

199

199

` pointee.attrs.retain(|attr| !attr.has_name(sym::pointee));

`

200

200

`}

`

201

201

``