3
3
4
4
use rustc_hir::def_id::{DefId, DefIdSet};
5
5
use rustc_middle::middle::privacy::AccessLevels;
6
- use rustc_session::lint;
7
6
use rustc_span::{InnerSpan, Span, DUMMY_SP};
8
7
use std::mem;
9
8
use std::ops::Range;
@@ -12,7 +11,6 @@ use self::Condition::*;
12
11
use crate::clean::{self, GetDefId, Item};
13
12
use crate::core::DocContext;
14
13
use crate::fold::{DocFolder, StripItem};
15
- use crate::html::markdown::{find_testable_code, ErrorCodes, LangString};
16
14
17
15
mod collapse_docs;
18
16
pub use self::collapse_docs::COLLAPSE_DOCS;
@@ -312,59 +310,6 @@ impl DocFolder for ImportStripper {
312
310
}
313
311
}
314
312
315
- pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
316
- let hir_id = match cx.as_local_hir_id(item.def_id) {
317
- Some(hir_id) => hir_id,
318
- None => {
319
- // If non-local, no need to check anything.
320
- return;
321
- }
322
- };
323
-
324
- struct Tests {
325
- found_tests: usize,
326
- }
327
-
328
- impl crate::test::Tester for Tests {
329
- fn add_test(&mut self, _: String, _: LangString, _: usize) {
330
- self.found_tests += 1;
331
- }
332
- }
333
-
334
- let mut tests = Tests { found_tests: 0 };
335
-
336
- find_testable_code(&dox, &mut tests, ErrorCodes::No, false, None);
337
-
338
- if tests.found_tests == 0 {
339
- use clean::ItemEnum::*;
340
-
341
- let should_report = match item.inner {
342
- ExternCrateItem(_, _) | ImportItem(_) | PrimitiveItem(_) | KeywordItem(_) => false,
343
- _ => true,
344
- };
345
- if should_report {
346
- debug!("reporting error for {:?} (hir_id={:?})", item, hir_id);
347
- let sp = span_of_attrs(&item.attrs).unwrap_or(item.source.span());
348
- cx.tcx.struct_span_lint_hir(
349
- lint::builtin::MISSING_DOC_CODE_EXAMPLES,
350
- hir_id,
351
- sp,
352
- |lint| lint.build("missing code example in this documentation").emit(),
353
- );
354
- }
355
- } else if rustc_feature::UnstableFeatures::from_environment().is_nightly_build()
356
- && tests.found_tests > 0
357
- && !cx.renderinfo.borrow().access_levels.is_public(item.def_id)
358
- {
359
- cx.tcx.struct_span_lint_hir(
360
- lint::builtin::PRIVATE_DOC_TESTS,
361
- hir_id,
362
- span_of_attrs(&item.attrs).unwrap_or(item.source.span()),
363
- |lint| lint.build("documentation test in private item").emit(),
364
- );
365
- }
366
- }
367
-
368
313
/// Returns a span encompassing all the given attributes.
369
314
crate fn span_of_attrs(attrs: &clean::Attributes) -> Option<Span> {
370
315
if attrs.doc_strings.is_empty() {
0 commit comments