From 75ef0832ae00477f837a73356ea7f12f64134c7c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 7 Apr 2015 00:16:35 -0700 Subject: 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 (`::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 --- src/test/rustdoc/issue-20727-2.rs | 32 +++++++++++++++++++++++++ src/test/rustdoc/issue-20727-3.rs | 33 ++++++++++++++++++++++++++ src/test/rustdoc/issue-20727-4.rs | 49 +++++++++++++++++++++++++++++++++++++++ src/test/rustdoc/issue-20727.rs | 33 ++++++++++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 src/test/rustdoc/issue-20727-2.rs create mode 100644 src/test/rustdoc/issue-20727-3.rs create mode 100644 src/test/rustdoc/issue-20727-4.rs create mode 100644 src/test/rustdoc/issue-20727.rs (limited to 'src/test/rustdoc') 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 or the MIT license +// , 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 { + // @has - '//*[@class="rust trait"]' 'trait Add {' + // @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 {' + // @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 or the MIT license +// , 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 or the MIT license +// , 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 { + // @has - '//*[@class="rust trait"]' 'trait Index {' + // @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: Index { + // @has - '//*[@class="rust trait"]' \ + // 'trait IndexMut: Index {' + // @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 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: Index 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 or the MIT license +// , 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; +} -- cgit 1.4.1-3-g733a5