From cd737c8e62dd3193933367df775f05965a81e1b5 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 9 Aug 2024 17:27:20 +0200 Subject: [PATCH] github: update workflow (#27) and fix a few trivial clippy warnings... --- .github/workflows/main.yml | 24 ++++++++++++------------ Cargo.toml | 2 +- examples/adstool.rs | 10 +++++----- src/client.rs | 2 +- src/test/test_client.rs | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d912b09..1d6d717 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,9 @@ name: CI -on: [push, pull_request] +on: + push: + branches: [master] + pull_request: jobs: test: @@ -9,17 +12,14 @@ jobs: strategy: matrix: toolchain: - - 1.48.0 + - 1.63.0 - stable - nightly steps: - - name: Checkout the source code - uses: actions/checkout@master - - name: Install Rust - run: | - rustup toolchain update --no-self-update ${{ matrix.toolchain }} - rustup default ${{ matrix.toolchain }} - - name: Build - run: cargo build --all - - name: Test - run: cargo test --all + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + toolchain: ${{ matrix.toolchain }} + - run: cargo clippy --all-targets + - run: cargo test --all diff --git a/Cargo.toml b/Cargo.toml index 56a4d01..ff73cad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,4 +22,4 @@ quick-xml = "0.36.1" regex = "<1.10.0" structopt = "0.3.26" strum = { version = "0.26.3", features = ["derive"] } -time = { version = "<0.3.21", features = ["formatting"] } +time = { version = "<0.3.18", features = ["formatting"] } diff --git a/examples/adstool.rs b/examples/adstool.rs index c3df2dc..41b1d4d 100644 --- a/examples/adstool.rs +++ b/examples/adstool.rs @@ -389,7 +389,7 @@ fn main_inner(args: Args) -> Result<(), Error> { let namelen = LE::read_u32(&routeinfo[36..]) as usize; let host = String::from_utf8_lossy(&routeinfo[44..][..hostlen-1]); let name = String::from_utf8_lossy(&routeinfo[44+hostlen..][..namelen-1]); - print!("{:-20} {:-22} {:-18}", name, netid.to_string(), host); + print!("{:-20} {:-22} {:-18}", name, netid, host); if flags & 0x01 != 0 { print!(" temporary"); } if flags & 0x80 != 0 { print!(" unidirectional"); } if flags & 0x100 != 0 { print!(" virtual/nat"); } @@ -446,7 +446,7 @@ fn main_inner(args: Args) -> Result<(), Error> { let dev = client.device(amsaddr); match subargs { FileAction::List { path } => { - let entries = file::listdir(dev, &path)?; + let entries = file::listdir(dev, path)?; for (name, attr, size) in entries { println!("{} {:8} {}", if attr & file::DIRECTORY != 0 { "D" } else { " " }, @@ -465,7 +465,7 @@ fn main_inner(args: Args) -> Result<(), Error> { std::io::copy(&mut stdin(), &mut file)?; } FileAction::Delete { path } => { - file::File::delete(dev, &path, file::ENABLE_DIR)?; + file::File::delete(dev, path, file::ENABLE_DIR)?; } } } @@ -612,7 +612,7 @@ fn main_inner(args: Args) -> Result<(), Error> { for (name, ty) in &type_map { if name.to_lowercase().contains(&filter) { println!("** ({:6x}) {:40}", ty.size, name); - print_fields(&type_map, 0, &name, 1); + print_fields(&type_map, 0, name, 1); } } } @@ -774,7 +774,7 @@ fn convert_filetime(ft: i64) -> Option { /// Format a GUID. fn format_guid(guid: &[u8]) -> String { format!("{:08X}-{:04X}-{:04X}-{:04X}-{:012X}", - LE::read_u32(&guid), + LE::read_u32(guid), LE::read_u16(&guid[4..]), LE::read_u16(&guid[6..]), BE::read_u16(&guid[8..]), diff --git a/src/client.rs b/src/client.rs index 44a03b3..835af10 100644 --- a/src/client.rs +++ b/src/client.rs @@ -188,7 +188,7 @@ impl Client { let mut socket = if let Some(timeout) = timeouts.connect { TcpStream::connect_timeout(&addr, timeout).ctx("connecting TCP socket with timeout")? } else { - TcpStream::connect(&addr).ctx("connecting TCP socket")? + TcpStream::connect(addr).ctx("connecting TCP socket")? }; // Disable Nagle to ensure small requests are sent promptly; we're diff --git a/src/test/test_client.rs b/src/test/test_client.rs index 511f544..aa775e9 100644 --- a/src/test/test_client.rs +++ b/src/test/test_client.rs @@ -270,7 +270,7 @@ fn test_string_type() { let ret = device.read_value::(0x4020, 7).unwrap(); assert!(<[u8; 5]>::from(ret) == [b'a', b'b', b'c', 0, 0]); assert!(String::try_from(ret).unwrap() == "abc"); - assert!(>::try_from(ret).unwrap() == [b'a', b'b', b'c']); + assert!(>::from(ret) == [b'a', b'b', b'c']); }) } @@ -300,6 +300,6 @@ fn test_wstring_type() { let ret = device.read_value::(0x4020, 7).unwrap(); assert!(<[u16; 5]>::from(ret) == [b'a' as u16, b'b' as u16, b'c' as u16, 0, 0]); assert!(String::try_from(ret).unwrap() == "abc"); - assert!(>::try_from(ret).unwrap() == [b'a' as u16, b'b' as u16, b'c' as u16]); + assert!(>::from(ret) == [b'a' as u16, b'b' as u16, b'c' as u16]); }) }