Closed
Description
Note the current type of Variant
in rustdoc-json-types:
rust/src/rustdoc-json-types/lib.rs
Lines 271 to 275 in eaf6f46
Code
I tried this code:
pub enum MyEnum {
Variant(MyStruct),
}
pub struct MyStruct {
}
And ran this:
cargo +nightly rustdoc -- --output-format json -Z unstable-options
I expected to see this happen (or something along these lines saying it's a tuple variant):
"0:3": {
"id": "0:3",
"crate_id": 0,
"name": "MyEnum",
"span": { "filename": "src\\lib.rs", "begin": [1, 0], "end": [3, 1] },
"visibility": "public",
"docs": null,
"links": {},
"attrs": [],
"deprecation": null,
"kind": "enum",
"inner": {
"generics": { "params": [], "where_predicates": [] },
"variants_stripped": false,
"variants": ["0:4"],
"impls": [
"F0:0",
"F0:1",
"F0:2",
"F0:4",
"F0:5",
"F0:6",
"F0:7",
"F0:8",
"F0:9",
"F0:10",
"F0:11",
"F0:12"
]
}
},
"0:4": {
"id": "0:4",
"crate_id": 0,
"name": "Variant",
"span": { "filename": "src\\lib.rs", "begin": [2, 4], "end": [2, 21] },
"visibility": "default",
"docs": null,
"links": {},
"attrs": [],
"deprecation": null,
"kind": "variant",
"inner": {
"variant_kind": "tuple",
"variant_inner": [
{
"kind": "resolved_path",
"inner": {
"name": "MyStruct",
"id": "0:7",
"args": { "angle_bracketed": { "args": [], "bindings": [] } },
"param_names": []
}
}
]
}
}
Instead, this happened:
"0:3": {
"id": "0:3",
"crate_id": 0,
"name": "MyEnum",
"span": { "filename": "src\\lib.rs", "begin": [1, 0], "end": [3, 1] },
"visibility": "public",
"docs": null,
"links": {},
"attrs": [],
"deprecation": null,
"kind": "enum",
"inner": {
"generics": { "params": [], "where_predicates": [] },
"variants_stripped": false,
"variants": ["0:4"],
"impls": [
"a:2:2881-0:3",
"a:2:2893-0:3",
"a:2:2922-0:3",
"a:1:5759-0:3",
"a:1:5760-0:3",
"b:2:2814-0:3",
"b:2:2810-0:3",
"b:2:2825-0:3",
"b:2:2820-0:3",
"b:2:2486-0:3",
"b:2:2489-0:3",
"b:2:3546-0:3"
]
}
},
"0:4": {
"id": "0:4",
"crate_id": 0,
"name": "Variant",
"span": { "filename": "src\\lib.rs", "begin": [2, 4], "end": [2, 21] },
"visibility": "default",
"docs": null,
"links": {},
"attrs": [],
"deprecation": null,
"kind": "variant",
"inner": { "variant_kind": "struct", "variant_inner": ["0:6"] }
},
Another Example
Here's a more complicated example:
pub enum MyEnum {
Variant(MyStruct<String>, MyStruct<String>),
}
pub struct MyStruct<T> {
pub value: T,
}
Outputs:
"0:3": {
"id": "0:3",
"crate_id": 0,
"name": "MyEnum",
"span": { "filename": "src\\lib.rs", "begin": [1, 0], "end": [3, 1] },
"visibility": "public",
"docs": null,
"links": {},
"attrs": [],
"deprecation": null,
"kind": "enum",
"inner": {
"generics": { "params": [], "where_predicates": [] },
"variants_stripped": false,
"variants": ["0:4"],
"impls": [
"a:2:2881-0:3",
"a:2:2893-0:3",
"a:2:2922-0:3",
"a:1:5759-0:3",
"a:1:5760-0:3",
"b:2:2814-0:3",
"b:2:2810-0:3",
"b:2:2825-0:3",
"b:2:2820-0:3",
"b:2:2486-0:3",
"b:2:2489-0:3",
"b:2:3546-0:3"
]
}
},
"0:4": {
"id": "0:4",
"crate_id": 0,
"name": "Variant",
"span": { "filename": "src\\lib.rs", "begin": [2, 4], "end": [2, 47] },
"visibility": "default",
"docs": null,
"links": {},
"attrs": [],
"deprecation": null,
"kind": "variant",
"inner": { "variant_kind": "struct", "variant_inner": ["0:6", "0:7"] }
},
"0:6": {
"id": "0:6",
"crate_id": 0,
"name": "0",
"span": { "filename": "src\\lib.rs", "begin": [2, 12], "end": [2, 28] },
"visibility": "default",
"docs": null,
"links": {},
"attrs": [],
"deprecation": null,
"kind": "struct_field",
"inner": {
"kind": "resolved_path",
"inner": {
"name": "MyStruct",
"id": "0:8",
"args": {
"angle_bracketed": {
"args": [
{
"type": {
"kind": "resolved_path",
"inner": {
"name": "String",
"id": "5:7431",
"args": {
"angle_bracketed": { "args": [], "bindings": [] }
},
"param_names": []
}
}
}
],
"bindings": []
}
},
"param_names": []
}
}
},
"0:7": {
"id": "0:7",
"crate_id": 0,
"name": "1",
"span": { "filename": "src\\lib.rs", "begin": [2, 30], "end": [2, 46] },
"visibility": "default",
"docs": null,
"links": {},
"attrs": [],
"deprecation": null,
"kind": "struct_field",
"inner": {
"kind": "resolved_path",
"inner": {
"name": "MyStruct",
"id": "0:8",
"args": {
"angle_bracketed": {
"args": [
{
"type": {
"kind": "resolved_path",
"inner": {
"name": "String",
"id": "5:7431",
"args": {
"angle_bracketed": { "args": [], "bindings": [] }
},
"param_names": []
}
}
}
],
"bindings": []
}
},
"param_names": []
}
}
}
Version it worked on
It most recently worked on: nightly-2021-06-27 -- I did not do any tests for the specific version it started failing in
Version with regression
rustc +nightly --version --verbose
:
rustc 1.56.0-nightly (ad981d58e 2021-08-08)
binary: rustc
commit-hash: ad981d58e1ca16bcf4072577934630deb11c5e14
commit-date: 2021-08-08
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1