@@ -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 ,
@@ -218,44 +218,64 @@ pub enum Attribute {
218218 reason : Option < String > ,
219219 } ,
220220
221+ /// `#[export_name = "name"]`
222+ ExportName ( String ) ,
223+
221224 /// `#[automatically_derived]`
222225 AutomaticallyDerived ,
223226
224227 /// `#[repr]`
225228 Repr ( AttributeRepr ) ,
226229
227- ExportName ( String ) ,
228- /// `#[doc(hidden)]`
229- DocHidden ,
230230 /// `#[no_mangle]`
231231 NoMangle ,
232232
233233 /// Something else.
234234 ///
235235 /// 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)]"`.
239242 Other ( String ) ,
240243}
241244
242245#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
246+ /// The contents of a `#[repr(...)]` attribute.
247+ ///
248+ /// Used in [`Attribute::Repr`].
243249pub struct AttributeRepr {
250+ /// The representation, e.g. `#[repr(C)]`, `#[repr(transparent)]`
244251 pub kind : ReprKind ,
245252
246- /// Alignment, in bytes.
253+ /// Alignment in bytes, if explicitly specified by `#[repr(align(...)]` .
247254 pub align : Option < u64 > ,
255+ /// Alignment in bytes, if explicitly specified by `#[repr(packed(...)]]`.
248256 pub packed : Option < u64 > ,
249257
258+ /// The integer type for an enum descriminant, if explicitly specified.
259+ ///
260+ /// e.g. `"i32"`, for `#[repr(C, i32)]`
250261 pub int : Option < String > ,
251262}
252263
253264#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
254265#[ serde( rename_all = "snake_case" ) ]
266+ /// The kind of `#[repr]`.
267+ ///
268+ /// See [AttributeRepr::kind]`.
255269pub enum ReprKind {
270+ /// `#[repr(Rust)]`
271+ ///
272+ /// Also the default.
256273 Rust ,
274+ /// `#[repr(C)]`
257275 C ,
276+ /// `#[repr(transparent)]
258277 Transparent ,
278+ /// `#[repr(simd)]`
259279 Simd ,
260280}
261281
0 commit comments