Skip to content

Upgrade Dependencies to Newest Versions#2

Open
jscatena88 wants to merge 4 commits intomarcelbuesing:masterfrom
jscatena88:dep_updates
Open

Upgrade Dependencies to Newest Versions#2
jscatena88 wants to merge 4 commits intomarcelbuesing:masterfrom
jscatena88:dep_updates

Conversation

@jscatena88
Copy link

I took a crack at upgrading all dependencies to their newest versions. I have not yet tested this on real hardware with real DBC files, I'll try to get to that in the next few days and report back. In the meantime I figured I would throw this up for comment.

Copy link

@wallem89 wallem89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work done @jscatena88 ! I want to use this crate too but ran into the same issues. Some existing once but also some new clippy issues.
I have put them as comments on the existing and new code. Can you fix them?

I am also to get a hold of @marcelbuesing to discus maintenance of this crate because I would love to help out here!

use futures::StreamExt;
use socketcan::CANFrame;
use socketcan::Id;
use socketcan::{tokio::CanSocket, CanFrame, EmbeddedFrame};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can merge this into one import:
use socketcan::{Id, {tokio::CanSocket, CanFrame, EmbeddedFrame}};

let mut socket_rx = tokio_socketcan::CANSocket::open(&opt.can_interface).unwrap();
let mut socket_rx = CanSocket::open(&opt.can_interface).unwrap();

let byte_hex_table: Vec<String> = (0u8..=u8::max_value())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: usage of a legacy numeric method
   --> src/bin/candumprb.rs:102:46
    |
102 |     let byte_hex_table: Vec<String> = (0u8..=u8::max_value())
    |                                              ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#legacy_numeric_constants
    = note: `#[warn(clippy::legacy_numeric_constants)]` on by default
help: use the associated constant instead
    |
102 -     let byte_hex_table: Vec<String> = (0u8..=u8::max_value())
102 +     let byte_hex_table: Vec<String> = (0u8..=u8::MAX)

}
}

fn as_char(self) -> char {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this?

warning: method `as_char` is never used
  --> src/bin/candumprb.rs:67:8
   |
37 | impl Byte {
   | --------- method in this implementation
...
67 |     fn as_char(self) -> char {

const COLOR_CAN_EFF: Color = Color::Red;

const COLOR_NULL: Color = Fixed(242); // grey
const COLOR_OFFSET: Color = Fixed(242); // grey

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used, remove too?

warning: constant `COLOR_OFFSET` is never used
  --> src/bin/candumprb.rs:20:7
   |
20 | const COLOR_OFFSET: Color = Fixed(242); // grey
   |       ^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

} else {
false
};
let mut rand_frame_data = Vec::new();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: slow zero-filling initialization
   --> src/bin/cangenrb.rs:294:35
    |
294 |           let mut rand_frame_data = Vec::new();
    |  ___________________________________^
295 | |         rand_frame_data.resize(*message.message_size() as usize, 0);
    | |___________________________________________________________________^ help: consider replacing this with: `vec![0; *message.message_size() as usize]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#slow_vector_initialization
    = note: `#[warn(clippy::slow_vector_initialization)]` on by default

println!("Non random message body due to currently unsupported size `{}` - id: `{:#?}`. Size {} > 8", message.message_name(), message.message_id(), message.message_size());
vec![0; 8]
} else {
self.gen_msg_frame_data(&message)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/bin/cangenrb.rs:178:37
    |
178 |             self.gen_msg_frame_data(&message)
    |                                     ^^^^^^^^ help: change this to: `message`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

_ => |id, data| (CanRemoteFrame::new(id, data).map(CanFrame::Remote)),
}
}
(false, false) => |id, data| (CanDataFrame::new(id, data).map(CanFrame::Data)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this and all identical above too

warning: unnecessary parentheses around closure body
   --> src/bin/cangenrb.rs:291:42
    |
291 |             (false, false) => |id, data| (CanDataFrame::new(id, data).map(CanFrame::Data)),
    |                                          ^                                               ^
    |
help: remove these parentheses
    |
291 -             (false, false) => |id, data| (CanDataFrame::new(id, data).map(CanFrame::Data)),
291 +             (false, false) => |id, data| CanDataFrame::new(id, data).map(CanFrame::Data) ,
    |

nanos: map_res!(digit1, |d: &str| d.parse()) >>
tag!(")") >>
(Timestamp { seconds, nanos })
fn timestamp(input: &str) -> nom::IResult<&str, Timestamp> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function `timestamp` is never used
  --> src/candump_parser.rs:15:4
   |
15 | fn timestamp(input: &str) -> nom::IResult<&str, Timestamp> {
   |    ^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

tag!("#") >>
frame_body: map_res!(hex_digit1, |d| u64::from_str_radix(d, 16)) >>
(CanFrame { frame_id, frame_body })
fn can_frame(input: &str) -> nom::IResult<&str, CanFrame> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function `can_frame` is never used
  --> src/candump_parser.rs:35:4
   |
35 | fn can_frame(input: &str) -> nom::IResult<&str, CanFrame> {
   |    ^^^^^^^^^

(DumpEntry { timestamp, can_interface: can_interface.to_string(), can_frame })
)
);
fn dump_entry(input: &str) -> nom::IResult<&str, DumpEntry> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function `dump_entry` is never used
  --> src/candump_parser.rs:74:4
   |
74 | fn dump_entry(input: &str) -> nom::IResult<&str, DumpEntry> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants