@@ -85,8 +85,6 @@ impl DocVisitor for LocalSourcesCollector<'_, '_> {
8585 fn visit_item ( & mut self , item : & clean:: Item ) {
8686 self . add_local_source ( item) ;
8787
88- // FIXME: if `include_sources` isn't set and DocFolder didn't require consuming the crate by value,
89- // we could return None here without having to walk the rest of the crate.
9088 self . visit_item_recur ( item)
9189 }
9290}
@@ -102,14 +100,18 @@ struct SourceCollector<'a, 'tcx> {
102100
103101impl DocVisitor for SourceCollector < ' _ , ' _ > {
104102 fn visit_item ( & mut self , item : & clean:: Item ) {
103+ if !self . cx . include_sources {
104+ return ;
105+ }
106+
105107 let tcx = self . cx . tcx ( ) ;
106108 let span = item. span ( tcx) ;
107109 let sess = tcx. sess ;
108110
109111 // If we're not rendering sources, there's nothing to do.
110112 // If we're including source files, and we haven't seen this file yet,
111113 // then we need to render it out to the filesystem.
112- if self . cx . include_sources && is_real_and_local ( span, sess) {
114+ if is_real_and_local ( span, sess) {
113115 let filename = span. filename ( sess) ;
114116 let span = span. inner ( ) ;
115117 let pos = sess. source_map ( ) . lookup_source_file ( span. lo ( ) ) ;
@@ -134,8 +136,7 @@ impl DocVisitor for SourceCollector<'_, '_> {
134136 }
135137 } ;
136138 }
137- // FIXME: if `include_sources` isn't set and DocFolder didn't require consuming the crate by value,
138- // we could return None here without having to walk the rest of the crate.
139+
139140 self . visit_item_recur ( item)
140141 }
141142}
0 commit comments