diff options
Diffstat (limited to '')
88 files changed, 1192 insertions, 506 deletions
diff --git a/src/test/rustdoc-json/assoc_items.rs b/src/test/rustdoc-json/assoc_items.rs index 2ee64c9f6..6d7f6bb96 100644 --- a/src/test/rustdoc-json/assoc_items.rs +++ b/src/test/rustdoc-json/assoc_items.rs @@ -1,29 +1,37 @@ #![no_std] -// @has assoc_items.json - pub struct Simple; impl Simple { - // @has - "$.index[*][?(@.name=='CONSTANT')].kind" \"assoc_const\" + // @is "$.index[*][?(@.name=='CONSTANT')].kind" \"assoc_const\" pub const CONSTANT: usize = 0; } pub trait EasyToImpl { - // @has - "$.index[*][?(@.name=='ToDeclare')].kind" \"assoc_type\" - // @has - "$.index[*][?(@.name=='ToDeclare')].inner.default" null + // @is "$.index[*][?(@.docs=='ToDeclare trait')].kind" \"assoc_type\" + // @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.default" null + // @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.bounds" [] + /// ToDeclare trait type ToDeclare; - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].kind" \"assoc_const\" - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.default" null + // @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"' + /// AN_ATTRIBUTE trait const AN_ATTRIBUTE: usize; } impl EasyToImpl for Simple { - // @has - "$.index[*][?(@.name=='ToDeclare')].inner.default.kind" \"primitive\" - // @has - "$.index[*][?(@.name=='ToDeclare')].inner.default.inner" \"usize\" + // @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\" + /// ToDeclare impl type ToDeclare = usize; - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.type.kind" \"primitive\" - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.type.inner" \"usize\" - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.default" \"12\" + + // @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\" + /// AN_ATTRIBUTE impl const AN_ATTRIBUTE: usize = 12; } diff --git a/src/test/rustdoc-json/assoc_type.rs b/src/test/rustdoc-json/assoc_type.rs index 716bb3d28..edc1f73c8 100644 --- a/src/test/rustdoc-json/assoc_type.rs +++ b/src/test/rustdoc-json/assoc_type.rs @@ -1,10 +1,9 @@ // Regression test for <https://github.com/rust-lang/rust/issues/98547>. -// @has assoc_type.json -// @has - "$.index[*][?(@.name=='Trait')]" -// @has - "$.index[*][?(@.name=='AssocType')]" -// @has - "$.index[*][?(@.name=='S')]" -// @has - "$.index[*][?(@.name=='S2')]" +// @has "$.index[*][?(@.name=='Trait')]" +// @has "$.index[*][?(@.name=='AssocType')]" +// @has "$.index[*][?(@.name=='S')]" +// @has "$.index[*][?(@.name=='S2')]" pub trait Trait { type AssocType; diff --git a/src/test/rustdoc-json/blanket_impls.rs b/src/test/rustdoc-json/blanket_impls.rs index edf1a9fe2..c5cc87ca1 100644 --- a/src/test/rustdoc-json/blanket_impls.rs +++ b/src/test/rustdoc-json/blanket_impls.rs @@ -2,8 +2,7 @@ #![no_std] -// @has blanket_impls.json -// @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')].kind" \"assoc_type\" +// @has "$.index[*][?(@.name=='Error')].inner.default.kind" \"resolved_path\" +// @has "$.index[*][?(@.name=='Error')].inner.default.inner.name" \"Infallible\" pub struct ForBlanketTryFromImpl; diff --git a/src/test/rustdoc-json/doc_hidden_failure.rs b/src/test/rustdoc-json/doc_hidden_failure.rs index 5c4ccf996..6573166c4 100644 --- a/src/test/rustdoc-json/doc_hidden_failure.rs +++ b/src/test/rustdoc-json/doc_hidden_failure.rs @@ -14,7 +14,7 @@ mod auto { } } -// @count doc_hidden_failure.json "$.index[*][?(@.name=='builders')]" 2 +// @count "$.index[*][?(@.name=='builders')]" 2 pub use auto::*; pub mod builders { diff --git a/src/test/rustdoc-json/enums/discriminant/basic.rs b/src/test/rustdoc-json/enums/discriminant/basic.rs new file mode 100644 index 000000000..8c221615a --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/basic.rs @@ -0,0 +1,12 @@ +#[repr(i8)] +pub enum Ordering { + // @is "$.index[*][?(@.name=='Less')].inner.variant_inner.expr" '"-1"' + // @is "$.index[*][?(@.name=='Less')].inner.variant_inner.value" '"-1"' + Less = -1, + // @is "$.index[*][?(@.name=='Equal')].inner.variant_inner.expr" '"0"' + // @is "$.index[*][?(@.name=='Equal')].inner.variant_inner.value" '"0"' + Equal = 0, + // @is "$.index[*][?(@.name=='Greater')].inner.variant_inner.expr" '"1"' + // @is "$.index[*][?(@.name=='Greater')].inner.variant_inner.value" '"1"' + Greater = 1, +} diff --git a/src/test/rustdoc-json/enums/discriminant/expr.rs b/src/test/rustdoc-json/enums/discriminant/expr.rs new file mode 100644 index 000000000..235b0b473 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/expr.rs @@ -0,0 +1,39 @@ +pub enum Foo { + // @is "$.index[*][?(@.name=='Addition')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='Addition')].inner.variant_inner.expr" '"{ _ }"' + Addition = 0 + 0, + // @is "$.index[*][?(@.name=='Bin')].inner.variant_inner.value" '"1"' + // @is "$.index[*][?(@.name=='Bin')].inner.variant_inner.expr" '"0b1"' + Bin = 0b1, + // @is "$.index[*][?(@.name=='Oct')].inner.variant_inner.value" '"2"' + // @is "$.index[*][?(@.name=='Oct')].inner.variant_inner.expr" '"0o2"' + Oct = 0o2, + // @is "$.index[*][?(@.name=='PubConst')].inner.variant_inner.value" '"3"' + // @is "$.index[*][?(@.name=='PubConst')].inner.variant_inner.expr" '"THREE"' + PubConst = THREE, + // @is "$.index[*][?(@.name=='Hex')].inner.variant_inner.value" '"4"' + // @is "$.index[*][?(@.name=='Hex')].inner.variant_inner.expr" '"0x4"' + Hex = 0x4, + // @is "$.index[*][?(@.name=='Cast')].inner.variant_inner.value" '"5"' + // @is "$.index[*][?(@.name=='Cast')].inner.variant_inner.expr" '"{ _ }"' + Cast = 5 as isize, + // @is "$.index[*][?(@.name=='PubCall')].inner.variant_inner.value" '"6"' + // @is "$.index[*][?(@.name=='PubCall')].inner.variant_inner.expr" '"{ _ }"' + PubCall = six(), + // @is "$.index[*][?(@.name=='PrivCall')].inner.variant_inner.value" '"7"' + // @is "$.index[*][?(@.name=='PrivCall')].inner.variant_inner.expr" '"{ _ }"' + PrivCall = seven(), + // @is "$.index[*][?(@.name=='PrivConst')].inner.variant_inner.value" '"8"' + // @is "$.index[*][?(@.name=='PrivConst')].inner.variant_inner.expr" '"EIGHT"' + PrivConst = EIGHT, +} + +pub const THREE: isize = 3; +const EIGHT: isize = 8; + +pub const fn six() -> isize { + 6 +} +const fn seven() -> isize { + 7 +} diff --git a/src/test/rustdoc-json/enums/discriminant/limits.rs b/src/test/rustdoc-json/enums/discriminant/limits.rs new file mode 100644 index 000000000..8df73d78d --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/limits.rs @@ -0,0 +1,43 @@ +// ignore-tidy-linelength +#![feature(repr128)] +#![allow(incomplete_features)] + +#[repr(u64)] +pub enum U64 { + // @is "$.index[*][?(@.name=='U64Min')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='U64Min')].inner.variant_inner.expr" '"u64::MIN"' + U64Min = u64::MIN, + // @is "$.index[*][?(@.name=='U64Max')].inner.variant_inner.value" '"18446744073709551615"' + // @is "$.index[*][?(@.name=='U64Max')].inner.variant_inner.expr" '"u64::MAX"' + U64Max = u64::MAX, +} + +#[repr(i64)] +pub enum I64 { + // @is "$.index[*][?(@.name=='I64Min')].inner.variant_inner.value" '"-9223372036854775808"' + // @is "$.index[*][?(@.name=='I64Min')].inner.variant_inner.expr" '"i64::MIN"' + I64Min = i64::MIN, + // @is "$.index[*][?(@.name=='I64Max')].inner.variant_inner.value" '"9223372036854775807"' + // @is "$.index[*][?(@.name=='I64Max')].inner.variant_inner.expr" '"i64::MAX"' + I64Max = i64::MAX, +} + +#[repr(u128)] +pub enum U128 { + // @is "$.index[*][?(@.name=='U128Min')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='U128Min')].inner.variant_inner.expr" '"u128::MIN"' + U128Min = u128::MIN, + // @is "$.index[*][?(@.name=='U128Max')].inner.variant_inner.value" '"340282366920938463463374607431768211455"' + // @is "$.index[*][?(@.name=='U128Max')].inner.variant_inner.expr" '"u128::MAX"' + U128Max = u128::MAX, +} + +#[repr(i128)] +pub enum I128 { + // @is "$.index[*][?(@.name=='I128Min')].inner.variant_inner.value" '"-170141183460469231731687303715884105728"' + // @is "$.index[*][?(@.name=='I128Min')].inner.variant_inner.expr" '"i128::MIN"' + I128Min = i128::MIN, + // @is "$.index[*][?(@.name=='I128Max')].inner.variant_inner.value" '"170141183460469231731687303715884105727"' + // @is "$.index[*][?(@.name=='I128Max')].inner.variant_inner.expr" '"i128::MAX"' + I128Max = i128::MAX, +} diff --git a/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs b/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs new file mode 100644 index 000000000..3417baa07 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs @@ -0,0 +1,15 @@ +#[repr(u32)] +pub enum Foo { + // @is "$.index[*][?(@.name=='Basic')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='Basic')].inner.variant_inner.expr" '"0"' + Basic = 0, + // @is "$.index[*][?(@.name=='Suffix')].inner.variant_inner.value" '"10"' + // @is "$.index[*][?(@.name=='Suffix')].inner.variant_inner.expr" '"10u32"' + Suffix = 10u32, + // @is "$.index[*][?(@.name=='Underscore')].inner.variant_inner.value" '"100"' + // @is "$.index[*][?(@.name=='Underscore')].inner.variant_inner.expr" '"1_0_0"' + Underscore = 1_0_0, + // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant_inner.value" '"1000"' + // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant_inner.expr" '"1_0_0_0u32"' + SuffixUnderscore = 1_0_0_0u32, +} diff --git a/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs b/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs new file mode 100644 index 000000000..6af944a22 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs @@ -0,0 +1,10 @@ +pub enum Foo { + // @is "$.index[*][?(@.name=='Has')].inner.variant_inner" '{"expr":"0", "value":"0"}' + Has = 0, + // @is "$.index[*][?(@.name=='Doesnt')].inner.variant_inner" null + Doesnt, + // @is "$.index[*][?(@.name=='AlsoDoesnt')].inner.variant_inner" null + AlsoDoesnt, + // @is "$.index[*][?(@.name=='AlsoHas')].inner.variant_inner" '{"expr":"44", "value":"44"}' + AlsoHas = 44, +} diff --git a/src/test/rustdoc-json/enums/field_hidden.rs b/src/test/rustdoc-json/enums/field_hidden.rs new file mode 100644 index 000000000..e6310cc3b --- /dev/null +++ b/src/test/rustdoc-json/enums/field_hidden.rs @@ -0,0 +1,13 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/100529>. + +#![no_core] +#![feature(no_core)] + +// @has "$.index[*][?(@.name=='ParseError')]" +// @has "$.index[*][?(@.name=='UnexpectedEndTag')]" +// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"' +// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" [null] + +pub enum ParseError { + UnexpectedEndTag(#[doc(hidden)] u32), +} diff --git a/src/test/rustdoc-json/enums/kind.rs b/src/test/rustdoc-json/enums/kind.rs new file mode 100644 index 000000000..e9ea3ae23 --- /dev/null +++ b/src/test/rustdoc-json/enums/kind.rs @@ -0,0 +1,37 @@ +// ignore-tidy-linelength + +#![feature(no_core)] +#![no_core] + +pub enum Foo { + // @set Unit = "$.index[*][?(@.name=='Unit')].id" + // @is "$.index[*][?(@.name=='Unit')].inner.variant_kind" '"plain"' + // @is "$.index[*][?(@.name=='Unit')].inner.variant_inner" null + Unit, + // @set Named = "$.index[*][?(@.name=='Named')].id" + // @is "$.index[*][?(@.name=='Named')].inner.variant_kind" '"struct"' + // @is "$.index[*][?(@.name=='Named')].inner.variant_inner" '{"fields": [], "fields_stripped": false}' + Named {}, + // @set Tuple = "$.index[*][?(@.name=='Tuple')].id" + // @is "$.index[*][?(@.name=='Tuple')].inner.variant_kind" '"tuple"' + // @is "$.index[*][?(@.name=='Tuple')].inner.variant_inner" [] + Tuple(), + // @set NamedField = "$.index[*][?(@.name=='NamedField')].id" + // @set x = "$.index[*][?(@.name=='x' && @.kind=='struct_field')].id" + // @is "$.index[*][?(@.name=='NamedField')].inner.variant_kind" '"struct"' + // @is "$.index[*][?(@.name=='NamedField')].inner.variant_inner.fields[*]" $x + // @is "$.index[*][?(@.name=='NamedField')].inner.variant_inner.fields_stripped" false + NamedField { x: i32 }, + // @set TupleField = "$.index[*][?(@.name=='TupleField')].id" + // @is "$.index[*][?(@.name=='TupleField')].inner.variant_kind" '"tuple"' + // @set tup_field = "$.index[*][?(@.name=='0' && @.kind=='struct_field')].id" + // @is "$.index[*][?(@.name=='TupleField')].inner.variant_inner[*]" $tup_field + TupleField(i32), +} + +// @is "$.index[*][?(@.name=='Foo')].inner.variants[0]" $Unit +// @is "$.index[*][?(@.name=='Foo')].inner.variants[1]" $Named +// @is "$.index[*][?(@.name=='Foo')].inner.variants[2]" $Tuple +// @is "$.index[*][?(@.name=='Foo')].inner.variants[3]" $NamedField +// @is "$.index[*][?(@.name=='Foo')].inner.variants[4]" $TupleField +// @count "$.index[*][?(@.name=='Foo')].inner.variants[*]" 5 diff --git a/src/test/rustdoc-json/enums/struct_field_hidden.rs b/src/test/rustdoc-json/enums/struct_field_hidden.rs new file mode 100644 index 000000000..f612a34a4 --- /dev/null +++ b/src/test/rustdoc-json/enums/struct_field_hidden.rs @@ -0,0 +1,17 @@ +pub enum Foo { + Variant { + #[doc(hidden)] + a: i32, + // @set b = "$.index[*][?(@.name=='b')].id" + b: i32, + #[doc(hidden)] + x: i32, + // @set y = "$.index[*][?(@.name=='y')].id" + y: i32, + }, + // @is "$.index[*][?(@.name=='Variant')].inner.variant_kind" '"struct"' + // @is "$.index[*][?(@.name=='Variant')].inner.variant_inner.fields_stripped" true + // @is "$.index[*][?(@.name=='Variant')].inner.variant_inner.fields[0]" $b + // @is "$.index[*][?(@.name=='Variant')].inner.variant_inner.fields[1]" $y + // @count "$.index[*][?(@.name=='Variant')].inner.variant_inner.fields[*]" 2 +} diff --git a/src/test/rustdoc-json/enums/tuple_fields_hidden.rs b/src/test/rustdoc-json/enums/tuple_fields_hidden.rs new file mode 100644 index 000000000..f546eaa0d --- /dev/null +++ b/src/test/rustdoc-json/enums/tuple_fields_hidden.rs @@ -0,0 +1,94 @@ +#![feature(no_core)] +#![no_core] + +// @set 1.1.0 = "$.index[*][?(@.docs=='1.1.0')].id" +// @set 2.1.0 = "$.index[*][?(@.docs=='2.1.0')].id" +// @set 2.1.1 = "$.index[*][?(@.docs=='2.1.1')].id" +// @set 2.2.1 = "$.index[*][?(@.docs=='2.2.1')].id" +// @set 2.3.0 = "$.index[*][?(@.docs=='2.3.0')].id" +// @set 3.1.1 = "$.index[*][?(@.docs=='3.1.1')].id" +// @set 3.1.2 = "$.index[*][?(@.docs=='3.1.2')].id" +// @set 3.2.0 = "$.index[*][?(@.docs=='3.2.0')].id" +// @set 3.2.2 = "$.index[*][?(@.docs=='3.2.2')].id" +// @set 3.3.0 = "$.index[*][?(@.docs=='3.3.0')].id" +// @set 3.3.1 = "$.index[*][?(@.docs=='3.3.1')].id" + +pub enum EnumWithStrippedTupleVariants { + // @is "$.index[*][?(@.name=='None')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='None')].inner.variant_inner[*]" 0 + None(), + + // @is "$.index[*][?(@.name=='One')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='One')].inner.variant_inner[*]" 1 + // @is "$.index[*][?(@.name=='One')].inner.variant_inner[0]" $1.1.0 + One(/** 1.1.0*/ bool), + // @is "$.index[*][?(@.name=='OneHidden')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='OneHidden')].inner.variant_inner[*]" 1 + // @is "$.index[*][?(@.name=='OneHidden')].inner.variant_inner[0]" null + OneHidden(#[doc(hidden)] bool), + + // @is "$.index[*][?(@.name=='Two')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='Two')].inner.variant_inner[*]" 2 + // @is "$.index[*][?(@.name=='Two')].inner.variant_inner[0]" $2.1.0 + // @is "$.index[*][?(@.name=='Two')].inner.variant_inner[1]" $2.1.1 + Two(/** 2.1.0*/ bool, /** 2.1.1*/ bool), + // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant_inner[*]" 2 + // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant_inner[0]" null + // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant_inner[1]" $2.2.1 + TwoLeftHidden(#[doc(hidden)] bool, /** 2.2.1*/ bool), + // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='TwoRightHidden')].inner.variant_inner[*]" 2 + // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.variant_inner[0]" $2.3.0 + // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.variant_inner[1]" null + TwoRightHidden(/** 2.3.0*/ bool, #[doc(hidden)] bool), + // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='TwoBothHidden')].inner.variant_inner[*]" 2 + // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.variant_inner[0]" null + // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.variant_inner[1]" null + TwoBothHidden(#[doc(hidden)] bool, #[doc(hidden)] bool), + + // @is "$.index[*][?(@.name=='Three1')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='Three1')].inner.variant_inner[*]" 3 + // @is "$.index[*][?(@.name=='Three1')].inner.variant_inner[0]" null + // @is "$.index[*][?(@.name=='Three1')].inner.variant_inner[1]" $3.1.1 + // @is "$.index[*][?(@.name=='Three1')].inner.variant_inner[2]" $3.1.2 + Three1(#[doc(hidden)] bool, /** 3.1.1*/ bool, /** 3.1.2*/ bool), + // @is "$.index[*][?(@.name=='Three2')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='Three2')].inner.variant_inner[*]" 3 + // @is "$.index[*][?(@.name=='Three2')].inner.variant_inner[0]" $3.2.0 + // @is "$.index[*][?(@.name=='Three2')].inner.variant_inner[1]" null + // @is "$.index[*][?(@.name=='Three2')].inner.variant_inner[2]" $3.2.2 + Three2(/** 3.2.0*/ bool, #[doc(hidden)] bool, /** 3.2.2*/ bool), + // @is "$.index[*][?(@.name=='Three3')].inner.variant_kind" '"tuple"' + // @count "$.index[*][?(@.name=='Three3')].inner.variant_inner[*]" 3 + // @is "$.index[*][?(@.name=='Three3')].inner.variant_inner[0]" $3.3.0 + // @is "$.index[*][?(@.name=='Three3')].inner.variant_inner[1]" $3.3.1 + // @is "$.index[*][?(@.name=='Three3')].inner.variant_inner[2]" null + Three3(/** 3.3.0*/ bool, /** 3.3.1*/ bool, #[doc(hidden)] bool), +} + + +// @is "$.index[*][?(@.docs=='1.1.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='2.1.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='2.1.1')].name" '"1"' +// @is "$.index[*][?(@.docs=='2.2.1')].name" '"1"' +// @is "$.index[*][?(@.docs=='2.3.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='3.1.1')].name" '"1"' +// @is "$.index[*][?(@.docs=='3.1.2')].name" '"2"' +// @is "$.index[*][?(@.docs=='3.2.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='3.2.2')].name" '"2"' +// @is "$.index[*][?(@.docs=='3.3.0')].name" '"0"' +// @is "$.index[*][?(@.docs=='3.3.1')].name" '"1"' + +// @is "$.index[*][?(@.docs=='1.1.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='2.1.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='2.1.1')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='2.2.1')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='2.3.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.1.1')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.1.2')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.2.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.2.2')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.3.0')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='3.3.1')].inner" '{"kind": "primitive", "inner": "bool"}' diff --git a/src/test/rustdoc-json/enums/variant_struct.rs b/src/test/rustdoc-json/enums/variant_struct.rs index fcd92887c..23b854d8d 100644 --- a/src/test/rustdoc-json/enums/variant_struct.rs +++ b/src/test/rustdoc-json/enums/variant_struct.rs @@ -1,9 +1,9 @@ -// @has variant_struct.json "$.index[*][?(@.name=='EnumStruct')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='EnumStruct')].kind" \"enum\" +// @is "$.index[*][?(@.name=='EnumStruct')].visibility" \"public\" +// @is "$.index[*][?(@.name=='EnumStruct')].kind" \"enum\" pub enum EnumStruct { - // @has - "$.index[*][?(@.name=='VariantS')].inner.variant_kind" \"struct\" - // @has - "$.index[*][?(@.name=='x')].kind" \"struct_field\" - // @has - "$.index[*][?(@.name=='y')].kind" \"struct_field\" + // @is "$.index[*][?(@.name=='VariantS')].inner.variant_kind" \"struct\" + // @is "$.index[*][?(@.name=='x')].kind" \"struct_field\" + // @is "$.index[*][?(@.name=='y')].kind" \"struct_field\" VariantS { x: u32, y: String, diff --git a/src/test/rustdoc-json/enums/variant_tuple_struct.rs b/src/test/rustdoc-json/enums/variant_tuple_struct.rs index ac3e72e29..b71ec47a8 100644 --- a/src/test/rustdoc-json/enums/variant_tuple_struct.rs +++ b/src/test/rustdoc-json/enums/variant_tuple_struct.rs @@ -1,8 +1,8 @@ -// @has variant_tuple_struct.json "$.index[*][?(@.name=='EnumTupleStruct')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='EnumTupleStruct')].kind" \"enum\" +// @is "$.index[*][?(@.name=='EnumTupleStruct')].visibility" \"public\" +// @is "$.index[*][?(@.name=='EnumTupleStruct')].kind" \"enum\" pub enum EnumTupleStruct { - // @has - "$.index[*][?(@.name=='VariantA')].inner.variant_kind" \"tuple\" - // @has - "$.index[*][?(@.name=='0')].kind" \"struct_field\" - // @has - "$.index[*][?(@.name=='1')].kind" \"struct_field\" + // @is "$.index[*][?(@.name=='VariantA')].inner.variant_kind" \"tuple\" + // @is "$.index[*][?(@.name=='0')].kind" \"struct_field\" + // @is "$.index[*][?(@.name=='1')].kind" \"struct_field\" VariantA(u32, String), } diff --git a/src/test/rustdoc-json/fn_pointer/abi.rs b/src/test/rustdoc-json/fn_pointer/abi.rs index eef20e60a..3c1a453d1 100644 --- a/src/test/rustdoc-json/fn_pointer/abi.rs +++ b/src/test/rustdoc-json/fn_pointer/abi.rs @@ -3,23 +3,23 @@ #![feature(abi_vectorcall)] #![feature(c_unwind)] -// @is abi.json "$.index[*][?(@.name=='AbiRust')].inner.type.inner.header.abi" \"Rust\" +// @is "$.index[*][?(@.name=='AbiRust')].inner.type.inner.header.abi" \"Rust\" pub type AbiRust = fn(); -// @is - "$.index[*][?(@.name=='AbiC')].inner.type.inner.header.abi" '{"C": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiC')].inner.type.inner.header.abi" '{"C": {"unwind": false}}' pub type AbiC = extern "C" fn(); -// @is - "$.index[*][?(@.name=='AbiSystem')].inner.type.inner.header.abi" '{"System": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiSystem')].inner.type.inner.header.abi" '{"System": {"unwind": false}}' pub type AbiSystem = extern "system" fn(); -// @is - "$.index[*][?(@.name=='AbiCUnwind')].inner.type.inner.header.abi" '{"C": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiCUnwind')].inner.type.inner.header.abi" '{"C": {"unwind": true}}' pub type AbiCUnwind = extern "C-unwind" fn(); -// @is - "$.index[*][?(@.name=='AbiSystemUnwind')].inner.type.inner.header.abi" '{"System": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiSystemUnwind')].inner.type.inner.header.abi" '{"System": {"unwind": true}}' pub type AbiSystemUnwind = extern "system-unwind" fn(); -// @is - "$.index[*][?(@.name=='AbiVecorcall')].inner.type.inner.header.abi.Other" '"\"vectorcall\""' +// @is "$.index[*][?(@.name=='AbiVecorcall')].inner.type.inner.header.abi.Other" '"\"vectorcall\""' pub type AbiVecorcall = extern "vectorcall" fn(); -// @is - "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.type.inner.header.abi.Other" '"\"vectorcall-unwind\""' +// @is "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.type.inner.header.abi.Other" '"\"vectorcall-unwind\""' pub type AbiVecorcallUnwind = extern "vectorcall-unwind" fn(); diff --git a/src/test/rustdoc-json/fn_pointer/generics.rs b/src/test/rustdoc-json/fn_pointer/generics.rs index 646f720e6..a93b01ac2 100644 --- a/src/test/rustdoc-json/fn_pointer/generics.rs +++ b/src/test/rustdoc-json/fn_pointer/generics.rs @@ -3,12 +3,12 @@ #![feature(no_core)] #![no_core] -// @count generics.json "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][0]" '"val"' -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].inner.lifetime" \"\'c\" -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.output" '{ "kind": "primitive", "inner": "i32" }' -// @count - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[*]" 1 -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].name" \"\'c\" -// @is - "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][0]" '"val"' +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].inner.lifetime" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.output" '{ "kind": "primitive", "inner": "i32" }' +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].name" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' pub type WithHigherRankTraitBounds = for<'c> fn(val: &'c i32) -> i32; diff --git a/src/test/rustdoc-json/fn_pointer/qualifiers.rs b/src/test/rustdoc-json/fn_pointer/qualifiers.rs index 381922085..bd65bb3ee 100644 --- a/src/test/rustdoc-json/fn_pointer/qualifiers.rs +++ b/src/test/rustdoc-json/fn_pointer/qualifiers.rs @@ -1,9 +1,9 @@ -// @is qualifiers.json "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.unsafe" false -// @is - "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.const" false -// @is - "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.async" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.unsafe" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.const" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.async" false pub type FnPointer = fn(); -// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.unsafe" true -// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.const" false -// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.async" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.unsafe" true +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.const" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.async" false pub type UnsafePointer = unsafe fn(); diff --git a/src/test/rustdoc-json/fns/abi.rs b/src/test/rustdoc-json/fns/abi.rs index 16b579130..0e8b78bc0 100644 --- a/src/test/rustdoc-json/fns/abi.rs +++ b/src/test/rustdoc-json/fns/abi.rs @@ -3,23 +3,23 @@ #![feature(abi_vectorcall)] #![feature(c_unwind)] -// @is abi.json "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" +// @is "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" pub fn abi_rust() {} -// @is - "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' +// @is "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' pub extern "C" fn abi_c() {} -// @is - "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' +// @is "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' pub extern "system" fn abi_system() {} -// @is - "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' +// @is "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' pub extern "C-unwind" fn abi_c_unwind() {} -// @is - "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' +// @is "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' pub extern "system-unwind" fn abi_system_unwind() {} -// @is - "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' +// @is "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' pub extern "vectorcall" fn abi_vectorcall() {} -// @is - "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' +// @is "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {} diff --git a/src/test/rustdoc-json/fns/async_return.rs b/src/test/rustdoc-json/fns/async_return.rs new file mode 100644 index 000000000..b89781ca9 --- /dev/null +++ b/src/test/rustdoc-json/fns/async_return.rs @@ -0,0 +1,36 @@ +// edition:2021 +// ignore-tidy-linelength + +// Regression test for <https://github.com/rust-lang/rust/issues/101199> + +use std::future::Future; + +// @is "$.index[*][?(@.name=='get_int')].inner.decl.output" '{"inner": "i32", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='get_int')].inner.header.async" false +pub fn get_int() -> i32 { + 42 +} + +// @is "$.index[*][?(@.name=='get_int_async')].inner.decl.output" '{"inner": "i32", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='get_int_async')].inner.header.async" true +pub async fn get_int_async() -> i32 { + 42 +} + +// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.kind" '"impl_trait"' +// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.name" '"Future"' +// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' +// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type" '{"inner": "i32", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='get_int_future')].inner.header.async" false +pub fn get_int_future() -> impl Future<Output = i32> { + async { 42 } +} + +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.kind" '"impl_trait"' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.name" '"Future"' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type" '{"inner": "i32", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.header.async" true +pub async fn get_int_future_async() -> impl Future<Output = i32> { + async { 42 } +} diff --git a/src/test/rustdoc-json/fns/generic_args.rs b/src/test/rustdoc-json/fns/generic_args.rs index 69150443c..eec295efe 100644 --- a/src/test/rustdoc-json/fns/generic_args.rs +++ b/src/test/rustdoc-json/fns/generic_args.rs @@ -3,65 +3,65 @@ #![feature(no_core)] #![no_core] -// @set foo = generic_args.json "$.index[*][?(@.name=='Foo')].id" +// @set foo = "$.index[*][?(@.name=='Foo')].id" pub trait Foo {} -// @set generic_foo = generic_args.json "$.index[*][?(@.name=='GenericFoo')].id" +// @set generic_foo = "$.index[*][?(@.name=='GenericFoo')].id" pub trait GenericFoo<'a> {} -// @is - "$.index[*][?(@.name=='generics')].inner.generics.where_predicates" "[]" -// @count - "$.index[*][?(@.name=='generics')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].name" '"F"' -// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.default" 'null' -// @count - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" '$foo' -// @count - "$.index[*][?(@.name=='generics')].inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][0]" '"f"' -// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].kind" '"generic"' -// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].inner" '"F"' +// @is "$.index[*][?(@.name=='generics')].inner.generics.where_predicates" "[]" +// @count "$.index[*][?(@.name=='generics')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].name" '"F"' +// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.default" 'null' +// @count "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" '$foo' +// @count "$.index[*][?(@.name=='generics')].inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][0]" '"f"' +// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].kind" '"generic"' +// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].inner" '"F"' pub fn generics<F: Foo>(f: F) {} -// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.where_predicates" "[]" -// @count - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].name" '"impl Foo"' -// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $foo -// @count - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][0]" '"f"' -// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].kind" '"impl_trait"' -// @count - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[*]" 1 -// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.inner.id" $foo +// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.where_predicates" "[]" +// @count "$.index[*][?(@.name=='impl_trait')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].name" '"impl Foo"' +// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $foo +// @count "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][0]" '"f"' +// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].kind" '"impl_trait"' +// @count "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $foo pub fn impl_trait(f: impl Foo) {} -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.params[*]" 3 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].name" '"F"' -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].kind" '{"type": {"bounds": [], "default": null, "synthetic": false}}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[*]" 3 -// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][0]" '"f"' -// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].kind" '"generic"' -// @is - "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].inner" '"F"' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[*]" 3 +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.params[*]" 3 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].name" '"F"' +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].kind" '{"type": {"bounds": [], "default": null, "synthetic": false}}' +// @count "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[*]" 3 +// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][0]" '"f"' +// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].kind" '"generic"' +// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].inner" '"F"' +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[*]" 3 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F", "kind": "generic"}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F", "kind": "generic"}' +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.id" $foo -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.type" '{"inner": "G", "kind": "generic"}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.trait.inner.id" $generic_foo -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].name" \"\'a\" -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.generic_params" "[]" +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.type" '{"inner": "G", "kind": "generic"}' +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.trait.id" $generic_foo +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.generic_params" "[]" -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.lifetime" \"\'b\" -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.type" '{"inner": "H", "kind": "generic"}' -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.generic_params" "[]" -// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[*]" 1 -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].name" \"\'b\" -// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.lifetime" \"\'b\" +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.type" '{"inner": "H", "kind": "generic"}' +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.trait.id" $foo +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.generic_params" "[]" +// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].name" \"\'b\" +// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' pub fn where_clase<F, G, H>(f: F, g: G, h: H) where F: Foo, diff --git a/src/test/rustdoc-json/fns/generic_returns.rs b/src/test/rustdoc-json/fns/generic_returns.rs index 1a0f33fe3..a9bc2d5d7 100644 --- a/src/test/rustdoc-json/fns/generic_returns.rs +++ b/src/test/rustdoc-json/fns/generic_returns.rs @@ -3,15 +3,15 @@ #![feature(no_core)] #![no_core] -// @count generic_returns.json "$.index[*][?(@.name=='generic_returns')].inner.items[*]" 2 +// @count "$.index[*][?(@.name=='generic_returns')].inner.items[*]" 2 -// @set foo = - "$.index[*][?(@.name=='Foo')].id" +// @set foo = "$.index[*][?(@.name=='Foo')].id" pub trait Foo {} -// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.inputs" [] -// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.output.kind" '"impl_trait"' -// @count - "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[*]" 1 -// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[0].trait_bound.trait.inner.id" $foo +// @is "$.index[*][?(@.name=='get_foo')].inner.decl.inputs" [] +// @is "$.index[*][?(@.name=='get_foo')].inner.decl.output.kind" '"impl_trait"' +// @count "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[*]" 1 +// @is "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[0].trait_bound.trait.id" $foo pub fn get_foo() -> impl Foo { Fooer {} } diff --git a/src/test/rustdoc-json/fns/generics.rs b/src/test/rustdoc-json/fns/generics.rs index e777fabaa..7b70ff1df 100644 --- a/src/test/rustdoc-json/fns/generics.rs +++ b/src/test/rustdoc-json/fns/generics.rs @@ -3,24 +3,24 @@ #![feature(no_core)] #![no_core] -// @set wham_id = generics.json "$.index[*][?(@.name=='Wham')].id" +// @set wham_id = "$.index[*][?(@.name=='Wham')].id" pub trait Wham {} -// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.where_predicates" [] -// @count - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].name" '"T"' -// @has - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" false -// @has - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $wham_id -// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.decl.inputs" '[["w", {"inner": "T", "kind": "generic"}]]' +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.where_predicates" [] +// @count "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].name" '"T"' +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" false +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $wham_id +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.decl.inputs" '[["w", {"inner": "T", "kind": "generic"}]]' pub fn one_generic_param_fn<T: Wham>(w: T) {} -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.where_predicates" [] -// @count - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].name" '"impl Wham"' -// @has - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" true -// @has - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $wham_id -// @count - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][0]" '"w"' -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].kind" '"impl_trait"' -// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.inner.id" $wham_id +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.where_predicates" [] +// @count "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].name" '"impl Wham"' +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" true +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $wham_id +// @count "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][0]" '"w"' +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].kind" '"impl_trait"' +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $wham_id pub fn one_synthetic_generic_param_fn(w: impl Wham) {} diff --git a/src/test/rustdoc-json/fns/qualifiers.rs b/src/test/rustdoc-json/fns/qualifiers.rs index 5cb3b43e6..7ff542900 100644 --- a/src/test/rustdoc-json/fns/qualifiers.rs +++ b/src/test/rustdoc-json/fns/qualifiers.rs @@ -1,33 +1,33 @@ // edition:2018 -// @is qualifiers.json "$.index[*][?(@.name=='nothing_fn')].inner.header.async" false -// @is - "$.index[*][?(@.name=='nothing_fn')].inner.header.const" false -// @is - "$.index[*][?(@.name=='nothing_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.async" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.const" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.unsafe" false pub fn nothing_fn() {} -// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.async" false -// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.const" false -// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.async" false +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.const" false +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.unsafe" true pub unsafe fn unsafe_fn() {} -// @is - "$.index[*][?(@.name=='const_fn')].inner.header.async" false -// @is - "$.index[*][?(@.name=='const_fn')].inner.header.const" true -// @is - "$.index[*][?(@.name=='const_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='const_fn')].inner.header.async" false +// @is "$.index[*][?(@.name=='const_fn')].inner.header.const" true +// @is "$.index[*][?(@.name=='const_fn')].inner.header.unsafe" false pub const fn const_fn() {} -// @is - "$.index[*][?(@.name=='async_fn')].inner.header.async" true -// @is - "$.index[*][?(@.name=='async_fn')].inner.header.const" false -// @is - "$.index[*][?(@.name=='async_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='async_fn')].inner.header.async" true +// @is "$.index[*][?(@.name=='async_fn')].inner.header.const" false +// @is "$.index[*][?(@.name=='async_fn')].inner.header.unsafe" false pub async fn async_fn() {} -// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.async" true -// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.const" false -// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.async" true +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.const" false +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.unsafe" true pub async unsafe fn async_unsafe_fn() {} -// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.async" false -// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.const" true -// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.async" false +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.const" true +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.unsafe" true pub const unsafe fn const_unsafe_fn() {} // It's impossible for a function to be both const and async, so no test for that diff --git a/src/test/rustdoc-json/generic-associated-types/gats.rs b/src/test/rustdoc-json/generic-associated-types/gats.rs index 368ff8d8d..e5809783a 100644 --- a/src/test/rustdoc-json/generic-associated-types/gats.rs +++ b/src/test/rustdoc-json/generic-associated-types/gats.rs @@ -1,44 +1,42 @@ // ignore-tidy-linelength #![no_core] -#![feature(generic_associated_types, lang_items, no_core)] +#![feature(lang_items, no_core)] #[lang = "sized"] pub trait Sized {} pub trait Display {} -// @has gats.json pub trait LendingIterator { - // @count - "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*]" 1 - // @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*].name" \"\'a\" - // @count - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*]" 1 - // @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.type.inner" \"Self\" - // @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.bounds[*].outlives" \"\'a\" - // @count - "$.index[*][?(@.name=='LendingItem')].inner.bounds[*]" 1 + // @count "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*]" 1 + // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*].name" \"\'a\" + // @count "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*]" 1 + // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.type.inner" \"Self\" + // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.bounds[*].outlives" \"\'a\" + // @count "$.index[*][?(@.name=='LendingItem')].inner.bounds[*]" 1 type LendingItem<'a>: Display where Self: 'a; - // @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.kind" \"qualified_path\" - // @count - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 1 - // @count - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 - // @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.self_type.inner" \"Self\" - // @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.name" \"LendingItem\" + // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.kind" \"qualified_path\" + // @count "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 1 + // @count "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 + // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.self_type.inner" \"Self\" + // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.name" \"LendingItem\" fn lending_next<'a>(&'a self) -> Self::LendingItem<'a>; } -// @has gats.json pub trait Iterator { - // @count - "$.index[*][?(@.name=='Item')].inner.generics.params[*]" 0 - // @count - "$.index[*][?(@.name=='Item')].inner.generics.where_predicates[*]" 0 - // @count - "$.index[*][?(@.name=='Item')].inner.bounds[*]" 1 + // @count "$.index[*][?(@.name=='Item')].inner.generics.params[*]" 0 + // @count "$.index[*][?(@.name=='Item')].inner.generics.where_predicates[*]" 0 + // @count "$.index[*][?(@.name=='Item')].inner.bounds[*]" 1 type Item: Display; - // @is - "$.index[*][?(@.name=='next')].inner.decl.output.kind" \"qualified_path\" - // @count - "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 0 - // @count - "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 - // @is - "$.index[*][?(@.name=='next')].inner.decl.output.inner.self_type.inner" \"Self\" - // @is - "$.index[*][?(@.name=='next')].inner.decl.output.inner.name" \"Item\" + // @is "$.index[*][?(@.name=='next')].inner.decl.output.kind" \"qualified_path\" + // @count "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 0 + // @count "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 + // @is "$.index[*][?(@.name=='next')].inner.decl.output.inner.self_type.inner" \"Self\" + // @is "$.index[*][?(@.name=='next')].inner.decl.output.inner.name" \"Item\" fn next<'a>(&'a self) -> Self::Item; } diff --git a/src/test/rustdoc-json/generic_impl.rs b/src/test/rustdoc-json/generic_impl.rs index ac68ba578..31f41d0f3 100644 --- a/src/test/rustdoc-json/generic_impl.rs +++ b/src/test/rustdoc-json/generic_impl.rs @@ -1,9 +1,8 @@ // Regression test for <https://github.com/rust-lang/rust/issues/97986>. -// @has generic_impl.json -// @has - "$.index[*][?(@.name=='f')]" -// @has - "$.index[*][?(@.name=='AssocTy')]" -// @has - "$.index[*][?(@.name=='AssocConst')]" +// @has "$.index[*][?(@.name=='f')]" +// @has "$.index[*][?(@.name=='AssocTy')]" +// @has "$.index[*][?(@.name=='AssocConst')]" pub mod m { pub struct S; diff --git a/src/test/rustdoc-json/glob_import.rs b/src/test/rustdoc-json/glob_import.rs index d7ac952d1..00051b121 100644 --- a/src/test/rustdoc-json/glob_import.rs +++ b/src/test/rustdoc-json/glob_import.rs @@ -4,9 +4,8 @@ #![no_std] #![no_core] -// @has glob_import.json -// @has - "$.index[*][?(@.name=='glob')]" -// @has - "$.index[*][?(@.kind=='import')].inner.name" \"*\" +// @has "$.index[*][?(@.name=='glob')]" +// @has "$.index[*][?(@.kind=='import')].inner.name" \"*\" mod m1 { diff --git a/src/test/rustdoc-json/impls/auto.rs b/src/test/rustdoc-json/impls/auto.rs new file mode 100644 index 000000000..50d852414 --- /dev/null +++ b/src/test/rustdoc-json/impls/auto.rs @@ -0,0 +1,18 @@ +#![feature(no_core, auto_traits, lang_items)] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +pub auto trait Bar {} + +/// has span +impl Foo { + pub fn baz(&self) {} +} + +// Testing spans, so all tests below code +// @is "$.index[*][?(@.kind=='impl' && @.inner.synthetic==true)].span" null +// @is "$.index[*][?(@.docs=='has span')].span.begin" "[10, 0]" +// @is "$.index[*][?(@.docs=='has span')].span.end" "[12, 1]" +pub struct Foo; diff --git a/src/test/rustdoc-json/impls/auxiliary/foreign_struct.rs b/src/test/rustdoc-json/impls/auxiliary/foreign_struct.rs new file mode 100644 index 000000000..832d0fce5 --- /dev/null +++ b/src/test/rustdoc-json/impls/auxiliary/foreign_struct.rs @@ -0,0 +1 @@ +pub struct ForeignStruct; diff --git a/src/test/rustdoc-json/impls/auxiliary/foreign_trait.rs b/src/test/rustdoc-json/impls/auxiliary/foreign_trait.rs new file mode 100644 index 000000000..2c81bee61 --- /dev/null +++ b/src/test/rustdoc-json/impls/auxiliary/foreign_trait.rs @@ -0,0 +1 @@ +pub trait ForeignTrait {} diff --git a/src/test/rustdoc-json/impls/blanket_with_local.rs b/src/test/rustdoc-json/impls/blanket_with_local.rs index a3d55b35f..2fb4a84b9 100644 --- a/src/test/rustdoc-json/impls/blanket_with_local.rs +++ b/src/test/rustdoc-json/impls/blanket_with_local.rs @@ -1,11 +1,11 @@ // Test for the ICE in rust/83718 // A blanket impl plus a local type together shouldn't result in mismatched ID issues -// @has blanket_with_local.json "$.index[*][?(@.name=='Load')]" +// @has "$.index[*][?(@.name=='Load')]" pub trait Load { - // @has - "$.index[*][?(@.name=='load')]" + // @has "$.index[*][?(@.name=='load')]" fn load() {} - // @has - "$.index[*][?(@.name=='write')]" + // @has "$.index[*][?(@.name=='write')]" fn write(self) {} } @@ -14,5 +14,5 @@ impl<P> Load for P { fn write(self) {} } -// @has - "$.index[*][?(@.name=='Wrapper')]" +// @has "$.index[*][?(@.name=='Wrapper')]" pub struct Wrapper {} diff --git a/src/test/rustdoc-json/impls/foreign_for_local.rs b/src/test/rustdoc-json/impls/foreign_for_local.rs new file mode 100644 index 000000000..290c2d571 --- /dev/null +++ b/src/test/rustdoc-json/impls/foreign_for_local.rs @@ -0,0 +1,18 @@ +// aux-build: foreign_trait.rs +extern crate foreign_trait; + +/// ForeignTrait id hack +pub use foreign_trait::ForeignTrait as _; +// @set ForeignTrait = "$.index[*][?(@.docs=='ForeignTrait id hack')].inner.id" + +pub struct LocalStruct; +// @set LocalStruct = "$.index[*][?(@.name=='LocalStruct')].id" + +/// foreign for local +impl foreign_trait::ForeignTrait for LocalStruct {} + +// @set impl = "$.index[*][?(@.docs=='foreign for local')].id" +// @is "$.index[*][?(@.docs=='foreign for local')].inner.for.inner.id" $LocalStruct +// @is "$.index[*][?(@.docs=='foreign for local')].inner.trait.id" $ForeignTrait + +// @has "$.index[*][?(@.name=='LocalStruct')].inner.impls[*]" $impl diff --git a/src/test/rustdoc-json/impls/import_from_private.rs b/src/test/rustdoc-json/impls/import_from_private.rs new file mode 100644 index 000000000..856f7c701 --- /dev/null +++ b/src/test/rustdoc-json/impls/import_from_private.rs @@ -0,0 +1,22 @@ +// https://github.com/rust-lang/rust/issues/100252 + +#![feature(no_core)] +#![no_core] + +mod bar { + // @set baz = "$.index[*][?(@.kind=='struct')].id" + pub struct Baz; + // @set impl = "$.index[*][?(@.kind=='impl')].id" + impl Baz { + // @set doit = "$.index[*][?(@.kind=='method')].id" + pub fn doit() {} + } +} + +// @set import = "$.index[*][?(@.kind=='import')].id" +pub use bar::Baz; + +// @is "$.index[*][?(@.kind=='module')].inner.items[*]" $import +// @is "$.index[*][?(@.kind=='import')].inner.id" $baz +// @is "$.index[*][?(@.kind=='struct')].inner.impls[*]" $impl +// @is "$.index[*][?(@.kind=='impl')].inner.items[*]" $doit diff --git a/src/test/rustdoc-json/impls/local_for_foreign.rs b/src/test/rustdoc-json/impls/local_for_foreign.rs new file mode 100644 index 000000000..74f2f08b5 --- /dev/null +++ b/src/test/rustdoc-json/impls/local_for_foreign.rs @@ -0,0 +1,18 @@ +// aux-build: foreign_struct.rs +extern crate foreign_struct; + +/// ForeignStruct id hack +pub use foreign_struct::ForeignStruct as _; +// @set ForeignStruct = "$.index[*][?(@.docs=='ForeignStruct id hack')].inner.id" + +pub trait LocalTrait {} +// @set LocalTrait = "$.index[*][?(@.name=='LocalTrait')].id" + +/// local for foreign +impl LocalTrait for foreign_struct::ForeignStruct {} + +// @set impl = "$.index[*][?(@.docs=='local for foreign')].id" +// @is "$.index[*][?(@.docs=='local for foreign')].inner.trait.id" $LocalTrait +// @is "$.index[*][?(@.docs=='local for foreign')].inner.for.inner.id" $ForeignStruct + +// @is "$.index[*][?(@.name=='LocalTrait')].inner.implementations[*]" $impl diff --git a/src/test/rustdoc-json/impls/local_for_local.rs b/src/test/rustdoc-json/impls/local_for_local.rs new file mode 100644 index 000000000..93dedb7ec --- /dev/null +++ b/src/test/rustdoc-json/impls/local_for_local.rs @@ -0,0 +1,15 @@ +#![feature(no_core)] +#![no_core] + +// @set struct = "$.index[*][?(@.name=='Struct')].id" +pub struct Struct; +// @set trait = "$.index[*][?(@.name=='Trait')].id" +pub trait Trait {} +// @set impl = "$.index[*][?(@.docs=='impl')].id" +/// impl +impl Trait for Struct {} + +// @is "$.index[*][?(@.name=='Struct')].inner.impls[*]" $impl +// @is "$.index[*][?(@.name=='Trait')].inner.implementations[*]" $impl +// @is "$.index[*][?(@.docs=='impl')].inner.trait.id" $trait +// @is "$.index[*][?(@.docs=='impl')].inner.for.inner.id" $struct diff --git a/src/test/rustdoc-json/impls/local_for_local_primitive.rs b/src/test/rustdoc-json/impls/local_for_local_primitive.rs new file mode 100644 index 000000000..38e7e2658 --- /dev/null +++ b/src/test/rustdoc-json/impls/local_for_local_primitive.rs @@ -0,0 +1,21 @@ +#![feature(no_core)] +#![feature(rustdoc_internals)] +#![no_core] + +// @set Local = "$.index[*][?(@.name=='Local')].id" +pub trait Local {} + +// @is "$.index[*][?(@.docs=='Local for bool')].inner.trait.id" $Local +// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.kind" '"primitive"' +// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.inner" '"bool"' +/// Local for bool +impl Local for bool {} + +// @set impl = "$.index[*][?(@.docs=='Local for bool')].id" +// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl + +// FIXME(#101695): Test bool's `impls` include "Local for bool" +// @has "$.index[*][?(@.name=='bool')]" +#[doc(primitive = "bool")] +/// Boolean docs +mod prim_bool {} diff --git a/src/test/rustdoc-json/impls/local_for_primitive.rs b/src/test/rustdoc-json/impls/local_for_primitive.rs new file mode 100644 index 000000000..7702a526f --- /dev/null +++ b/src/test/rustdoc-json/impls/local_for_primitive.rs @@ -0,0 +1,7 @@ +// @set local = "$.index[*][?(@.name=='Local')]" +pub trait Local {} + +// @set impl = "$.index[*][?(@.docs=='local for bool')].id" +// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl +/// local for bool +impl Local for bool {} diff --git a/src/test/rustdoc-json/intra-doc-links/non_page.rs b/src/test/rustdoc-json/intra-doc-links/non_page.rs new file mode 100644 index 000000000..73c5334bb --- /dev/null +++ b/src/test/rustdoc-json/intra-doc-links/non_page.rs @@ -0,0 +1,34 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/101531>, +// where links where to the item who's HTML page had the item linked to. + +//! [`Struct::struct_field`] +//! [`Enum::Variant`] +//! [`Trait::AssocType`] +//! [`Trait::ASSOC_CONST`] +//! [`Trait::method`] + +// @set struct_field = "$.index[*][?(@.name=='struct_field')].id" +// @set Variant = "$.index[*][?(@.name=='Variant')].id" +// @set AssocType = "$.index[*][?(@.name=='AssocType')].id" +// @set ASSOC_CONST = "$.index[*][?(@.name=='ASSOC_CONST')].id" +// @set method = "$.index[*][?(@.name=='method')].id" + +// @is "$.index[*][?(@.name=='non_page')].links['`Struct::struct_field`']" $struct_field +// @is "$.index[*][?(@.name=='non_page')].links['`Enum::Variant`']" $Variant +// @is "$.index[*][?(@.name=='non_page')].links['`Trait::AssocType`']" $AssocType +// @is "$.index[*][?(@.name=='non_page')].links['`Trait::ASSOC_CONST`']" $ASSOC_CONST +// @is "$.index[*][?(@.name=='non_page')].links['`Trait::method`']" $method + +pub struct Struct { + pub struct_field: i32, +} + +pub enum Enum { + Variant(), +} + +pub trait Trait { + const ASSOC_CONST: i32; + type AssocType; + fn method(); +} diff --git a/src/test/rustdoc-json/intra-doc-links/user_written.rs b/src/test/rustdoc-json/intra-doc-links/user_written.rs new file mode 100644 index 000000000..6871dfea4 --- /dev/null +++ b/src/test/rustdoc-json/intra-doc-links/user_written.rs @@ -0,0 +1,8 @@ +//! For motivation, see [the reasons](foo#reasons) + +/// # Reasons +/// To test rustdoc json +pub fn foo() {} + +// @set foo = "$.index[*][?(@.name=='foo')].id" +// @is "$.index[*][?(@.name=='user_written')].links['foo#reasons']" $foo diff --git a/src/test/rustdoc-json/keyword.rs b/src/test/rustdoc-json/keyword.rs index 78a843aca..3446b212c 100644 --- a/src/test/rustdoc-json/keyword.rs +++ b/src/test/rustdoc-json/keyword.rs @@ -6,16 +6,15 @@ #![feature(rustdoc_internals)] #![no_std] -// @has keyword.json -// @!has - "$.index[*][?(@.name=='match')]" -// @has - "$.index[*][?(@.name=='foo')]" +// @!has "$.index[*][?(@.name=='match')]" +// @has "$.index[*][?(@.name=='foo')]" #[doc(keyword = "match")] /// this is a test! pub mod foo {} -// @!has - "$.index[*][?(@.name=='hello')]" -// @!has - "$.index[*][?(@.name=='bar')]" +// @!has "$.index[*][?(@.name=='hello')]" +// @!has "$.index[*][?(@.name=='bar')]" #[doc(keyword = "hello")] /// hello mod bar {} diff --git a/src/test/rustdoc-json/lifetime/longest.rs b/src/test/rustdoc-json/lifetime/longest.rs index 95b99599e..326dab8e5 100644 --- a/src/test/rustdoc-json/lifetime/longest.rs +++ b/src/test/rustdoc-json/lifetime/longest.rs @@ -3,30 +3,30 @@ #![feature(no_core)] #![no_core] -// @is longest.json "$.index[*][?(@.name=='longest')].inner.generics.params[0].name" \"\'a\" -// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' -// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' -// @count - "$.index[*][?(@.name=='longest')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='longest')].inner.generics.where_predicates" [] +// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' +// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' +// @count "$.index[*][?(@.name=='longest')].inner.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='longest')].inner.generics.where_predicates" [] -// @count - "$.index[*][?(@.name=='longest')].inner.decl.inputs[*]" 2 -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][0]" '"l"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][0]" '"r"' +// @count "$.index[*][?(@.name=='longest')].inner.decl.inputs[*]" 2 +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][0]" '"l"' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][0]" '"r"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.mutable" false -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.type" '{"inner": "str", "kind": "primitive"}' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.mutable" false -// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.type" '{"inner": "str", "kind": "primitive"}' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.mutable" false -// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.decl.output.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.type" '{"inner": "str", "kind": "primitive"}' pub fn longest<'a>(l: &'a str, r: &'a str) -> &'a str { if l.len() > r.len() { l } else { r } diff --git a/src/test/rustdoc-json/lifetime/outlives.rs b/src/test/rustdoc-json/lifetime/outlives.rs index 096dd7f7a..e15a533ef 100644 --- a/src/test/rustdoc-json/lifetime/outlives.rs +++ b/src/test/rustdoc-json/lifetime/outlives.rs @@ -3,21 +3,21 @@ #![feature(no_core)] #![no_core] -// @count outlives.json "$.index[*][?(@.name=='foo')].inner.generics.params[*]" 3 -// @is - "$.index[*][?(@.name=='foo')].inner.generics.where_predicates" [] -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[0].name" \"\'a\" -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[1].name" \"\'b\" -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].name" '"T"' -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[0].kind.lifetime.outlives" [] -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[1].kind.lifetime.outlives" [\"\'a\"] -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.default" null -// @count - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[0].outlives" \"\'b\" -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.mutable" false -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.kind" '"borrowed_ref"' -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.lifetime" \"\'b\" -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.mutable" false -// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.type" '{"inner": "T", "kind": "generic"}' +// @count "$.index[*][?(@.name=='foo')].inner.generics.params[*]" 3 +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates" [] +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[1].name" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].name" '"T"' +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[0].kind.lifetime.outlives" [] +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[1].kind.lifetime.outlives" [\"\'a\"] +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.default" null +// @count "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[*]" 1 +// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[0].outlives" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.mutable" false +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.lifetime" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.mutable" false +// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.type" '{"inner": "T", "kind": "generic"}' pub fn foo<'a, 'b: 'a, T: 'b>(_: &'a &'b T) {} diff --git a/src/test/rustdoc-json/methods/abi.rs b/src/test/rustdoc-json/methods/abi.rs index 07b01d03b..4c97d97ce 100644 --- a/src/test/rustdoc-json/methods/abi.rs +++ b/src/test/rustdoc-json/methods/abi.rs @@ -5,51 +5,51 @@ #![feature(no_core)] #![no_core] -// @has abi.json "$.index[*][?(@.name=='Foo')]" +// @has "$.index[*][?(@.name=='Foo')]" pub struct Foo; impl Foo { - // @is - "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" + // @is "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" pub fn abi_rust() {} - // @is - "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' + // @is "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' pub extern "C" fn abi_c() {} - // @is - "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' + // @is "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' pub extern "system" fn abi_system() {} - // @is - "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' + // @is "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' pub extern "C-unwind" fn abi_c_unwind() {} - // @is - "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' + // @is "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' pub extern "system-unwind" fn abi_system_unwind() {} - // @is - "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' + // @is "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' pub extern "vectorcall" fn abi_vectorcall() {} - // @is - "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' + // @is "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {} } pub trait Bar { - // @is - "$.index[*][?(@.name=='trait_abi_rust')].inner.header.abi" \"Rust\" + // @is "$.index[*][?(@.name=='trait_abi_rust')].inner.header.abi" \"Rust\" fn trait_abi_rust() {} - // @is - "$.index[*][?(@.name=='trait_abi_c')].inner.header.abi" '{"C": {"unwind": false}}' + // @is "$.index[*][?(@.name=='trait_abi_c')].inner.header.abi" '{"C": {"unwind": false}}' extern "C" fn trait_abi_c() {} - // @is - "$.index[*][?(@.name=='trait_abi_system')].inner.header.abi" '{"System": {"unwind": false}}' + // @is "$.index[*][?(@.name=='trait_abi_system')].inner.header.abi" '{"System": {"unwind": false}}' extern "system" fn trait_abi_system() {} - // @is - "$.index[*][?(@.name=='trait_abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' + // @is "$.index[*][?(@.name=='trait_abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' extern "C-unwind" fn trait_abi_c_unwind() {} - // @is - "$.index[*][?(@.name=='trait_abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' + // @is "$.index[*][?(@.name=='trait_abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' extern "system-unwind" fn trait_abi_system_unwind() {} - // @is - "$.index[*][?(@.name=='trait_abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' + // @is "$.index[*][?(@.name=='trait_abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' extern "vectorcall" fn trait_abi_vectorcall() {} - // @is - "$.index[*][?(@.name=='trait_abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' + // @is "$.index[*][?(@.name=='trait_abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' extern "vectorcall-unwind" fn trait_abi_vectorcall_unwind() {} } diff --git a/src/test/rustdoc-json/methods/qualifiers.rs b/src/test/rustdoc-json/methods/qualifiers.rs index af36d36b6..b9a5e5601 100644 --- a/src/test/rustdoc-json/methods/qualifiers.rs +++ b/src/test/rustdoc-json/methods/qualifiers.rs @@ -3,34 +3,34 @@ pub struct Foo; impl Foo { - // @is qualifiers.json "$.index[*][?(@.name=='const_meth')].inner.header.async" false - // @is - "$.index[*][?(@.name=='const_meth')].inner.header.const" true - // @is - "$.index[*][?(@.name=='const_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='const_meth')].inner.header.async" false + // @is "$.index[*][?(@.name=='const_meth')].inner.header.const" true + // @is "$.index[*][?(@.name=='const_meth')].inner.header.unsafe" false pub const fn const_meth() {} - // @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.async" false - // @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.const" false - // @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.async" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.const" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.unsafe" false pub fn nothing_meth() {} - // @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.async" false - // @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.const" false - // @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.async" false + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.const" false + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.unsafe" true pub unsafe fn unsafe_meth() {} - // @is - "$.index[*][?(@.name=='async_meth')].inner.header.async" true - // @is - "$.index[*][?(@.name=='async_meth')].inner.header.const" false - // @is - "$.index[*][?(@.name=='async_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='async_meth')].inner.header.async" true + // @is "$.index[*][?(@.name=='async_meth')].inner.header.const" false + // @is "$.index[*][?(@.name=='async_meth')].inner.header.unsafe" false pub async fn async_meth() {} - // @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.async" true - // @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.const" false - // @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.async" true + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.const" false + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.unsafe" true pub async unsafe fn async_unsafe_meth() {} - // @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.async" false - // @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.const" true - // @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.async" false + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.const" true + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.unsafe" true pub const unsafe fn const_unsafe_meth() {} // It's impossible for a method to be both const and async, so no test for that diff --git a/src/test/rustdoc-json/nested.rs b/src/test/rustdoc-json/nested.rs index b0e717d8a..ee2d2efa9 100644 --- a/src/test/rustdoc-json/nested.rs +++ b/src/test/rustdoc-json/nested.rs @@ -1,30 +1,31 @@ // edition:2018 // compile-flags: --crate-version 1.0.0 -// @is nested.json "$.crate_version" \"1.0.0\" -// @is - "$.index[*][?(@.name=='nested')].kind" \"module\" -// @is - "$.index[*][?(@.name=='nested')].inner.is_crate" true -// @count - "$.index[*][?(@.name=='nested')].inner.items[*]" 1 +// @is "$.crate_version" \"1.0.0\" +// @is "$.index[*][?(@.name=='nested')].kind" \"module\" +// @is "$.index[*][?(@.name=='nested')].inner.is_crate" true -// @is nested.json "$.index[*][?(@.name=='l1')].kind" \"module\" -// @is - "$.index[*][?(@.name=='l1')].inner.is_crate" false -// @count - "$.index[*][?(@.name=='l1')].inner.items[*]" 2 -pub mod l1 { +// @set l1_id = "$.index[*][?(@.name=='l1')].id" +// @ismany "$.index[*][?(@.name=='nested')].inner.items[*]" $l1_id - // @is nested.json "$.index[*][?(@.name=='l3')].kind" \"module\" - // @is - "$.index[*][?(@.name=='l3')].inner.is_crate" false - // @count - "$.index[*][?(@.name=='l3')].inner.items[*]" 1 - // @set l3_id = - "$.index[*][?(@.name=='l3')].id" - // @has - "$.index[*][?(@.name=='l1')].inner.items[*]" $l3_id +// @is "$.index[*][?(@.name=='l1')].kind" \"module\" +// @is "$.index[*][?(@.name=='l1')].inner.is_crate" false +pub mod l1 { + // @is "$.index[*][?(@.name=='l3')].kind" \"module\" + // @is "$.index[*][?(@.name=='l3')].inner.is_crate" false + // @set l3_id = "$.index[*][?(@.name=='l3')].id" pub mod l3 { - // @is nested.json "$.index[*][?(@.name=='L4')].kind" \"struct\" - // @is - "$.index[*][?(@.name=='L4')].inner.struct_type" \"unit\" - // @set l4_id = - "$.index[*][?(@.name=='L4')].id" - // @has - "$.index[*][?(@.name=='l3')].inner.items[*]" $l4_id + // @is "$.index[*][?(@.name=='L4')].kind" \"struct\" + // @is "$.index[*][?(@.name=='L4')].inner.kind" \"unit\" + // @set l4_id = "$.index[*][?(@.name=='L4')].id" + // @ismany "$.index[*][?(@.name=='l3')].inner.items[*]" $l4_id pub struct L4; } - // @is nested.json "$.index[*][?(@.inner.source=='l3::L4')].kind" \"import\" - // @is - "$.index[*][?(@.inner.source=='l3::L4')].inner.glob" false + // @is "$.index[*][?(@.inner.source=='l3::L4')].kind" \"import\" + // @is "$.index[*][?(@.inner.source=='l3::L4')].inner.glob" false + // @is "$.index[*][?(@.inner.source=='l3::L4')].inner.id" $l4_id + // @set l4_use_id = "$.index[*][?(@.inner.source=='l3::L4')].id" pub use l3::L4; } +// @ismany "$.index[*][?(@.name=='l1')].inner.items[*]" $l3_id $l4_use_id diff --git a/src/test/rustdoc-json/output_generics.rs b/src/test/rustdoc-json/output_generics.rs index d80656c7f..04b1a358f 100644 --- a/src/test/rustdoc-json/output_generics.rs +++ b/src/test/rustdoc-json/output_generics.rs @@ -2,12 +2,11 @@ // This is a regression test for #98009. -// @has output_generics.json -// @has - "$.index[*][?(@.name=='this_compiles')]" -// @has - "$.index[*][?(@.name=='this_does_not')]" -// @has - "$.index[*][?(@.name=='Events')]" -// @has - "$.index[*][?(@.name=='Other')]" -// @has - "$.index[*][?(@.name=='Trait')]" +// @has "$.index[*][?(@.name=='this_compiles')]" +// @has "$.index[*][?(@.name=='this_does_not')]" +// @has "$.index[*][?(@.name=='Events')]" +// @has "$.index[*][?(@.name=='Other')]" +// @has "$.index[*][?(@.name=='Trait')]" struct Events<R>(R); diff --git a/src/test/rustdoc-json/primitive.rs b/src/test/rustdoc-json/primitive.rs index b84c2f7c6..6454dd7f5 100644 --- a/src/test/rustdoc-json/primitive.rs +++ b/src/test/rustdoc-json/primitive.rs @@ -5,10 +5,16 @@ #[doc(primitive = "usize")] mod usize {} -// @set local_crate_id = primitive.json "$.index[*][?(@.name=='primitive')].crate_id" +// @set local_crate_id = "$.index[*][?(@.name=='primitive')].crate_id" -// @has - "$.index[*][?(@.name=='log10')]" -// @!is - "$.index[*][?(@.name=='log10')].crate_id" $local_crate_id -// @has - "$.index[*][?(@.name=='checked_add')]" -// @!is - "$.index[*][?(@.name=='checked_add')]" $local_crate_id -// @!has - "$.index[*][?(@.name=='is_ascii_uppercase')]" +// @has "$.index[*][?(@.name=='ilog10')]" +// @!is "$.index[*][?(@.name=='ilog10')].crate_id" $local_crate_id +// @has "$.index[*][?(@.name=='checked_add')]" +// @!is "$.index[*][?(@.name=='checked_add')]" $local_crate_id +// @!has "$.index[*][?(@.name=='is_ascii_uppercase')]" + +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='my_i32')].inner.id" null +pub use i32 as my_i32; + +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='u32')].inner.id" null +pub use u32; diff --git a/src/test/rustdoc-json/primitive_overloading.rs b/src/test/rustdoc-json/primitive_overloading.rs index a10d5a837..56b35cd14 100644 --- a/src/test/rustdoc-json/primitive_overloading.rs +++ b/src/test/rustdoc-json/primitive_overloading.rs @@ -7,9 +7,8 @@ #![no_core] -// @has primitive_overloading.json -// @has - "$.index[*][?(@.name=='usize')]" -// @has - "$.index[*][?(@.name=='prim')]" +// @has "$.index[*][?(@.name=='usize')]" +// @has "$.index[*][?(@.name=='prim')]" #[doc(primitive = "usize")] /// This is the built-in type `usize`. diff --git a/src/test/rustdoc-json/primitives.rs b/src/test/rustdoc-json/primitives.rs index fd04f04da..8024044bc 100644 --- a/src/test/rustdoc-json/primitives.rs +++ b/src/test/rustdoc-json/primitives.rs @@ -1,22 +1,22 @@ #![feature(never_type)] -// @has primitives.json "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='PrimNever')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimNever')].inner.type.inner" \"never\" +// @is "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.type.inner" \"never\" pub type PrimNever = !; -// @has - "$.index[*][?(@.name=='PrimStr')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimStr')].inner.type.inner" \"str\" +// @is "$.index[*][?(@.name=='PrimStr')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimStr')].inner.type.inner" \"str\" pub type PrimStr = str; -// @has - "$.index[*][?(@.name=='PrimBool')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimBool')].inner.type.inner" \"bool\" +// @is "$.index[*][?(@.name=='PrimBool')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimBool')].inner.type.inner" \"bool\" pub type PrimBool = bool; -// @has - "$.index[*][?(@.name=='PrimChar')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimChar')].inner.type.inner" \"char\" +// @is "$.index[*][?(@.name=='PrimChar')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimChar')].inner.type.inner" \"char\" pub type PrimChar = char; -// @has - "$.index[*][?(@.name=='PrimU8')].inner.type.kind" \"primitive\" -// @has - "$.index[*][?(@.name=='PrimU8')].inner.type.inner" \"u8\" +// @is "$.index[*][?(@.name=='PrimU8')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimU8')].inner.type.inner" \"u8\" pub type PrimU8 = u8; diff --git a/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs b/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs new file mode 100644 index 000000000..f076feb71 --- /dev/null +++ b/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs @@ -0,0 +1,11 @@ +//! Regression test for <https://github.com/rust-lang/rust/issues/100531> + +#![feature(no_core)] +#![no_core] + +#![crate_name = "export_extern_crate_as_self"] + +// ignore-tidy-linelength + +// @is "$.index[*][?(@.kind=='module')].name" \"export_extern_crate_as_self\" +pub extern crate self as export_extern_crate_as_self; // Must be the same name as the crate already has diff --git a/src/test/rustdoc-json/reexport/glob_collision.rs b/src/test/rustdoc-json/reexport/glob_collision.rs new file mode 100644 index 000000000..f91144dbf --- /dev/null +++ b/src/test/rustdoc-json/reexport/glob_collision.rs @@ -0,0 +1,28 @@ +// Regression test for https://github.com/rust-lang/rust/issues/100973 + +#![feature(no_core)] +#![no_core] + +// @set m1 = "$.index[*][?(@.name == 'm1' && @.kind == 'module')].id" +// @is "$.index[*][?(@.name == 'm1' && @.kind == 'module')].inner.items" [] +// @is "$.index[*][?(@.name == 'm1' && @.kind == 'module')].inner.is_stripped" true +mod m1 { + pub fn f() {} +} +// @set m2 = "$.index[*][?(@.name == 'm2' && @.kind == 'module')].id" +// @is "$.index[*][?(@.name == 'm2' && @.kind == 'module')].inner.items" [] +// @is "$.index[*][?(@.name == 'm2' && @.kind == 'module')].inner.is_stripped" true +mod m2 { + pub fn f(_: u8) {} +} + +// @set m1_use = "$.index[*][?(@.inner.name=='m1')].id" +// @is "$.index[*][?(@.inner.name=='m1')].inner.id" $m1 +// @is "$.index[*][?(@.inner.name=='m1')].inner.glob" true +pub use m1::*; +// @set m2_use = "$.index[*][?(@.inner.name=='m2')].id" +// @is "$.index[*][?(@.inner.name=='m2')].inner.id" $m2 +// @is "$.index[*][?(@.inner.name=='m2')].inner.glob" true +pub use m2::*; + +// @ismany "$.index[*][?(@.inner.is_crate==true)].inner.items[*]" $m1_use $m2_use diff --git a/src/test/rustdoc-json/reexport/glob_empty_mod.rs b/src/test/rustdoc-json/reexport/glob_empty_mod.rs new file mode 100644 index 000000000..da6822835 --- /dev/null +++ b/src/test/rustdoc-json/reexport/glob_empty_mod.rs @@ -0,0 +1,8 @@ +// Regression test for https://github.com/rust-lang/rust/issues/100973 + +// @is "$.index[*][?(@.name=='m1' && @.kind == 'module')].inner.is_stripped" true +// @set m1 = "$.index[*][?(@.name=='m1')].id" +mod m1 {} + +// @is "$.index[*][?(@.inner.name=='m1' && @.kind=='import')].inner.id" $m1 +pub use m1::*; diff --git a/src/test/rustdoc-json/reexport/glob_extern.rs b/src/test/rustdoc-json/reexport/glob_extern.rs index ba1cfd8a0..7a1e8c11f 100644 --- a/src/test/rustdoc-json/reexport/glob_extern.rs +++ b/src/test/rustdoc-json/reexport/glob_extern.rs @@ -3,16 +3,21 @@ #![no_core] #![feature(no_core)] -// @is glob_extern.json "$.index[*][?(@.name=='mod1')].kind" \"module\" -// @is glob_extern.json "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" +// @is "$.index[*][?(@.name=='mod1')].kind" \"module\" +// @is "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" mod mod1 { extern "C" { - // @has - "$.index[*][?(@.name=='public_fn')].id" + // @set public_fn_id = "$.index[*][?(@.name=='public_fn')].id" pub fn public_fn(); - // @!has - "$.index[*][?(@.name=='private_fn')]" + // @!has "$.index[*][?(@.name=='private_fn')]" fn private_fn(); } + // @ismany "$.index[*][?(@.name=='mod1')].inner.items[*]" $public_fn_id + // @set mod1_id = "$.index[*][?(@.name=='mod1')].id" } -// @is - "$.index[*][?(@.kind=='import')].inner.glob" true +// @is "$.index[*][?(@.kind=='import')].inner.glob" true +// @is "$.index[*][?(@.kind=='import')].inner.id" $mod1_id +// @set use_id = "$.index[*][?(@.kind=='import')].id" +// @ismany "$.index[*][?(@.name=='glob_extern')].inner.items[*]" $use_id pub use mod1::*; diff --git a/src/test/rustdoc-json/reexport/glob_private.rs b/src/test/rustdoc-json/reexport/glob_private.rs index e6a44748c..3a83a2081 100644 --- a/src/test/rustdoc-json/reexport/glob_private.rs +++ b/src/test/rustdoc-json/reexport/glob_private.rs @@ -3,30 +3,31 @@ #![no_core] #![feature(no_core)] -// @is glob_private.json "$.index[*][?(@.name=='mod1')].kind" \"module\" -// @is glob_private.json "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" +// @is "$.index[*][?(@.name=='mod1')].kind" \"module\" +// @is "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" mod mod1 { - // @is - "$.index[*][?(@.name=='mod2')].kind" \"module\" - // @is - "$.index[*][?(@.name=='mod2')].inner.is_stripped" "true" + // @is "$.index[*][?(@.name=='mod2')].kind" \"module\" + // @is "$.index[*][?(@.name=='mod2')].inner.is_stripped" "true" mod mod2 { - // @set m2pub_id = - "$.index[*][?(@.name=='Mod2Public')].id" + // @set m2pub_id = "$.index[*][?(@.name=='Mod2Public')].id" pub struct Mod2Public; - // @!has - "$.index[*][?(@.name=='Mod2Private')]" + // @!has "$.index[*][?(@.name=='Mod2Private')]" struct Mod2Private; } - // @has - "$.index[*][?(@.kind=='import' && @.inner.name=='mod2')]" + // @set mod2_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod2')].id" pub use self::mod2::*; - // @set m1pub_id = - "$.index[*][?(@.name=='Mod1Public')].id" + // @set m1pub_id = "$.index[*][?(@.name=='Mod1Public')].id" pub struct Mod1Public; - // @!has - "$.index[*][?(@.name=='Mod1Private')]" + // @!has "$.index[*][?(@.name=='Mod1Private')]" struct Mod1Private; } -// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')]" +// @set mod1_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')].id" pub use mod1::*; -// @has - "$.index[*][?(@.name=='mod2')].inner.items[*]" $m2pub_id -// @has - "$.index[*][?(@.name=='mod1')].inner.items[*]" $m1pub_id +// @ismany "$.index[*][?(@.name=='mod2')].inner.items[*]" $m2pub_id +// @ismany "$.index[*][?(@.name=='mod1')].inner.items[*]" $m1pub_id $mod2_use_id +// @ismany "$.index[*][?(@.name=='glob_private')].inner.items[*]" $mod1_use_id diff --git a/src/test/rustdoc-json/reexport/in_root_and_mod.rs b/src/test/rustdoc-json/reexport/in_root_and_mod.rs index 7bf10a986..7b97ebf21 100644 --- a/src/test/rustdoc-json/reexport/in_root_and_mod.rs +++ b/src/test/rustdoc-json/reexport/in_root_and_mod.rs @@ -1,17 +1,16 @@ #![feature(no_core)] #![no_core] -// @is in_root_and_mod.json "$.index[*][?(@.name=='foo')].kind" \"module\" -// @is in_root_and_mod.json "$.index[*][?(@.name=='foo')].inner.is_stripped" "true" +// @!has "$.index[*][?(@.name=='foo')]" mod foo { - // @has - "$.index[*][?(@.name=='Foo')]" + // @has "$.index[*][?(@.name=='Foo')]" pub struct Foo; } -// @has - "$.index[*][?(@.kind=='import' && @.inner.source=='foo::Foo')]" +// @has "$.index[*][?(@.kind=='import' && @.inner.source=='foo::Foo')]" pub use foo::Foo; pub mod bar { - // @has - "$.index[*][?(@.kind=='import' && @.inner.source=='crate::foo::Foo')]" + // @has "$.index[*][?(@.kind=='import' && @.inner.source=='crate::foo::Foo')]" pub use crate::foo::Foo; } diff --git a/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs b/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs index 2daadf762..f6d932d92 100644 --- a/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs +++ b/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs @@ -2,19 +2,19 @@ #![no_core] pub mod foo { - // @set bar_id = in_root_and_mod_pub.json "$.index[*][?(@.name=='Bar')].id" - // @has - "$.index[*][?(@.name=='foo')].inner.items[*]" $bar_id + // @set bar_id = "$.index[*][?(@.name=='Bar')].id" + // @ismany "$.index[*][?(@.name=='foo')].inner.items[*]" $bar_id pub struct Bar; } -// @set root_import_id = - "$.index[*][?(@.inner.source=='foo::Bar')].id" -// @is - "$.index[*][?(@.inner.source=='foo::Bar')].inner.id" $bar_id -// @has - "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.items[*]" $root_import_id +// @set root_import_id = "$.index[*][?(@.inner.source=='foo::Bar')].id" +// @is "$.index[*][?(@.inner.source=='foo::Bar')].inner.id" $bar_id +// @has "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.items[*]" $root_import_id pub use foo::Bar; pub mod baz { - // @set baz_import_id = - "$.index[*][?(@.inner.source=='crate::foo::Bar')].id" - // @is - "$.index[*][?(@.inner.source=='crate::foo::Bar')].inner.id" $bar_id - // @has - "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id + // @set baz_import_id = "$.index[*][?(@.inner.source=='crate::foo::Bar')].id" + // @is "$.index[*][?(@.inner.source=='crate::foo::Bar')].inner.id" $bar_id + // @ismany "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id pub use crate::foo::Bar; } diff --git a/src/test/rustdoc-json/reexport/macro.rs b/src/test/rustdoc-json/reexport/macro.rs index b86614ffb..b4882100f 100644 --- a/src/test/rustdoc-json/reexport/macro.rs +++ b/src/test/rustdoc-json/reexport/macro.rs @@ -3,15 +3,13 @@ #![no_core] #![feature(no_core)] -// @count macro.json "$.index[*][?(@.name=='macro')].inner.items[*]" 2 - -// @set repro_id = macro.json "$.index[*][?(@.name=='repro')].id" -// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id +// @set repro_id = "$.index[*][?(@.name=='repro')].id" #[macro_export] macro_rules! repro { () => {}; } -// @set repro2_id = macro.json "$.index[*][?(@.inner.name=='repro2')].id" -// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro2_id +// @set repro2_id = "$.index[*][?(@.inner.name=='repro2')].id" pub use crate::repro as repro2; + +// @ismany "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id $repro2_id diff --git a/src/test/rustdoc-json/reexport/mod_not_included.rs b/src/test/rustdoc-json/reexport/mod_not_included.rs new file mode 100644 index 000000000..7b7600ef2 --- /dev/null +++ b/src/test/rustdoc-json/reexport/mod_not_included.rs @@ -0,0 +1,14 @@ +// Regression test for https://github.com/rust-lang/rust/issues/101103 + +#![feature(no_core)] +#![no_core] + +mod m1 { + pub fn x() {} +} + +pub use m1::x; + +// @has "$.index[*][?(@.name=='x' && @.kind=='function')]" +// @has "$.index[*][?(@.kind=='import' && @.inner.name=='x')].inner.source" '"m1::x"' +// @!has "$.index[*][?(@.name=='m1')]" diff --git a/src/test/rustdoc-json/reexport/private_twice_one_inline.rs b/src/test/rustdoc-json/reexport/private_twice_one_inline.rs index 327b0f45f..687a3b2ac 100644 --- a/src/test/rustdoc-json/reexport/private_twice_one_inline.rs +++ b/src/test/rustdoc-json/reexport/private_twice_one_inline.rs @@ -1,18 +1,28 @@ // aux-build:pub-struct.rs +// ignore-tidy-linelength -// Test for the ICE in rust/83057 -// Am external type re-exported with different attributes shouldn't cause an error +// Test for the ICE in https://github.com/rust-lang/rust/issues/83057 +// An external type re-exported with different attributes shouldn't cause an error #![no_core] #![feature(no_core)] extern crate pub_struct as foo; - #[doc(inline)] + +// @set crate_use_id = "$.index[*][?(@.docs=='Hack A')].id" +// @set foo_id = "$.index[*][?(@.docs=='Hack A')].inner.id" +/// Hack A pub use foo::Foo; +// @set bar_id = "$.index[*][?(@.name=='bar')].id" pub mod bar { + // @is "$.index[*][?(@.docs=='Hack B')].inner.id" $foo_id + // @set bar_use_id = "$.index[*][?(@.docs=='Hack B')].id" + // @ismany "$.index[*][?(@.name=='bar')].inner.items[*]" $bar_use_id + /// Hack B pub use foo::Foo; } -// @count private_twice_one_inline.json "$.index[*][?(@.kind=='import')]" 2 +// @ismany "$.index[*][?(@.kind=='import')].id" $crate_use_id $bar_use_id +// @ismany "$.index[*][?(@.name=='private_twice_one_inline')].inner.items[*]" $bar_id $crate_use_id diff --git a/src/test/rustdoc-json/reexport/private_two_names.rs b/src/test/rustdoc-json/reexport/private_two_names.rs index 36d6a50d3..9858538a9 100644 --- a/src/test/rustdoc-json/reexport/private_two_names.rs +++ b/src/test/rustdoc-json/reexport/private_two_names.rs @@ -1,17 +1,22 @@ -// Test for the ICE in rust/83720 +// ignore-tidy-linelength + +// Test for the ICE in https://github.com/rust-lang/rust/issues/83720 // A pub-in-private type re-exported under two different names shouldn't cause an error #![no_core] #![feature(no_core)] -// @is private_two_names.json "$.index[*][?(@.name=='style')].kind" \"module\" -// @is private_two_names.json "$.index[*][?(@.name=='style')].inner.is_stripped" "true" +// @!has "$.index[*][?(@.name=='style')]" mod style { - // @has - "$.index[*](?(@.name=='Color'))" + // @set color_struct_id = "$.index[*][?(@.kind=='struct' && @.name=='Color')].id" pub struct Color; } -// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='Color')]" +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].inner.id" $color_struct_id +// @set color_export_id = "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].id" pub use style::Color; -// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')]" +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].inner.id" $color_struct_id +// @set colour_export_id = "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].id" pub use style::Color as Colour; + +// @ismany "$.index[*][?(@.name=='private_two_names')].inner.items[*]" $color_export_id $colour_export_id diff --git a/src/test/rustdoc-json/reexport/rename_private.rs b/src/test/rustdoc-json/reexport/rename_private.rs index 2476399bd..8fd850f9b 100644 --- a/src/test/rustdoc-json/reexport/rename_private.rs +++ b/src/test/rustdoc-json/reexport/rename_private.rs @@ -3,12 +3,11 @@ #![no_core] #![feature(no_core)] -// @is rename_private.json "$.index[*][?(@.name=='inner')].kind" \"module\" -// @is rename_private.json "$.index[*][?(@.name=='inner')].inner.is_stripped" "true" +// @!has "$.index[*][?(@.kind=='inner')]" mod inner { - // @has - "$.index[*][?(@.name=='Public')]" + // @has "$.index[*][?(@.name=='Public')]" pub struct Public; } -// @is - "$.index[*][?(@.kind=='import')].inner.name" \"NewName\" +// @is "$.index[*][?(@.kind=='import')].inner.name" \"NewName\" pub use inner::Public as NewName; diff --git a/src/test/rustdoc-json/reexport/rename_public.rs b/src/test/rustdoc-json/reexport/rename_public.rs index 2dd438d22..e30907fe2 100644 --- a/src/test/rustdoc-json/reexport/rename_public.rs +++ b/src/test/rustdoc-json/reexport/rename_public.rs @@ -3,15 +3,15 @@ #![no_core] #![feature(no_core)] -// @set inner_id = rename_public.json "$.index[*][?(@.name=='inner')].id" -// @has - "$.index[*][?(@.name=='rename_public')].inner.items[*]" $inner_id +// @set inner_id = "$.index[*][?(@.name=='inner')].id" pub mod inner { - // @set public_id = - "$.index[*][?(@.name=='Public')].id" - // @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id + // @set public_id = "$.index[*][?(@.name=='Public')].id" + // @ismany "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id pub struct Public; } -// @set import_id = - "$.index[*][?(@.inner.name=='NewName')].id" -// @!has - "$.index[*][?(@.inner.name=='Public')]" -// @has - "$.index[*][?(@.name=='rename_public')].inner.items[*]" $import_id -// @is - "$.index[*][?(@.inner.name=='NewName')].inner.source" \"inner::Public\" +// @set import_id = "$.index[*][?(@.inner.name=='NewName')].id" +// @!has "$.index[*][?(@.inner.name=='Public')]" +// @is "$.index[*][?(@.inner.name=='NewName')].inner.source" \"inner::Public\" pub use inner::Public as NewName; + +// @ismany "$.index[*][?(@.name=='rename_public')].inner.items[*]" $inner_id $import_id diff --git a/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs b/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs index eedddd6a7..880dbdc44 100644 --- a/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs +++ b/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs @@ -1,15 +1,21 @@ +// ignore-tidy-linelength + // Regression test for <https://github.com/rust-lang/rust/issues/97432>. #![feature(no_core)] #![no_std] #![no_core] -// @has same_type_reexported_more_than_once.json -// @has - "$.index[*][?(@.name=='Trait')]" -pub use inner::Trait; -// @has - "$.index[*].inner[?(@.name=='Reexport')].id" -pub use inner::Trait as Reexport; - mod inner { + // @set trait_id = "$.index[*][?(@.name=='Trait')].id" pub trait Trait {} } + +// @set export_id = "$.index[*][?(@.inner.name=='Trait')].id" +// @is "$.index[*][?(@.inner.name=='Trait')].inner.id" $trait_id +pub use inner::Trait; +// @set reexport_id = "$.index[*][?(@.inner.name=='Reexport')].id" +// @is "$.index[*][?(@.inner.name=='Reexport')].inner.id" $trait_id +pub use inner::Trait as Reexport; + +// @ismany "$.index[*][?(@.name=='same_type_reexported_more_than_once')].inner.items[*]" $reexport_id $export_id diff --git a/src/test/rustdoc-json/reexport/simple_private.rs b/src/test/rustdoc-json/reexport/simple_private.rs index 5ec13e403..d058ce059 100644 --- a/src/test/rustdoc-json/reexport/simple_private.rs +++ b/src/test/rustdoc-json/reexport/simple_private.rs @@ -2,14 +2,15 @@ #![no_core] #![feature(no_core)] -// @is simple_private.json "$.index[*][?(@.name=='inner')].kind" \"module\" -// @is simple_private.json "$.index[*][?(@.name=='inner')].inner.is_stripped" "true" +// @!has "$.index[*][?(@.name=='inner')]" mod inner { - // @set pub_id = - "$.index[*][?(@.name=='Public')].id" + // @set pub_id = "$.index[*][?(@.name=='Public')].id" pub struct Public; } -// @is - "$.index[*][?(@.kind=='import')].inner.name" \"Public\" +// @is "$.index[*][?(@.kind=='import')].inner.name" \"Public\" +// @is "$.index[*][?(@.kind=='import')].inner.id" $pub_id +// @set use_id = "$.index[*][?(@.kind=='import')].id" pub use inner::Public; -// @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $pub_id +// @ismany "$.index[*][?(@.name=='simple_private')].inner.items[*]" $use_id diff --git a/src/test/rustdoc-json/reexport/simple_public.rs b/src/test/rustdoc-json/reexport/simple_public.rs index 2e4de301f..e64a0dcb7 100644 --- a/src/test/rustdoc-json/reexport/simple_public.rs +++ b/src/test/rustdoc-json/reexport/simple_public.rs @@ -3,16 +3,16 @@ #![no_core] #![feature(no_core)] -// @set inner_id = simple_public.json "$.index[*][?(@.name=='inner')].id" -// @has - "$.index[*][?(@.name=='simple_public')].inner.items[*]" $inner_id +// @set inner_id = "$.index[*][?(@.name=='inner')].id" pub mod inner { - // @set public_id = - "$.index[*][?(@.name=='Public')].id" - // @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id + // @set public_id = "$.index[*][?(@.name=='Public')].id" + // @ismany "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id pub struct Public; } -// @set import_id = - "$.index[*][?(@.inner.name=='Public')].id" -// @has - "$.index[*][?(@.name=='simple_public')].inner.items[*]" $import_id -// @is - "$.index[*][?(@.inner.name=='Public')].inner.source" \"inner::Public\" +// @set import_id = "$.index[*][?(@.inner.name=='Public')].id" +// @is "$.index[*][?(@.inner.name=='Public')].inner.source" \"inner::Public\" pub use inner::Public; + +// @ismany "$.index[*][?(@.name=='simple_public')].inner.items[*]" $import_id $inner_id diff --git a/src/test/rustdoc-json/return_private.rs b/src/test/rustdoc-json/return_private.rs index 6b324d009..a8d1fae30 100644 --- a/src/test/rustdoc-json/return_private.rs +++ b/src/test/rustdoc-json/return_private.rs @@ -8,8 +8,8 @@ mod secret { pub struct Secret; } -// @is return_private.json "$.index[*][?(@.name=='get_secret')].kind" \"function\" -// @is return_private.json "$.index[*][?(@.name=='get_secret')].inner.decl.output.inner.name" \"secret::Secret\" +// @is "$.index[*][?(@.name=='get_secret')].kind" \"function\" +// @is "$.index[*][?(@.name=='get_secret')].inner.decl.output.inner.name" \"secret::Secret\" pub fn get_secret() -> secret::Secret { secret::Secret } diff --git a/src/test/rustdoc-json/stripped_modules.rs b/src/test/rustdoc-json/stripped_modules.rs index 91f9f02ad..d2664b49e 100644 --- a/src/test/rustdoc-json/stripped_modules.rs +++ b/src/test/rustdoc-json/stripped_modules.rs @@ -1,20 +1,20 @@ #![no_core] #![feature(no_core)] -// @!has stripped_modules.json "$.index[*][?(@.name=='no_pub_inner')]" +// @!has "$.index[*][?(@.name=='no_pub_inner')]" mod no_pub_inner { fn priv_inner() {} } -// @!has - "$.index[*][?(@.name=='pub_inner_unreachable')]" +// @!has "$.index[*][?(@.name=='pub_inner_unreachable')]" mod pub_inner_unreachable { - // @!has - "$.index[*][?(@.name=='pub_inner_1')]" + // @!has "$.index[*][?(@.name=='pub_inner_1')]" pub fn pub_inner_1() {} } -// @has - "$.index[*][?(@.name=='pub_inner_reachable')]" +// @!has "$.index[*][?(@.name=='pub_inner_reachable')]" mod pub_inner_reachable { - // @has - "$.index[*][?(@.name=='pub_inner_2')]" + // @has "$.index[*][?(@.name=='pub_inner_2')]" pub fn pub_inner_2() {} } diff --git a/src/test/rustdoc-json/structs/plain_all_pub.rs b/src/test/rustdoc-json/structs/plain_all_pub.rs new file mode 100644 index 000000000..b86ab93c2 --- /dev/null +++ b/src/test/rustdoc-json/structs/plain_all_pub.rs @@ -0,0 +1,11 @@ +pub struct Demo { + pub x: i32, + pub y: i32, +} + +// @set x = "$.index[*][?(@.name=='x')].id" +// @set y = "$.index[*][?(@.name=='y')].id" +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[1]" $y +// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 2 +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" false diff --git a/src/test/rustdoc-json/structs/plain_doc_hidden.rs b/src/test/rustdoc-json/structs/plain_doc_hidden.rs new file mode 100644 index 000000000..7800b55a4 --- /dev/null +++ b/src/test/rustdoc-json/structs/plain_doc_hidden.rs @@ -0,0 +1,11 @@ +pub struct Demo { + pub x: i32, + #[doc(hidden)] + pub y: i32, +} + +// @set x = "$.index[*][?(@.name=='x')].id" +// @!has "$.index[*][?(@.name=='y')].id" +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x +// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 1 +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" true diff --git a/src/test/rustdoc-json/structs/plain_empty.rs b/src/test/rustdoc-json/structs/plain_empty.rs index a251caf4b..1d01b8bc1 100644 --- a/src/test/rustdoc-json/structs/plain_empty.rs +++ b/src/test/rustdoc-json/structs/plain_empty.rs @@ -1,6 +1,5 @@ -// @has plain_empty.json "$.index[*][?(@.name=='PlainEmpty')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='PlainEmpty')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='PlainEmpty')].inner.struct_type" \"plain\" -// @has - "$.index[*][?(@.name=='PlainEmpty')].inner.fields_stripped" false -// @has - "$.index[*][?(@.name=='PlainEmpty')].inner.fields" [] +// @is "$.index[*][?(@.name=='PlainEmpty')].visibility" \"public\" +// @is "$.index[*][?(@.name=='PlainEmpty')].kind" \"struct\" +// @is "$.index[*][?(@.name=='PlainEmpty')].inner.kind.plain.fields_stripped" false +// @is "$.index[*][?(@.name=='PlainEmpty')].inner.kind.plain.fields" [] pub struct PlainEmpty {} diff --git a/src/test/rustdoc-json/structs/plain_pub_priv.rs b/src/test/rustdoc-json/structs/plain_pub_priv.rs new file mode 100644 index 000000000..9b771224d --- /dev/null +++ b/src/test/rustdoc-json/structs/plain_pub_priv.rs @@ -0,0 +1,9 @@ +pub struct Demo { + pub x: i32, + y: i32, +} + +// @set x = "$.index[*][?(@.name=='x')].id" +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x +// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 1 +// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" true diff --git a/src/test/rustdoc-json/structs/tuple.rs b/src/test/rustdoc-json/structs/tuple.rs index 4e510b398..6bdb753ee 100644 --- a/src/test/rustdoc-json/structs/tuple.rs +++ b/src/test/rustdoc-json/structs/tuple.rs @@ -1,5 +1,4 @@ -// @has tuple.json "$.index[*][?(@.name=='Tuple')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Tuple')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='Tuple')].inner.struct_type" \"tuple\" -// @has - "$.index[*][?(@.name=='Tuple')].inner.fields_stripped" true +// @is "$.index[*][?(@.name=='Tuple')].visibility" \"public\" +// @is "$.index[*][?(@.name=='Tuple')].kind" \"struct\" +// @is "$.index[*][?(@.name=='Tuple')].inner.kind.tuple" '[null, null]' pub struct Tuple(u32, String); diff --git a/src/test/rustdoc-json/structs/tuple_empty.rs b/src/test/rustdoc-json/structs/tuple_empty.rs new file mode 100644 index 000000000..0ad6a8954 --- /dev/null +++ b/src/test/rustdoc-json/structs/tuple_empty.rs @@ -0,0 +1,2 @@ +// @is "$.index[*][?(@.name=='TupleUnit')].inner.kind.tuple" [] +pub struct TupleUnit(); diff --git a/src/test/rustdoc-json/structs/tuple_pub_priv.rs b/src/test/rustdoc-json/structs/tuple_pub_priv.rs new file mode 100644 index 000000000..9d5a1d1c8 --- /dev/null +++ b/src/test/rustdoc-json/structs/tuple_pub_priv.rs @@ -0,0 +1,13 @@ +pub struct Demo( + i32, + /// field + pub i32, + #[doc(hidden)] i32, +); + +// @set field = "$.index[*][?(@.docs=='field')].id" + +// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[0]" null +// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[1]" $field +// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[2]" null +// @count "$.index[*][?(@.name=='Demo')].inner.kind.tuple[*]" 3 diff --git a/src/test/rustdoc-json/structs/unit.rs b/src/test/rustdoc-json/structs/unit.rs index 559d3068d..265709717 100644 --- a/src/test/rustdoc-json/structs/unit.rs +++ b/src/test/rustdoc-json/structs/unit.rs @@ -1,5 +1,4 @@ -// @has unit.json "$.index[*][?(@.name=='Unit')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Unit')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='Unit')].inner.struct_type" \"unit\" -// @has - "$.index[*][?(@.name=='Unit')].inner.fields" [] +// @is "$.index[*][?(@.name=='Unit')].visibility" \"public\" +// @is "$.index[*][?(@.name=='Unit')].kind" \"struct\" +// @is "$.index[*][?(@.name=='Unit')].inner.kind" \"unit\" pub struct Unit; diff --git a/src/test/rustdoc-json/structs/with_generics.rs b/src/test/rustdoc-json/structs/with_generics.rs index 65cfe7eff..00474800a 100644 --- a/src/test/rustdoc-json/structs/with_generics.rs +++ b/src/test/rustdoc-json/structs/with_generics.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; -// @has with_generics.json "$.index[*][?(@.name=='WithGenerics')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='WithGenerics')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].name" \"T\" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].kind.type" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].name" \"U\" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].kind.type" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.struct_type" \"plain\" -// @has - "$.index[*][?(@.name=='WithGenerics')].inner.fields_stripped" true +// @is "$.index[*][?(@.name=='WithGenerics')].visibility" \"public\" +// @is "$.index[*][?(@.name=='WithGenerics')].kind" \"struct\" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].name" \"T\" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].kind.type.bounds" [] +// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].name" \"U\" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].kind.type.bounds" [] +// @is "$.index[*][?(@.name=='WithGenerics')].inner.kind.plain.fields_stripped" true +// @is "$.index[*][?(@.name=='WithGenerics')].inner.kind.plain.fields" [] pub struct WithGenerics<T, U> { stuff: Vec<T>, things: HashMap<U, U>, diff --git a/src/test/rustdoc-json/structs/with_primitives.rs b/src/test/rustdoc-json/structs/with_primitives.rs index 9e64317ec..9c5a37f39 100644 --- a/src/test/rustdoc-json/structs/with_primitives.rs +++ b/src/test/rustdoc-json/structs/with_primitives.rs @@ -1,9 +1,9 @@ -// @has with_primitives.json "$.index[*][?(@.name=='WithPrimitives')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='WithPrimitives')].kind" \"struct\" -// @has - "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].name" \"\'a\" -// @has - "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].kind.lifetime.outlives" [] -// @has - "$.index[*][?(@.name=='WithPrimitives')].inner.struct_type" \"plain\" -// @has - "$.index[*][?(@.name=='WithPrimitives')].inner.fields_stripped" true +// @is "$.index[*][?(@.name=='WithPrimitives')].visibility" \"public\" +// @is "$.index[*][?(@.name=='WithPrimitives')].kind" \"struct\" +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].kind.lifetime.outlives" [] +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.kind.plain.fields_stripped" true +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.kind.plain.fields" [] pub struct WithPrimitives<'a> { num: u32, s: &'a str, diff --git a/src/test/rustdoc-json/traits/has_body.rs b/src/test/rustdoc-json/traits/has_body.rs index 44dacb1ee..a57cb97d4 100644 --- a/src/test/rustdoc-json/traits/has_body.rs +++ b/src/test/rustdoc-json/traits/has_body.rs @@ -1,21 +1,21 @@ -// @has has_body.json "$.index[*][?(@.name=='Foo')]" +// @has "$.index[*][?(@.name=='Foo')]" pub trait Foo { - // @has - "$.index[*][?(@.name=='no_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='no_self')].inner.has_body" false fn no_self(); - // @has - "$.index[*][?(@.name=='move_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='move_self')].inner.has_body" false fn move_self(self); - // @has - "$.index[*][?(@.name=='ref_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='ref_self')].inner.has_body" false fn ref_self(&self); - // @has - "$.index[*][?(@.name=='no_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='no_self_def')].inner.has_body" true fn no_self_def() {} - // @has - "$.index[*][?(@.name=='move_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='move_self_def')].inner.has_body" true fn move_self_def(self) {} - // @has - "$.index[*][?(@.name=='ref_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='ref_self_def')].inner.has_body" true fn ref_self_def(&self) {} } pub trait Bar: Clone { - // @has - "$.index[*][?(@.name=='method')].inner.has_body" false + // @is "$.index[*][?(@.name=='method')].inner.has_body" false fn method(&self, param: usize); } diff --git a/src/test/rustdoc-json/traits/implementors.rs b/src/test/rustdoc-json/traits/implementors.rs index f7f03d987..db3fe5df7 100644 --- a/src/test/rustdoc-json/traits/implementors.rs +++ b/src/test/rustdoc-json/traits/implementors.rs @@ -1,19 +1,19 @@ #![feature(no_core)] #![no_core] -// @set wham = implementors.json "$.index[*][?(@.name=='Wham')].id" -// @count - "$.index[*][?(@.name=='Wham')].inner.implementations[*]" 1 -// @set gmWham = - "$.index[*][?(@.name=='Wham')].inner.implementations[0]" +// @set wham = "$.index[*][?(@.name=='Wham')].id" +// @count "$.index[*][?(@.name=='Wham')].inner.implementations[*]" 1 +// @set gmWham = "$.index[*][?(@.name=='Wham')].inner.implementations[0]" pub trait Wham {} -// @count - "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[*]" 1 -// @is - "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[0]" $gmWham -// @set gm = - "$.index[*][?(@.name=='Wham')].id" +// @count "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[*]" 1 +// @is "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[0]" $gmWham +// @set gm = "$.index[*][?(@.name=='Wham')].id" // jsonpath_lib isnt expressive enough (for now) to get the "impl" item, so we // just check it isn't pointing to the type, but when you port to jsondocck-ng // check what the impl item is -// @!is - "$.index[*][?(@.name=='Wham')].inner.implementations[0]" $gm +// @!is "$.index[*][?(@.name=='Wham')].inner.implementations[0]" $gm pub struct GeorgeMichael {} impl Wham for GeorgeMichael {} diff --git a/src/test/rustdoc-json/traits/supertrait.rs b/src/test/rustdoc-json/traits/supertrait.rs index 486a8e713..4048fdd74 100644 --- a/src/test/rustdoc-json/traits/supertrait.rs +++ b/src/test/rustdoc-json/traits/supertrait.rs @@ -4,23 +4,23 @@ #![feature(lang_items)] #![no_core] -// @set loud_id = supertrait.json "$.index[*][?(@.name=='Loud')].id" +// @set loud_id = "$.index[*][?(@.name=='Loud')].id" pub trait Loud {} -// @set very_loud_id = - "$.index[*][?(@.name=='VeryLoud')].id" -// @count - "$.index[*][?(@.name=='VeryLoud')].inner.bounds[*]" 1 -// @is - "$.index[*][?(@.name=='VeryLoud')].inner.bounds[0].trait_bound.trait.inner.id" $loud_id +// @set very_loud_id = "$.index[*][?(@.name=='VeryLoud')].id" +// @count "$.index[*][?(@.name=='VeryLoud')].inner.bounds[*]" 1 +// @is "$.index[*][?(@.name=='VeryLoud')].inner.bounds[0].trait_bound.trait.id" $loud_id pub trait VeryLoud: Loud {} -// @set sounds_good_id = - "$.index[*][?(@.name=='SoundsGood')].id" +// @set sounds_good_id = "$.index[*][?(@.name=='SoundsGood')].id" pub trait SoundsGood {} -// @count - "$.index[*][?(@.name=='MetalBand')].inner.bounds[*]" 2 -// @is - "$.index[*][?(@.name=='MetalBand')].inner.bounds[0].trait_bound.trait.inner.id" $very_loud_id -// @is - "$.index[*][?(@.name=='MetalBand')].inner.bounds[1].trait_bound.trait.inner.id" $sounds_good_id +// @count "$.index[*][?(@.name=='MetalBand')].inner.bounds[*]" 2 +// @is "$.index[*][?(@.name=='MetalBand')].inner.bounds[0].trait_bound.trait.id" $very_loud_id +// @is "$.index[*][?(@.name=='MetalBand')].inner.bounds[1].trait_bound.trait.id" $sounds_good_id pub trait MetalBand: VeryLoud + SoundsGood {} -// @count - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[*]" 2 -// @is - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[1].trait_bound.trait.inner.id" $very_loud_id -// @is - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[0].trait_bound.trait.inner.id" $sounds_good_id +// @count "$.index[*][?(@.name=='DnabLatem')].inner.bounds[*]" 2 +// @is "$.index[*][?(@.name=='DnabLatem')].inner.bounds[1].trait_bound.trait.id" $very_loud_id +// @is "$.index[*][?(@.name=='DnabLatem')].inner.bounds[0].trait_bound.trait.id" $sounds_good_id pub trait DnabLatem: SoundsGood + VeryLoud {} diff --git a/src/test/rustdoc-json/traits/uses_extern_trait.rs b/src/test/rustdoc-json/traits/uses_extern_trait.rs new file mode 100644 index 000000000..430dd1543 --- /dev/null +++ b/src/test/rustdoc-json/traits/uses_extern_trait.rs @@ -0,0 +1,7 @@ +#![no_std] +pub fn drop_default<T: core::default::Default>(_x: T) {} + +// FIXME(adotinthevoid): Theses shouldn't be here +// @has "$.index[*][?(@.name=='Debug')]" +// @set Debug_fmt = "$.index[*][?(@.name=='Debug')].inner.items[*]" +// @has "$.index[*][?(@.name=='fmt')].id" $Debug_fmt diff --git a/src/test/rustdoc-json/type/dyn.rs b/src/test/rustdoc-json/type/dyn.rs index f53dc03f4..eaf249252 100644 --- a/src/test/rustdoc-json/type/dyn.rs +++ b/src/test/rustdoc-json/type/dyn.rs @@ -1,21 +1,46 @@ // ignore-tidy-linelength +use std::fmt::Debug; -// @count dyn.json "$.index[*][?(@.name=='dyn')].inner.items" 1 -// @set sync_int_gen = - "$.index[*][?(@.name=='SyncIntGen')].id" -// @is - "$.index[*][?(@.name=='dyn')].inner.items[0]" $sync_int_gen +// @count "$.index[*][?(@.name=='dyn')].inner.items[*]" 3 +// @set sync_int_gen = "$.index[*][?(@.name=='SyncIntGen')].id" +// @set ref_fn = "$.index[*][?(@.name=='RefFn')].id" +// @set weird_order = "$.index[*][?(@.name=='WeirdOrder')].id" +// @ismany "$.index[*][?(@.name=='dyn')].inner.items[*]" $sync_int_gen $ref_fn $weird_order -// @is - "$.index[*][?(@.name=='SyncIntGen')].kind" \"typedef\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.generics" '{"params": [], "where_predicates": []}' -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.name" \"Box\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.bindings" [] -// @count - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args" 1 -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.name" \"Fn\" -// @count - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[*]" 3 -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[0].trait_bound.trait.inner.name" \"Send\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[1].trait_bound.trait.inner.name" \"Sync\" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[2]" "{\"outlives\": \"'static\"}" -// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.args" '{"parenthesized": {"inputs": [],"output": {"inner": "i32","kind": "primitive"}}}' +// @is "$.index[*][?(@.name=='SyncIntGen')].kind" \"typedef\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.generics" '{"params": [], "where_predicates": []}' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.kind" \"resolved_path\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.name" \"Box\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.bindings" [] +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args" 1 +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"dyn_trait\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.lifetime" \"\'static\" +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[*]" 3 +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[2].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.name" '"Fn"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[2].trait.name" '"Sync"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.args" '{"parenthesized": {"inputs": [],"output": {"inner": "i32","kind": "primitive"}}}' pub type SyncIntGen = Box<dyn Fn() -> i32 + Send + Sync + 'static>; + +// @is "$.index[*][?(@.name=='RefFn')].kind" \"typedef\" +// @is "$.index[*][?(@.name=='RefFn')].inner.generics" '{"params": [{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"}],"where_predicates": []}' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.mutable" 'false' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.lifetime" "\"'a\"" +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.kind" '"dyn_trait"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.lifetime" null +// @count "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[*]" 1 +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.name" '"Fn"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.inputs[0].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.inputs[0].inner.lifetime" "\"'b\"" +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.output.kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.output.inner.lifetime" "\"'b\"" +pub type RefFn<'a> = &'a dyn for<'b> Fn(&'b i32) -> &'b i32; + +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].trait.name" '"Debug"' +pub type WeirdOrder = Box<dyn Send + Debug>; diff --git a/src/test/rustdoc-json/type/extern.rs b/src/test/rustdoc-json/type/extern.rs new file mode 100644 index 000000000..d287d5ebe --- /dev/null +++ b/src/test/rustdoc-json/type/extern.rs @@ -0,0 +1,10 @@ +#![feature(extern_types)] + +extern { + /// No inner information + pub type Foo; +} + +// @is "$.index[*][?(@.docs=='No inner information')].name" '"Foo"' +// @is "$.index[*][?(@.docs=='No inner information')].kind" '"foreign_type"' +// @!has "$.index[*][?(@.docs=='No inner information')].inner" diff --git a/src/test/rustdoc-json/type/fn_lifetime.rs b/src/test/rustdoc-json/type/fn_lifetime.rs index e0d1e9649..d7216ec76 100644 --- a/src/test/rustdoc-json/type/fn_lifetime.rs +++ b/src/test/rustdoc-json/type/fn_lifetime.rs @@ -1,28 +1,27 @@ // ignore-tidy-linelength -// @is fn_lifetime.json "$.index[*][?(@.name=='GenericFn')].kind" \"typedef\" +// @is "$.index[*][?(@.name=='GenericFn')].kind" \"typedef\" -// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*]" 1 -// @is - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].name" \"\'a\" -// @has - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime" -// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime.outlives[*]" 0 -// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.where_predicates[*]" 0 -// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.kind" \"function_pointer\" -// @count - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.generic_params[*]" 0 -// @count - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" +// @ismany "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.generics.where_predicates[*]" 0 +// @is "$.index[*][?(@.name=='GenericFn')].inner.type.kind" \"function_pointer\" +// @count "$.index[*][?(@.name=='GenericFn')].inner.type.inner.generic_params[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" pub type GenericFn<'a> = fn(&'a i32) -> &'a i32; -// @is fn_lifetime.json "$.index[*][?(@.name=='ForAll')].kind" \"typedef\" -// @count - "$.index[*][?(@.name=='ForAll')].inner.generics.params[*]" 0 -// @count - "$.index[*][?(@.name=='ForAll')].inner.generics.where_predicates[*]" 0 -// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*]" 1 -// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].name" \"\'a\" -// @has - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime" -// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime.outlives[*]" 0 -// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*]" 1 -// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" -// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='ForAll')].kind" \"typedef\" +// @count "$.index[*][?(@.name=='ForAll')].inner.generics.params[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" pub type ForAll = for<'a> fn(&'a i32) -> &'a i32; diff --git a/src/test/rustdoc-json/type/generic_default.rs b/src/test/rustdoc-json/type/generic_default.rs index b6bb6dcc5..9c6d4540b 100644 --- a/src/test/rustdoc-json/type/generic_default.rs +++ b/src/test/rustdoc-json/type/generic_default.rs @@ -1,33 +1,33 @@ // ignore-tidy-linelength -// @set result = generic_default.json "$.index[*][?(@.name=='Result')].id" +// @set result = "$.index[*][?(@.name=='Result')].id" pub enum Result<T, E> { Ok(T), Err(E), } -// @set my_error = - "$.index[*][?(@.name=='MyError')].id" +// @set my_error = "$.index[*][?(@.name=='MyError')].id" pub struct MyError {} -// @is - "$.index[*][?(@.name=='MyResult')].kind" \"typedef\" -// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.where_predicates[*]" 0 -// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[*]" 2 -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].name" \"T\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].name" \"E\" -// @has - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type" -// @has - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type" -// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.bounds[*]" 0 -// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.bounds[*]" 0 -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.default" null -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.id" $my_error -// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.name" \"MyError\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.kind" \"resolved_path\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.id" $result -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.name" \"Result\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.bindings" [] -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"generic\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.kind" \"generic\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.inner" \"T\" -// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.inner" \"E\" +// @is "$.index[*][?(@.name=='MyResult')].kind" \"typedef\" +// @count "$.index[*][?(@.name=='MyResult')].inner.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[*]" 2 +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].name" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].name" \"E\" +// @has "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type" +// @has "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type" +// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.bounds[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.bounds[*]" 0 +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.default" null +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.kind" \"resolved_path\" +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.id" $my_error +// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.name" \"MyError\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.kind" \"resolved_path\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.id" $result +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.name" \"Result\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.bindings" [] +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"generic\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.kind" \"generic\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.inner" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.inner" \"E\" pub type MyResult<T, E = MyError> = Result<T, E>; diff --git a/src/test/rustdoc-json/type/hrtb.rs b/src/test/rustdoc-json/type/hrtb.rs new file mode 100644 index 000000000..2c4ee00d4 --- /dev/null +++ b/src/test/rustdoc-json/type/hrtb.rs @@ -0,0 +1,24 @@ +// ignore-tidy-linelength + +// @is "$.index[*][?(@.name=='genfn')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F","kind": "generic"}' +// @is "$.index[*][?(@.name=='genfn')].inner.generics.where_predicates[0].bound_predicate.generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +pub fn genfn<F>(f: F) +where + for<'a, 'b> F: Fn(&'a i32, &'b i32), +{ + let zero = 0; + f(&zero, &zero); +} + +// @is "$.index[*][?(@.name=='dynfn')].inner.generics" '{"params": [], "where_predicates": []}' +// @is "$.index[*][?(@.name=='dynfn')].inner.generics" '{"params": [], "where_predicates": []}' +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.kind" '"dyn_trait"' +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.lifetime" null +// @count "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[*]" 1 +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[0].trait.name" '"Fn"' +pub fn dynfn(f: &dyn for<'a, 'b> Fn(&'a i32, &'b i32)) { + let zero = 0; + f(&zero, &zero); +} diff --git a/src/test/rustdoc-json/unions/impl.rs b/src/test/rustdoc-json/unions/impl.rs index 0388b4a8c..4454a69ec 100644 --- a/src/test/rustdoc-json/unions/impl.rs +++ b/src/test/rustdoc-json/unions/impl.rs @@ -1,15 +1,15 @@ #![no_std] -// @has impl.json "$.index[*][?(@.name=='Ux')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Ux')].kind" \"union\" +// @is "$.index[*][?(@.name=='Ux')].visibility" \"public\" +// @is "$.index[*][?(@.name=='Ux')].kind" \"union\" pub union Ux { a: u32, b: u64 } -// @has - "$.index[*][?(@.name=='Num')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Num')].kind" \"trait\" +// @is "$.index[*][?(@.name=='Num')].visibility" \"public\" +// @is "$.index[*][?(@.name=='Num')].kind" \"trait\" pub trait Num {} -// @count - "$.index[*][?(@.name=='Ux')].inner.impls" 1 +// @count "$.index[*][?(@.name=='Ux')].inner.impls" 1 impl Num for Ux {} diff --git a/src/test/rustdoc-json/unions/union.rs b/src/test/rustdoc-json/unions/union.rs index ac2eb7977..c9df2b81c 100644 --- a/src/test/rustdoc-json/unions/union.rs +++ b/src/test/rustdoc-json/unions/union.rs @@ -1,7 +1,15 @@ -// @has union.json "$.index[*][?(@.name=='Union')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Union')].kind" \"union\" -// @!has - "$.index[*][?(@.name=='Union')].inner.struct_type" +// @has "$.index[*][?(@.name=='Union')].visibility" \"public\" +// @has "$.index[*][?(@.name=='Union')].kind" \"union\" +// @!has "$.index[*][?(@.name=='Union')].inner.struct_type" +// @set Union = "$.index[*][?(@.name=='Union')].id" pub union Union { int: i32, float: f32, } + + +// @is "$.index[*][?(@.name=='make_int_union')].inner.decl.output.kind" '"resolved_path"' +// @is "$.index[*][?(@.name=='make_int_union')].inner.decl.output.inner.id" $Union +pub fn make_int_union(int: i32) -> Union { + Union { int } +} |