@@ -44,6 +44,7 @@ use crate::config::{
4444 SwitchWithOptPath ,
4545} ;
4646use crate :: filesearch:: FileSearch ;
47+ use crate :: lint:: LintId ;
4748use crate :: parse:: { ParseSess , add_feature_diagnostics} ;
4849use crate :: search_paths:: SearchPath ;
4950use crate :: { errors, filesearch, lint} ;
@@ -139,7 +140,10 @@ pub struct CompilerIO {
139140 pub temps_dir : Option < PathBuf > ,
140141}
141142
142- pub trait LintStoreMarker : Any + DynSync + DynSend { }
143+ pub trait DynLintStore : Any + DynSync + DynSend {
144+ /// Provides a way to access lint groups without depending on `rustc_lint`
145+ fn lint_groups_iter ( & self ) -> Box < dyn Iterator < Item = LintGroup > + ' _ > ;
146+ }
143147
144148/// Represents the data associated with a compilation
145149/// session for a single crate.
@@ -164,7 +168,7 @@ pub struct Session {
164168 pub code_stats : CodeStats ,
165169
166170 /// This only ever stores a `LintStore` but we don't want a dependency on that type here.
167- pub lint_store : Option < Arc < dyn LintStoreMarker > > ,
171+ pub lint_store : Option < Arc < dyn DynLintStore > > ,
168172
169173 /// Cap lint level specified by a driver specifically.
170174 pub driver_lint_caps : FxHashMap < lint:: LintId , lint:: Level > ,
@@ -240,6 +244,12 @@ impl CodegenUnits {
240244 }
241245}
242246
247+ pub struct LintGroup {
248+ pub name : & ' static str ,
249+ pub lints : Vec < LintId > ,
250+ pub is_externally_loaded : bool ,
251+ }
252+
243253impl Session {
244254 pub fn miri_unleashed_feature ( & self , span : Span , feature_gate : Option < Symbol > ) {
245255 self . miri_unleashed_features . lock ( ) . push ( ( span, feature_gate) ) ;
@@ -596,6 +606,13 @@ impl Session {
596606 ( & * self . target . staticlib_prefix , & * self . target . staticlib_suffix )
597607 }
598608 }
609+
610+ pub fn lint_groups_iter ( & self ) -> Box < dyn Iterator < Item = LintGroup > + ' _ > {
611+ match self . lint_store {
612+ Some ( ref lint_store) => lint_store. lint_groups_iter ( ) ,
613+ None => Box :: new ( std:: iter:: empty ( ) ) ,
614+ }
615+ }
599616}
600617
601618// JUSTIFICATION: defn of the suggested wrapper fns
0 commit comments