Skip to content

Commit

Permalink
Auto merge of #100678 - GuillaumeGomez:improve-rustdoc-json-tests, r=…
Browse files Browse the repository at this point in the history
…aDotInTheVoid

Improve rustdoc json tests

Fixes #100588.

r? `@aDotInTheVoid`
  • Loading branch information
bors committed Aug 23, 2022
2 parents 8818b00 + d3d9e22 commit 7e3e8a8
Show file tree
Hide file tree
Showing 62 changed files with 605 additions and 674 deletions.
22 changes: 10 additions & 12 deletions src/test/rustdoc-json/assoc_items.rs
Original file line number Diff line number Diff line change
@@ -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;
}
9 changes: 4 additions & 5 deletions src/test/rustdoc-json/assoc_type.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Regression test for <https://github.com/rust-lang/rust/issues/98547>.

// @has assoc_type.json
// @has - "$.index[*][?(@.name=='Trait')]"
// @has - "$.index[*][?(@.name=='AssocType')]"
// @has - "$.index[*][?(@.name=='S')]"
// @has - "$.index[*][?(@.name=='S2')]"
// @has "$.index[*][?(@.name=='Trait')]"
// @has "$.index[*][?(@.name=='AssocType')]"
// @has "$.index[*][?(@.name=='S')]"
// @has "$.index[*][?(@.name=='S2')]"

pub trait Trait {
type AssocType;
Expand Down
7 changes: 3 additions & 4 deletions src/test/rustdoc-json/blanket_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion src/test/rustdoc-json/doc_hidden_failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/test/rustdoc-json/enum_variant_hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 5 additions & 5 deletions src/test/rustdoc-json/enums/variant_struct.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/test/rustdoc-json/enums/variant_tuple_struct.rs
Original file line number Diff line number Diff line change
@@ -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),
}
14 changes: 7 additions & 7 deletions src/test/rustdoc-json/fn_pointer/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
16 changes: 8 additions & 8 deletions src/test/rustdoc-json/fn_pointer/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
12 changes: 6 additions & 6 deletions src/test/rustdoc-json/fn_pointer/qualifiers.rs
Original file line number Diff line number Diff line change
@@ -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();
14 changes: 7 additions & 7 deletions src/test/rustdoc-json/fns/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Loading

0 comments on commit 7e3e8a8

Please sign in to comment.