diff options
Diffstat (limited to 'src/test/rustdoc-json/fns')
-rw-r--r-- | src/test/rustdoc-json/fns/abi.rs | 25 | ||||
-rw-r--r-- | src/test/rustdoc-json/fns/generic_args.rs | 71 | ||||
-rw-r--r-- | src/test/rustdoc-json/fns/generic_returns.rs | 21 | ||||
-rw-r--r-- | src/test/rustdoc-json/fns/generics.rs | 26 | ||||
-rw-r--r-- | src/test/rustdoc-json/fns/qualifiers.rs | 33 |
5 files changed, 176 insertions, 0 deletions
diff --git a/src/test/rustdoc-json/fns/abi.rs b/src/test/rustdoc-json/fns/abi.rs new file mode 100644 index 000000000..16b579130 --- /dev/null +++ b/src/test/rustdoc-json/fns/abi.rs @@ -0,0 +1,25 @@ +// ignore-tidy-linelength + +#![feature(abi_vectorcall)] +#![feature(c_unwind)] + +// @is abi.json "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" +pub fn abi_rust() {} + +// @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}}' +pub extern "system" fn abi_system() {} + +// @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}}' +pub extern "system-unwind" fn abi_system_unwind() {} + +// @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\""' +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 new file mode 100644 index 000000000..69150443c --- /dev/null +++ b/src/test/rustdoc-json/fns/generic_args.rs @@ -0,0 +1,71 @@ +// ignore-tidy-linelength + +#![feature(no_core)] +#![no_core] + +// @set foo = generic_args.json "$.index[*][?(@.name=='Foo')].id" +pub trait Foo {} + +// @set generic_foo = generic_args.json "$.index[*][?(@.name=='GenericFoo')].id" +pub trait GenericFoo<'a> {} + +// @is - "$.index[*][?(@.name=='generics')].inner.generics.where_predicates" "[]" +// @count - "$.index[*][?(@.name=='generics')].inner.generics.params[*]" 1 +// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].name" '"F"' +// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.default" 'null' +// @count - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[*]" 1 +// @is - "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" '$foo' +// @count - "$.index[*][?(@.name=='generics')].inner.decl.inputs[*]" 1 +// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][0]" '"f"' +// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].kind" '"generic"' +// @is - "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].inner" '"F"' +pub fn generics<F: Foo>(f: F) {} + +// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.where_predicates" "[]" +// @count - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[*]" 1 +// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].name" '"impl Foo"' +// @is - "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $foo +// @count - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[*]" 1 +// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][0]" '"f"' +// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].kind" '"impl_trait"' +// @count - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[*]" 1 +// @is - "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.inner.id" $foo +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 + +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F", "kind": "generic"}' +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo + +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.type" '{"inner": "G", "kind": "generic"}' +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.trait.inner.id" $generic_foo +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].name" \"\'a\" +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.generic_params" "[]" + +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.kind" '"borrowed_ref"' +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.lifetime" \"\'b\" +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.type" '{"inner": "H", "kind": "generic"}' +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.trait.inner.id" $foo +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.generic_params" "[]" +// @count - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[*]" 1 +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].name" \"\'b\" +// @is - "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +pub fn where_clase<F, G, H>(f: F, g: G, h: H) +where + F: Foo, + G: for<'a> GenericFoo<'a>, + for<'b> &'b H: Foo, +{ +} diff --git a/src/test/rustdoc-json/fns/generic_returns.rs b/src/test/rustdoc-json/fns/generic_returns.rs new file mode 100644 index 000000000..1a0f33fe3 --- /dev/null +++ b/src/test/rustdoc-json/fns/generic_returns.rs @@ -0,0 +1,21 @@ +// ignore-tidy-linelength + +#![feature(no_core)] +#![no_core] + +// @count generic_returns.json "$.index[*][?(@.name=='generic_returns')].inner.items[*]" 2 + +// @set foo = - "$.index[*][?(@.name=='Foo')].id" +pub trait Foo {} + +// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.inputs" [] +// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.output.kind" '"impl_trait"' +// @count - "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[*]" 1 +// @is - "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[0].trait_bound.trait.inner.id" $foo +pub fn get_foo() -> impl Foo { + Fooer {} +} + +struct Fooer {} + +impl Foo for Fooer {} diff --git a/src/test/rustdoc-json/fns/generics.rs b/src/test/rustdoc-json/fns/generics.rs new file mode 100644 index 000000000..e777fabaa --- /dev/null +++ b/src/test/rustdoc-json/fns/generics.rs @@ -0,0 +1,26 @@ +// ignore-tidy-linelength + +#![feature(no_core)] +#![no_core] + +// @set wham_id = generics.json "$.index[*][?(@.name=='Wham')].id" +pub trait Wham {} + +// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.where_predicates" [] +// @count - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[*]" 1 +// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].name" '"T"' +// @has - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" false +// @has - "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $wham_id +// @is - "$.index[*][?(@.name=='one_generic_param_fn')].inner.decl.inputs" '[["w", {"inner": "T", "kind": "generic"}]]' +pub fn one_generic_param_fn<T: Wham>(w: T) {} + +// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.where_predicates" [] +// @count - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[*]" 1 +// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].name" '"impl Wham"' +// @has - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" true +// @has - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.inner.id" $wham_id +// @count - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[*]" 1 +// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][0]" '"w"' +// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].kind" '"impl_trait"' +// @is - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.inner.id" $wham_id +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 new file mode 100644 index 000000000..5cb3b43e6 --- /dev/null +++ b/src/test/rustdoc-json/fns/qualifiers.rs @@ -0,0 +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 +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 +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 +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 +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 +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 +pub const unsafe fn const_unsafe_fn() {} + +// It's impossible for a function to be both const and async, so no test for that |