]> git.lizzy.rs Git - rust.git/commitdiff
Store nightly build instead of checking env var every time
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 29 Sep 2018 15:16:06 +0000 (17:16 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 9 Oct 2018 14:47:14 +0000 (16:47 +0200)
src/librustc/lint/builtin.rs
src/librustdoc/core.rs
src/librustdoc/passes/collect_intra_doc_links.rs

index 66cb6f2b52acff46569999965cfa2b1577a4cf29..202a4284f4c82a2b07215909275bea8c208cd47c 100644 (file)
 }
 
 declare_lint! {
-    pub MISSING_DOC_ITEM_CODE_EXAMPLE,
+    pub MISSING_DOC_CODE_EXAMPLES,
     Allow,
     "warn about missing code example in an item's documentation"
 }
index fdd6929d98aedcb1b83a9187955ce1a8667d8ddb..76ca408327095a6070a9dee9712cb9db289a8d27 100644 (file)
@@ -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.
index f97300357153b0f833372c57e931250ea773e8e2..a780322e85e86af2c8ca2f7eb9494092d1bd44ca 100644 (file)
@@ -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<NodeId>,
+    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<Item> {
 
         look_for_tests(&cx, &dox, &item);
 
-        if !UnstableFeatures::from_environment().is_nightly_build() {
+        if !self.is_nightly_build {
             return None;
         }