Auto merge of #33002 - mitaa:rdoc-cross-impls, r=alexcrichton
rustdoc: refine cross-crate impl inlining This changes the current rule that impls within `doc(hidden)` modules aren't inlined, to only inlining impls where the implemented trait and type are reachable in documentation. fixes #14586 fixes #31948 .. and also applies the reachability checking to cross-crate links. fixes #28480 r? @alexcrichton
This commit is contained in:
commit
478a33dabc
18 changed files with 473 additions and 130 deletions
22
src/test/auxiliary/rustdoc-hidden-sig.rs
Normal file
22
src/test/auxiliary/rustdoc-hidden-sig.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
pub struct Bar;
|
||||
|
||||
impl Bar {
|
||||
pub fn bar(_: u8) -> hidden::Hidden {
|
||||
hidden::Hidden
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod hidden {
|
||||
pub struct Hidden;
|
||||
}
|
||||
44
src/test/auxiliary/rustdoc-nonreachable-impls.rs
Normal file
44
src/test/auxiliary/rustdoc-nonreachable-impls.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
pub struct Foo;
|
||||
|
||||
pub trait Woof {}
|
||||
pub trait Bark {}
|
||||
|
||||
mod private {
|
||||
// should be shown
|
||||
impl ::Woof for ::Foo {}
|
||||
|
||||
pub trait Bar {}
|
||||
pub struct Wibble;
|
||||
|
||||
// these should not be shown
|
||||
impl Bar for ::Foo {}
|
||||
impl Bar for Wibble {}
|
||||
impl ::Bark for Wibble {}
|
||||
impl ::Woof for Wibble {}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod hidden {
|
||||
// should be shown
|
||||
impl ::Bark for ::Foo {}
|
||||
|
||||
pub trait Qux {}
|
||||
pub struct Wobble;
|
||||
|
||||
|
||||
// these should only be shown if they're reexported correctly
|
||||
impl Qux for ::Foo {}
|
||||
impl Qux for Wobble {}
|
||||
impl ::Bark for Wobble {}
|
||||
impl ::Woof for Wobble {}
|
||||
}
|
||||
23
src/test/rustdoc/inline_cross/issue-28480.rs
Normal file
23
src/test/rustdoc/inline_cross/issue-28480.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2016 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:rustdoc-hidden-sig.rs
|
||||
// build-aux-docs
|
||||
// ignore-cross-compile
|
||||
|
||||
// @has rustdoc_hidden_sig/struct.Bar.html
|
||||
// @!has - '//a/@title' 'Hidden'
|
||||
// @has - '//a' 'u8'
|
||||
extern crate rustdoc_hidden_sig;
|
||||
|
||||
// @has issue_28480/struct.Bar.html
|
||||
// @!has - '//a/@title' 'Hidden'
|
||||
// @has - '//a' 'u8'
|
||||
pub use rustdoc_hidden_sig::Bar;
|
||||
37
src/test/rustdoc/inline_cross/issue-31948-1.rs
Normal file
37
src/test/rustdoc/inline_cross/issue-31948-1.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2016 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:rustdoc-nonreachable-impls.rs
|
||||
// build-aux-docs
|
||||
// ignore-cross-compile
|
||||
|
||||
extern crate rustdoc_nonreachable_impls;
|
||||
|
||||
// @has issue_31948_1/struct.Wobble.html
|
||||
// @has - '//*[@class="impl"]//code' 'Bark for'
|
||||
// @has - '//*[@class="impl"]//code' 'Woof for'
|
||||
// @!has - '//*[@class="impl"]//code' 'Bar for'
|
||||
// @!has - '//*[@class="impl"]//code' 'Qux for'
|
||||
pub use rustdoc_nonreachable_impls::hidden::Wobble;
|
||||
|
||||
// @has issue_31948_1/trait.Bark.html
|
||||
// FIXME(33025): has - '//code' 'for Foo'
|
||||
// @has - '//code' 'for Wobble'
|
||||
// @!has - '//code' 'for Wibble'
|
||||
pub use rustdoc_nonreachable_impls::Bark;
|
||||
|
||||
// @has issue_31948_1/trait.Woof.html
|
||||
// FIXME(33025): has - '//code' 'for Foo'
|
||||
// @has - '//code' 'for Wobble'
|
||||
// @!has - '//code' 'for Wibble'
|
||||
pub use rustdoc_nonreachable_impls::Woof;
|
||||
|
||||
// @!has issue_31948_1/trait.Bar.html
|
||||
// @!has issue_31948_1/trait.Qux.html
|
||||
31
src/test/rustdoc/inline_cross/issue-31948-2.rs
Normal file
31
src/test/rustdoc/inline_cross/issue-31948-2.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2016 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:rustdoc-nonreachable-impls.rs
|
||||
// build-aux-docs
|
||||
// ignore-cross-compile
|
||||
|
||||
extern crate rustdoc_nonreachable_impls;
|
||||
|
||||
// @has issue_31948_2/struct.Wobble.html
|
||||
// @has - '//*[@class="impl"]//code' 'Qux for'
|
||||
// @has - '//*[@class="impl"]//code' 'Bark for'
|
||||
// @has - '//*[@class="impl"]//code' 'Woof for'
|
||||
// @!has - '//*[@class="impl"]//code' 'Bar for'
|
||||
pub use rustdoc_nonreachable_impls::hidden::Wobble;
|
||||
|
||||
// @has issue_31948_2/trait.Qux.html
|
||||
// FIXME(33025): has - '//code' 'for Foo'
|
||||
// @has - '//code' 'for Wobble'
|
||||
pub use rustdoc_nonreachable_impls::hidden::Qux;
|
||||
|
||||
// @!has issue_31948_2/trait.Bar.html
|
||||
// @!has issue_31948_2/trait.Woof.html
|
||||
// @!has issue_31948_2/trait.Bark.html
|
||||
39
src/test/rustdoc/inline_cross/issue-31948.rs
Normal file
39
src/test/rustdoc/inline_cross/issue-31948.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2016 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:rustdoc-nonreachable-impls.rs
|
||||
// build-aux-docs
|
||||
// ignore-cross-compile
|
||||
|
||||
extern crate rustdoc_nonreachable_impls;
|
||||
|
||||
// @has issue_31948/struct.Foo.html
|
||||
// @has - '//*[@class="impl"]//code' 'Bark for'
|
||||
// @has - '//*[@class="impl"]//code' 'Woof for'
|
||||
// @!has - '//*[@class="impl"]//code' 'Bar for'
|
||||
// @!has - '//*[@class="impl"]//code' 'Qux for'
|
||||
pub use rustdoc_nonreachable_impls::Foo;
|
||||
|
||||
// @has issue_31948/trait.Bark.html
|
||||
// @has - '//code' 'for Foo'
|
||||
// @!has - '//code' 'for Wibble'
|
||||
// @!has - '//code' 'for Wobble'
|
||||
pub use rustdoc_nonreachable_impls::Bark;
|
||||
|
||||
// @has issue_31948/trait.Woof.html
|
||||
// @has - '//code' 'for Foo'
|
||||
// @!has - '//code' 'for Wibble'
|
||||
// @!has - '//code' 'for Wobble'
|
||||
pub use rustdoc_nonreachable_impls::Woof;
|
||||
|
||||
// @!has issue_31948/trait.Bar.html
|
||||
// @!has issue_31948/trait.Qux.html
|
||||
// @!has issue_31948/struct.Wibble.html
|
||||
// @!has issue_31948/struct.Wobble.html
|
||||
Loading…
Add table
Add a link
Reference in a new issue