@@ -17,7 +17,7 @@ macro_rules! path {
1717    ( $span: expr,  $( $part: ident) ::* )  => {  vec![ $( Ident :: new( sym:: $part,  $span) , ) * ]  } 
1818} 
1919
20- pub ( crate )  fn  expand_deriving_smart_ptr ( 
20+ pub ( crate )  fn  expand_deriving_coerce_referent ( 
2121    cx :  & ExtCtxt < ' _ > , 
2222    span :  Span , 
2323    _mitem :  & MetaItem , 
@@ -37,7 +37,7 @@ pub(crate) fn expand_deriving_smart_ptr(
3737            cx. dcx ( ) 
3838                . struct_span_err ( 
3939                    span, 
40-                     "`SmartPointer ` can only be derived on `struct`s with `#[repr(transparent)]`" , 
40+                     "`CoerceReferent ` can only be derived on `struct`s with `#[repr(transparent)]`" , 
4141                ) 
4242                . emit ( ) ; 
4343            return ; 
@@ -50,7 +50,7 @@ pub(crate) fn expand_deriving_smart_ptr(
5050            cx. dcx ( ) 
5151                . struct_span_err ( 
5252                    span, 
53-                     "`SmartPointer ` can only be derived on `struct`s with at least one field" , 
53+                     "`CoerceReferent ` can only be derived on `struct`s with at least one field" , 
5454                ) 
5555                . emit ( ) ; 
5656            return ; 
@@ -60,7 +60,7 @@ pub(crate) fn expand_deriving_smart_ptr(
6060        cx. dcx ( ) 
6161            . struct_span_err ( 
6262                span, 
63-                 "`SmartPointer ` can only be derived on `struct`s with `#[repr(transparent)]`" , 
63+                 "`CoerceReferent ` can only be derived on `struct`s with `#[repr(transparent)]`" , 
6464            ) 
6565            . emit ( ) ; 
6666        return ; 
@@ -82,42 +82,42 @@ pub(crate) fn expand_deriving_smart_ptr(
8282        . enumerate ( ) 
8383        . filter_map ( |( idx,  p) | { 
8484            if  let  GenericParamKind :: Type  {  .. }  = p. kind  { 
85-                 Some ( ( idx,  p. span ( ) ,  p. attrs ( ) . iter ( ) . any ( |attr| attr. has_name ( sym:: pointee ) ) ) ) 
85+                 Some ( ( idx,  p. span ( ) ,  p. attrs ( ) . iter ( ) . any ( |attr| attr. has_name ( sym:: referent ) ) ) ) 
8686            }  else  { 
8787                None 
8888            } 
8989        } ) 
9090        . collect ( ) ; 
9191
92-     let  pointee_param_idx  = if  type_params. is_empty ( )  { 
93-         // `#[derive(SmartPointer )]` requires at least one generic type on the target `struct` 
92+     let  referent_param_idx  = if  type_params. is_empty ( )  { 
93+         // `#[derive(CoerceReferent )]` requires at least one generic type on the target `struct` 
9494        cx. dcx ( ) . struct_span_err ( 
9595            span, 
96-             "`SmartPointer ` can only be derived on `struct`s that are generic over at least one type" , 
96+             "`CoerceReferent ` can only be derived on `struct`s that are generic over at least one type" , 
9797        ) . emit ( ) ; 
9898        return ; 
9999    }  else  if  type_params. len ( )  == 1  { 
100-         // Regardless of the only type param being designed as `#[pointee ]` or not, we can just use it as such 
100+         // Regardless of the only type param being designed as `#[referent ]` or not, we can just use it as such 
101101        type_params[ 0 ] . 0 
102102    }  else  { 
103-         let  mut  pointees  = type_params
103+         let  mut  referents  = type_params
104104            . iter ( ) 
105-             . filter_map ( |& ( idx,  span,  is_pointee ) | is_pointee . then_some ( ( idx,  span) ) ) 
105+             . filter_map ( |& ( idx,  span,  is_referent ) | is_referent . then_some ( ( idx,  span) ) ) 
106106            . fuse ( ) ; 
107-         match  ( pointees . next ( ) ,  pointees . next ( ) )  { 
107+         match  ( referents . next ( ) ,  referents . next ( ) )  { 
108108            ( Some ( ( idx,  _span) ) ,  None )  => idx, 
109109            ( None ,  _)  => { 
110110                cx. dcx ( ) . struct_span_err ( 
111111                    span, 
112-                     "exactly one generic type parameter must be marked as #[pointee ] to derive SmartPointer  traits" , 
112+                     "exactly one generic type parameter must be marked as #[referent ] to derive CoerceReferent  traits" , 
113113                ) . emit ( ) ; 
114114                return ; 
115115            } 
116116            ( Some ( ( _,  one) ) ,  Some ( ( _,  another) ) )  => { 
117117                cx. dcx ( ) 
118118                    . struct_span_err ( 
119119                        vec ! [ one,  another] , 
120-                         "only one type parameter can be marked as `#[pointee ]` when deriving SmartPointer  traits" , 
120+                         "only one type parameter can be marked as `#[referent ]` when deriving CoerceReferent  traits" , 
121121                    ) 
122122                    . emit ( ) ; 
123123                return ; 
@@ -155,53 +155,53 @@ pub(crate) fn expand_deriving_smart_ptr(
155155        push ( Annotatable :: Item ( item) ) ; 
156156    } ; 
157157
158-     // Create unsized `self`, that is, one where the `#[pointee ]` type arg is replaced with `__S`. For 
158+     // Create unsized `self`, that is, one where the `#[referent ]` type arg is replaced with `__S`. For 
159159    // example, instead of `MyType<'a, T>`, it will be `MyType<'a, __S>`. 
160160    let  s_ty = cx. ty_ident ( span,  Ident :: new ( sym:: __S,  span) ) ; 
161161    let  mut  alt_self_params = self_params; 
162-     alt_self_params[ pointee_param_idx ]  = GenericArg :: Type ( s_ty. clone ( ) ) ; 
162+     alt_self_params[ referent_param_idx ]  = GenericArg :: Type ( s_ty. clone ( ) ) ; 
163163    let  alt_self_type = cx. ty_path ( cx. path_all ( span,  false ,  vec ! [ name_ident] ,  alt_self_params) ) ; 
164164
165-     // # Add `Unsize<__S>` bound to `#[pointee ]` at the generic parameter location 
165+     // # Add `Unsize<__S>` bound to `#[referent ]` at the generic parameter location 
166166    // 
167-     // Find the `#[pointee ]` parameter and add an `Unsize<__S>` bound to it. 
167+     // Find the `#[referent ]` parameter and add an `Unsize<__S>` bound to it. 
168168    let  mut  impl_generics = generics. clone ( ) ; 
169-     let  pointee_ty_ident  = generics. params [ pointee_param_idx ] . ident ; 
169+     let  referent_ty_ident  = generics. params [ referent_param_idx ] . ident ; 
170170    let  mut  self_bounds; 
171171    { 
172-         let  pointee  = & mut  impl_generics. params [ pointee_param_idx ] ; 
173-         self_bounds = pointee . bounds . clone ( ) ; 
172+         let  referent  = & mut  impl_generics. params [ referent_param_idx ] ; 
173+         self_bounds = referent . bounds . clone ( ) ; 
174174        if  !contains_maybe_sized_bound ( & self_bounds) 
175-             && !contains_maybe_sized_bound_on_pointee ( 
175+             && !contains_maybe_sized_bound_on_referent ( 
176176                & generics. where_clause . predicates , 
177-                 pointee_ty_ident . name , 
177+                 referent_ty_ident . name , 
178178            ) 
179179        { 
180180            cx. dcx ( ) 
181181                . struct_span_err ( 
182-                     pointee_ty_ident . span , 
182+                     referent_ty_ident . span , 
183183                    format ! ( 
184-                         "`derive(SmartPointer )` requires {} to be marked `?Sized`" , 
185-                         pointee_ty_ident . name
184+                         "`derive(CoerceReferent )` requires {} to be marked `?Sized`" , 
185+                         referent_ty_ident . name
186186                    ) , 
187187                ) 
188188                . emit ( ) ; 
189189            return ; 
190190        } 
191191        let  arg = GenericArg :: Type ( s_ty. clone ( ) ) ; 
192192        let  unsize = cx. path_all ( span,  true ,  path ! ( span,  core:: marker:: Unsize ) ,  vec ! [ arg] ) ; 
193-         pointee . bounds . push ( cx. trait_bound ( unsize,  false ) ) ; 
194-         // Drop `#[pointee ]` attribute since it should not be recognized outside `derive(SmartPointer )` 
195-         pointee . attrs . retain ( |attr| !attr. has_name ( sym:: pointee ) ) ; 
193+         referent . bounds . push ( cx. trait_bound ( unsize,  false ) ) ; 
194+         // Drop `#[referent ]` attribute since it should not be recognized outside `derive(CoerceReferent )` 
195+         referent . attrs . retain ( |attr| !attr. has_name ( sym:: referent ) ) ; 
196196    } 
197197
198198    // # Rewrite generic parameter bounds 
199-     // For each bound `U: ..` in `struct<U: ..>`, make a new bound with `__S` in place of `#[pointee ]` 
199+     // For each bound `U: ..` in `struct<U: ..>`, make a new bound with `__S` in place of `#[referent ]` 
200200    // Example: 
201201    // ``` 
202202    // struct< 
203203    //     U: Trait<T>, 
204-     //     #[pointee ] T: Trait<T> + ?Sized, 
204+     //     #[referent ] T: Trait<T> + ?Sized, 
205205    //     V: Trait<T>> ... 
206206    // ``` 
207207    // ... generates this `impl` generic parameters 
@@ -224,22 +224,22 @@ pub(crate) fn expand_deriving_smart_ptr(
224224            ast:: GenericParamKind :: Type  {  default }  => * default = None , 
225225            ast:: GenericParamKind :: Lifetime  => { } 
226226        } 
227-         // We CANNOT rewrite `#[pointee ]` type parameter bounds. 
227+         // We CANNOT rewrite `#[referent ]` type parameter bounds. 
228228        // This has been set in stone. (**) 
229229        // So we skip over it. 
230230        // Otherwise, we push extra bounds involving `__S`. 
231-         if  idx != pointee_param_idx  { 
231+         if  idx != referent_param_idx  { 
232232            for  bound in  & orig_params. bounds  { 
233233                let  mut  bound = bound. clone ( ) ; 
234234                let  mut  substitution = TypeSubstitution  { 
235-                     from_name :  pointee_ty_ident . name , 
235+                     from_name :  referent_ty_ident . name , 
236236                    to_ty :  & s_ty, 
237237                    rewritten :  false , 
238238                } ; 
239239                substitution. visit_param_bound ( & mut  bound,  BoundKind :: Bound ) ; 
240240                if  substitution. rewritten  { 
241-                     // We found use of `#[pointee ]` somewhere, 
242-                     // so we make a new bound using `__S` in place of `#[pointee ]` 
241+                     // We found use of `#[referent ]` somewhere, 
242+                     // so we make a new bound using `__S` in place of `#[referent ]` 
243243                    params. bounds . push ( bound) ; 
244244                } 
245245            } 
@@ -249,10 +249,10 @@ pub(crate) fn expand_deriving_smart_ptr(
249249    // # Insert `__S` type parameter 
250250    // 
251251    // We now insert `__S` with the missing bounds marked with (*) above. 
252-     // We should also write the bounds from `#[pointee ]` to `__S` as required by `Unsize<__S>`. 
252+     // We should also write the bounds from `#[referent ]` to `__S` as required by `Unsize<__S>`. 
253253    { 
254254        let  mut  substitution =
255-             TypeSubstitution  {  from_name :  pointee_ty_ident . name ,  to_ty :  & s_ty,  rewritten :  false  } ; 
255+             TypeSubstitution  {  from_name :  referent_ty_ident . name ,  to_ty :  & s_ty,  rewritten :  false  } ; 
256256        for  bound in  & mut  self_bounds { 
257257            substitution. visit_param_bound ( bound,  BoundKind :: Bound ) ; 
258258        } 
@@ -263,7 +263,7 @@ pub(crate) fn expand_deriving_smart_ptr(
263263    // Move on to `where` clauses. 
264264    // Example: 
265265    // ``` 
266-     // struct MyPointer<#[pointee ] T, ..> 
266+     // struct MyPointer<#[referent ] T, ..> 
267267    // where 
268268    //   U: Trait<V> + Trait<T>, 
269269    //   Companion<T>: Trait<T>, 
@@ -282,12 +282,12 @@ pub(crate) fn expand_deriving_smart_ptr(
282282    //   __S: Trait<__S> + ?Sized, 
283283    // ``` 
284284    // 
285-     // We should also write a few new `where` bounds from `#[pointee ] T` to `__S` 
286-     // as well as any bound that indirectly involves the `#[pointee ] T` type. 
285+     // We should also write a few new `where` bounds from `#[referent ] T` to `__S` 
286+     // as well as any bound that indirectly involves the `#[referent ] T` type. 
287287    for  bound in  & generics. where_clause . predicates  { 
288288        if  let  ast:: WherePredicate :: BoundPredicate ( bound)  = bound { 
289289            let  mut  substitution = TypeSubstitution  { 
290-                 from_name :  pointee_ty_ident . name , 
290+                 from_name :  referent_ty_ident . name , 
291291                to_ty :  & s_ty, 
292292                rewritten :  false , 
293293            } ; 
@@ -305,18 +305,18 @@ pub(crate) fn expand_deriving_smart_ptr(
305305    } 
306306
307307    let  extra_param = cx. typaram ( span,  Ident :: new ( sym:: __S,  span) ,  self_bounds,  None ) ; 
308-     impl_generics. params . insert ( pointee_param_idx  + 1 ,  extra_param) ; 
308+     impl_generics. params . insert ( referent_param_idx  + 1 ,  extra_param) ; 
309309
310310    // Add the impl blocks for `DispatchFromDyn` and `CoerceUnsized`. 
311311    let  gen_args = vec ! [ GenericArg :: Type ( alt_self_type. clone( ) ) ] ; 
312312    add_impl_block ( impl_generics. clone ( ) ,  sym:: DispatchFromDyn ,  gen_args. clone ( ) ) ; 
313313    add_impl_block ( impl_generics. clone ( ) ,  sym:: CoerceUnsized ,  gen_args) ; 
314314} 
315315
316- fn  contains_maybe_sized_bound_on_pointee ( predicates :  & [ WherePredicate ] ,  pointee :  Symbol )  -> bool  { 
316+ fn  contains_maybe_sized_bound_on_referent ( predicates :  & [ WherePredicate ] ,  referent :  Symbol )  -> bool  { 
317317    for  bound in  predicates { 
318318        if  let  ast:: WherePredicate :: BoundPredicate ( bound)  = bound
319-             && bound. bounded_ty . kind . is_simple_path ( ) . is_some_and ( |name| name == pointee ) 
319+             && bound. bounded_ty . kind . is_simple_path ( ) . is_some_and ( |name| name == referent ) 
320320        { 
321321            for  bound in  & bound. bounds  { 
322322                if  is_maybe_sized_bound ( bound)  { 
0 commit comments