Skip to content

Commit 4ad37b7

Browse files
committed
rust: second round of lint/build fixes
1 parent 99d67de commit 4ad37b7

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

ledger/src/proofs/transaction.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3850,6 +3850,10 @@ pub fn compute_witness<C: ProofConstants, F: FieldWitness>(
38503850
let mut res: [_; COLUMNS] = std::array::from_fn(|_| vec![F::zero(); num_rows]);
38513851

38523852
// public input
3853+
#[allow(
3854+
clippy::needless_range_loop,
3855+
reason = "Clippy incorrectly assumes we're indexing res with `i`, but we're actually not!"
3856+
)]
38533857
for i in 0..public_input_size {
38543858
res[0][i] = external_values(i);
38553859
}

node/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn main() -> Result<(), Box<dyn Error>> {
192192
let action_name_base =
193193
action_name[..(action_name.len().saturating_sub(6))].to_string();
194194
let mut variant_lines = vec![];
195-
while let Some(line) = lines.next() {
195+
for line in lines.by_ref() {
196196
let line = line.unwrap();
197197
if line.ends_with('}') {
198198
break;

node/src/ledger/ledger_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ impl LedgerCtx {
12741274
let mut iter = jobs.iter().peekable();
12751275
let mut res = Vec::with_capacity(jobs.len());
12761276

1277-
while let Some(job) = iter.next() {
1277+
for job in iter {
12781278
let (stmt, seq_no, job_kind, is_done) = match &job.job {
12791279
JobValue::Leaf(JobValueBase::Empty)
12801280
| JobValue::Node(JobValueMerge::Empty)

node/src/recorder/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl RecordedActionWithMeta<'_> {
5858
}
5959

6060
pub fn as_action_with_meta(self) -> Result<ActionWithMeta, Self> {
61-
if self.action.is_some() {
62-
let action = self.action.unwrap().into_owned();
61+
if let Some(action) = self.action {
62+
let action = action.into_owned();
6363
Ok(self.meta.with_action(action))
6464
} else {
6565
Err(self)

p2p/libp2p-rpc-behaviour/src/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl Inner {
182182
let h_id = u64::from_le_bytes(*b"RPC\x00\x00\x00\x00\x00");
183183
while let Some(v) = self.buffer.try_cut() {
184184
// TODO: proper error type
185-
let (header, bytes) = v.map_err(|err| io::Error::other(err))?;
185+
let (header, bytes) = v.map_err(io::Error::other)?;
186186
match header {
187187
MessageHeader::Heartbeat => {
188188
// TODO: handle heartbeat properly
@@ -195,7 +195,7 @@ impl Inner {
195195
let mut bytes_slice = bytes.as_slice();
196196
type P = ResponsePayload<<VersionedRpcMenuV1 as RpcMethod>::Response>;
197197
let menu = P::binprot_read(&mut bytes_slice)
198-
.map_err(|err| io::Error::other(err))?
198+
.map_err(io::Error::other)?
199199
.0
200200
.ok()
201201
.map(|NeedsLength(x)| x)

tools/testing/src/cluster/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ impl ClusterConfig {
6060
}
6161

6262
pub fn set_all_rust_to_rust_use_webrtc(&mut self) -> &mut Self {
63-
assert!(cfg!(feature = "p2p-webrtc"));
63+
if !cfg!(feature = "p2p-webrtc") {
64+
unreachable!();
65+
}
6466
self.all_rust_to_rust_use_webrtc = true;
6567
self
6668
}

tools/testing/src/service/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ impl NodeTestingService {
186186
}
187187

188188
pub fn set_rust_to_rust_use_webrtc(&mut self) -> &mut Self {
189-
assert!(cfg!(feature = "p2p-webrtc"));
189+
if !cfg!(feature = "p2p-webrtc") {
190+
unreachable!();
191+
}
190192
self.rust_to_rust_use_webrtc = true;
191193
self
192194
}

0 commit comments

Comments
 (0)