Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rustdoc][JSON] Use exclusively externally tagged enums in the JSON representation #111427

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ dependencies = [
"serde",
]

[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]

[[package]]
name = "bitflags"
version = "1.3.2"
Expand Down Expand Up @@ -4351,6 +4360,7 @@ dependencies = [
name = "rustdoc-json-types"
version = "0.1.0"
dependencies = [
"bincode",
"rustc-hash",
"serde",
"serde_json",
Expand Down
1 change: 1 addition & 0 deletions src/rustdoc-json-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ rustc-hash = "1.1.0"

[dev-dependencies]
serde_json = "1.0"
bincode = "1"
6 changes: 2 additions & 4 deletions src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf;

/// rustdoc format-version.
pub const FORMAT_VERSION: u32 = 25;
pub const FORMAT_VERSION: u32 = 26;

/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
/// about the language items in the local crate, as well as info about external items to allow
Expand Down Expand Up @@ -83,7 +83,6 @@ pub struct Item {
/// Stringified versions of the attributes on this item (e.g. `"#[inline]"`)
pub attrs: Vec<String>,
pub deprecation: Option<Deprecation>,
#[serde(flatten)]
pub inner: ItemEnum,
}

Expand Down Expand Up @@ -222,7 +221,7 @@ pub enum ItemKind {
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(tag = "kind", content = "inner", rename_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum ItemEnum {
Module(Module),
ExternCrate {
Expand Down Expand Up @@ -543,7 +542,6 @@ pub enum Term {

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(tag = "kind", content = "inner")]
pub enum Type {
/// Structs, enums, and unions
ResolvedPath(Path),
Expand Down
16 changes: 12 additions & 4 deletions src/rustdoc-json-types/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ fn test_struct_info_roundtrip() {
impls: vec![],
});

// JSON
let struct_json = serde_json::to_string(&s).unwrap();

let de_s = serde_json::from_str(&struct_json).unwrap();

assert_eq!(s, de_s);

// Bincode
let encoded: Vec<u8> = bincode::serialize(&s).unwrap();
let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
assert_eq!(s, decoded);
}

#[test]
Expand All @@ -24,9 +28,13 @@ fn test_union_info_roundtrip() {
impls: vec![],
});

// JSON
let union_json = serde_json::to_string(&u).unwrap();

let de_u = serde_json::from_str(&union_json).unwrap();

assert_eq!(u, de_u);

// Bincode
let encoded: Vec<u8> = bincode::serialize(&u).unwrap();
let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
assert_eq!(u, decoded);
}
27 changes: 12 additions & 15 deletions tests/rustdoc-json/assoc_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,32 @@
pub struct Simple;

impl Simple {
// @is "$.index[*][?(@.name=='CONSTANT')].kind" \"assoc_const\"
// @has "$.index[*][?(@.name=='CONSTANT')].inner.assoc_const"
pub const CONSTANT: usize = 0;
}

pub trait EasyToImpl {
// @is "$.index[*][?(@.docs=='ToDeclare trait')].kind" \"assoc_type\"
// @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.default" null
// @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.bounds" []
// @has "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type"
// @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type.default" null
// @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type.bounds" []
/// ToDeclare trait
type ToDeclare;
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].kind" \"assoc_const\"
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.default" null
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.type.kind" '"primitive"'
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.type.inner" '"usize"'
// @has "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const"
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const.default" null
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const.type.primitive" '"usize"'
/// AN_ATTRIBUTE trait
const AN_ATTRIBUTE: usize;
}

impl EasyToImpl for Simple {
// @is "$.index[*][?(@.docs=='ToDeclare impl')].kind" '"assoc_type"'
// @is "$.index[*][?(@.docs=='ToDeclare impl')].inner.default.kind" \"primitive\"
// @is "$.index[*][?(@.docs=='ToDeclare impl')].inner.default.inner" \"usize\"
// @has "$.index[*][?(@.docs=='ToDeclare impl')].inner.assoc_type"
// @is "$.index[*][?(@.docs=='ToDeclare impl')].inner.assoc_type.default.primitive" \"usize\"
/// ToDeclare impl
type ToDeclare = usize;

// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].kind" '"assoc_const"'
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.type.kind" \"primitive\"
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.type.inner" \"usize\"
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.default" \"12\"
// @has "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const"
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const.type.primitive" \"usize\"
// @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const.default" \"12\"
/// AN_ATTRIBUTE impl
const AN_ATTRIBUTE: usize = 12;
}
6 changes: 3 additions & 3 deletions tests/rustdoc-json/blanket_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![no_std]

// @has "$.index[*][?(@.name=='Error')].kind" \"assoc_type\"
// @has "$.index[*][?(@.name=='Error')].inner.default.kind" \"resolved_path\"
// @has "$.index[*][?(@.name=='Error')].inner.default.inner.name" \"Infallible\"
// @has "$.index[*][?(@.name=='Error')].inner.assoc_type"
// @has "$.index[*][?(@.name=='Error')].inner.assoc_type.default.resolved_path"
// @has "$.index[*][?(@.name=='Error')].inner.assoc_type.default.resolved_path.name" \"Infallible\"
pub struct ForBlanketTryFromImpl;
12 changes: 6 additions & 6 deletions tests/rustdoc-json/enums/discriminant/basic.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#[repr(i8)]
pub enum Ordering {
// @is "$.index[*][?(@.name=='Less')].inner.discriminant.expr" '"-1"'
// @is "$.index[*][?(@.name=='Less')].inner.discriminant.value" '"-1"'
// @is "$.index[*][?(@.name=='Less')].inner.variant.discriminant.expr" '"-1"'
// @is "$.index[*][?(@.name=='Less')].inner.variant.discriminant.value" '"-1"'
Less = -1,
// @is "$.index[*][?(@.name=='Equal')].inner.discriminant.expr" '"0"'
// @is "$.index[*][?(@.name=='Equal')].inner.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='Equal')].inner.variant.discriminant.expr" '"0"'
// @is "$.index[*][?(@.name=='Equal')].inner.variant.discriminant.value" '"0"'
Equal = 0,
// @is "$.index[*][?(@.name=='Greater')].inner.discriminant.expr" '"1"'
// @is "$.index[*][?(@.name=='Greater')].inner.discriminant.value" '"1"'
// @is "$.index[*][?(@.name=='Greater')].inner.variant.discriminant.expr" '"1"'
// @is "$.index[*][?(@.name=='Greater')].inner.variant.discriminant.value" '"1"'
Greater = 1,
}
36 changes: 18 additions & 18 deletions tests/rustdoc-json/enums/discriminant/expr.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
pub enum Foo {
// @is "$.index[*][?(@.name=='Addition')].inner.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='Addition')].inner.discriminant.expr" '"{ _ }"'
// @is "$.index[*][?(@.name=='Addition')].inner.variant.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='Addition')].inner.variant.discriminant.expr" '"{ _ }"'
Addition = 0 + 0,
// @is "$.index[*][?(@.name=='Bin')].inner.discriminant.value" '"1"'
// @is "$.index[*][?(@.name=='Bin')].inner.discriminant.expr" '"0b1"'
// @is "$.index[*][?(@.name=='Bin')].inner.variant.discriminant.value" '"1"'
// @is "$.index[*][?(@.name=='Bin')].inner.variant.discriminant.expr" '"0b1"'
Bin = 0b1,
// @is "$.index[*][?(@.name=='Oct')].inner.discriminant.value" '"2"'
// @is "$.index[*][?(@.name=='Oct')].inner.discriminant.expr" '"0o2"'
// @is "$.index[*][?(@.name=='Oct')].inner.variant.discriminant.value" '"2"'
// @is "$.index[*][?(@.name=='Oct')].inner.variant.discriminant.expr" '"0o2"'
Oct = 0o2,
// @is "$.index[*][?(@.name=='PubConst')].inner.discriminant.value" '"3"'
// @is "$.index[*][?(@.name=='PubConst')].inner.discriminant.expr" '"THREE"'
// @is "$.index[*][?(@.name=='PubConst')].inner.variant.discriminant.value" '"3"'
// @is "$.index[*][?(@.name=='PubConst')].inner.variant.discriminant.expr" '"THREE"'
PubConst = THREE,
// @is "$.index[*][?(@.name=='Hex')].inner.discriminant.value" '"4"'
// @is "$.index[*][?(@.name=='Hex')].inner.discriminant.expr" '"0x4"'
// @is "$.index[*][?(@.name=='Hex')].inner.variant.discriminant.value" '"4"'
// @is "$.index[*][?(@.name=='Hex')].inner.variant.discriminant.expr" '"0x4"'
Hex = 0x4,
// @is "$.index[*][?(@.name=='Cast')].inner.discriminant.value" '"5"'
// @is "$.index[*][?(@.name=='Cast')].inner.discriminant.expr" '"{ _ }"'
// @is "$.index[*][?(@.name=='Cast')].inner.variant.discriminant.value" '"5"'
// @is "$.index[*][?(@.name=='Cast')].inner.variant.discriminant.expr" '"{ _ }"'
Cast = 5 as isize,
// @is "$.index[*][?(@.name=='PubCall')].inner.discriminant.value" '"6"'
// @is "$.index[*][?(@.name=='PubCall')].inner.discriminant.expr" '"{ _ }"'
// @is "$.index[*][?(@.name=='PubCall')].inner.variant.discriminant.value" '"6"'
// @is "$.index[*][?(@.name=='PubCall')].inner.variant.discriminant.expr" '"{ _ }"'
PubCall = six(),
// @is "$.index[*][?(@.name=='PrivCall')].inner.discriminant.value" '"7"'
// @is "$.index[*][?(@.name=='PrivCall')].inner.discriminant.expr" '"{ _ }"'
// @is "$.index[*][?(@.name=='PrivCall')].inner.variant.discriminant.value" '"7"'
// @is "$.index[*][?(@.name=='PrivCall')].inner.variant.discriminant.expr" '"{ _ }"'
PrivCall = seven(),
// @is "$.index[*][?(@.name=='PrivConst')].inner.discriminant.value" '"8"'
// @is "$.index[*][?(@.name=='PrivConst')].inner.discriminant.expr" '"EIGHT"'
// @is "$.index[*][?(@.name=='PrivConst')].inner.variant.discriminant.value" '"8"'
// @is "$.index[*][?(@.name=='PrivConst')].inner.variant.discriminant.expr" '"EIGHT"'
PrivConst = EIGHT,
}

Expand Down
32 changes: 16 additions & 16 deletions tests/rustdoc-json/enums/discriminant/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@

#[repr(u64)]
pub enum U64 {
// @is "$.index[*][?(@.name=='U64Min')].inner.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='U64Min')].inner.discriminant.expr" '"u64::MIN"'
// @is "$.index[*][?(@.name=='U64Min')].inner.variant.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='U64Min')].inner.variant.discriminant.expr" '"u64::MIN"'
U64Min = u64::MIN,
// @is "$.index[*][?(@.name=='U64Max')].inner.discriminant.value" '"18446744073709551615"'
// @is "$.index[*][?(@.name=='U64Max')].inner.discriminant.expr" '"u64::MAX"'
// @is "$.index[*][?(@.name=='U64Max')].inner.variant.discriminant.value" '"18446744073709551615"'
// @is "$.index[*][?(@.name=='U64Max')].inner.variant.discriminant.expr" '"u64::MAX"'
U64Max = u64::MAX,
}

#[repr(i64)]
pub enum I64 {
// @is "$.index[*][?(@.name=='I64Min')].inner.discriminant.value" '"-9223372036854775808"'
// @is "$.index[*][?(@.name=='I64Min')].inner.discriminant.expr" '"i64::MIN"'
// @is "$.index[*][?(@.name=='I64Min')].inner.variant.discriminant.value" '"-9223372036854775808"'
// @is "$.index[*][?(@.name=='I64Min')].inner.variant.discriminant.expr" '"i64::MIN"'
I64Min = i64::MIN,
// @is "$.index[*][?(@.name=='I64Max')].inner.discriminant.value" '"9223372036854775807"'
// @is "$.index[*][?(@.name=='I64Max')].inner.discriminant.expr" '"i64::MAX"'
// @is "$.index[*][?(@.name=='I64Max')].inner.variant.discriminant.value" '"9223372036854775807"'
// @is "$.index[*][?(@.name=='I64Max')].inner.variant.discriminant.expr" '"i64::MAX"'
I64Max = i64::MAX,
}

#[repr(u128)]
pub enum U128 {
// @is "$.index[*][?(@.name=='U128Min')].inner.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='U128Min')].inner.discriminant.expr" '"u128::MIN"'
// @is "$.index[*][?(@.name=='U128Min')].inner.variant.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='U128Min')].inner.variant.discriminant.expr" '"u128::MIN"'
U128Min = u128::MIN,
// @is "$.index[*][?(@.name=='U128Max')].inner.discriminant.value" '"340282366920938463463374607431768211455"'
// @is "$.index[*][?(@.name=='U128Max')].inner.discriminant.expr" '"u128::MAX"'
// @is "$.index[*][?(@.name=='U128Max')].inner.variant.discriminant.value" '"340282366920938463463374607431768211455"'
// @is "$.index[*][?(@.name=='U128Max')].inner.variant.discriminant.expr" '"u128::MAX"'
U128Max = u128::MAX,
}

#[repr(i128)]
pub enum I128 {
// @is "$.index[*][?(@.name=='I128Min')].inner.discriminant.value" '"-170141183460469231731687303715884105728"'
// @is "$.index[*][?(@.name=='I128Min')].inner.discriminant.expr" '"i128::MIN"'
// @is "$.index[*][?(@.name=='I128Min')].inner.variant.discriminant.value" '"-170141183460469231731687303715884105728"'
// @is "$.index[*][?(@.name=='I128Min')].inner.variant.discriminant.expr" '"i128::MIN"'
I128Min = i128::MIN,
// @is "$.index[*][?(@.name=='I128Max')].inner.discriminant.value" '"170141183460469231731687303715884105727"'
// @is "$.index[*][?(@.name=='I128Max')].inner.discriminant.expr" '"i128::MAX"'
// @is "$.index[*][?(@.name=='I128Max')].inner.variant.discriminant.value" '"170141183460469231731687303715884105727"'
// @is "$.index[*][?(@.name=='I128Max')].inner.variant.discriminant.expr" '"i128::MAX"'
I128Max = i128::MAX,
}
18 changes: 10 additions & 8 deletions tests/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// ignore-tidy-linelength

#[repr(u32)]
pub enum Foo {
// @is "$.index[*][?(@.name=='Basic')].inner.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='Basic')].inner.discriminant.expr" '"0"'
// @is "$.index[*][?(@.name=='Basic')].inner.variant.discriminant.value" '"0"'
// @is "$.index[*][?(@.name=='Basic')].inner.variant.discriminant.expr" '"0"'
Basic = 0,
// @is "$.index[*][?(@.name=='Suffix')].inner.discriminant.value" '"10"'
// @is "$.index[*][?(@.name=='Suffix')].inner.discriminant.expr" '"10u32"'
// @is "$.index[*][?(@.name=='Suffix')].inner.variant.discriminant.value" '"10"'
// @is "$.index[*][?(@.name=='Suffix')].inner.variant.discriminant.expr" '"10u32"'
Suffix = 10u32,
// @is "$.index[*][?(@.name=='Underscore')].inner.discriminant.value" '"100"'
// @is "$.index[*][?(@.name=='Underscore')].inner.discriminant.expr" '"1_0_0"'
// @is "$.index[*][?(@.name=='Underscore')].inner.variant.discriminant.value" '"100"'
// @is "$.index[*][?(@.name=='Underscore')].inner.variant.discriminant.expr" '"1_0_0"'
Underscore = 1_0_0,
// @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.discriminant.value" '"1000"'
// @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.discriminant.expr" '"1_0_0_0u32"'
// @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant.discriminant.value" '"1000"'
// @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant.discriminant.expr" '"1_0_0_0u32"'
SuffixUnderscore = 1_0_0_0u32,
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// ignore-tidy-linelength

pub enum Foo {
// @is "$.index[*][?(@.name=='Has')].inner.discriminant" '{"expr":"0", "value":"0"}'
// @is "$.index[*][?(@.name=='Has')].inner.variant.discriminant" '{"expr":"0", "value":"0"}'
Has = 0,
// @is "$.index[*][?(@.name=='Doesnt')].inner.discriminant" null
// @is "$.index[*][?(@.name=='Doesnt')].inner.variant.discriminant" null
Doesnt,
// @is "$.index[*][?(@.name=='AlsoDoesnt')].inner.discriminant" null
// @is "$.index[*][?(@.name=='AlsoDoesnt')].inner.variant.discriminant" null
AlsoDoesnt,
// @is "$.index[*][?(@.name=='AlsoHas')].inner.discriminant" '{"expr":"44", "value":"44"}'
// @is "$.index[*][?(@.name=='AlsoHas')].inner.variant.discriminant" '{"expr":"44", "value":"44"}'
AlsoHas = 44,
}
12 changes: 6 additions & 6 deletions tests/rustdoc-json/enums/discriminant/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#[repr(i32)]
// @is "$.index[*][?(@.name=='Foo')].attrs" '["#[repr(i32)]"]'
pub enum Foo {
// @is "$.index[*][?(@.name=='Struct')].inner.discriminant" null
// @count "$.index[*][?(@.name=='Struct')].inner.kind.struct.fields[*]" 0
// @is "$.index[*][?(@.name=='Struct')].inner.variant.discriminant" null
// @count "$.index[*][?(@.name=='Struct')].inner.variant.kind.struct.fields[*]" 0
Struct {},
// @is "$.index[*][?(@.name=='StructWithDiscr')].inner.discriminant" '{"expr": "42", "value": "42"}'
// @count "$.index[*][?(@.name=='StructWithDiscr')].inner.kind.struct.fields[*]" 1
// @is "$.index[*][?(@.name=='StructWithDiscr')].inner.variant.discriminant" '{"expr": "42", "value": "42"}'
// @count "$.index[*][?(@.name=='StructWithDiscr')].inner.variant.kind.struct.fields[*]" 1
StructWithDiscr { x: i32 } = 42,
// @is "$.index[*][?(@.name=='StructWithHexDiscr')].inner.discriminant" '{"expr": "0x42", "value": "66"}'
// @count "$.index[*][?(@.name=='StructWithHexDiscr')].inner.kind.struct.fields[*]" 2
// @is "$.index[*][?(@.name=='StructWithHexDiscr')].inner.variant.discriminant" '{"expr": "0x42", "value": "66"}'
// @count "$.index[*][?(@.name=='StructWithHexDiscr')].inner.variant.kind.struct.fields[*]" 2
StructWithHexDiscr { x: i32, y: bool } = 0x42,
}
12 changes: 6 additions & 6 deletions tests/rustdoc-json/enums/discriminant/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#[repr(u32)]
// @is "$.index[*][?(@.name=='Foo')].attrs" '["#[repr(u32)]"]'
pub enum Foo {
// @is "$.index[*][?(@.name=='Tuple')].inner.discriminant" null
// @count "$.index[*][?(@.name=='Tuple')].inner.kind.tuple[*]" 0
// @is "$.index[*][?(@.name=='Tuple')].inner.variant.discriminant" null
// @count "$.index[*][?(@.name=='Tuple')].inner.variant.kind.tuple[*]" 0
Tuple(),
// @is "$.index[*][?(@.name=='TupleWithDiscr')].inner.discriminant" '{"expr": "1", "value": "1"}'
// @count "$.index[*][?(@.name=='TupleWithDiscr')].inner.kind.tuple[*]" 1
// @is "$.index[*][?(@.name=='TupleWithDiscr')].inner.variant.discriminant" '{"expr": "1", "value": "1"}'
// @count "$.index[*][?(@.name=='TupleWithDiscr')].inner.variant.kind.tuple[*]" 1
TupleWithDiscr(i32) = 1,
// @is "$.index[*][?(@.name=='TupleWithBinDiscr')].inner.discriminant" '{"expr": "0b10", "value": "2"}'
// @count "$.index[*][?(@.name=='TupleWithBinDiscr')].inner.kind.tuple[*]" 2
// @is "$.index[*][?(@.name=='TupleWithBinDiscr')].inner.variant.discriminant" '{"expr": "0b10", "value": "2"}'
// @count "$.index[*][?(@.name=='TupleWithBinDiscr')].inner.variant.kind.tuple[*]" 2
TupleWithBinDiscr(i32, i32) = 0b10,
}
2 changes: 1 addition & 1 deletion tests/rustdoc-json/enums/doc_link_to_foreign_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
extern crate color;
use color::Color::Red;

// @set red = "$.index[*][?(@.inner.is_crate == true)].links.Red"
// @set red = "$.index[*][?(@.inner.module.is_crate)].links.Red"

// @!has "$.index[*][?(@.name == 'Red')]"
// @!has "$.index[*][?(@.name == 'Color')]"
4 changes: 2 additions & 2 deletions tests/rustdoc-json/enums/field_hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

// @has "$.index[*][?(@.name=='ParseError')]"
// @has "$.index[*][?(@.name=='UnexpectedEndTag')]"
// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.kind.tuple" [null]
// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.discriminant" null
// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant.kind.tuple" [null]
// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant.discriminant" null

pub enum ParseError {
UnexpectedEndTag(#[doc(hidden)] u32),
Expand Down
Loading