File tree 3 files changed +11
-16
lines changed
oxc_linter/src/rules/react
3 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -228,12 +228,7 @@ impl Rule for RulesOfHooks {
228
228
return ;
229
229
}
230
230
231
- if !petgraph:: algo:: has_path_connecting (
232
- & semantic. cfg ( ) . graph ,
233
- func_cfg_id,
234
- node_cfg_id,
235
- None ,
236
- ) {
231
+ if !ctx. semantic ( ) . cfg ( ) . is_reachabale ( func_cfg_id, node_cfg_id) {
237
232
// There should always be a control flow path between a parent and child node.
238
233
// If there is none it means we always do an early exit before reaching our hook call.
239
234
// In some cases it might mean that we are operating on an invalid `cfg` but in either
Original file line number Diff line number Diff line change @@ -111,7 +111,8 @@ fn main() -> std::io::Result<()> {
111
111
}
112
112
} ) ;
113
113
format!(
114
- "xlabel = \" nodes [{}]\\ l\" , label = \" bb{}\n {}\" " ,
114
+ "xlabel = \" nodes{} [{}]\\ l\" , label = \" bb{}\n {}\" " ,
115
+ node. 1 ,
115
116
nodes,
116
117
node. 1 ,
117
118
semantic. semantic. cfg( ) . basic_blocks[ * node. 1 ]
Original file line number Diff line number Diff line change @@ -197,17 +197,16 @@ impl ControlFlowGraph {
197
197
let graph = & self . graph ;
198
198
depth_first_search ( & self . graph , Some ( from) , |event| match event {
199
199
DfsEvent :: TreeEdge ( a, b) => {
200
- if b == to {
201
- return Control :: Break ( true ) ;
202
- }
203
-
204
- let test = graph. edges_connecting ( a, b) . all ( |edge| {
205
- !matches ! ( edge. weight( ) , EdgeType :: NewFunction | EdgeType :: Unreachable )
200
+ let unreachable = graph. edges_connecting ( a, b) . all ( |edge| {
201
+ matches ! ( edge. weight( ) , EdgeType :: NewFunction | EdgeType :: Unreachable )
206
202
} ) ;
207
- if test {
208
- Control :: Continue
209
- } else {
203
+
204
+ if unreachable {
210
205
Control :: Prune
206
+ } else if b == to {
207
+ return Control :: Break ( true ) ;
208
+ } else {
209
+ Control :: Continue
211
210
}
212
211
}
213
212
_ => Control :: Continue ,
You can’t perform that action at this time.
0 commit comments