about summary refs log tree commit diff
path: root/tests/rustdoc-json
diff options
context:
space:
mode:
authorAlona Enraght-Moony <code@alona.page>2024-07-03 19:57:15 +0000
committerAlona Enraght-Moony <code@alona.page>2024-07-03 20:00:56 +0000
commit7e8aac553e756b0eb03fe98e1a65ffc47836ec51 (patch)
tree074fd4ae0a4fb8eea22d2c6f006fcba916d319e3 /tests/rustdoc-json
parentc872a1418a4be3ea84a8d5232238b60d35339ba9 (diff)
downloadrust-7e8aac553e756b0eb03fe98e1a65ffc47836ec51.tar.gz
rust-7e8aac553e756b0eb03fe98e1a65ffc47836ec51.zip
rustdoc-json: Better representation of lifetime bounds in where clauses.
As suggested [on zulip][1], there's no need to use `GenericBound` here,
as the only bound a lifetime can have is that it outlives other
lifetimes.

While we're making breaking changes here, I also renamed it from using
"region" to "lifetime", as this is more user-aligned. See [this
comment][2] for details.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/.60ItemEnum.3A.3AOpaqueTy.60/near/448871430
[2]: https://github.com/rust-lang/rust/issues/100961#issuecomment-2206565556
Diffstat (limited to 'tests/rustdoc-json')
-rw-r--r--tests/rustdoc-json/lifetime/outlives_in_param.rs8
-rw-r--r--tests/rustdoc-json/lifetime/outlives_in_where.rs24
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/rustdoc-json/lifetime/outlives_in_param.rs b/tests/rustdoc-json/lifetime/outlives_in_param.rs
new file mode 100644
index 00000000000..f6db93c9183
--- /dev/null
+++ b/tests/rustdoc-json/lifetime/outlives_in_param.rs
@@ -0,0 +1,8 @@
+// ignore-tidy-linelength
+
+// @count '$.index[*][?(@.name=="outlives")].inner.function.generics.params[*]' 2
+// @is    '$.index[*][?(@.name=="outlives")].inner.function.generics.params[0].name' \"\'a\"
+// @is    '$.index[*][?(@.name=="outlives")].inner.function.generics.params[0].kind.lifetime.outlives' []
+// @is    '$.index[*][?(@.name=="outlives")].inner.function.generics.params[1].name' '"T"'
+// @is    '$.index[*][?(@.name=="outlives")].inner.function.generics.params[1].kind.type.bounds' '[{"outlives": "'\''a"}]'
+pub fn outlives<'a, T: 'a>() {}
diff --git a/tests/rustdoc-json/lifetime/outlives_in_where.rs b/tests/rustdoc-json/lifetime/outlives_in_where.rs
new file mode 100644
index 00000000000..ca3e1a150ce
--- /dev/null
+++ b/tests/rustdoc-json/lifetime/outlives_in_where.rs
@@ -0,0 +1,24 @@
+// ignore-tidy-linelength
+
+// @is '$.index[*][?(@.name=="on_lifetimes")].inner.function.generics.where_predicates' '[{"lifetime_predicate": {"lifetime": "'\''all", "outlives": ["'\''a", "'\''b", "'\''c"]}}]'
+pub fn on_lifetimes<'a, 'b, 'c, 'all>()
+where
+    'all: 'a + 'b + 'c,
+{
+}
+
+// @count '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[*]' 2
+// @is    '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[0].name' \"\'a\"
+// @is    '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[0].kind.lifetime.outlives' []
+// @is    '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[1].name' '"T"'
+// @is    '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[1].kind.type.bounds' []
+// @is    '$.index[*][?(@.name=="on_trait")].inner.function.generics.params[1].kind.type.bounds' []
+// @count '$.index[*][?(@.name=="on_trait")].inner.function.generics.where_predicates[*]' 1
+// @is    '$.index[*][?(@.name=="on_trait")].inner.function.generics.where_predicates[0].bound_predicate.type.generic' '"T"'
+// @count '$.index[*][?(@.name=="on_trait")].inner.function.generics.where_predicates[0].bound_predicate.bounds[*]' 1
+// @is    '$.index[*][?(@.name=="on_trait")].inner.function.generics.where_predicates[0].bound_predicate.bounds[0].outlives' \"\'a\"
+pub fn on_trait<'a, T>()
+where
+    T: 'a,
+{
+}