about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNoah Lev <camelidcamel@gmail.com>2021-10-31 21:05:09 -0700
committerNoah Lev <camelidcamel@gmail.com>2021-10-31 21:05:09 -0700
commit4ee2d0351a67e382f56a85eaeada0b7c773f0691 (patch)
treeea26016e4758d9b460274844f931ef3c7706db4e /src
parent6215f7c85fe7dae4240d9bdb35c46fcaf5b5903d (diff)
downloadrust-4ee2d0351a67e382f56a85eaeada0b7c773f0691.tar.gz
rust-4ee2d0351a67e382f56a85eaeada0b7c773f0691.zip
Fix FIXMEs in `rustdoc::html::sources`
One of the FIXMEs is irrelevant since that code is only run if
`include_sources` is set. I fixed the other FIXME.
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/sources.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs
index 0a9f9741d7b..30ec592ba23 100644
--- a/src/librustdoc/html/sources.rs
+++ b/src/librustdoc/html/sources.rs
@@ -85,8 +85,6 @@ impl DocVisitor for LocalSourcesCollector<'_, '_> {
     fn visit_item(&mut self, item: &clean::Item) {
         self.add_local_source(item);
 
-        // FIXME: if `include_sources` isn't set and DocFolder didn't require consuming the crate by value,
-        // we could return None here without having to walk the rest of the crate.
         self.visit_item_recur(item)
     }
 }
@@ -102,6 +100,10 @@ struct SourceCollector<'a, 'tcx> {
 
 impl DocVisitor for SourceCollector<'_, '_> {
     fn visit_item(&mut self, item: &clean::Item) {
+        if !self.cx.include_sources {
+            return;
+        }
+
         let tcx = self.cx.tcx();
         let span = item.span(tcx);
         let sess = tcx.sess;
@@ -109,7 +111,7 @@ impl DocVisitor for SourceCollector<'_, '_> {
         // If we're not rendering sources, there's nothing to do.
         // If we're including source files, and we haven't seen this file yet,
         // then we need to render it out to the filesystem.
-        if self.cx.include_sources && is_real_and_local(span, sess) {
+        if is_real_and_local(span, sess) {
             let filename = span.filename(sess);
             let span = span.inner();
             let pos = sess.source_map().lookup_source_file(span.lo());
@@ -134,8 +136,7 @@ impl DocVisitor for SourceCollector<'_, '_> {
                 }
             };
         }
-        // FIXME: if `include_sources` isn't set and DocFolder didn't require consuming the crate by value,
-        // we could return None here without having to walk the rest of the crate.
+
         self.visit_item_recur(item)
     }
 }