@@ -85,8 +85,6 @@ impl DocVisitor for LocalSourcesCollector<'_, '_> {
85
85
fn visit_item ( & mut self , item : & clean:: Item ) {
86
86
self . add_local_source ( item) ;
87
87
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.
90
88
self . visit_item_recur ( item)
91
89
}
92
90
}
@@ -102,14 +100,18 @@ struct SourceCollector<'a, 'tcx> {
102
100
103
101
impl DocVisitor for SourceCollector < ' _ , ' _ > {
104
102
fn visit_item ( & mut self , item : & clean:: Item ) {
103
+ if !self . cx . include_sources {
104
+ return ;
105
+ }
106
+
105
107
let tcx = self . cx . tcx ( ) ;
106
108
let span = item. span ( tcx) ;
107
109
let sess = tcx. sess ;
108
110
109
111
// If we're not rendering sources, there's nothing to do.
110
112
// If we're including source files, and we haven't seen this file yet,
111
113
// 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) {
113
115
let filename = span. filename ( sess) ;
114
116
let span = span. inner ( ) ;
115
117
let pos = sess. source_map ( ) . lookup_source_file ( span. lo ( ) ) ;
@@ -134,8 +136,7 @@ impl DocVisitor for SourceCollector<'_, '_> {
134
136
}
135
137
} ;
136
138
}
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
+
139
140
self . visit_item_recur ( item)
140
141
}
141
142
}
0 commit comments