diff options
| author | bors <bors@rust-lang.org> | 2022-03-04 00:27:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-04 00:27:23 +0000 |
| commit | 6d7684101a51f1c375ec84aef5d2fbdeb214bbc2 (patch) | |
| tree | d86722eb5dda8ae7ef9980dd4a19deebb9f37cf4 /src/test/rustdoc | |
| parent | 40d3040ae19b8c43c0027bc6d3e9805e5ee5e0ee (diff) | |
| parent | 0e57a16c88cbb042bf4d19934e0ccdd3838645ec (diff) | |
| download | rust-6d7684101a51f1c375ec84aef5d2fbdeb214bbc2.tar.gz rust-6d7684101a51f1c375ec84aef5d2fbdeb214bbc2.zip | |
Auto merge of #94009 - compiler-errors:gat-rustdoc, r=GuillaumeGomez
Support GATs in Rustdoc Implements: 1. Rendering GATs in trait definitions and impl blocks 2. Rendering GATs in types (e.g. in the return type of a function) Fixes #92341 This is my first rustdoc PR, so I have absolutely no idea how to produce tests for this. Advice from the rustdoc team would be wonderful! I tested locally and things looked correct: 
Diffstat (limited to 'src/test/rustdoc')
| -rw-r--r-- | src/test/rustdoc/generic-associated-types/gats.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/rustdoc/generic-associated-types/gats.rs b/src/test/rustdoc/generic-associated-types/gats.rs new file mode 100644 index 00000000000..ae981b9499a --- /dev/null +++ b/src/test/rustdoc/generic-associated-types/gats.rs @@ -0,0 +1,34 @@ +#![crate_name = "foo"] +#![feature(generic_associated_types)] + +// @has foo/trait.LendingIterator.html +pub trait LendingIterator { + // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a" + type Item<'a> where Self: 'a; + + // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]' \ + // "fn next<'a>(&'a self) -> Self::Item<'a>" + // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]//a[@href="trait.LendingIterator.html#associatedtype.Item"]' \ + // "Item" + fn next<'a>(&'a self) -> Self::Item<'a>; +} + +// @has foo/trait.LendingIterator.html +// @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item<'a> = ()" +impl LendingIterator for () { + type Item<'a> = (); + + fn next<'a>(&self) -> () {} +} + +pub struct Infinite<T>(T); + +// @has foo/trait.LendingIterator.html +// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a = &'a T" +impl<T> LendingIterator for Infinite<T> { + type Item<'a> where Self: 'a = &'a T; + + fn next<'a>(&'a self) -> Self::Item<'a> { + &self.0 + } +} |
