diff options
| author | Shoyu Vanilla <modulo641@gmail.com> | 2024-02-17 14:27:05 +0900 |
|---|---|---|
| committer | Shoyu Vanilla <modulo641@gmail.com> | 2024-02-17 14:27:05 +0900 |
| commit | f5d43a052b9eb464e54af819143467954d814a24 (patch) | |
| tree | d84d8fc644f6633519ec2b30620a980f7f06a8bf | |
| parent | c9a7db6e20c8892f770b94dd6d5a16a03721b658 (diff) | |
| download | rust-f5d43a052b9eb464e54af819143467954d814a24.tar.gz rust-f5d43a052b9eb464e54af819143467954d814a24.zip | |
Fix missing trait impls for type in rustc docs
| -rw-r--r-- | src/librustdoc/clean/inline.rs | 19 | ||||
| -rw-r--r-- | src/librustdoc/config.rs | 4 | ||||
| -rw-r--r-- | tests/rustdoc/inline_cross/auxiliary/issue-76736-1.rs | 6 | ||||
| -rw-r--r-- | tests/rustdoc/inline_cross/auxiliary/issue-76736-2.rs | 5 | ||||
| -rw-r--r-- | tests/rustdoc/inline_cross/issue-76736-1.rs | 15 | ||||
| -rw-r--r-- | tests/rustdoc/inline_cross/issue-76736-2.rs | 16 | ||||
| -rw-r--r-- | tests/rustdoc/inline_cross/issue-76736-3.rs | 16 |
7 files changed, 74 insertions, 7 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index e2f2c9a5e56..03f62f41a26 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -443,11 +443,13 @@ pub(crate) fn build_impl( return; } - if let Some(stab) = tcx.lookup_stability(did) - && stab.is_unstable() - && stab.feature == sym::rustc_private - { - return; + if !tcx.features().rustc_private && !cx.render_options.force_unstable_if_unmarked { + if let Some(stab) = tcx.lookup_stability(did) + && stab.is_unstable() + && stab.feature == sym::rustc_private + { + return; + } } } @@ -477,8 +479,11 @@ pub(crate) fn build_impl( return; } - if let Some(stab) = tcx.lookup_stability(did) { - if stab.is_unstable() && stab.feature == sym::rustc_private { + if !tcx.features().rustc_private && !cx.render_options.force_unstable_if_unmarked { + if let Some(stab) = tcx.lookup_stability(did) + && stab.is_unstable() + && stab.feature == sym::rustc_private + { return; } } diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index c46047aa0db..4b1a417b211 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -281,6 +281,8 @@ pub(crate) struct RenderOptions { pub(crate) no_emit_shared: bool, /// If `true`, HTML source code pages won't be generated. pub(crate) html_no_source: bool, + /// Whether `-Zforce-unstable-if-unmarked` unstable option is set + pub(crate) force_unstable_if_unmarked: bool, } #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -347,6 +349,7 @@ impl Options { let codegen_options = CodegenOptions::build(early_dcx, matches); let unstable_opts = UnstableOptions::build(early_dcx, matches); + let force_unstable_if_unmarked = unstable_opts.force_unstable_if_unmarked; let dcx = new_dcx(error_format, None, diagnostic_width, &unstable_opts); @@ -760,6 +763,7 @@ impl Options { call_locations, no_emit_shared: false, html_no_source, + force_unstable_if_unmarked, }; Some((options, render_options)) } diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-76736-1.rs b/tests/rustdoc/inline_cross/auxiliary/issue-76736-1.rs new file mode 100644 index 00000000000..4ae9f79a532 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-76736-1.rs @@ -0,0 +1,6 @@ +#![feature(staged_api)] +#![unstable(feature = "rustc_private", issue = "none")] + +pub trait MaybeResult<T> {} + +impl<T> MaybeResult<T> for T {} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-76736-2.rs b/tests/rustdoc/inline_cross/auxiliary/issue-76736-2.rs new file mode 100644 index 00000000000..b5fbac97082 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-76736-2.rs @@ -0,0 +1,5 @@ +#![feature(rustc_private)] + +extern crate issue_76736_1; + +pub struct Bar; diff --git a/tests/rustdoc/inline_cross/issue-76736-1.rs b/tests/rustdoc/inline_cross/issue-76736-1.rs new file mode 100644 index 00000000000..25feae2c8d6 --- /dev/null +++ b/tests/rustdoc/inline_cross/issue-76736-1.rs @@ -0,0 +1,15 @@ +// aux-build:issue-76736-1.rs +// aux-build:issue-76736-2.rs + +#![crate_name = "foo"] + +extern crate issue_76736_1; +extern crate issue_76736_2; + +// @has foo/struct.Foo.html +// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +pub struct Foo; + +// @has foo/struct.Bar.html +// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +pub use issue_76736_2::Bar; diff --git a/tests/rustdoc/inline_cross/issue-76736-2.rs b/tests/rustdoc/inline_cross/issue-76736-2.rs new file mode 100644 index 00000000000..e43c825d6e1 --- /dev/null +++ b/tests/rustdoc/inline_cross/issue-76736-2.rs @@ -0,0 +1,16 @@ +// aux-build:issue-76736-1.rs +// aux-build:issue-76736-2.rs + +#![crate_name = "foo"] +#![feature(rustc_private)] + +extern crate issue_76736_1; +extern crate issue_76736_2; + +// @has foo/struct.Foo.html +// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +pub struct Foo; + +// @has foo/struct.Bar.html +// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +pub use issue_76736_2::Bar; diff --git a/tests/rustdoc/inline_cross/issue-76736-3.rs b/tests/rustdoc/inline_cross/issue-76736-3.rs new file mode 100644 index 00000000000..9542f3f3557 --- /dev/null +++ b/tests/rustdoc/inline_cross/issue-76736-3.rs @@ -0,0 +1,16 @@ +// compile-flags: -Zforce-unstable-if-unmarked +// aux-build:issue-76736-1.rs +// aux-build:issue-76736-2.rs + +#![crate_name = "foo"] + +extern crate issue_76736_1; +extern crate issue_76736_2; + +// @has foo/struct.Foo.html +// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +pub struct Foo; + +// @has foo/struct.Bar.html +// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +pub use issue_76736_2::Bar; |
