From 2def81a5f1d48625f74ed401329fd9af4e8668f2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 29 Sep 2018 17:16:06 +0200 Subject: [PATCH] Store nightly build instead of checking env var every time --- src/librustc/lint/builtin.rs | 2 +- src/librustdoc/core.rs | 2 +- src/librustdoc/passes/collect_intra_doc_links.rs | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 66cb6f2b52a..202a4284f4c 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -313,7 +313,7 @@ } declare_lint! { - pub MISSING_DOC_ITEM_CODE_EXAMPLE, + pub MISSING_DOC_CODE_EXAMPLES, Allow, "warn about missing code example in an item's documentation" } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index fdd6929d98a..76ca4083270 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -348,7 +348,7 @@ pub fn run_core(search_paths: SearchPaths, let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE.name; let warnings_lint_name = lint::builtin::WARNINGS.name; let missing_docs = rustc_lint::builtin::MISSING_DOCS.name; - let missing_doc_example = rustc_lint::builtin::MISSING_DOC_ITEM_CODE_EXAMPLE.name; + let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name; // In addition to those specific lints, we also need to whitelist those given through // command line, otherwise they'll get ignored and we don't want that. diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index f9730035715..a780322e85e 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -57,6 +57,7 @@ enum PathKind { struct LinkCollector<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> { cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>, mod_ids: Vec, + is_nightly_build: bool, } impl<'a, 'tcx, 'rcx, 'cstore> LinkCollector<'a, 'tcx, 'rcx, 'cstore> { @@ -64,6 +65,7 @@ fn new(cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>) -> Self { LinkCollector { cx, mod_ids: Vec::new(), + is_nightly_build: UnstableFeatures::from_environment().is_nightly_build(), } } @@ -240,7 +242,7 @@ fn add_test(&mut self, _: String, _: LangString, _: usize) { if find_testable_code(&dox, &mut tests, ErrorCodes::No).is_ok() { if tests.found_tests == 0 { let mut diag = cx.tcx.struct_span_lint_node( - lint::builtin::MISSING_DOC_ITEM_CODE_EXAMPLE, + lint::builtin::MISSING_DOC_CODE_EXAMPLES, NodeId::new(0), span_of_attrs(&item.attrs), "Missing code example in this documentation"); @@ -313,7 +315,7 @@ fn fold_item(&mut self, mut item: Item) -> Option { look_for_tests(&cx, &dox, &item); - if !UnstableFeatures::from_environment().is_nightly_build() { + if !self.is_nightly_build { return None; } -- 2.44.0