Skip to content

Commit 0e57a16

Browse files
add tests
1 parent 9f21514 commit 0e57a16

File tree

2 files changed

+76
-0
lines changed
  • src/test
    • rustdoc/generic-associated-types
    • rustdoc-json/generic-associated-types

2 files changed

+76
-0
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// ignore-tidy-linelength
2+
3+
#![no_core]
4+
#![feature(generic_associated_types, lang_items, no_core)]
5+
6+
#[lang = "sized"]
7+
pub trait Sized {}
8+
9+
pub trait Display {}
10+
11+
// @has gats.json
12+
pub trait LendingIterator {
13+
// @count - "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*]" 1
14+
// @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*].name" \"\'a\"
15+
// @count - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*]" 1
16+
// @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.ty.inner" \"Self\"
17+
// @is - "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.bounds[*].outlives" \"\'a\"
18+
// @count - "$.index[*][?(@.name=='LendingItem')].inner.bounds[*]" 1
19+
type LendingItem<'a>: Display where Self: 'a;
20+
21+
// @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.kind" \"qualified_path\"
22+
// @count - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 1
23+
// @count - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0
24+
// @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.self_type.inner" \"Self\"
25+
// @is - "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.name" \"LendingItem\"
26+
fn lending_next<'a>(&'a self) -> Self::LendingItem<'a>;
27+
}
28+
29+
// @has gats.json
30+
pub trait Iterator {
31+
// @count - "$.index[*][?(@.name=='Item')].inner.generics.params[*]" 0
32+
// @count - "$.index[*][?(@.name=='Item')].inner.generics.where_predicates[*]" 0
33+
// @count - "$.index[*][?(@.name=='Item')].inner.bounds[*]" 1
34+
type Item: Display;
35+
36+
// @is - "$.index[*][?(@.name=='next')].inner.decl.output.kind" \"qualified_path\"
37+
// @count - "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 0
38+
// @count - "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0
39+
// @is - "$.index[*][?(@.name=='next')].inner.decl.output.inner.self_type.inner" \"Self\"
40+
// @is - "$.index[*][?(@.name=='next')].inner.decl.output.inner.name" \"Item\"
41+
fn next<'a>(&'a self) -> Self::Item;
42+
}

Diff for: src/test/rustdoc/generic-associated-types/gats.rs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![crate_name = "foo"]
2+
#![feature(generic_associated_types)]
3+
4+
// @has foo/trait.LendingIterator.html
5+
pub trait LendingIterator {
6+
// @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a"
7+
type Item<'a> where Self: 'a;
8+
9+
// @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]' \
10+
// "fn next<'a>(&'a self) -> Self::Item<'a>"
11+
// @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]//a[@href="trait.LendingIterator.html#associatedtype.Item"]' \
12+
// "Item"
13+
fn next<'a>(&'a self) -> Self::Item<'a>;
14+
}
15+
16+
// @has foo/trait.LendingIterator.html
17+
// @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item<'a> = ()"
18+
impl LendingIterator for () {
19+
type Item<'a> = ();
20+
21+
fn next<'a>(&self) -> () {}
22+
}
23+
24+
pub struct Infinite<T>(T);
25+
26+
// @has foo/trait.LendingIterator.html
27+
// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a = &'a T"
28+
impl<T> LendingIterator for Infinite<T> {
29+
type Item<'a> where Self: 'a = &'a T;
30+
31+
fn next<'a>(&'a self) -> Self::Item<'a> {
32+
&self.0
33+
}
34+
}

0 commit comments

Comments
 (0)