@@ -13,6 +13,8 @@ use rustc_span::symbol::{sym, Ident};
13
13
use rustc_span:: { Span , Symbol } ;
14
14
use thin_vec:: { thin_vec, ThinVec } ;
15
15
16
+ use crate :: errors;
17
+
16
18
macro_rules! path {
17
19
( $span: expr, $( $part: ident) ::* ) => { vec![ $( Ident :: new( sym:: $part, $span) , ) * ] }
18
20
}
@@ -25,6 +27,8 @@ pub(crate) fn expand_deriving_smart_ptr(
25
27
push : & mut dyn FnMut ( Annotatable ) ,
26
28
_is_const : bool ,
27
29
) {
30
+ item. visit_with ( & mut DetectNonGenericPointeeAttr { cx } ) ;
31
+
28
32
let ( name_ident, generics) = if let Annotatable :: Item ( aitem) = item
29
33
&& let ItemKind :: Struct ( struct_data, g) = & aitem. kind
30
34
{
@@ -396,3 +400,24 @@ impl<'a> ast::mut_visit::MutVisitor for TypeSubstitution<'a> {
396
400
}
397
401
}
398
402
}
403
+
404
+ struct DetectNonGenericPointeeAttr < ' a , ' b > {
405
+ cx : & ' a ExtCtxt < ' b > ,
406
+ }
407
+
408
+ impl < ' a , ' b > rustc_ast:: visit:: Visitor < ' a > for DetectNonGenericPointeeAttr < ' a , ' b > {
409
+ fn visit_attribute ( & mut self , attr : & ' a rustc_ast:: Attribute ) -> Self :: Result {
410
+ if attr. has_name ( sym:: pointee) {
411
+ self . cx . dcx ( ) . emit_err ( errors:: NonGenericPointee { span : attr. span } ) ;
412
+ }
413
+ }
414
+
415
+ fn visit_generic_param ( & mut self , param : & ' a rustc_ast:: GenericParam ) -> Self :: Result {
416
+ match param. kind {
417
+ GenericParamKind :: Type { .. } => return ,
418
+ GenericParamKind :: Lifetime | GenericParamKind :: Const { .. } => {
419
+ rustc_ast:: visit:: walk_generic_param ( self , param)
420
+ }
421
+ }
422
+ }
423
+ }
0 commit comments