forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#113374 - GuillaumeGomez:private-to-public-p…
…ath, r=notriddle,fmease [rustdoc] If re-export is private, get the next item until a public one is found or expose the private item directly Fixes rust-lang#81141. If we have: ```rust use Private as Something; pub fn foo() -> Something {} ``` Then `Something` will be replaced by `Private`. r? ````@notriddle````
- Loading branch information
Showing
3 changed files
with
234 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// edition:2015 | ||
|
||
#![crate_name = "foo"] | ||
|
||
use external::Public as Private; | ||
|
||
pub mod external { | ||
pub struct Public; | ||
|
||
// @has 'foo/external/fn.make.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' | ||
pub fn make() -> ::Private { super::Private } | ||
} |
124 changes: 124 additions & 0 deletions
124
tests/rustdoc/issue-81141-private-reexport-in-public-api.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// This test ensures that if a private re-export is present in a public API, it'll be | ||
// replaced by the first public item in the re-export chain or by the private item. | ||
|
||
#![crate_name = "foo"] | ||
|
||
use crate::bar::Bar as Alias; | ||
|
||
pub use crate::bar::Bar as Whatever; | ||
use crate::Whatever as Whatever2; | ||
use crate::Whatever2 as Whatever3; | ||
pub use crate::bar::Inner as Whatever4; | ||
|
||
mod bar { | ||
pub struct Bar; | ||
pub use self::Bar as Inner; | ||
} | ||
|
||
// @has 'foo/fn.bar.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' | ||
pub fn bar() -> Alias { | ||
Alias | ||
} | ||
|
||
// @has 'foo/fn.bar2.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Whatever' | ||
pub fn bar2() -> Whatever3 { | ||
Whatever | ||
} | ||
|
||
// @has 'foo/fn.bar3.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Whatever4' | ||
pub fn bar3() -> Whatever4 { | ||
Whatever | ||
} | ||
|
||
// @has 'foo/fn.bar4.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar4() -> Bar' | ||
pub fn bar4() -> crate::Alias { | ||
Alias | ||
} | ||
|
||
// @has 'foo/fn.bar5.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar5() -> Whatever' | ||
pub fn bar5() -> crate::Whatever3 { | ||
Whatever | ||
} | ||
|
||
// @has 'foo/fn.bar6.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar6() -> Whatever4' | ||
pub fn bar6() -> crate::Whatever4 { | ||
Whatever | ||
} | ||
|
||
|
||
// @has 'foo/fn.bar7.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar7() -> Bar' | ||
pub fn bar7() -> self::Alias { | ||
Alias | ||
} | ||
|
||
// @has 'foo/fn.bar8.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar8() -> Whatever' | ||
pub fn bar8() -> self::Whatever3 { | ||
Whatever | ||
} | ||
|
||
// @has 'foo/fn.bar9.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar9() -> Whatever4' | ||
pub fn bar9() -> self::Whatever4 { | ||
Whatever | ||
} | ||
|
||
mod nested { | ||
pub(crate) use crate::Alias; | ||
pub(crate) use crate::Whatever3; | ||
pub(crate) use crate::Whatever4; | ||
pub(crate) use crate::nested as nested2; | ||
} | ||
|
||
// @has 'foo/fn.bar10.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar10() -> Bar' | ||
pub fn bar10() -> nested::Alias { | ||
Alias | ||
} | ||
|
||
// @has 'foo/fn.bar11.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar11() -> Whatever' | ||
pub fn bar11() -> nested::Whatever3 { | ||
Whatever | ||
} | ||
|
||
// @has 'foo/fn.bar12.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar12() -> Whatever4' | ||
pub fn bar12() -> nested::Whatever4 { | ||
Whatever | ||
} | ||
|
||
// @has 'foo/fn.bar13.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar13() -> Bar' | ||
pub fn bar13() -> nested::nested2::Alias { | ||
Alias | ||
} | ||
|
||
// @has 'foo/fn.bar14.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar14() -> Whatever' | ||
pub fn bar14() -> nested::nested2::Whatever3 { | ||
Whatever | ||
} | ||
|
||
// @has 'foo/fn.bar15.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar15() -> Whatever4' | ||
pub fn bar15() -> nested::nested2::Whatever4 { | ||
Whatever | ||
} | ||
|
||
use external::Public as Private; | ||
|
||
pub mod external { | ||
pub struct Public; | ||
|
||
// @has 'foo/external/fn.make.html' | ||
// @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' | ||
pub fn make() -> super::Private { super::Private } | ||
} |