Skip to content

Commit af63e12

Browse files
Merge pull request #411 from MarijnS95/clippy
Fix clippy lints since Rust 1.83
2 parents eac155e + 6142a2c commit af63e12

File tree

10 files changed

+32
-68
lines changed

10 files changed

+32
-68
lines changed

.github/workflows/ci.yaml

+3-23
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,28 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest, windows-latest, macos-latest]
11-
rust: [stable]
1211
runs-on: ${{ matrix.os }}
1312
steps:
1413
- uses: actions/checkout@v2
15-
- uses: actions-rs/toolchain@v1
16-
with:
17-
toolchain: ${{ matrix.rust }}
18-
override: true
1914
- name: Cargo build
20-
uses: actions-rs/cargo@v1
21-
with:
22-
command: build
23-
args: --workspace --all-targets
15+
run: cargo build --workspace --all-targets
2416
test:
2517
name: Test
2618
strategy:
2719
matrix:
2820
os: [ubuntu-latest, windows-latest, macos-latest]
29-
rust: [stable]
3021
runs-on: ${{ matrix.os }}
3122
steps:
3223
- uses: actions/checkout@v2
33-
- uses: actions-rs/toolchain@v1
34-
with:
35-
toolchain: ${{ matrix.rust }}
36-
override: true
3724
- name: Cargo test
38-
uses: actions-rs/cargo@v1
39-
with:
40-
command: test
41-
args: --workspace --all-targets
25+
run: cargo test --workspace --all-targets
4226
lint:
4327
name: Lint
4428
strategy:
4529
matrix:
4630
os: [ubuntu-latest, windows-latest, macos-latest]
47-
rust: [stable]
4831
runs-on: ${{ matrix.os }}
4932
steps:
5033
- uses: actions/checkout@v2
5134
- name: Cargo clippy
52-
uses: actions-rs/cargo@v1
53-
with:
54-
command: clippy
55-
args: --workspace --all-targets -- -D warnings
35+
run: cargo clippy --workspace --all-targets -- -D warnings

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ pub fn version() -> (i32, i32, i32) {
371371
zmq_sys::zmq_version(&mut major, &mut minor, &mut patch);
372372
}
373373

374-
(major as i32, minor as i32, patch as i32)
374+
(major, minor, patch)
375375
}
376376

377377
struct RawContext {
@@ -442,7 +442,7 @@ impl Context {
442442
/// Set the size of the ØMQ thread pool to handle I/O operations.
443443
pub fn set_io_threads(&self, value: i32) -> Result<()> {
444444
zmq_try!(unsafe {
445-
zmq_sys::zmq_ctx_set(self.raw.ctx, zmq_sys::ZMQ_IO_THREADS as _, value as i32)
445+
zmq_sys::zmq_ctx_set(self.raw.ctx, zmq_sys::ZMQ_IO_THREADS as _, value)
446446
});
447447
Ok(())
448448
}

src/message.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,14 @@ impl From<Box<[u8]>> for Message {
232232
}
233233
}
234234

235-
impl<'a> From<&'a str> for Message {
235+
impl From<&str> for Message {
236236
/// Construct a message from a string slice by copying the UTF-8 data.
237237
fn from(msg: &str) -> Self {
238238
Message::from(msg.as_bytes())
239239
}
240240
}
241241

242-
impl<'a> From<&'a String> for Message {
242+
impl From<&String> for Message {
243243
/// Construct a message from a string slice by copying the UTF-8 data.
244244
fn from(msg: &String) -> Self {
245245
Message::from(msg.as_bytes())

src/sockopt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ fn setsockopt_null(sock: *mut c_void, opt: c_int) -> Result<()> {
101101
Ok(())
102102
}
103103

104-
impl<'a> Setter for &'a str {
104+
impl Setter for &str {
105105
fn set(sock: *mut c_void, opt: c_int, value: Self) -> Result<()> {
106106
set(sock, opt, value.as_bytes())
107107
}
108108
}
109109

110-
impl<'a> Setter for Option<&'a str> {
110+
impl Setter for Option<&str> {
111111
fn set(sock: *mut c_void, opt: c_int, value: Self) -> Result<()> {
112112
if let Some(s) = value {
113113
set(sock, opt, s.as_bytes())

tests/compile-fail/no-leaking-poll-items.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ error[E0597]: `socket` does not live long enough
44
3 | let _poll_item = {
55
| ---------- borrow later stored here
66
4 | let socket = context.socket(zmq::PAIR).unwrap();
7+
| ------ binding `socket` declared here
78
5 | socket.as_poll_item(zmq::POLLIN)
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
9+
| ^^^^^^ borrowed value does not live long enough
910
6 | }; //~^ ERROR `socket` does not live long enough [E0597]
1011
| - `socket` dropped here while still borrowed
+18-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
error[E0277]: `*mut c_void` cannot be shared between threads safely
2-
--> tests/compile-fail/socket-thread-unsafe.rs:13:13
3-
|
4-
13 | let t = thread::spawn(move || {
5-
| ^^^^^^^^^^^^^ `*mut c_void` cannot be shared between threads safely
6-
|
7-
= help: within `Socket`, the trait `Sync` is not implemented for `*mut c_void`
8-
= note: required because it appears within the type `Socket`
9-
= note: required because of the requirements on the impl of `Send` for `&Socket`
10-
note: required because it's used within this closure
112
--> tests/compile-fail/socket-thread-unsafe.rs:13:27
123
|
134
13 | let t = thread::spawn(move || {
14-
| ___________________________^
5+
| _____________-------------_^
6+
| | |
7+
| | required by a bound introduced by this call
158
14 | | t!(s.bind("tcp://127.0.0.1:12345"))
169
15 | | });
17-
| |_____^
10+
| |_____^ `*mut c_void` cannot be shared between threads safely
11+
|
12+
= help: within `Socket`, the trait `Sync` is not implemented for `*mut c_void`, which is required by `{closure@$DIR/tests/compile-fail/socket-thread-unsafe.rs:13:27: 13:34}: Send`
13+
note: required because it appears within the type `Socket`
14+
--> src/lib.rs
15+
|
16+
| pub struct Socket {
17+
| ^^^^^^
18+
= note: required for `&Socket` to implement `Send`
19+
note: required because it's used within this closure
20+
--> tests/compile-fail/socket-thread-unsafe.rs:13:27
21+
|
22+
13 | let t = thread::spawn(move || {
23+
| ^^^^^^^
1824
note: required by a bound in `spawn`
25+
--> $RUST/std/src/thread/mod.rs

tests/message_from_boxed_slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static A: Allocator = Allocator;
2626
#[test]
2727
fn message_from_boxed_slice() {
2828
let mut b: Box<[u8]> = Box::new([0u8; 42]);
29-
CHECK_PTR.store(b.as_mut_ptr() as *mut u8, Ordering::SeqCst);
29+
CHECK_PTR.store(b.as_mut_ptr(), Ordering::SeqCst);
3030
let _ = zmq::Message::from(b);
3131
assert_eq!(CHECK_PTR.load(Ordering::SeqCst), ptr::null_mut());
3232
}

tests/monitor.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
mod common;
33

44
use std::str;
5-
use std::u16;
65

76
fn version_ge_4_3() -> bool {
87
let (major, minor, _) = zmq::version();

tests/test.rs

+1-24
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ test!(test_exchanging_multipart, {
7171
let (sender, receiver) = create_socketpair();
7272

7373
// convenience API
74-
sender.send_multipart(&["foo", "bar"], 0).unwrap();
74+
sender.send_multipart(["foo", "bar"], 0).unwrap();
7575
assert_eq!(receiver.recv_multipart(0).unwrap(), vec![b"foo", b"bar"]);
7676

7777
// manually
@@ -585,26 +585,3 @@ test!(test_getset_connect_timeout, {
585585
assert_eq!(sock.get_connect_timeout().unwrap(), 5000);
586586
}
587587
});
588-
589-
#[cfg(feature = "compiletest_rs")]
590-
mod compile {
591-
extern crate compiletest_rs as compiletest;
592-
593-
use std::path::PathBuf;
594-
595-
fn run_mode(mode: &'static str) {
596-
let mut config = compiletest::Config::default();
597-
let cfg_mode = mode.parse().expect("Invalid mode");
598-
599-
config.mode = cfg_mode;
600-
config.src_base = PathBuf::from(format!("tests/{}", mode));
601-
config.target_rustcflags = Some("-L target/debug -L target/debug/deps".to_string());
602-
603-
compiletest::run_tests(&config);
604-
}
605-
606-
#[test]
607-
fn expected_failures() {
608-
run_mode("compile-fail");
609-
}
610-
}

tests/z85.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ fn test_decode_errors() {
3333
}
3434
}
3535

36+
/*
3637
// Valid input for z85 encoding (i.e. a slice of bytes with its length
3738
// being a multiple of 4)
3839
#[derive(Clone, Debug)]
3940
struct Input(Vec<u8>);
4041
41-
/*
4242
// Disabled because quickcheck doesn't expose gen_range and gen anymore
4343
4444
impl Arbitrary for Input {

0 commit comments

Comments
 (0)