@@ -202,13 +202,13 @@ pub struct Item {
202202 pub inner : ItemEnum ,
203203}
204204
205+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
206+ #[ serde( rename_all = "snake_case" ) ]
205207/// An attribute, eg `#[repr(C)]`
206208///
207209/// This doesn't include:
208210/// - `#[doc = "Doc Comment"]` or `/// Doc comment`. These are in [`Item::docs`] instead.
209211/// - `#[deprecated]`. These are in [`Item::deprecation`] instead.
210- #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
211- #[ serde( rename_all = "snake_case" ) ]
212212pub enum Attribute {
213213 /// `#[non_exhaustive]`
214214 NonExhaustive ,
@@ -224,38 +224,55 @@ pub enum Attribute {
224224 /// `#[repr]`
225225 Repr ( AttributeRepr ) ,
226226
227- ExportName ( String ) ,
228- /// `#[doc(hidden)]`
229- DocHidden ,
230227 /// `#[no_mangle]`
231228 NoMangle ,
232229
233230 /// Something else.
234231 ///
235232 /// 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.
233+ /// constant, and may change without bumping the format version.
234+ ///
235+ /// As an implementation detail, this is currently either:
236+ /// 1. A HIR debug printing, like `"#[attr = Optimize(Speed)]"`
237+ /// 2. The attribute as it appears in source form, like
238+ /// `"#[optimize(speed)]"`.
239239 Other ( String ) ,
240- }
240+ g
241241
242242#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
243+ /// The contents of a `#[repr(...)]` attribute.
244+ ///
245+ /// Used in [`Attribute::Repr`].
243246pub struct AttributeRepr {
247+ /// The representation, e.g. `#[repr(C)]`, `#[repr(transparent)]`
244248 pub kind : ReprKind ,
245249
246- /// Alignment, in bytes.
250+ /// Alignment in bytes, if explicitly specified by `#[repr(align(...)]` .
247251 pub align : Option < u64 > ,
252+ /// Alignment in bytes, if explicitly specified by `#[repr(packed(...)]]`.
248253 pub packed : Option < u64 > ,
249254
255+ /// The integer type for an enum descriminant, if explicitly specified.
256+ ///
257+ /// e.g. `"i32"`, for `#[repr(C, i32)]`
250258 pub int : Option < String > ,
251259}
252260
253261#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
254262#[ serde( rename_all = "snake_case" ) ]
263+ /// The kind of `#[repr]`.
264+ ///
265+ /// See [AttributeRepr::kind]`.
255266pub enum ReprKind {
267+ /// `#[repr(Rust)]`
268+ ///
269+ /// Also the default.
256270 Rust ,
271+ /// `#[repr(C)]`
257272 C ,
273+ /// `#[repr(transparent)]
258274 Transparent ,
275+ /// `#[repr(simd)]`
259276 Simd ,
260277}
261278
0 commit comments