Skip to content

Commit fd5adef

Browse files
committed
rustdoc-json: Add tests for fn qualifiers and ABI
1 parent aa60157 commit fd5adef

File tree

10 files changed

+184
-78
lines changed

10 files changed

+184
-78
lines changed
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ignore-tidy-linelength
2+
3+
#![feature(abi_vectorcall)]
4+
#![feature(c_unwind)]
5+
6+
// @is abi.json "$.index[*][?(@.name=='AbiRust')].inner.type.inner.header.abi" \"Rust\"
7+
pub type AbiRust = fn();
8+
9+
// @is - "$.index[*][?(@.name=='AbiC')].inner.type.inner.header.abi" '{"C": {"unwind": false}}'
10+
pub type AbiC = extern "C" fn();
11+
12+
// @is - "$.index[*][?(@.name=='AbiSystem')].inner.type.inner.header.abi" '{"System": {"unwind": false}}'
13+
pub type AbiSystem = extern "system" fn();
14+
15+
// @is - "$.index[*][?(@.name=='AbiCUnwind')].inner.type.inner.header.abi" '{"C": {"unwind": true}}'
16+
pub type AbiCUnwind = extern "C-unwind" fn();
17+
18+
// @is - "$.index[*][?(@.name=='AbiSystemUnwind')].inner.type.inner.header.abi" '{"System": {"unwind": true}}'
19+
pub type AbiSystemUnwind = extern "system-unwind" fn();
20+
21+
// @is - "$.index[*][?(@.name=='AbiVecorcall')].inner.type.inner.header.abi.Other" '"\"vectorcall\""'
22+
pub type AbiVecorcall = extern "vectorcall" fn();
23+
24+
// @is - "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.type.inner.header.abi.Other" '"\"vectorcall-unwind\""'
25+
pub type AbiVecorcallUnwind = extern "vectorcall-unwind" fn();

src/test/rustdoc-json/fn_pointer/header.rs

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @is qualifiers.json "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.unsafe" false
2+
// @is - "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.const" false
3+
// @is - "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.async" false
4+
pub type FnPointer = fn();
5+
6+
// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.unsafe" true
7+
// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.const" false
8+
// @is - "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.async" false
9+
pub type UnsafePointer = unsafe fn();

src/test/rustdoc-json/fns/abi.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ignore-tidy-linelength
2+
3+
#![feature(abi_vectorcall)]
4+
#![feature(c_unwind)]
5+
6+
// @is abi.json "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\"
7+
pub fn abi_rust() {}
8+
9+
// @is - "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}'
10+
pub extern "C" fn abi_c() {}
11+
12+
// @is - "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}'
13+
pub extern "system" fn abi_system() {}
14+
15+
// @is - "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}'
16+
pub extern "C-unwind" fn abi_c_unwind() {}
17+
18+
// @is - "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}'
19+
pub extern "system-unwind" fn abi_system_unwind() {}
20+
21+
// @is - "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""'
22+
pub extern "vectorcall" fn abi_vectorcall() {}
23+
24+
// @is - "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""'
25+
pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {}

src/test/rustdoc-json/fns/header.rs

-22
This file was deleted.
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// edition:2018
2+
3+
// @is qualifiers.json "$.index[*][?(@.name=='nothing_fn')].inner.header.async" false
4+
// @is - "$.index[*][?(@.name=='nothing_fn')].inner.header.const" false
5+
// @is - "$.index[*][?(@.name=='nothing_fn')].inner.header.unsafe" false
6+
pub fn nothing_fn() {}
7+
8+
// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.async" false
9+
// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.const" false
10+
// @is - "$.index[*][?(@.name=='unsafe_fn')].inner.header.unsafe" true
11+
pub unsafe fn unsafe_fn() {}
12+
13+
// @is - "$.index[*][?(@.name=='const_fn')].inner.header.async" false
14+
// @is - "$.index[*][?(@.name=='const_fn')].inner.header.const" true
15+
// @is - "$.index[*][?(@.name=='const_fn')].inner.header.unsafe" false
16+
pub const fn const_fn() {}
17+
18+
// @is - "$.index[*][?(@.name=='async_fn')].inner.header.async" true
19+
// @is - "$.index[*][?(@.name=='async_fn')].inner.header.const" false
20+
// @is - "$.index[*][?(@.name=='async_fn')].inner.header.unsafe" false
21+
pub async fn async_fn() {}
22+
23+
// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.async" true
24+
// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.const" false
25+
// @is - "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.unsafe" true
26+
pub async unsafe fn async_unsafe_fn() {}
27+
28+
// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.async" false
29+
// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.const" true
30+
// @is - "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.unsafe" true
31+
pub const unsafe fn const_unsafe_fn() {}
32+
33+
// It's impossible for a function to be both const and async, so no test for that

src/test/rustdoc-json/method_abi.rs

-25
This file was deleted.

src/test/rustdoc-json/methods/abi.rs

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// ignore-tidy-linelength
2+
3+
#![feature(abi_vectorcall)]
4+
#![feature(c_unwind)]
5+
#![feature(no_core)]
6+
#![no_core]
7+
8+
// @has abi.json "$.index[*][?(@.name=='Foo')]"
9+
pub struct Foo;
10+
11+
impl Foo {
12+
// @is - "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\"
13+
pub fn abi_rust() {}
14+
15+
// @is - "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}'
16+
pub extern "C" fn abi_c() {}
17+
18+
// @is - "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}'
19+
pub extern "system" fn abi_system() {}
20+
21+
// @is - "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}'
22+
pub extern "C-unwind" fn abi_c_unwind() {}
23+
24+
// @is - "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}'
25+
pub extern "system-unwind" fn abi_system_unwind() {}
26+
27+
// @is - "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""'
28+
pub extern "vectorcall" fn abi_vectorcall() {}
29+
30+
// @is - "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""'
31+
pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {}
32+
}
33+
34+
pub trait Bar {
35+
// @is - "$.index[*][?(@.name=='trait_abi_rust')].inner.header.abi" \"Rust\"
36+
fn trait_abi_rust() {}
37+
38+
// @is - "$.index[*][?(@.name=='trait_abi_c')].inner.header.abi" '{"C": {"unwind": false}}'
39+
extern "C" fn trait_abi_c() {}
40+
41+
// @is - "$.index[*][?(@.name=='trait_abi_system')].inner.header.abi" '{"System": {"unwind": false}}'
42+
extern "system" fn trait_abi_system() {}
43+
44+
// @is - "$.index[*][?(@.name=='trait_abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}'
45+
extern "C-unwind" fn trait_abi_c_unwind() {}
46+
47+
// @is - "$.index[*][?(@.name=='trait_abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}'
48+
extern "system-unwind" fn trait_abi_system_unwind() {}
49+
50+
// @is - "$.index[*][?(@.name=='trait_abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""'
51+
extern "vectorcall" fn trait_abi_vectorcall() {}
52+
53+
// @is - "$.index[*][?(@.name=='trait_abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""'
54+
extern "vectorcall-unwind" fn trait_abi_vectorcall_unwind() {}
55+
}

src/test/rustdoc-json/methods/header.rs

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// edition:2018
2+
3+
pub struct Foo;
4+
5+
impl Foo {
6+
// @is qualifiers.json "$.index[*][?(@.name=='const_meth')].inner.header.async" false
7+
// @is - "$.index[*][?(@.name=='const_meth')].inner.header.const" true
8+
// @is - "$.index[*][?(@.name=='const_meth')].inner.header.unsafe" false
9+
pub const fn const_meth() {}
10+
11+
// @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.async" false
12+
// @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.const" false
13+
// @is - "$.index[*][?(@.name=='nothing_meth')].inner.header.unsafe" false
14+
pub fn nothing_meth() {}
15+
16+
// @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.async" false
17+
// @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.const" false
18+
// @is - "$.index[*][?(@.name=='unsafe_meth')].inner.header.unsafe" true
19+
pub unsafe fn unsafe_meth() {}
20+
21+
// @is - "$.index[*][?(@.name=='async_meth')].inner.header.async" true
22+
// @is - "$.index[*][?(@.name=='async_meth')].inner.header.const" false
23+
// @is - "$.index[*][?(@.name=='async_meth')].inner.header.unsafe" false
24+
pub async fn async_meth() {}
25+
26+
// @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.async" true
27+
// @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.const" false
28+
// @is - "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.unsafe" true
29+
pub async unsafe fn async_unsafe_meth() {}
30+
31+
// @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.async" false
32+
// @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.const" true
33+
// @is - "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.unsafe" true
34+
pub const unsafe fn const_unsafe_meth() {}
35+
36+
// It's impossible for a method to be both const and async, so no test for that
37+
}

0 commit comments

Comments
 (0)