diff --git a/src/test/rustdoc-json/assoc_items.rs b/src/test/rustdoc-json/assoc_items.rs index 2ee64c9f6eb99..2eb413fb40203 100644 --- a/src/test/rustdoc-json/assoc_items.rs +++ b/src/test/rustdoc-json/assoc_items.rs @@ -1,29 +1,27 @@ #![no_std] -// @has assoc_items.json - pub struct Simple; impl Simple { - // @has - "$.index[*][?(@.name=='CONSTANT')].kind" \"assoc_const\" + // @has "$.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 + // @has "$.index[*][?(@.name=='ToDeclare')].kind" \"assoc_type\" + // @has "$.index[*][?(@.name=='ToDeclare')].inner.default" null type ToDeclare; - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].kind" \"assoc_const\" - // @has - "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.default" null + // @has "$.index[*][?(@.name=='AN_ATTRIBUTE')].kind" \"assoc_const\" + // @has "$.index[*][?(@.name=='AN_ATTRIBUTE')].inner.default" null const AN_ATTRIBUTE: usize; } impl EasyToImpl for Simple { - // @has - "$.index[*][?(@.name=='ToDeclare')].inner.default.kind" \"primitive\" - // @has - "$.index[*][?(@.name=='ToDeclare')].inner.default.inner" \"usize\" + // @has "$.index[*][?(@.name=='ToDeclare')].inner.default.kind" \"primitive\" + // @has "$.index[*][?(@.name=='ToDeclare')].inner.default.inner" \"usize\" 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\" + // @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\" const AN_ATTRIBUTE: usize = 12; } diff --git a/src/test/rustdoc-json/assoc_type.rs b/src/test/rustdoc-json/assoc_type.rs index 716bb3d2848cc..edc1f73c866db 100644 --- a/src/test/rustdoc-json/assoc_type.rs +++ b/src/test/rustdoc-json/assoc_type.rs @@ -1,10 +1,9 @@ // Regression test for . -// @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 edf1a9fe2fcf9..c5cc87ca1eb30 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 5c4ccf996a54f..6573166c47f22 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/enum_variant_hidden.rs b/src/test/rustdoc-json/enum_variant_hidden.rs index 96c96a975d31a..c5e063a055c56 100644 --- a/src/test/rustdoc-json/enum_variant_hidden.rs +++ b/src/test/rustdoc-json/enum_variant_hidden.rs @@ -3,10 +3,10 @@ #![no_core] #![feature(no_core)] -// @has enum_variant_hidden.json "$.index[*][?(@.name=='ParseError')]" -// @has - "$.index[*][?(@.name=='UnexpectedEndTag')]" -// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"' -// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" [] +// @has "$.index[*][?(@.name=='ParseError')]" +// @has "$.index[*][?(@.name=='UnexpectedEndTag')]" +// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"' +// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" [] pub enum ParseError { UnexpectedEndTag(#[doc(hidden)] u32), diff --git a/src/test/rustdoc-json/enums/variant_struct.rs b/src/test/rustdoc-json/enums/variant_struct.rs index fcd92887c0bfb..704ec35d2f0ba 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\" +// @has "$.index[*][?(@.name=='EnumStruct')].visibility" \"public\" +// @has "$.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\" + // @has "$.index[*][?(@.name=='VariantS')].inner.variant_kind" \"struct\" + // @has "$.index[*][?(@.name=='x')].kind" \"struct_field\" + // @has "$.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 ac3e72e2905d2..71ddd73ec76a4 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\" +// @has "$.index[*][?(@.name=='EnumTupleStruct')].visibility" \"public\" +// @has "$.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\" + // @has "$.index[*][?(@.name=='VariantA')].inner.variant_kind" \"tuple\" + // @has "$.index[*][?(@.name=='0')].kind" \"struct_field\" + // @has "$.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 eef20e60a6a46..3c1a453d12de2 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 646f720e66396..a93b01ac2c4eb 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 3819220853639..bd65bb3eefe2c 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 16b579130656a..0e8b78bc0e6eb 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/generic_args.rs b/src/test/rustdoc-json/fns/generic_args.rs index 98ba8e99d820c..eec295efec0f0 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.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: 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.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 +// @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.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.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.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: 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 46f250a99b9b6..a9bc2d5d727d3 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.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 e55e1e9400dc6..e47c8c25513f6 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.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"' +// @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.id" $wham_id +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.decl.inputs" '[["w", {"inner": "T", "kind": "generic"}]]' pub fn one_generic_param_fn(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.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 +// @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.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 5cb3b43e66a96..7ff542900423b 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 368ff8d8da08a..cbaa0621dc2bb 100644 --- a/src/test/rustdoc-json/generic-associated-types/gats.rs +++ b/src/test/rustdoc-json/generic-associated-types/gats.rs @@ -8,37 +8,35 @@ 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 ac68ba578b6fb..31f41d0f335be 100644 --- a/src/test/rustdoc-json/generic_impl.rs +++ b/src/test/rustdoc-json/generic_impl.rs @@ -1,9 +1,8 @@ // Regression test for . -// @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 d7ac952d1bbc5..00051b1219974 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 index fb32d7c31bc9b..50d8524142730 100644 --- a/src/test/rustdoc-json/impls/auto.rs +++ b/src/test/rustdoc-json/impls/auto.rs @@ -12,7 +12,7 @@ impl Foo { } // Testing spans, so all tests below code -// @is auto.json "$.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]" +// @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/blanket_with_local.rs b/src/test/rustdoc-json/impls/blanket_with_local.rs index a3d55b35f0018..2fb4a84b9a67b 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

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/import_from_private.rs b/src/test/rustdoc-json/impls/import_from_private.rs index ef4d8aa39f88c..a34046ac12fb5 100644 --- a/src/test/rustdoc-json/impls/import_from_private.rs +++ b/src/test/rustdoc-json/impls/import_from_private.rs @@ -4,21 +4,21 @@ #![no_core] mod bar { - // @set baz = import_from_private.json "$.index[*][?(@.kind=='struct')].id" + // @set baz = "$.index[*][?(@.kind=='struct')].id" pub struct Baz; - // @set impl = - "$.index[*][?(@.kind=='impl')].id" + // @set impl = "$.index[*][?(@.kind=='impl')].id" impl Baz { - // @set doit = - "$.index[*][?(@.kind=='method')].id" + // @set doit = "$.index[*][?(@.kind=='method')].id" pub fn doit() {} } } -// @set import = - "$.index[*][?(@.kind=='import')].id" +// @set import = "$.index[*][?(@.kind=='import')].id" pub use bar::Baz; // FIXME(adotinthevoid): Use hasexact once #99474 lands -// @has - "$.index[*][?(@.kind=='module')].inner.items[*]" $import -// @is - "$.index[*][?(@.kind=='import')].inner.id" $baz -// @has - "$.index[*][?(@.kind=='struct')].inner.impls[*]" $impl -// @has - "$.index[*][?(@.kind=='impl')].inner.items[*]" $doit +// @has "$.index[*][?(@.kind=='module')].inner.items[*]" $import +// @is "$.index[*][?(@.kind=='import')].inner.id" $baz +// @has "$.index[*][?(@.kind=='struct')].inner.impls[*]" $impl +// @has "$.index[*][?(@.kind=='impl')].inner.items[*]" $doit diff --git a/src/test/rustdoc-json/keyword.rs b/src/test/rustdoc-json/keyword.rs index 78a843aca7b95..3446b212c563d 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 95b99599e737d..326dab8e57ace 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 096dd7f7a6918..e15a533efdc03 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 07b01d03bf6e3..4c97d97ceba52 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 af36d36b6607d..b9a5e56012e3a 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 9ff1f60c0d5c7..73ec9392ce94b 100644 --- a/src/test/rustdoc-json/nested.rs +++ b/src/test/rustdoc-json/nested.rs @@ -1,31 +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 +// @is "$.crate_version" \"1.0.0\" +// @is "$.index[*][?(@.name=='nested')].kind" \"module\" +// @is "$.index[*][?(@.name=='nested')].inner.is_crate" true -// @set l1_id = - "$.index[*][?(@.name=='l1')].id" -// @ismany - "$.index[*][?(@.name=='nested')].inner.items[*]" $l1_id +// @set l1_id = "$.index[*][?(@.name=='l1')].id" +// @ismany "$.index[*][?(@.name=='nested')].inner.items[*]" $l1_id -// @is nested.json "$.index[*][?(@.name=='l1')].kind" \"module\" -// @is - "$.index[*][?(@.name=='l1')].inner.is_crate" false +// @is "$.index[*][?(@.name=='l1')].kind" \"module\" +// @is "$.index[*][?(@.name=='l1')].inner.is_crate" false pub mod l1 { - // @is nested.json "$.index[*][?(@.name=='l3')].kind" \"module\" - // @is - "$.index[*][?(@.name=='l3')].inner.is_crate" false - // @set l3_id = - "$.index[*][?(@.name=='l3')].id" + // @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" - // @ismany - "$.index[*][?(@.name=='l3')].inner.items[*]" $l4_id + // @is "$.index[*][?(@.name=='L4')].kind" \"struct\" + // @is "$.index[*][?(@.name=='L4')].inner.struct_type" \"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')].inner.id" $l4_id - // @set l4_use_id = - "$.index[*][?(@.inner.source=='l3::L4')].id" + // @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 +// @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 d80656c7fc8aa..04b1a358fba4e 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); diff --git a/src/test/rustdoc-json/primitive.rs b/src/test/rustdoc-json/primitive.rs index 8d1141b58648d..6454dd7f51fab 100644 --- a/src/test/rustdoc-json/primitive.rs +++ b/src/test/rustdoc-json/primitive.rs @@ -5,16 +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=='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')]" +// @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 +// @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 +// @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 a10d5a83795c7..56b35cd14c0f2 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 fd04f04da066a..491a7b1add483 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\" +// @has "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" +// @has "$.index[*][?(@.name=='PrimNever')].inner.type.kind" \"primitive\" +// @has "$.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\" +// @has "$.index[*][?(@.name=='PrimStr')].inner.type.kind" \"primitive\" +// @has "$.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\" +// @has "$.index[*][?(@.name=='PrimBool')].inner.type.kind" \"primitive\" +// @has "$.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\" +// @has "$.index[*][?(@.name=='PrimChar')].inner.type.kind" \"primitive\" +// @has "$.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\" +// @has "$.index[*][?(@.name=='PrimU8')].inner.type.kind" \"primitive\" +// @has "$.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 index fda38056a094a..f076feb7185a7 100644 --- a/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs +++ b/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs @@ -7,5 +7,5 @@ // ignore-tidy-linelength -// @is export_extern_crate_as_self.json "$.index[*][?(@.kind=='module')].name" \"export_extern_crate_as_self\" +// @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_extern.rs b/src/test/rustdoc-json/reexport/glob_extern.rs index 4fe25904423ed..7a1e8c11ffa75 100644 --- a/src/test/rustdoc-json/reexport/glob_extern.rs +++ b/src/test/rustdoc-json/reexport/glob_extern.rs @@ -3,21 +3,21 @@ #![no_core] #![feature(no_core)] -// @is glob_extern.json "$.index[*][?(@.name=='mod1')].kind" \"module\" -// @is - "$.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" { - // @set public_fn_id = - "$.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" + // @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.id" $mod1_id -// @set use_id = - "$.index[*][?(@.kind=='import')].id" -// @ismany - "$.index[*][?(@.name=='glob_extern')].inner.items[*]" $use_id +// @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 04460a817f130..3a83a20818b8a 100644 --- a/src/test/rustdoc-json/reexport/glob_private.rs +++ b/src/test/rustdoc-json/reexport/glob_private.rs @@ -3,31 +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; } - // @set mod2_use_id = - "$.index[*][?(@.kind=='import' && @.inner.name=='mod2')].id" + // @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; } -// @set mod1_use_id = - "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')].id" +// @set mod1_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')].id" pub use mod1::*; -// @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 +// @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 7bf10a9868616..68cb694f49949 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,17 @@ #![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" +// @is "$.index[*][?(@.name=='foo')].kind" \"module\" +// @is "$.index[*][?(@.name=='foo')].inner.is_stripped" "true" 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 09302ee3acb2d..f6d932d927b8d 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" - // @ismany - "$.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 - // @ismany - "$.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 0959736f30988..b4882100f0656 100644 --- a/src/test/rustdoc-json/reexport/macro.rs +++ b/src/test/rustdoc-json/reexport/macro.rs @@ -3,13 +3,13 @@ #![no_core] #![feature(no_core)] -// @set repro_id = macro.json "$.index[*][?(@.name=='repro')].id" +// @set repro_id = "$.index[*][?(@.name=='repro')].id" #[macro_export] macro_rules! repro { () => {}; } -// @set repro2_id = macro.json "$.index[*][?(@.inner.name=='repro2')].id" +// @set repro2_id = "$.index[*][?(@.inner.name=='repro2')].id" pub use crate::repro as repro2; -// @ismany macro.json "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id $repro2_id +// @ismany "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id $repro2_id 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 a76d352b28ba4..687a3b2ac8b2c 100644 --- a/src/test/rustdoc-json/reexport/private_twice_one_inline.rs +++ b/src/test/rustdoc-json/reexport/private_twice_one_inline.rs @@ -10,19 +10,19 @@ extern crate pub_struct as foo; #[doc(inline)] -// @set crate_use_id = private_twice_one_inline.json "$.index[*][?(@.docs=='Hack A')].id" -// @set foo_id = - "$.index[*][?(@.docs=='Hack A')].inner.id" +// @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" +// @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 + // @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; } -// @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 +// @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 cd8212cf34419..ec78b06d09ac8 100644 --- a/src/test/rustdoc-json/reexport/private_two_names.rs +++ b/src/test/rustdoc-json/reexport/private_two_names.rs @@ -6,18 +6,18 @@ #![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" +// @is "$.index[*][?(@.name=='style')].kind" \"module\" +// @is "$.index[*][?(@.name=='style')].inner.is_stripped" "true" mod style { - // @set color_struct_id = - "$.index[*][?(@.kind=='struct' && @.name=='Color')].id" + // @set color_struct_id = "$.index[*][?(@.kind=='struct' && @.name=='Color')].id" pub struct Color; } -// @is - "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].inner.id" $color_struct_id -// @set color_export_id = - "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].id" +// @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; -// @is - "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].inner.id" $color_struct_id -// @set colour_export_id = - "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].id" +// @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 +// @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 2476399bd561c..1537f834481f4 100644 --- a/src/test/rustdoc-json/reexport/rename_private.rs +++ b/src/test/rustdoc-json/reexport/rename_private.rs @@ -3,12 +3,12 @@ #![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" +// @is "$.index[*][?(@.name=='inner')].kind" \"module\" +// @is "$.index[*][?(@.name=='inner')].inner.is_stripped" "true" 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 d41556974b43b..e30907fe25618 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" +// @set inner_id = "$.index[*][?(@.name=='inner')].id" pub mod inner { - // @set public_id = - "$.index[*][?(@.name=='Public')].id" - // @ismany - "$.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')]" -// @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 +// @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 1d76c7e139bdb..880dbdc4416e9 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 @@ -6,18 +6,16 @@ #![no_std] #![no_core] -// @has same_type_reexported_more_than_once.json - mod inner { - // @set trait_id = - "$.index[*][?(@.name=='Trait')].id" + // @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 +// @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 +// @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 +// @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 55523bcd1deef..82348b383c363 100644 --- a/src/test/rustdoc-json/reexport/simple_private.rs +++ b/src/test/rustdoc-json/reexport/simple_private.rs @@ -2,16 +2,16 @@ #![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" +// @is "$.index[*][?(@.name=='inner')].kind" \"module\" +// @is "$.index[*][?(@.name=='inner')].inner.is_stripped" "true" 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\" -// @set use_id = - "$.index[*][?(@.kind=='import')].id" +// @is "$.index[*][?(@.kind=='import')].inner.name" \"Public\" +// @set use_id = "$.index[*][?(@.kind=='import')].id" pub use inner::Public; -// @ismany - "$.index[*][?(@.name=='inner')].inner.items[*]" $pub_id -// @ismany - "$.index[*][?(@.name=='simple_private')].inner.items[*]" $use_id +// @ismany "$.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 a3156a2b33a8e..e64a0dcb769fa 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" +// @set inner_id = "$.index[*][?(@.name=='inner')].id" pub mod inner { - // @set public_id = - "$.index[*][?(@.name=='Public')].id" - // @ismany - "$.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" -// @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 +// @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 6b324d0090a15..a8d1fae30dfef 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 91f9f02ad7b47..33e95ce69d059 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_empty.rs b/src/test/rustdoc-json/structs/plain_empty.rs index a251caf4ba933..2ad9e86096c36 100644 --- a/src/test/rustdoc-json/structs/plain_empty.rs +++ b/src/test/rustdoc-json/structs/plain_empty.rs @@ -1,6 +1,6 @@ -// @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" [] +// @has "$.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" [] pub struct PlainEmpty {} diff --git a/src/test/rustdoc-json/structs/tuple.rs b/src/test/rustdoc-json/structs/tuple.rs index 4e510b3982507..91fac359422e9 100644 --- a/src/test/rustdoc-json/structs/tuple.rs +++ b/src/test/rustdoc-json/structs/tuple.rs @@ -1,5 +1,5 @@ -// @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 +// @has "$.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 pub struct Tuple(u32, String); diff --git a/src/test/rustdoc-json/structs/unit.rs b/src/test/rustdoc-json/structs/unit.rs index 559d3068de6e4..85a515b5e78ac 100644 --- a/src/test/rustdoc-json/structs/unit.rs +++ b/src/test/rustdoc-json/structs/unit.rs @@ -1,5 +1,5 @@ -// @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" [] +// @has "$.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" [] pub struct Unit; diff --git a/src/test/rustdoc-json/structs/with_generics.rs b/src/test/rustdoc-json/structs/with_generics.rs index 65cfe7effa5f1..b0ad1883f8a2f 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 +// @has "$.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 pub struct WithGenerics { stuff: Vec, things: HashMap, diff --git a/src/test/rustdoc-json/structs/with_primitives.rs b/src/test/rustdoc-json/structs/with_primitives.rs index 9e64317ec203f..b74050dde7869 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 +// @has "$.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 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 44dacb1ee75bf..4565aba65879d 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 + // @has "$.index[*][?(@.name=='no_self')].inner.has_body" false fn no_self(); - // @has - "$.index[*][?(@.name=='move_self')].inner.has_body" false + // @has "$.index[*][?(@.name=='move_self')].inner.has_body" false fn move_self(self); - // @has - "$.index[*][?(@.name=='ref_self')].inner.has_body" false + // @has "$.index[*][?(@.name=='ref_self')].inner.has_body" false fn ref_self(&self); - // @has - "$.index[*][?(@.name=='no_self_def')].inner.has_body" true + // @has "$.index[*][?(@.name=='no_self_def')].inner.has_body" true fn no_self_def() {} - // @has - "$.index[*][?(@.name=='move_self_def')].inner.has_body" true + // @has "$.index[*][?(@.name=='move_self_def')].inner.has_body" true fn move_self_def(self) {} - // @has - "$.index[*][?(@.name=='ref_self_def')].inner.has_body" true + // @has "$.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 + // @has "$.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 f7f03d987207e..db3fe5df73920 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 ce2f3912ba650..4048fdd74b490 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.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.id" $very_loud_id -// @is - "$.index[*][?(@.name=='MetalBand')].inner.bounds[1].trait_bound.trait.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.id" $very_loud_id -// @is - "$.index[*][?(@.name=='DnabLatem')].inner.bounds[0].trait_bound.trait.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/type/dyn.rs b/src/test/rustdoc-json/type/dyn.rs index 690dccc828704..03c6481f80ea2 100644 --- a/src/test/rustdoc-json/type/dyn.rs +++ b/src/test/rustdoc-json/type/dyn.rs @@ -1,48 +1,48 @@ // ignore-tidy-linelength use std::fmt::Debug; -// @count dyn.json "$.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" -// @has - "$.index[*][?(@.name=='dyn')].inner.items[*]" $sync_int_gen -// @has - "$.index[*][?(@.name=='dyn')].inner.items[*]" $ref_fn -// @has - "$.index[*][?(@.name=='dyn')].inner.items[*]" $weird_order +// @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" +// @has "$.index[*][?(@.name=='dyn')].inner.items[*]" $sync_int_gen +// @has "$.index[*][?(@.name=='dyn')].inner.items[*]" $ref_fn +// @has "$.index[*][?(@.name=='dyn')].inner.items[*]" $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" \"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"}}}' +// @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 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\"" +// @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"' +// @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; diff --git a/src/test/rustdoc-json/type/fn_lifetime.rs b/src/test/rustdoc-json/type/fn_lifetime.rs index fd49a0890c0df..d7216ec7675a3 100644 --- a/src/test/rustdoc-json/type/fn_lifetime.rs +++ b/src/test/rustdoc-json/type/fn_lifetime.rs @@ -1,27 +1,27 @@ // ignore-tidy-linelength -// @is fn_lifetime.json "$.index[*][?(@.name=='GenericFn')].kind" \"typedef\" +// @is "$.index[*][?(@.name=='GenericFn')].kind" \"typedef\" -// @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\" +// @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 b6bb6dcc5fe2d..9c6d4540bfb59 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 { 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 = Result; diff --git a/src/test/rustdoc-json/type/hrtb.rs b/src/test/rustdoc-json/type/hrtb.rs index 5b0c4caee2186..2c4ee00d468d4 100644 --- a/src/test/rustdoc-json/type/hrtb.rs +++ b/src/test/rustdoc-json/type/hrtb.rs @@ -1,9 +1,7 @@ // ignore-tidy-linelength -// @has hrtb.json - -// @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"}]' +// @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) where for<'a, 'b> F: Fn(&'a i32, &'b i32), @@ -12,14 +10,14 @@ where 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"' +// @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 0388b4a8c3c3b..8dfbbfc1baed4 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\" +// @has "$.index[*][?(@.name=='Ux')].visibility" \"public\" +// @has "$.index[*][?(@.name=='Ux')].kind" \"union\" pub union Ux { a: u32, b: u64 } -// @has - "$.index[*][?(@.name=='Num')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Num')].kind" \"trait\" +// @has "$.index[*][?(@.name=='Num')].visibility" \"public\" +// @has "$.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 ac2eb797791f3..5467f68477fc7 100644 --- a/src/test/rustdoc-json/unions/union.rs +++ b/src/test/rustdoc-json/unions/union.rs @@ -1,6 +1,6 @@ -// @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" pub union Union { int: i32, float: f32, diff --git a/src/tools/jsondocck/src/cache.rs b/src/tools/jsondocck/src/cache.rs index a188750c56ae3..f9e54232750b6 100644 --- a/src/tools/jsondocck/src/cache.rs +++ b/src/tools/jsondocck/src/cache.rs @@ -1,77 +1,31 @@ -use crate::error::CkError; +use crate::config::Config; use serde_json::Value; use std::collections::HashMap; -use std::io; -use std::path::{Path, PathBuf}; +use std::path::Path; use fs_err as fs; #[derive(Debug)] pub struct Cache { - root: PathBuf, - files: HashMap, - values: HashMap, + value: Value, pub variables: HashMap, - last_path: Option, } impl Cache { /// Create a new cache, used to read files only once and otherwise store their contents. - pub fn new(doc_dir: &str) -> Cache { + pub fn new(config: &Config) -> Cache { + let root = Path::new(&config.doc_dir); + let filename = Path::new(&config.template).file_stem().unwrap(); + let file_path = root.join(&Path::with_extension(Path::new(filename), "json")); + let content = fs::read_to_string(&file_path).expect("failed to read JSON file"); + Cache { - root: Path::new(doc_dir).to_owned(), - files: HashMap::new(), - values: HashMap::new(), + value: serde_json::from_str::(&content).expect("failed to convert from JSON"), variables: HashMap::new(), - last_path: None, } } - fn resolve_path(&mut self, path: &String) -> PathBuf { - if path != "-" { - let resolve = self.root.join(path); - self.last_path = Some(resolve.clone()); - resolve - } else { - self.last_path - .as_ref() - // FIXME: Point to a line number - .expect("No last path set. Make sure to specify a full path before using `-`") - .clone() - } - } - - fn read_file(&mut self, path: PathBuf) -> Result { - if let Some(f) = self.files.get(&path) { - return Ok(f.clone()); - } - - let file = fs::read_to_string(&path)?; - - self.files.insert(path, file.clone()); - - Ok(file) - } - - /// Get the text from a file. If called multiple times, the file will only be read once - pub fn get_file(&mut self, path: &String) -> Result { - let path = self.resolve_path(path); - self.read_file(path) - } - - /// Parse the JSON from a file. If called multiple times, the file will only be read once. - pub fn get_value(&mut self, path: &String) -> Result { - let path = self.resolve_path(path); - - if let Some(v) = self.values.get(&path) { - return Ok(v.clone()); - } - - let content = self.read_file(path.clone())?; - let val = serde_json::from_str::(&content)?; - - self.values.insert(path, val.clone()); - - Ok(val) + pub fn value(&self) -> &Value { + &self.value } } diff --git a/src/tools/jsondocck/src/main.rs b/src/tools/jsondocck/src/main.rs index 022f7eb8e02d0..76770fe36a708 100644 --- a/src/tools/jsondocck/src/main.rs +++ b/src/tools/jsondocck/src/main.rs @@ -17,7 +17,7 @@ fn main() -> Result<(), String> { let config = parse_config(env::args().collect()); let mut failed = Vec::new(); - let mut cache = Cache::new(&config.doc_dir); + let mut cache = Cache::new(&config); let commands = get_commands(&config.template) .map_err(|_| format!("Jsondocck failed for {}", &config.template))?; @@ -55,12 +55,12 @@ pub enum CommandKind { } impl CommandKind { - fn validate(&self, args: &[String], command_num: usize, lineno: usize) -> bool { + fn validate(&self, args: &[String], lineno: usize) -> bool { let count = match self { - CommandKind::Has => (1..=3).contains(&args.len()), - CommandKind::IsMany => args.len() >= 3, - CommandKind::Count | CommandKind::Is => 3 == args.len(), - CommandKind::Set => 4 == args.len(), + CommandKind::Has => (1..=2).contains(&args.len()), + CommandKind::IsMany => args.len() >= 2, + CommandKind::Count | CommandKind::Is => 2 == args.len(), + CommandKind::Set => 3 == args.len(), }; if !count { @@ -68,15 +68,10 @@ impl CommandKind { return false; } - if args[0] == "-" && command_num == 0 { - print_err(&format!("Tried to use the previous path in the first command"), lineno); - return false; - } - if let CommandKind::Count = self { - if args[2].parse::().is_err() { + if args[1].parse::().is_err() { print_err( - &format!("Third argument to @count must be a valid usize (got `{}`)", args[2]), + &format!("Second argument to @count must be a valid usize (got `{}`)", args[2]), lineno, ); return false; @@ -181,7 +176,7 @@ fn get_commands(template: &str) -> Result, ()> { } }; - if !cmd.validate(&args, commands.len(), lineno) { + if !cmd.validate(&args, lineno) { errors = true; continue; } @@ -199,26 +194,24 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> { let result = match command.kind { CommandKind::Has => { match command.args.len() { - // @has = file existence - 1 => cache.get_file(&command.args[0]).is_ok(), - // @has = check path exists - 2 => { - let val = cache.get_value(&command.args[0])?; - let results = select(&val, &command.args[1]).unwrap(); + // @has = check path exists + 1 => { + let val = cache.value(); + let results = select(val, &command.args[0]).unwrap(); !results.is_empty() } - // @has = check *any* item matched by path equals value - 3 => { - let val = cache.get_value(&command.args[0])?; - let results = select(&val, &command.args[1]).unwrap(); - let pat = string_to_value(&command.args[2], cache); + // @has = check *any* item matched by path equals value + 2 => { + let val = cache.value().clone(); + let results = select(&val, &command.args[0]).unwrap(); + let pat = string_to_value(&command.args[1], cache); let has = results.contains(&pat.as_ref()); // Give better error for when @has check fails if !command.negated && !has { return Err(CkError::FailedCheck( format!( "{} matched to {:?} but didn't have {:?}", - &command.args[1], + &command.args[0], results, pat.as_ref() ), @@ -233,13 +226,13 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> { } CommandKind::IsMany => { // @ismany ... - let (path, query, values) = if let [path, query, values @ ..] = &command.args[..] { - (path, query, values) + let (query, values) = if let [query, values @ ..] = &command.args[..] { + (query, values) } else { unreachable!("Checked in CommandKind::validate") }; - let val = cache.get_value(path)?; - let got_values = select(&val, &query).unwrap(); + let val = cache.value(); + let got_values = select(val, &query).unwrap(); assert!(!command.negated, "`@!ismany` is not supported"); // Serde json doesn't implement Ord or Hash for Value, so we must @@ -270,18 +263,17 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> { true } CommandKind::Count => { - // @count = Check that the jsonpath matches exactly [count] times - assert_eq!(command.args.len(), 3); - let expected: usize = command.args[2].parse().unwrap(); - - let val = cache.get_value(&command.args[0])?; - let results = select(&val, &command.args[1]).unwrap(); + // @count = Check that the jsonpath matches exactly [count] times + assert_eq!(command.args.len(), 2); + let expected: usize = command.args[1].parse().unwrap(); + let val = cache.value(); + let results = select(val, &command.args[0]).unwrap(); let eq = results.len() == expected; if !command.negated && !eq { return Err(CkError::FailedCheck( format!( "`{}` matched to `{:?}` with length {}, but expected length {}", - &command.args[1], + &command.args[0], results, results.len(), expected @@ -293,17 +285,17 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> { } } CommandKind::Is => { - // @has = check *exactly one* item matched by path, and it equals value - assert_eq!(command.args.len(), 3); - let val = cache.get_value(&command.args[0])?; - let results = select(&val, &command.args[1]).unwrap(); - let pat = string_to_value(&command.args[2], cache); + // @has = check *exactly one* item matched by path, and it equals value + assert_eq!(command.args.len(), 2); + let val = cache.value().clone(); + let results = select(&val, &command.args[0]).unwrap(); + let pat = string_to_value(&command.args[1], cache); let is = results.len() == 1 && results[0] == pat.as_ref(); if !command.negated && !is { return Err(CkError::FailedCheck( format!( "{} matched to {:?}, but expected {:?}", - &command.args[1], + &command.args[0], results, pat.as_ref() ), @@ -314,16 +306,16 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> { } } CommandKind::Set => { - // @set = - assert_eq!(command.args.len(), 4); + // @set = + assert_eq!(command.args.len(), 3); assert_eq!(command.args[1], "=", "Expected an `=`"); - let val = cache.get_value(&command.args[2])?; - let results = select(&val, &command.args[3]).unwrap(); + let val = cache.value().clone(); + let results = select(&val, &command.args[2]).unwrap(); assert_eq!( results.len(), 1, "Expected 1 match for `{}` (because of @set): matched to {:?}", - command.args[3], + command.args[2], results ); match results.len() { @@ -336,7 +328,7 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> { _ => { panic!( "Got multiple results in `@set` for `{}`: {:?}", - &command.args[3], results + &command.args[2], results, ); } }