Skip to content

Commit 26829c0

Browse files
committed
rustdoc-json: Lifetime tests
1 parent dc6b5cb commit 26829c0

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ignore-tidy-linelength
2+
3+
#![feature(no_core)]
4+
#![no_core]
5+
6+
// @is longest.json "$.index[*][?(@.name=='longest')].inner.generics.params[0].name" \"\'a\"
7+
// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}'
8+
// @is - "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}'
9+
// @count - "$.index[*][?(@.name=='longest')].inner.generics.params[*]" 1
10+
// @is - "$.index[*][?(@.name=='longest')].inner.generics.where_predicates" []
11+
12+
// @count - "$.index[*][?(@.name=='longest')].inner.decl.inputs[*]" 2
13+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][0]" '"l"'
14+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][0]" '"r"'
15+
16+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].kind" '"borrowed_ref"'
17+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\"
18+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.mutable" false
19+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.type" '{"inner": "str", "kind": "primitive"}'
20+
21+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].kind" '"borrowed_ref"'
22+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.lifetime" \"\'a\"
23+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.mutable" false
24+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.type" '{"inner": "str", "kind": "primitive"}'
25+
26+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.kind" '"borrowed_ref"'
27+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.lifetime" \"\'a\"
28+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.mutable" false
29+
// @is - "$.index[*][?(@.name=='longest')].inner.decl.output.inner.type" '{"inner": "str", "kind": "primitive"}'
30+
31+
pub fn longest<'a>(l: &'a str, r: &'a str) -> &'a str {
32+
if l.len() > r.len() { l } else { r }
33+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// ignore-tidy-linelength
2+
3+
#![feature(no_core)]
4+
#![no_core]
5+
6+
// @count outlives.json "$.index[*][?(@.name=='foo')].inner.generics.params[*]" 3
7+
// @is - "$.index[*][?(@.name=='foo')].inner.generics.where_predicates" []
8+
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[0].name" \"\'a\"
9+
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[1].name" \"\'b\"
10+
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].name" '"T"'
11+
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[0].kind.lifetime.outlives" []
12+
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[1].kind.lifetime.outlives" [\"\'a\"]
13+
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.default" null
14+
// @count - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[*]" 1
15+
// @is - "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[0].outlives" \"\'b\"
16+
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].kind" '"borrowed_ref"'
17+
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\"
18+
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.mutable" false
19+
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.kind" '"borrowed_ref"'
20+
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.lifetime" \"\'b\"
21+
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.mutable" false
22+
// @is - "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.type" '{"inner": "T", "kind": "generic"}'
23+
pub fn foo<'a, 'b: 'a, T: 'b>(_: &'a &'b T) {}

0 commit comments

Comments
 (0)