@@ -237,12 +237,12 @@ impl Rule for RulesOfHooks {
237
237
}
238
238
239
239
// Is this node cyclic?
240
- if self . is_cyclic ( ctx , node , parent_func ) {
240
+ if semantic . cfg ( ) . is_cyclic ( node_cfg_id ) {
241
241
return ctx. diagnostic ( diagnostics:: loop_hook ( span, hook_name) ) ;
242
242
}
243
243
244
- if self . is_conditional ( ctx, func_cfg_id, node_cfg_id)
245
- || self . breaks_early ( ctx, func_cfg_id, node_cfg_id)
244
+ if Self :: is_conditional ( ctx, func_cfg_id, node_cfg_id)
245
+ || Self :: breaks_early ( ctx, func_cfg_id, node_cfg_id)
246
246
{
247
247
#[ allow( clippy:: needless_return) ]
248
248
return ctx. diagnostic ( diagnostics:: conditional_hook ( span, hook_name) ) ;
@@ -252,26 +252,8 @@ impl Rule for RulesOfHooks {
252
252
253
253
// TODO: all `dijkstra` algorithms can be merged together for better performance.
254
254
impl RulesOfHooks {
255
- #![ allow( clippy:: unused_self, clippy:: inline_always) ]
256
- #[ inline( always) ]
257
- fn is_cyclic ( & self , ctx : & LintContext , node : & AstNode , func : & AstNode ) -> bool {
258
- // TODO: use cfg instead
259
- ctx. nodes ( ) . ancestors ( node. id ( ) ) . take_while ( |id| * id != func. id ( ) ) . any ( |id| {
260
- let maybe_loop = ctx. nodes ( ) . kind ( id) ;
261
- matches ! {
262
- maybe_loop,
263
- | AstKind :: DoWhileStatement ( _)
264
- | AstKind :: ForInStatement ( _)
265
- | AstKind :: ForOfStatement ( _)
266
- | AstKind :: ForStatement ( _)
267
- | AstKind :: WhileStatement ( _)
268
- }
269
- } )
270
- }
271
-
272
- #[ inline( always) ]
255
+ #[ inline]
273
256
fn is_conditional (
274
- & self ,
275
257
ctx : & LintContext ,
276
258
func_cfg_id : BasicBlockId ,
277
259
node_cfg_id : BasicBlockId ,
@@ -288,9 +270,8 @@ impl RulesOfHooks {
288
270
. any ( |( f, _) | !cfg. is_reachabale ( f, node_cfg_id) )
289
271
}
290
272
291
- #[ inline( always ) ]
273
+ #[ inline]
292
274
fn breaks_early (
293
- & self ,
294
275
ctx : & LintContext ,
295
276
func_cfg_id : BasicBlockId ,
296
277
node_cfg_id : BasicBlockId ,
0 commit comments