diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/rustdoc/generic-associated-types | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rustdoc/generic-associated-types')
-rw-r--r-- | tests/rustdoc/generic-associated-types/gats.rs | 33 | ||||
-rw-r--r-- | tests/rustdoc/generic-associated-types/issue-94683.rs | 12 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/rustdoc/generic-associated-types/gats.rs b/tests/rustdoc/generic-associated-types/gats.rs new file mode 100644 index 000000000..bcead3115 --- /dev/null +++ b/tests/rustdoc/generic-associated-types/gats.rs @@ -0,0 +1,33 @@ +#![crate_name = "foo"] + +// @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 + } +} diff --git a/tests/rustdoc/generic-associated-types/issue-94683.rs b/tests/rustdoc/generic-associated-types/issue-94683.rs new file mode 100644 index 000000000..985c7e983 --- /dev/null +++ b/tests/rustdoc/generic-associated-types/issue-94683.rs @@ -0,0 +1,12 @@ +#![crate_name = "foo"] + +pub trait Trait { + type Gat<'a>; +} + +// Make sure that the elided lifetime shows up + +// @has foo/type.T.html +// @hasraw - "pub type T = " +// @hasraw - "<'_>" +pub type T = fn(&<() as Trait>::Gat<'_>); |