diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-07 00:16:35 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-07 17:54:34 -0700 |
| commit | 75ef0832ae00477f837a73356ea7f12f64134c7c (patch) | |
| tree | 589e3b6fb2f10c5d5905650bbd936b8fd249a04f /src/test/rustdoc | |
| parent | 11f26f999581e639233e64f4f1fbc210a2bb856a (diff) | |
| download | rust-75ef0832ae00477f837a73356ea7f12f64134c7c.tar.gz rust-75ef0832ae00477f837a73356ea7f12f64134c7c.zip | |
rustdoc: Improve handling inlined associated types
* All bounds are now discovered through the trait to be inlined. * The `?Sized` bound now renders correctly for inlined associated types. * All `QPath`s (`<A as B>::C`) instances are rendered as `A::C` where `C` is a hyperlink to the trait `B`. This should improve at least how the docs look at least. * Supertrait bounds are now separated and display as the source lists them. Closes #20727 Closes #21145
Diffstat (limited to 'src/test/rustdoc')
| -rw-r--r-- | src/test/rustdoc/issue-20727-2.rs | 32 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-20727-3.rs | 33 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-20727-4.rs | 49 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-20727.rs | 33 |
4 files changed, 147 insertions, 0 deletions
diff --git a/src/test/rustdoc/issue-20727-2.rs b/src/test/rustdoc/issue-20727-2.rs new file mode 100644 index 00000000000..e0122d66de1 --- /dev/null +++ b/src/test/rustdoc/issue-20727-2.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-20727.rs + +extern crate issue_20727; + +// @has issue_20727_2/trait.Add.html +pub trait Add<RHS = Self> { + // @has - '//*[@class="rust trait"]' 'trait Add<RHS = Self> {' + // @has - '//*[@class="rust trait"]' 'type Output;' + type Output; + + // @has - '//*[@class="rust trait"]' 'fn add(self, rhs: RHS) -> Self::Output;' + fn add(self, rhs: RHS) -> Self::Output; +} + +// @has issue_20727_2/reexport/trait.Add.html +pub mod reexport { + // @has - '//*[@class="rust trait"]' 'trait Add<RHS = Self> {' + // @has - '//*[@class="rust trait"]' 'type Output;' + // @has - '//*[@class="rust trait"]' 'fn add(self, rhs: RHS) -> Self::Output;' + pub use issue_20727::Add; +} + diff --git a/src/test/rustdoc/issue-20727-3.rs b/src/test/rustdoc/issue-20727-3.rs new file mode 100644 index 00000000000..8338239a29d --- /dev/null +++ b/src/test/rustdoc/issue-20727-3.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-20727.rs + +extern crate issue_20727; + +pub trait Bar {} + +// @has issue_20727_3/trait.Deref2.html +pub trait Deref2 { + // @has - '//*[@class="rust trait"]' 'trait Deref2 {' + // @has - '//*[@class="rust trait"]' 'type Target: Bar;' + type Target: Bar; + + // @has - '//*[@class="rust trait"]' 'fn deref(&self) -> Self::Target;' + fn deref(&self) -> Self::Target; +} + +// @has issue_20727_3/reexport/trait.Deref2.html +pub mod reexport { + // @has - '//*[@class="rust trait"]' 'trait Deref2 {' + // @has - '//*[@class="rust trait"]' 'type Target: Bar;' + // @has - '//*[@class="rust trait"]' 'fn deref(&self) -> Self::Target;' + pub use issue_20727::Deref2; +} diff --git a/src/test/rustdoc/issue-20727-4.rs b/src/test/rustdoc/issue-20727-4.rs new file mode 100644 index 00000000000..ed361ed990a --- /dev/null +++ b/src/test/rustdoc/issue-20727-4.rs @@ -0,0 +1,49 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-20727.rs + +extern crate issue_20727; + +// @has issue_20727_4/trait.Index.html +pub trait Index<Idx: ?Sized> { + // @has - '//*[@class="rust trait"]' 'trait Index<Idx: ?Sized> {' + // @has - '//*[@class="rust trait"]' 'type Output: ?Sized' + type Output: ?Sized; + + // @has - '//*[@class="rust trait"]' \ + // 'fn index(&self, index: Idx) -> &Self::Output' + fn index(&self, index: Idx) -> &Self::Output; +} + +// @has issue_20727_4/trait.IndexMut.html +pub trait IndexMut<Idx: ?Sized>: Index<Idx> { + // @has - '//*[@class="rust trait"]' \ + // 'trait IndexMut<Idx: ?Sized>: Index<Idx> {' + // @has - '//*[@class="rust trait"]' \ + // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' + fn index_mut(&mut self, index: Idx) -> &mut Self::Output; +} + +pub mod reexport { + // @has issue_20727_4/reexport/trait.Index.html + // @has - '//*[@class="rust trait"]' 'trait Index<Idx> where Idx: ?Sized {' + // @has - '//*[@class="rust trait"]' 'type Output: ?Sized' + // @has - '//*[@class="rust trait"]' \ + // 'fn index(&self, index: Idx) -> &Self::Output' + pub use issue_20727::Index; + + // @has issue_20727_4/reexport/trait.IndexMut.html + // @has - '//*[@class="rust trait"]' \ + // 'trait IndexMut<Idx>: Index<Idx> where Idx: ?Sized {' + // @has - '//*[@class="rust trait"]' \ + // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' + pub use issue_20727::IndexMut; +} diff --git a/src/test/rustdoc/issue-20727.rs b/src/test/rustdoc/issue-20727.rs new file mode 100644 index 00000000000..9903ad34b4c --- /dev/null +++ b/src/test/rustdoc/issue-20727.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-20727.rs + +extern crate issue_20727; + +// @has issue_20727/trait.Deref.html +pub trait Deref { + // @has - '//*[@class="rust trait"]' 'trait Deref {' + // @has - '//*[@class="rust trait"]' 'type Target: ?Sized;' + type Target: ?Sized; + + // @has - '//*[@class="rust trait"]' \ + // "fn deref<'a>(&'a self) -> &'a Self::Target;" + fn deref<'a>(&'a self) -> &'a Self::Target; +} + +// @has issue_20727/reexport/trait.Deref.html +pub mod reexport { + // @has - '//*[@class="rust trait"]' 'trait Deref {' + // @has - '//*[@class="rust trait"]' 'type Target: ?Sized;' + // @has - '//*[@class="rust trait"]' \ + // "fn deref(&'a self) -> &'a Self::Target;" + pub use issue_20727::Deref; +} |
