@@ -14,6 +14,8 @@ use rustc_span::{Span, Symbol};
14
14
use smallvec:: { smallvec, SmallVec } ;
15
15
use thin_vec:: { thin_vec, ThinVec } ;
16
16
17
+ use crate :: errors;
18
+
17
19
macro_rules! path {
18
20
( $span: expr, $( $part: ident) ::* ) => { vec![ $( Ident :: new( sym:: $part, $span) , ) * ] }
19
21
}
@@ -26,6 +28,8 @@ pub fn expand_deriving_smart_ptr(
26
28
push : & mut dyn FnMut ( Annotatable ) ,
27
29
_is_const : bool ,
28
30
) {
31
+ item. visit_with ( & mut DetectNonGenericPointeeAttr { cx } ) ;
32
+
29
33
let ( name_ident, generics) = if let Annotatable :: Item ( aitem) = item
30
34
&& let ItemKind :: Struct ( struct_data, g) = & aitem. kind
31
35
{
@@ -377,3 +381,24 @@ impl<'a> ast::mut_visit::MutVisitor for TypeSubstitution<'a> {
377
381
}
378
382
}
379
383
}
384
+
385
+ struct DetectNonGenericPointeeAttr < ' a , ' b > {
386
+ cx : & ' a ExtCtxt < ' b > ,
387
+ }
388
+
389
+ impl < ' a , ' b > rustc_ast:: visit:: Visitor < ' a > for DetectNonGenericPointeeAttr < ' a , ' b > {
390
+ fn visit_attribute ( & mut self , attr : & ' a rustc_ast:: Attribute ) -> Self :: Result {
391
+ if attr. has_name ( sym:: pointee) {
392
+ self . cx . dcx ( ) . emit_err ( errors:: NonGenericPointee { span : attr. span } ) ;
393
+ }
394
+ }
395
+
396
+ fn visit_generic_param ( & mut self , param : & ' a rustc_ast:: GenericParam ) -> Self :: Result {
397
+ match param. kind {
398
+ GenericParamKind :: Type { .. } => return ,
399
+ GenericParamKind :: Lifetime | GenericParamKind :: Const { .. } => {
400
+ rustc_ast:: visit:: walk_generic_param ( self , param)
401
+ }
402
+ }
403
+ }
404
+ }
0 commit comments