@@ -44,6 +44,7 @@ use crate::config::{
44
44
SwitchWithOptPath ,
45
45
} ;
46
46
use crate :: filesearch:: FileSearch ;
47
+ use crate :: lint:: LintId ;
47
48
use crate :: parse:: { ParseSess , add_feature_diagnostics} ;
48
49
use crate :: search_paths:: SearchPath ;
49
50
use crate :: { errors, filesearch, lint} ;
@@ -139,7 +140,10 @@ pub struct CompilerIO {
139
140
pub temps_dir : Option < PathBuf > ,
140
141
}
141
142
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
+ }
143
147
144
148
/// Represents the data associated with a compilation
145
149
/// session for a single crate.
@@ -164,7 +168,7 @@ pub struct Session {
164
168
pub code_stats : CodeStats ,
165
169
166
170
/// 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 > > ,
168
172
169
173
/// Cap lint level specified by a driver specifically.
170
174
pub driver_lint_caps : FxHashMap < lint:: LintId , lint:: Level > ,
@@ -240,6 +244,12 @@ impl CodegenUnits {
240
244
}
241
245
}
242
246
247
+ pub struct LintGroup {
248
+ pub name : & ' static str ,
249
+ pub lints : Vec < LintId > ,
250
+ pub is_externally_loaded : bool ,
251
+ }
252
+
243
253
impl Session {
244
254
pub fn miri_unleashed_feature ( & self , span : Span , feature_gate : Option < Symbol > ) {
245
255
self . miri_unleashed_features . lock ( ) . push ( ( span, feature_gate) ) ;
@@ -596,6 +606,13 @@ impl Session {
596
606
( & * self . target . staticlib_prefix , & * self . target . staticlib_suffix )
597
607
}
598
608
}
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
+ }
599
616
}
600
617
601
618
// JUSTIFICATION: defn of the suggested wrapper fns
0 commit comments