@@ -43,6 +43,7 @@ impl From<&Item> for ItemKind {
4343#[ derive( Debug , Eq , PartialEq ) ]
4444enum ErrorKind {
4545 ForbiddenAbi ,
46+ ForbiddenAllow ,
4647 ForbiddenAttr ,
4748 ForbiddenItemKind ( ItemKind ) ,
4849 ForbiddenRepr ( Vec < Repr > ) ,
@@ -60,6 +61,7 @@ impl Display for ErrorKind {
6061 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
6162 match self {
6263 Self :: ForbiddenAbi => write ! ( f, "forbidden ABI" ) ,
64+ Self :: ForbiddenAllow => write ! ( f, "forbidden allow" ) ,
6365 Self :: ForbiddenAttr => write ! ( f, "forbidden attribute" ) ,
6466 Self :: ForbiddenItemKind ( ItemKind :: Enum ) => write ! (
6567 f,
@@ -140,6 +142,12 @@ fn is_pub(vis: &Visibility) -> bool {
140142 matches ! ( vis, Visibility :: Public ( _) )
141143}
142144
145+ /// Allowed `#[allow]` attributes.
146+ #[ derive( Debug , Clone , Copy ) ]
147+ enum Allow {
148+ NonCamelCaseTypes ,
149+ }
150+
143151/// Type repr. A type may have more than one of these (e.g. both `C` and `packed`).
144152#[ derive( Debug , Clone , Copy , Eq , PartialEq , Ord , PartialOrd ) ]
145153enum Repr {
@@ -154,6 +162,7 @@ enum Repr {
154162/// expected in `uefi-raw`.
155163#[ derive( Debug , Clone , Copy ) ]
156164enum ParsedAttr {
165+ Allow ( Allow ) ,
157166 Derive ,
158167 Doc ,
159168 Repr ( Repr ) ,
@@ -195,6 +204,20 @@ fn parse_attrs(attrs: &[Attribute], src: &Path) -> Result<Vec<ParsedAttr>, Error
195204 if unknown_repr_found {
196205 return Err ( Error :: new ( ErrorKind :: UnknownRepr , src, attr) ) ;
197206 }
207+ } else if path. is_ident ( "allow" ) {
208+ let mut unknown_allow_found = false ;
209+ attr. parse_nested_meta ( |meta| {
210+ if meta. path . is_ident ( "non_camel_case_types" ) {
211+ va. push ( ParsedAttr :: Allow ( Allow :: NonCamelCaseTypes ) ) ;
212+ } else {
213+ unknown_allow_found = true ;
214+ }
215+ Ok ( ( ) )
216+ } )
217+ . map_err ( |_| Error :: new ( ErrorKind :: MalformedAttrs , src, attr) ) ?;
218+ if unknown_allow_found {
219+ return Err ( Error :: new ( ErrorKind :: ForbiddenAllow , src, attr) ) ;
220+ }
198221 } else {
199222 return Err ( Error :: new ( ErrorKind :: ForbiddenAttr , src, attr) ) ;
200223 }
0 commit comments