Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
3.14 values has been upgraded to 3.15 to skip clippy errors (approximated Pi 😅)
  • Loading branch information
hpwxf committed Mar 9, 2025
1 parent b4fbfba commit 28161ab
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions rs/advanced/src/blockchain/block_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ mod tests {
};

let bytes = block.to_bytes();
let (block_ref, consumed) =
BlockRef::from_bytes(&bytes).expect("Parsing should succeed");
let (block_ref, consumed) = BlockRef::from_bytes(&bytes).expect("Parsing should succeed");
assert_eq!(consumed, bytes.len());

let block_converted: Block = block_ref.into();
Expand Down
3 changes: 2 additions & 1 deletion rs/advanced/src/blockchain/process.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{BlockRef, TransactionRef};

#[allow(dead_code)]
pub fn process<'a>(blocks: impl Iterator<Item = BlockRef<'a>>, mut f: impl FnMut(&TransactionRef)) {
blocks.for_each(|block| block.transactions.iter().for_each(|tx| f(tx)))
blocks.for_each(|block| block.transactions.iter().for_each(&mut f))
}

#[cfg(test)]
Expand Down
2 changes: 0 additions & 2 deletions rs/full-tree/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ mod dir1;
mod dir2;
mod f1; // declare an independent module (see f1.rs) // declare an independent module (see dir1.rs)

use mylib1; // declared in this project Cargo.tom

fn main() {
{
// direct usage
Expand Down
1 change: 1 addition & 0 deletions rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ fn check_macho_segments(addr: usize) -> Option<MemorySection> {
}
let slide = unsafe { _dyld_get_image_vmaddr_slide(i) } as usize;
// Interpret the header as a mach_header_64
#[allow(clippy::unnecessary_cast)]
let header = unsafe { &*(header_ptr as *const mach_o::header::mach_header_64) };
if let Some(section) = match_address_in_mach_header(header, slide, addr) {
return Some(section);
Expand Down
1 change: 1 addition & 0 deletions rs/tests/advanced_pin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(dead_code)]
#![allow(clippy::redundant_locals)]
use std::marker::PhantomPinned;
use std::pin::{pin, Pin};

Expand Down
2 changes: 1 addition & 1 deletion rs/tests/generics_rustlings3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where

fn main() {
let report_card = ReportCard {
grade: 3.14,
grade: 3.15,
student_name: "Gary Plotter".to_string(),
student_age: 11,
};
Expand Down
2 changes: 1 addition & 1 deletion rs/tests/generics_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn foo<T>(arg: T) {}

fn main() {
foo(1);
foo(3.14);
foo(0.577);
foo("Hello");
}

Expand Down
2 changes: 1 addition & 1 deletion rs/tests/hindler-milner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
// ... do things without using `var` and `v`

v.push(3); // now v is a vector of i32
var = 3.14; // now var is a f64
var = 3.15; // now var is a f64

// v.push(3.14); // error: expected integer, found floating-point number
// var = 3; // error: expected floating-point number, found integer
Expand Down
4 changes: 2 additions & 2 deletions rs/tests/overload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod tests {
b.moon();
B::moon(&b);

3.14.moon();
f64::moon(&3.14);
3.15.moon();
f64::moon(&3.15);
}
}
1 change: 1 addition & 0 deletions rs/tests/repr_c_specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ mod details {
}
}

#[rustfmt::skip]
fn main() {
let union = MyCUnion { f1: 256 };
println!("MyCUnion {{ f1: 256 }} : {}", details::to_str_bytes(&union));
Expand Down
1 change: 1 addition & 0 deletions rs/tests/string_to_bytes.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[rustfmt::skip]
fn main() {
let mut s = String::from("Éléphant 🦣 épatant");
println!("{}", s);
Expand Down

0 comments on commit 28161ab

Please sign in to comment.