@@ -202,13 +202,13 @@ pub struct Item {
202
202
pub inner : ItemEnum ,
203
203
}
204
204
205
+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
206
+ #[ serde( rename_all = "snake_case" ) ]
205
207
/// An attribute, eg `#[repr(C)]`
206
208
///
207
209
/// This doesn't include:
208
210
/// - `#[doc = "Doc Comment"]` or `/// Doc comment`. These are in [`Item::docs`] instead.
209
211
/// - `#[deprecated]`. These are in [`Item::deprecation`] instead.
210
- #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
211
- #[ serde( rename_all = "snake_case" ) ]
212
212
pub enum Attribute {
213
213
/// `#[non_exhaustive]`
214
214
NonExhaustive ,
@@ -218,44 +218,64 @@ pub enum Attribute {
218
218
reason : Option < String > ,
219
219
} ,
220
220
221
+ /// `#[export_name = "name"]`
222
+ ExportName ( String ) ,
223
+
221
224
/// `#[automatically_derived]`
222
225
AutomaticallyDerived ,
223
226
224
227
/// `#[repr]`
225
228
Repr ( AttributeRepr ) ,
226
229
227
- ExportName ( String ) ,
228
- /// `#[doc(hidden)]`
229
- DocHidden ,
230
230
/// `#[no_mangle]`
231
231
NoMangle ,
232
232
233
233
/// Something else.
234
234
///
235
235
/// Things here are explicitly *not* covered by the [`FORMAT_VERSION`]
236
- /// constant, and may change without bumping the format version. If you rely
237
- /// on an attribute here, please open an issue about adding a new variant for
238
- /// that attr.
236
+ /// constant, and may change without bumping the format version.
237
+ ///
238
+ /// As an implementation detail, this is currently either:
239
+ /// 1. A HIR debug printing, like `"#[attr = Optimize(Speed)]"`
240
+ /// 2. The attribute as it appears in source form, like
241
+ /// `"#[optimize(speed)]"`.
239
242
Other ( String ) ,
240
243
}
241
244
242
245
#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
246
+ /// The contents of a `#[repr(...)]` attribute.
247
+ ///
248
+ /// Used in [`Attribute::Repr`].
243
249
pub struct AttributeRepr {
250
+ /// The representation, e.g. `#[repr(C)]`, `#[repr(transparent)]`
244
251
pub kind : ReprKind ,
245
252
246
- /// Alignment, in bytes.
253
+ /// Alignment in bytes, if explicitly specified by `#[repr(align(...)]` .
247
254
pub align : Option < u64 > ,
255
+ /// Alignment in bytes, if explicitly specified by `#[repr(packed(...)]]`.
248
256
pub packed : Option < u64 > ,
249
257
258
+ /// The integer type for an enum descriminant, if explicitly specified.
259
+ ///
260
+ /// e.g. `"i32"`, for `#[repr(C, i32)]`
250
261
pub int : Option < String > ,
251
262
}
252
263
253
264
#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
254
265
#[ serde( rename_all = "snake_case" ) ]
266
+ /// The kind of `#[repr]`.
267
+ ///
268
+ /// See [AttributeRepr::kind]`.
255
269
pub enum ReprKind {
270
+ /// `#[repr(Rust)]`
271
+ ///
272
+ /// Also the default.
256
273
Rust ,
274
+ /// `#[repr(C)]`
257
275
C ,
276
+ /// `#[repr(transparent)]
258
277
Transparent ,
278
+ /// `#[repr(simd)]`
259
279
Simd ,
260
280
}
261
281
0 commit comments