@@ -14,6 +14,8 @@ use rustc_span::{Span, Symbol};
1414use smallvec:: { smallvec, SmallVec } ;
1515use thin_vec:: { thin_vec, ThinVec } ;
1616
17+ use crate :: errors;
18+
1719macro_rules! path {
1820 ( $span: expr, $( $part: ident) ::* ) => { vec![ $( Ident :: new( sym:: $part, $span) , ) * ] }
1921}
@@ -26,6 +28,8 @@ pub fn expand_deriving_smart_ptr(
2628 push : & mut dyn FnMut ( Annotatable ) ,
2729 _is_const : bool ,
2830) {
31+ item. visit_with ( & mut DetectNonGenericPointeeAttr { cx } ) ;
32+
2933 let ( name_ident, generics) = if let Annotatable :: Item ( aitem) = item
3034 && let ItemKind :: Struct ( struct_data, g) = & aitem. kind
3135 {
@@ -377,3 +381,24 @@ impl<'a> ast::mut_visit::MutVisitor for TypeSubstitution<'a> {
377381 }
378382 }
379383}
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