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