Skip to content

Commit c921d75

Browse files
committed
Make enum tuple variants match tuple structs, and not have free-floating struct_field members they don't reference.
1 parent 00755e4 commit c921d75

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

src/etc/check_missing_items.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ def check_type(ty):
143143
set(item["inner"]["variants"]) | set(item["inner"]["impls"])
144144
) - visited
145145
elif item["kind"] == "variant":
146-
if item["inner"]["variant_kind"] == "tuple":
147-
for ty in item["inner"]["variant_inner"]:
148-
check_type(ty)
149-
elif item["inner"]["variant_kind"] == "struct":
146+
if item["inner"]["variant_kind"] == "struct" or item["inner"]["variant_kind"] == "tuple":
150147
work_list |= set(item["inner"]["variant_inner"]) - visited
151148
elif item["kind"] in ("function", "method"):
152149
check_generics(item["inner"]["generics"])

src/librustdoc/json/conversions.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -602,22 +602,11 @@ impl FromWithTcx<clean::VariantStruct> for Struct {
602602
}
603603

604604
impl FromWithTcx<clean::Variant> for Variant {
605-
fn from_tcx(variant: clean::Variant, tcx: TyCtxt<'_>) -> Self {
605+
fn from_tcx(variant: clean::Variant, _tcx: TyCtxt<'_>) -> Self {
606606
use clean::Variant::*;
607607
match variant {
608608
CLike => Variant::Plain,
609-
Tuple(fields) => Variant::Tuple(
610-
fields
611-
.into_iter()
612-
.map(|f| {
613-
if let clean::StructFieldItem(ty) = *f.kind {
614-
ty.into_tcx(tcx)
615-
} else {
616-
unreachable!()
617-
}
618-
})
619-
.collect(),
620-
),
609+
Tuple(fields) => Variant::Tuple(ids(fields)),
621610
Struct(s) => Variant::Struct(ids(s.fields)),
622611
}
623612
}

src/rustdoc-json-types/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::path::PathBuf;
99
use serde::{Deserialize, Serialize};
1010

1111
/// rustdoc format-version.
12-
pub const FORMAT_VERSION: u32 = 14;
12+
pub const FORMAT_VERSION: u32 = 15;
1313

1414
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
1515
/// about the language items in the local crate, as well as info about external items to allow
@@ -277,7 +277,7 @@ pub struct Enum {
277277
#[serde(tag = "variant_kind", content = "variant_inner")]
278278
pub enum Variant {
279279
Plain,
280-
Tuple(Vec<Type>),
280+
Tuple(Vec<Id>),
281281
Struct(Vec<Id>),
282282
}
283283

@@ -451,7 +451,7 @@ pub enum Type {
451451
Tuple(Vec<Type>),
452452
/// `[u32]`
453453
Slice(Box<Type>),
454-
/// [u32; 15]
454+
/// `[u32; 15]`
455455
Array {
456456
#[serde(rename = "type")]
457457
type_: Box<Type>,

0 commit comments

Comments
 (0)