Add Render Layer API to Rust #303
Annotations
9 errors and 4 warnings
cargo fmt
Process completed with exit code 1.
|
call to `reserve` immediately after creation:
rust/rust/src/flowgraph.rs#L56
error: call to `reserve` immediately after creation
--> ./rust/rust/src/flowgraph.rs:56:9
|
56 | / let mut result = vec![];
57 | | result.reserve(count);
| |______________________________^ help: consider using `Vec::with_capacity(/* Space hint */)`: `let mut result = Vec::with_capacity(count);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#reserve_after_initialization
= note: `-D clippy::reserve-after-initialization` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::reserve_after_initialization)]`
|
the loop variable `i` is only used to index `nodes`:
rust/rust/src/flowgraph.rs#L59
error: the loop variable `i` is only used to index `nodes`
--> ./rust/rust/src/flowgraph.rs:59:18
|
59 | for i in 0..count {
| ^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
= note: `-D clippy::needless-range-loop` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::needless_range_loop)]`
help: consider using an iterator
|
59 | for <item> in nodes.iter().take(count) {
| ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
|
method `next` can be confused for the standard trait method `std::iter::Iterator::next`:
rust/rust/src/linear_view.rs#L335
error: method `next` can be confused for the standard trait method `std::iter::Iterator::next`
--> ./rust/rust/src/linear_view.rs:335:5
|
335 | / pub fn next(&mut self) -> bool {
336 | | unsafe { BNLinearViewCursorNext(self.handle) }
337 | | }
| |_____^
|
= help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
= note: `-D clippy::should-implement-trait` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::should_implement_trait)]`
|
called `map(..).flatten()` on `Iterator`:
rust/rust/src/render_layer.rs#L88
error: called `map(..).flatten()` on `Iterator`
--> ./rust/rust/src/render_layer.rs:88:18
|
88 | .map(|(_, lines)| {
| __________________^
89 | | let function = lines[0].function.to_owned();
90 | | let block = lines[0].basic_block.to_owned();
91 | | let (code_lines, other_lines): (Vec<_>, Vec<_>) = lines
... |
101 | | })
102 | | .flatten()
| |__________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
= note: `-D clippy::map-flatten` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::map_flatten)]`
help: try replacing `map` with `flat_map` and remove the `.flatten()`
|
88 ~ .flat_map(|(_, lines)| {
89 + let function = lines[0].function.to_owned();
90 + let block = lines[0].basic_block.to_owned();
91 + let (code_lines, other_lines): (Vec<_>, Vec<_>) = lines
92 + .into_iter()
93 + .partition(|line| matches!(line.ty, LinearDisassemblyLineType::CodeDisassemblyLineType));
94 + let code_text_lines: Vec<_> = code_lines.into_iter().map(|line| line.contents).collect();
95 + let new_code_text_lines = self.apply_to_block(&block, code_text_lines);
96 + let new_misc_text_lines = self.apply_to_misc_lines(object, _prev_object.as_deref(), _next_object.as_deref(), other_lines);
97 + new_code_text_lines
98 + .into_iter()
99 + .map(move |line| text_to_lines(&function, &block, line))
100 + .chain(new_misc_text_lines.into_iter())
101 + })
|
|
iterating on a map's values:
rust/rust/src/render_layer.rs#L86
error: iterating on a map's values
--> ./rust/rust/src/render_layer.rs:86:42
|
86 | let mut text_lines: Vec<_> = basic_blocks
| __________________________________________^
87 | | .into_iter()
88 | | .map(|(_, lines)| {
89 | | let function = lines[0].function.to_owned();
... |
100 | | .chain(new_misc_text_lines.into_iter())
101 | | })
| |__________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map
= note: `-D clippy::iter-kv-map` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::iter_kv_map)]`
help: try
|
86 ~ let mut text_lines: Vec<_> = basic_blocks.into_values().map(|lines| {
87 + let function = lines[0].function.to_owned();
88 + let block = lines[0].basic_block.to_owned();
89 + let (code_lines, other_lines): (Vec<_>, Vec<_>) = lines
90 + .into_iter()
91 + .partition(|line| matches!(line.ty, LinearDisassemblyLineType::CodeDisassemblyLineType));
92 + let code_text_lines: Vec<_> = code_lines.into_iter().map(|line| line.contents).collect();
93 + let new_code_text_lines = self.apply_to_block(&block, code_text_lines);
94 + let new_misc_text_lines = self.apply_to_misc_lines(object, _prev_object.as_deref(), _next_object.as_deref(), other_lines);
95 + new_code_text_lines
96 + .into_iter()
97 + .map(move |line| text_to_lines(&function, &block, line))
98 + .chain(new_misc_text_lines.into_iter())
99 + })
|
|
explicit call to `.into_iter()` in function argument accepting `IntoIterator`:
rust/rust/src/render_layer.rs#L100
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
--> ./rust/rust/src/render_layer.rs:100:32
|
100 | .chain(new_misc_text_lines.into_iter())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `new_misc_text_lines`
|
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
--> /rustc/9fc6b43126469e3858e2fe86cafb4f0fd5068869/library/core/src/iter/traits/iterator.rs:471:12
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
= note: `-D clippy::useless-conversion` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::useless_conversion)]`
|
redundant closure:
rust/rust/src/render_layer.rs#L231
error: redundant closure
--> ./rust/rust/src/render_layer.rs:231:34
|
231 | NonNull::new(result).map(|x| Self::from_raw(x))
| ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `Self::from_raw`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
= note: `-D clippy::redundant-closure` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]`
|
cargo clippy
Error: Clippy has exited with exit code 101
|
typos
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636
|
cargo fmt:
rust/src/render_layer.rs#L88
Diff in /home/runner/work/binaryninja-api/binaryninja-api/rust/src/render_layer.rs
|
cargo fmt:
rust/tests/render_layer.rs#L68
Diff in /home/runner/work/binaryninja-api/binaryninja-api/rust/tests/render_layer.rs
|
cargo clippy
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636
|