Skip to content

Commit

Permalink
Merge #882
Browse files Browse the repository at this point in the history
882: Fix clippy lints r=Yatekii a=Yatekii



Co-authored-by: Noah Hüsser <yatekii@yatekii.ch>
  • Loading branch information
bors[bot] and Yatekii committed Nov 10, 2021
2 parents ccb77ca + 369c5aa commit 841c27d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 34 deletions.
4 changes: 2 additions & 2 deletions probe-rs/examples/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rand::prelude::*;
use structopt::StructOpt;

#[derive(StructOpt)]
struct CLI {
struct Cli {
#[structopt(long = "chip")]
chip: Option<String>,
#[structopt(long = "address", parse(try_from_str = parse_hex))]
Expand All @@ -32,7 +32,7 @@ const SIZE: usize = 0x1000;
fn main() -> Result<(), &'static str> {
pretty_env_logger::init();

let matches = CLI::from_args();
let matches = Cli::from_args();

let mut probe = open_probe(None)?;

Expand Down
6 changes: 3 additions & 3 deletions probe-rs/examples/ram_download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use structopt::StructOpt;
use anyhow::{anyhow, Context, Result};

#[derive(StructOpt)]
struct CLI {
struct Cli {
#[structopt(long = "chip")]
chip: Option<String>,
#[structopt(long = "address", parse(try_from_str = parse_hex))]
Expand All @@ -29,7 +29,7 @@ fn parse_hex(src: &str) -> Result<u32, ParseIntError> {
fn main() -> Result<()> {
pretty_env_logger::init();

let matches = CLI::from_args();
let matches = Cli::from_args();

let mut probe = open_probe(None)?;

Expand Down Expand Up @@ -145,7 +145,7 @@ fn open_probe(index: Option<usize>) -> Result<Probe> {
let device = match index {
Some(index) => list
.get(index)
.ok_or(anyhow!("Probe with specified index not found"))?,
.ok_or_else(|| anyhow!("Probe with specified index not found"))?,
None => {
// open the default probe, if only one probe was found
if list.len() == 1 {
Expand Down
36 changes: 20 additions & 16 deletions probe-rs/src/flashing/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,16 @@ mod tests {
address: 0,
};

let mut flash_algorithm = FlashAlgorithm::default();
flash_algorithm.flash_properties = FlashProperties {
address_range: 0..1 << 16,
page_size: 1024,
erased_byte_value: 255,
program_page_timeout: 200,
erase_sector_timeout: 200,
sectors: vec![sd],
let flash_algorithm = FlashAlgorithm {
flash_properties: FlashProperties {
address_range: 0..1 << 16,
page_size: 1024,
erased_byte_value: 255,
program_page_timeout: 200,
erase_sector_timeout: 200,
sectors: vec![sd],
},
..Default::default()
};

let region = NvmRegion {
Expand All @@ -402,14 +404,16 @@ mod tests {
address: 0,
};

let mut flash_algorithm = FlashAlgorithm::default();
flash_algorithm.flash_properties = FlashProperties {
address_range: 0..1 << 16,
page_size: 1024,
erased_byte_value: 255,
program_page_timeout: 200,
erase_sector_timeout: 200,
sectors: vec![sd],
let flash_algorithm = FlashAlgorithm {
flash_properties: FlashProperties {
address_range: 0..1 << 16,
page_size: 1024,
erased_byte_value: 255,
program_page_timeout: 200,
erase_sector_timeout: 200,
sectors: vec![sd],
},
..Default::default()
};

let region = NvmRegion {
Expand Down
4 changes: 2 additions & 2 deletions probe-rs/src/probe/cmsisdap/commands/transfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ impl InnerTransferRequest {
fn creating_inner_transfer_request() {
let req = InnerTransferRequest::new(PortType::DebugPort, RW::W, 0x8, None);

assert_eq!(true, req.A3);
assert_eq!(false, req.A2);
assert!(req.A3);
assert!(!req.A2);
}

impl InnerTransferRequest {
Expand Down
7 changes: 3 additions & 4 deletions probe-rs/src/probe/jlink/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,14 @@ impl DebugProbe for JLink {
return Err(DebugProbeError::UnsupportedSpeed(speed_khz));
}
};
let actual_speed_khz = speed_khz;

let actual_speed_khz = speed_khz;

self.handle
.set_speed(SpeedConfig::khz(actual_speed_khz as u16).unwrap())?;
self.speed_khz = actual_speed_khz;
.set_speed(SpeedConfig::khz(speed_khz as u16).unwrap())?;
self.speed_khz = speed_khz;

Ok(actual_speed_khz)
Ok(speed_khz)
}

fn attach(&mut self) -> Result<(), super::DebugProbeError> {
Expand Down
6 changes: 1 addition & 5 deletions probe-rs/src/probe/jlink/swd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,11 +1288,7 @@ mod test {
}

impl RawSwdIo for MockJaylink {
fn swd_io<'a, D, S>(
&'a mut self,
dir: D,
swdio: S,
) -> Result<Vec<bool>, crate::DebugProbeError>
fn swd_io<D, S>(&mut self, dir: D, swdio: S) -> Result<Vec<bool>, crate::DebugProbeError>
where
D: IntoIterator<Item = bool>,
S: IntoIterator<Item = bool>,
Expand Down
3 changes: 1 addition & 2 deletions target-gen/tests/extract_pack.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use assert_cmd::Command;
use predicates;

const NORDIC_SAMPLE_PACK: &'static str =
const NORDIC_SAMPLE_PACK: &str =
"tests/test_data/NordicSemiconductor.nRF_DeviceFamilyPack.8.32.1.pack";

#[test]
Expand Down

0 comments on commit 841c27d

Please sign in to comment.