@@ -20,7 +20,7 @@ pub struct Project {
20
20
root : DesignRoot ,
21
21
files : FnvHashMap < PathBuf , SourceFile > ,
22
22
empty_libraries : FnvHashSet < Symbol > ,
23
- lint : UnusedDeclarationsLinter ,
23
+ lint : Option < UnusedDeclarationsLinter > ,
24
24
}
25
25
26
26
impl Project {
@@ -31,11 +31,15 @@ impl Project {
31
31
files : FnvHashMap :: default ( ) ,
32
32
empty_libraries : FnvHashSet :: default ( ) ,
33
33
parser,
34
- lint : Default :: default ( ) ,
34
+ lint : None ,
35
35
config : Config :: default ( ) ,
36
36
}
37
37
}
38
38
39
+ pub fn enable_unused_declaration_detection ( & mut self ) {
40
+ self . lint = Some ( UnusedDeclarationsLinter :: default ( ) ) ;
41
+ }
42
+
39
43
/// Create instance from given configuration.
40
44
/// Files referred by configuration are parsed into corresponding libraries.
41
45
pub fn from_config ( config : Config , messages : & mut dyn MessageHandler ) -> Project {
@@ -228,8 +232,10 @@ impl Project {
228
232
}
229
233
230
234
let analyzed_units = self . root . analyze ( & mut diagnostics) ;
231
- self . lint
232
- . lint ( & self . root , & self . config , & analyzed_units, & mut diagnostics) ;
235
+
236
+ if let Some ( ref mut lint) = self . lint {
237
+ lint. lint ( & self . root , & self . config , & analyzed_units, & mut diagnostics) ;
238
+ }
233
239
234
240
diagnostics
235
241
}
0 commit comments