diff --git a/cmd/dashboard/src/lib.rs b/cmd/dashboard/src/lib.rs index fa350a36e..ea152bf50 100644 --- a/cmd/dashboard/src/lib.rs +++ b/cmd/dashboard/src/lib.rs @@ -79,7 +79,7 @@ impl StatefulList { fn previous(&mut self) { self.state.select(match self.state.selected() { - Some(ndx) if ndx == 0 => Some(self.n - 1), + Some(0) => Some(self.n - 1), Some(ndx) => Some(ndx - 1), None => Some(0), }); @@ -114,8 +114,6 @@ trait Attributes { fn decrease(&mut self, _ndx: usize) -> Option { None } - - fn clear(&mut self) {} } struct TempGraph; @@ -185,12 +183,6 @@ impl Attributes for FanGraph { self.0[ndx] = if nval >= 0 { nval as u8 } else { 0 }; Some(self.0[ndx]) } - - fn clear(&mut self) { - for val in self.0.iter_mut() { - *val = 0; - } - } } struct CurrentGraph; diff --git a/cmd/monorail/src/lib.rs b/cmd/monorail/src/lib.rs index 0fa7e0db0..fb2bec2ed 100644 --- a/cmd/monorail/src/lib.rs +++ b/cmd/monorail/src/lib.rs @@ -756,7 +756,7 @@ fn monorail_status( Value::Enum(m) => { let mode = m.disc().to_uppercase(); let speed = m.contents().and_then(|speed| match speed { - Value::Tuple(t) => t.get(0).map(|t| match t { + Value::Tuple(t) => t.first().map(|t| match t { Value::Enum(t) => t.disc().replace("Speed", ""), v => panic!("Expected enum, got {:?}", v), }), diff --git a/cmd/net/src/lib.rs b/cmd/net/src/lib.rs index 5fbad8394..e85691bb5 100644 --- a/cmd/net/src/lib.rs +++ b/cmd/net/src/lib.rs @@ -14,6 +14,7 @@ //! - Sidecar //! - PSC //! - `gimletlet-mgmt` +//! //! These PCAs have the KSZ8463 switch + VSC85x2 PHY which is our standard //! management network interface. //! diff --git a/cmd/probe/src/lib.rs b/cmd/probe/src/lib.rs index 1f4df7ec1..cb93a2efc 100644 --- a/cmd/probe/src/lib.rs +++ b/cmd/probe/src/lib.rs @@ -270,7 +270,7 @@ fn probecmd(context: &mut ExecutionContext) -> Result<()> { Ok("progressing") } }) - .map_or_else(|_| "unable to step", |s| s) + .unwrap_or("unable to step") .to_string(); core.run()?; rval diff --git a/cmd/rpc/src/lib.rs b/cmd/rpc/src/lib.rs index c8d1d4e69..e5a4f337c 100644 --- a/cmd/rpc/src/lib.rs +++ b/cmd/rpc/src/lib.rs @@ -157,7 +157,7 @@ fn rpc_listen_one( interface: u32, port: u32, ) -> Result> { - let socket = match UdpSocket::bind(&format!("[::]:{port}")) { + let socket = match UdpSocket::bind(format!("[::]:{port}")) { Ok(s) => s, Err(e) => { if e.kind() == std::io::ErrorKind::PermissionDenied { diff --git a/humility-core/src/core.rs b/humility-core/src/core.rs index 84a628c7f..7da27d18d 100644 --- a/humility-core/src/core.rs +++ b/humility-core/src/core.rs @@ -1040,7 +1040,7 @@ impl GDBCore { // let val = u64::from_le_bytes(buf[..].try_into().unwrap()); - if val > std::u32::MAX.into() { + if val > u32::MAX.into() { Err(anyhow!("bad 64-bit return on cmd {}: {}", cmd, rstr)) } else { Ok(val as u32) diff --git a/humility-core/src/hubris.rs b/humility-core/src/hubris.rs index 5664e4e2d..2beba4e5d 100644 --- a/humility-core/src/hubris.rs +++ b/humility-core/src/hubris.rs @@ -799,7 +799,7 @@ impl HubrisArchive { // is less than our base. // for (&(addr, _depth), (len, goff, origin)) in - self.inlined.range(..=(pc, std::isize::MAX)).rev() + self.inlined.range(..=(pc, isize::MAX)).rev() { if addr + len < base { break; @@ -3031,7 +3031,7 @@ impl HubrisArchive { return Ok(v.size); } - if self.ptrtypes.get(&goff).is_some() { + if self.ptrtypes.contains_key(&goff) { return Ok(4); } @@ -3955,7 +3955,7 @@ impl HubrisObjectLoader { // If this is a zero-sized symbol or not against an allocated // section (e.g., .idolatry), we don't want to keep track of it. // - if sym.st_size == 0 || allocs.get(&sym.st_shndx).is_none() { + if sym.st_size == 0 || !allocs.contains(&sym.st_shndx) { continue; } diff --git a/humility-core/src/reflect.rs b/humility-core/src/reflect.rs index 52a87cd0f..13ebd1def 100644 --- a/humility-core/src/reflect.rs +++ b/humility-core/src/reflect.rs @@ -63,9 +63,9 @@ //! The derived `Load` impls do not require _exact_ type match. In particular, //! //! - A struct will match even if it contains more fields than your Rust -//! version, and +//! version, and //! - An enum will match even if you define variants that don't exist in the -//! program. +//! program. //! //! This is deliberate, and is intended to help interpret programs across ABI //! changes. If you implement a `Load` impl by hand, you should try to emulate @@ -508,9 +508,9 @@ impl Struct { /// Returns a reference to the value of the member named `name`, if it /// exists, or `None`, if no member with that name exists. - pub fn get(&self, name: &Q) -> Option<&Value> + pub fn get(&self, name: &Q) -> Option<&Value> where - Q: std::hash::Hash + indexmap::Equivalent, + Q: std::hash::Hash + indexmap::Equivalent + ?Sized, { self.members.get(name).map(Box::as_ref) } @@ -600,7 +600,7 @@ impl Format for Tuple { // Is this a bitflags-generated type? If so, just format it as a binary // value. if self.name().contains("InternalBitFlags") { - if let Some(flags) = self.1.get(0).and_then(|v| v.as_base().ok()) { + if let Some(flags) = self.1.first().and_then(|v| v.as_base().ok()) { write!(out, "{flags:#b}")?; return Ok(()); } diff --git a/humility-dump-agent/src/lib.rs b/humility-dump-agent/src/lib.rs index 11e492261..d9e0fa4ca 100644 --- a/humility-dump-agent/src/lib.rs +++ b/humility-dump-agent/src/lib.rs @@ -203,7 +203,7 @@ impl DumpAgentCore { &mut self, headers: Vec, total: u32, - dump: &Vec, + dump: &[u8], task: Option, ) -> Result { let header = headers[0]; diff --git a/humility-idol/src/lib.rs b/humility-idol/src/lib.rs index 152c4b50b..23beac08f 100644 --- a/humility-idol/src/lib.rs +++ b/humility-idol/src/lib.rs @@ -366,15 +366,15 @@ fn lookup<'a>( /// /// The humility hiffy cmd accepts multiple encodings of array arguments: /// - When passed a string of characters like `--arguments array=5432` the -/// string is passed to the operation 'as_bytes'. An idol op that takes a -/// 4 byte array will receive [ 53, 52, 51, 50 ] given the argument string -/// above. This is intended as a mechanism for passing ASCII characters to a -/// task. +/// string is passed to the operation 'as_bytes'. An idol op that takes a +/// 4 byte array will receive [ 53, 52, 51, 50 ] given the argument string +/// above. This is intended as a mechanism for passing ASCII characters to a +/// task. /// - To pass an array that's interpreted as the decimal representation of -/// bytes instead of ASCII, provide the array as a string enclosed in square -/// brackets with each array element separated by a space. The argument string -/// `--argument array=[37 1 255 127]` will result in the task receiving the -/// byte array `[ 37, 1, 255, 127 ]`. +/// bytes instead of ASCII, provide the array as a string enclosed in square +/// brackets with each array element separated by a space. The argument string +/// `--argument array=[37 1 255 127]` will result in the task receiving the +/// byte array `[ 37, 1, 255, 127 ]`. fn bytes_from_str(value: &str) -> Result> { if value.starts_with('[') && value.ends_with(']') { // use double ended iterator to drop first and last chars diff --git a/src/main.rs b/src/main.rs index fa94b5409..33c4e87d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ mod cmd; mod cmd_repl; fn main() -> Result<()> { - let (commands, m, args) = match parse_args(&mut std::env::args_os()) { + let (commands, m, args) = match parse_args(std::env::args_os()) { Some(s) => s, None => std::process::exit(1), };