diff options
| author | Michael Howell <michael@notriddle.com> | 2023-09-29 12:52:30 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2023-12-26 12:54:17 -0700 |
| commit | f6a045cc6b24dd033c207dd63d8adccdedf672d2 (patch) | |
| tree | 7ccbf87bff8e0dc808f45d9d9393cbab4a093be3 /tests/rustdoc-js | |
| parent | a75fed74b62f95d1659ff70bea7895ed5c85bdba (diff) | |
| download | rust-f6a045cc6b24dd033c207dd63d8adccdedf672d2.tar.gz rust-f6a045cc6b24dd033c207dd63d8adccdedf672d2.zip | |
rustdoc: search for tuples and unit by type with `()`
Diffstat (limited to 'tests/rustdoc-js')
| -rw-r--r-- | tests/rustdoc-js/tuple-unit.js | 80 | ||||
| -rw-r--r-- | tests/rustdoc-js/tuple-unit.rs | 18 |
2 files changed, 98 insertions, 0 deletions
diff --git a/tests/rustdoc-js/tuple-unit.js b/tests/rustdoc-js/tuple-unit.js new file mode 100644 index 00000000000..d24a3da328c --- /dev/null +++ b/tests/rustdoc-js/tuple-unit.js @@ -0,0 +1,80 @@ +// exact-check + +const EXPECTED = [ + { + 'query': '()', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'side_effect' }, + { 'path': 'tuple_unit', 'name': 'one' }, + { 'path': 'tuple_unit', 'name': 'two' }, + { 'path': 'tuple_unit', 'name': 'nest' }, + ], + 'in_args': [], + }, + { + 'query': 'primitive:unit', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'side_effect' }, + ], + 'in_args': [], + }, + { + 'query': 'primitive:tuple', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'one' }, + { 'path': 'tuple_unit', 'name': 'two' }, + { 'path': 'tuple_unit', 'name': 'nest' }, + ], + 'in_args': [], + }, + { + 'query': '(P)', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'not_tuple' }, + { 'path': 'tuple_unit', 'name': 'one' }, + { 'path': 'tuple_unit', 'name': 'two' }, + ], + 'in_args': [], + }, + { + 'query': '(P,)', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'one' }, + { 'path': 'tuple_unit', 'name': 'two' }, + ], + 'in_args': [], + }, + { + 'query': '(P, P)', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'two' }, + ], + 'in_args': [], + }, + { + 'query': '(P, ())', + 'returned': [], + 'in_args': [], + }, + { + 'query': '(Q, ())', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'nest' }, + ], + 'in_args': [], + }, + { + 'query': '(R)', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'nest' }, + ], + 'in_args': [], + }, + { + 'query': '(u32)', + 'returned': [ + { 'path': 'tuple_unit', 'name': 'nest' }, + ], + 'in_args': [], + }, +]; diff --git a/tests/rustdoc-js/tuple-unit.rs b/tests/rustdoc-js/tuple-unit.rs new file mode 100644 index 00000000000..93f9a671cbc --- /dev/null +++ b/tests/rustdoc-js/tuple-unit.rs @@ -0,0 +1,18 @@ +pub struct P; +pub struct Q; +pub struct R<T>(T); + +// Checks that tuple and unit both work +pub fn side_effect() { } + +// Check a non-tuple +pub fn not_tuple() -> P { loop {} } + +// Check a 1-tuple +pub fn one() -> (P,) { loop {} } + +// Check a 2-tuple +pub fn two() -> (P,P) { loop {} } + +// Check a nested tuple +pub fn nest() -> (Q, R<(u32,)>) { loop {} } |
