Skip to content

Commit 84b047b

Browse files
committed
Auto merge of #76032 - jyn514:lint-backport, r=Mark-Simulacrum
[beta] Backport fix for swapped stability attributes This backports the only commit in #75953, fixing one unstable lint which ran on stable and one stable lint which only ran on nightly. This change can be replicated with ``` git fetch origin git checkout origin/beta git cherry-pick 29399fa ```
2 parents 0f91f5c + adc747e commit 84b047b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: src/librustdoc/passes/doc_test_lints.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This pass is overloaded and runs two different lints.
22
//!
3-
//! - MISSING_DOC_CODE_EXAMPLES: this looks for public items missing doc-tests
4-
//! - PRIVATE_DOC_TESTS: this looks for private items with doc-tests.
3+
//! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doc-tests
4+
//! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doc-tests.
55
66
use super::{span_of_attrs, Pass};
77
use crate::clean;
@@ -89,7 +89,9 @@ pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
8989

9090
find_testable_code(&dox, &mut tests, ErrorCodes::No, false, None);
9191

92-
if tests.found_tests == 0 {
92+
if tests.found_tests == 0
93+
&& rustc_feature::UnstableFeatures::from_environment().is_nightly_build()
94+
{
9395
if should_have_doc_example(&item.inner) {
9496
debug!("reporting error for {:?} (hir_id={:?})", item, hir_id);
9597
let sp = span_of_attrs(&item.attrs).unwrap_or(item.source.span());
@@ -100,9 +102,7 @@ pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
100102
|lint| lint.build("missing code example in this documentation").emit(),
101103
);
102104
}
103-
} else if rustc_feature::UnstableFeatures::from_environment().is_nightly_build()
104-
&& tests.found_tests > 0
105-
&& !cx.renderinfo.borrow().access_levels.is_public(item.def_id)
105+
} else if tests.found_tests > 0 && !cx.renderinfo.borrow().access_levels.is_public(item.def_id)
106106
{
107107
cx.tcx.struct_span_lint_hir(
108108
lint::builtin::PRIVATE_DOC_TESTS,

0 commit comments

Comments
 (0)