Skip to content

Commit df1d953

Browse files
committed
[squash-before-merge] docs
1 parent 4491e2b commit df1d953

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

src/librustdoc/json/conversions.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -909,13 +909,8 @@ fn maybe_from_hir_attr(
909909
Attribute::ExportName(
910910
attr.value_str().expect("checked by attr validation").to_string(),
911911
)
912-
} else if attr.has_name(sym::doc)
913-
&& attr
914-
.meta_item_list()
915-
.is_some_and(|metas| metas.iter().any(|item| item.has_name(sym::hidden)))
916-
{
917-
Attribute::DocHidden
918912
} else {
913+
// FIXME: We should handle `#[doc(hidden)]` here.
919914
other_attr(tcx, attr)
920915
});
921916
}

src/rustdoc-json-types/lib.rs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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")]
212212
pub 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`].
243249
pub 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]`.
255269
pub 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

Comments
 (0)