1- use solar:: { interface:: data_structures:: Never , sema:: hir} ;
1+ use solar:: {
2+ interface:: data_structures:: Never ,
3+ sema:: { Gcx , hir} ,
4+ } ;
25use std:: ops:: ControlFlow ;
36
47use super :: LintContext ;
@@ -62,6 +65,15 @@ pub trait LateLintPass<'hir>: Send + Sync {
6265 _func : & ' hir hir:: Function < ' hir > ,
6366 ) {
6467 }
68+ fn check_function_with_gcx (
69+ & mut self ,
70+ ctx : & LintContext ,
71+ _gcx : Gcx < ' hir > ,
72+ hir : & ' hir hir:: Hir < ' hir > ,
73+ func : & ' hir hir:: Function < ' hir > ,
74+ ) {
75+ self . check_function ( ctx, hir, func) ;
76+ }
6577 fn check_modifier (
6678 & mut self ,
6779 _ctx : & LintContext ,
@@ -110,6 +122,7 @@ pub trait LateLintPass<'hir>: Send + Sync {
110122pub struct LateLintVisitor < ' a , ' s , ' hir > {
111123 ctx : & ' a LintContext < ' s , ' a > ,
112124 passes : & ' a mut [ Box < dyn LateLintPass < ' hir > + ' s > ] ,
125+ gcx : Gcx < ' hir > ,
113126 hir : & ' hir hir:: Hir < ' hir > ,
114127}
115128
@@ -120,9 +133,10 @@ where
120133 pub fn new (
121134 ctx : & ' a LintContext < ' s , ' a > ,
122135 passes : & ' a mut [ Box < dyn LateLintPass < ' hir > + ' s > ] ,
136+ gcx : Gcx < ' hir > ,
123137 hir : & ' hir hir:: Hir < ' hir > ,
124138 ) -> Self {
125- Self { ctx, passes, hir }
139+ Self { ctx, passes, gcx , hir }
126140 }
127141}
128142
@@ -183,7 +197,7 @@ where
183197
184198 fn visit_function ( & mut self , func : & ' hir hir:: Function < ' hir > ) -> ControlFlow < Self :: BreakValue > {
185199 for pass in self . passes . iter_mut ( ) {
186- pass. check_function ( self . ctx , self . hir , func) ;
200+ pass. check_function_with_gcx ( self . ctx , self . gcx , self . hir , func) ;
187201 }
188202 self . walk_function ( func)
189203 }
@@ -389,7 +403,7 @@ mod tests {
389403 ) ;
390404 let mut passes: Vec < Box < dyn LateLintPass < ' _ > > > =
391405 vec ! [ Box :: new( RecordingPass { counts: counts. clone( ) } ) ] ;
392- let mut visitor = LateLintVisitor :: new ( & ctx, & mut passes, & gcx. hir ) ;
406+ let mut visitor = LateLintVisitor :: new ( & ctx, & mut passes, gcx , & gcx. hir ) ;
393407 let _ = hir:: Visit :: visit_nested_source ( & mut visitor, source_id) ;
394408 Ok ( ( ) )
395409 } )
0 commit comments