@@ -3,7 +3,7 @@ use rustc_ast::token::CommentKind;
3
3
use rustc_ast:: { self as ast, AttrStyle } ;
4
4
use rustc_macros:: { Decodable , Encodable , HashStable_Generic , PrintAttribute } ;
5
5
use rustc_span:: hygiene:: Transparency ;
6
- use rustc_span:: { Span , Symbol } ;
6
+ use rustc_span:: { Ident , Span , Symbol } ;
7
7
use thin_vec:: ThinVec ;
8
8
9
9
use crate :: { DefaultBodyStability , PartialConstStability , PrintAttribute , RustcVersion , Stability } ;
@@ -69,6 +69,7 @@ pub enum ReprAttr {
69
69
ReprAlign ( Align ) ,
70
70
}
71
71
pub use ReprAttr :: * ;
72
+ use rustc_span:: def_id:: DefId ;
72
73
73
74
pub enum TransparencyError {
74
75
UnknownTransparency ( Symbol , Span ) ,
@@ -140,6 +141,30 @@ pub enum UsedBy {
140
141
Linker ,
141
142
}
142
143
144
+ #[ derive( Debug , Clone , Encodable , Decodable , HashStable_Generic ) ]
145
+ pub struct StrippedCfgItem < ModId = DefId > {
146
+ pub parent_module : ModId ,
147
+ pub ident : Ident ,
148
+ pub cfg : ( CfgEntry , Span ) ,
149
+ }
150
+
151
+ impl < ModId > StrippedCfgItem < ModId > {
152
+ pub fn map_mod_id < New > ( self , f : impl FnOnce ( ModId ) -> New ) -> StrippedCfgItem < New > {
153
+ StrippedCfgItem { parent_module : f ( self . parent_module ) , ident : self . ident , cfg : self . cfg }
154
+ }
155
+ }
156
+
157
+ #[ derive( Encodable , Decodable , Clone , Debug , PartialEq , Eq , Hash ) ]
158
+ #[ derive( HashStable_Generic , PrintAttribute ) ]
159
+ pub enum CfgEntry {
160
+ All ( ThinVec < CfgEntry > , Span ) ,
161
+ Any ( ThinVec < CfgEntry > , Span ) ,
162
+ Not ( Box < CfgEntry > , Span ) ,
163
+ Bool ( bool , Span ) ,
164
+ NameValue { name : Symbol , name_span : Span , value : Option < ( Symbol , Span ) > , span : Span } ,
165
+ Version ( Option < RustcVersion > , Span ) ,
166
+ }
167
+
143
168
/// Represents parsed *built-in* inert attributes.
144
169
///
145
170
/// ## Overview
@@ -211,6 +236,9 @@ pub enum AttributeKind {
211
236
span : Span ,
212
237
} ,
213
238
239
+ /// Represents `#[cfg]`.
240
+ Cfg ( CfgEntry , Span ) ,
241
+
214
242
/// Represents `#[cold]`.
215
243
Cold ( Span ) ,
216
244
0 commit comments