@@ -20,7 +20,7 @@ pub struct Project {
2020 root : DesignRoot ,
2121 files : FnvHashMap < PathBuf , SourceFile > ,
2222 empty_libraries : FnvHashSet < Symbol > ,
23- lint : UnusedDeclarationsLinter ,
23+ lint : Option < UnusedDeclarationsLinter > ,
2424}
2525
2626impl Project {
@@ -31,11 +31,15 @@ impl Project {
3131 files : FnvHashMap :: default ( ) ,
3232 empty_libraries : FnvHashSet :: default ( ) ,
3333 parser,
34- lint : Default :: default ( ) ,
34+ lint : None ,
3535 config : Config :: default ( ) ,
3636 }
3737 }
3838
39+ pub fn enable_unused_declaration_detection ( & mut self ) {
40+ self . lint = Some ( UnusedDeclarationsLinter :: default ( ) ) ;
41+ }
42+
3943 /// Create instance from given configuration.
4044 /// Files referred by configuration are parsed into corresponding libraries.
4145 pub fn from_config ( config : Config , messages : & mut dyn MessageHandler ) -> Project {
@@ -228,8 +232,10 @@ impl Project {
228232 }
229233
230234 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+ }
233239
234240 diagnostics
235241 }
0 commit comments