Skip to content

Commit f604bef

Browse files
authored
scanner: Fix loop stats in overall function stats summary (#3915)
We already have loop statistics ever since d2141e4, they were just not merged into the overall per-function summary (which had an unset `has_loop` column). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent fecc7e4 commit f604bef

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/scanner/src/analysis.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct FnStats {
3434
is_unsafe: Option<bool>,
3535
has_unsafe_ops: Option<bool>,
3636
has_unsupported_input: Option<bool>,
37-
has_loop: Option<bool>,
37+
has_loop_or_iterator: Option<bool>,
3838
}
3939

4040
impl FnStats {
@@ -44,8 +44,7 @@ impl FnStats {
4444
is_unsafe: None,
4545
has_unsafe_ops: None,
4646
has_unsupported_input: None,
47-
// TODO: Implement this.
48-
has_loop: None,
47+
has_loop_or_iterator: None,
4948
}
5049
}
5150
}
@@ -191,7 +190,10 @@ impl OverallStats {
191190
if !kind.is_fn() {
192191
return None;
193192
};
194-
Some(FnLoops::new(item.name()).collect(&item.body()))
193+
let fn_props = FnLoops::new(item.name()).collect(&item.body());
194+
self.fn_stats.get_mut(&item).unwrap().has_loop_or_iterator =
195+
Some(fn_props.has_iterators() || fn_props.has_loops());
196+
Some(fn_props)
195197
})
196198
.partition::<Vec<_>, _>(|props| props.has_iterators() || props.has_loops());
197199

0 commit comments

Comments
 (0)