Skip to content

Commit

Permalink
Bump to Rust 1.81.0 (#513)
Browse files Browse the repository at this point in the history
* Update to Rust 1.81

* Fix clippy complaints

* Make sorting stable and update trycmd tests
  • Loading branch information
mkeeter authored Oct 10, 2024
1 parent ac2272f commit 53c6f8a
Show file tree
Hide file tree
Showing 40 changed files with 338 additions and 342 deletions.
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
xtask = "run --package xtask --"

[profile.release]
overflow-checks = true
10 changes: 4 additions & 6 deletions cmd/counters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,12 @@ fn counters_dump_csv(
) {
// Sort the counters.
match opts.sort {
Some(Order::Value) => counters.sort_unstable_by(
Some(Order::Value) => counters.sort_by(
&mut |_, a: &CounterVariant, _, b: &CounterVariant| {
a.total().cmp(&b.total()).reverse()
},
),
Some(Order::Alpha) => {
counters.sort_unstable_by(&mut |a, _, b, _| a.cmp(b))
}
Some(Order::Alpha) => counters.sort_by(&mut |a, _, b, _| a.cmp(b)),
_ => {}
}

Expand Down Expand Up @@ -574,13 +572,13 @@ fn counter_dump(counters: &mut Counters, opts: &Options, pad: &str) {
// Therefore, sort by value by default, so the highest-valued counters
// are shown first.
Options { sort: Some(Order::Value), .. }
| Options { sort: None, full: false, .. } => counters.sort_unstable_by(
| Options { sort: None, full: false, .. } => counters.sort_by(
&mut |_, a: &CounterVariant, _, b: &CounterVariant| {
a.total().cmp(&b.total()).reverse()
},
),
Options { sort: Some(Order::Alpha), .. } => {
counters.sort_unstable_by(&mut |a, _, b, _| a.cmp(b))
counters.sort_by(&mut |a, _, b, _| a.cmp(b))
}
}

Expand Down
10 changes: 1 addition & 9 deletions cmd/dashboard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
Expand Down Expand Up @@ -114,8 +114,6 @@ trait Attributes {
fn decrease(&mut self, _ndx: usize) -> Option<u8> {
None
}

fn clear(&mut self) {}
}

struct TempGraph;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cmd/monorail/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}),
Expand Down
1 change: 1 addition & 0 deletions cmd/net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//! - Sidecar
//! - PSC
//! - `gimletlet-mgmt`
//!
//! These PCAs have the KSZ8463 switch + VSC85x2 PHY which is our standard
//! management network interface.
//!
Expand Down
2 changes: 1 addition & 1 deletion cmd/probe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/ringbuf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn ringbuf_dump(
// system, and can't easily be compared. Therefore, sort them by the
// value of the counter, so the most frequently recorded variants
// are displayed first.
counters.sort_unstable_by(
counters.sort_by(
&mut |_, a: &CounterVariant, _, b: &CounterVariant| {
a.total().cmp(&b.total()).reverse()
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn rpc_listen_one(
interface: u32,
port: u32,
) -> Result<BTreeSet<Target>> {
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 {
Expand Down
2 changes: 1 addition & 1 deletion humility-core/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions humility-core/src/hubris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3046,7 +3046,7 @@ impl HubrisArchive {
return Ok(v.size);
}

if self.ptrtypes.get(&goff).is_some() {
if self.ptrtypes.contains_key(&goff) {
return Ok(4);
}

Expand Down Expand Up @@ -3970,7 +3970,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;
}

Expand Down
10 changes: 5 additions & 5 deletions humility-core/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Q: ?Sized>(&self, name: &Q) -> Option<&Value>
pub fn get<Q>(&self, name: &Q) -> Option<&Value>
where
Q: std::hash::Hash + indexmap::Equivalent<String>,
Q: std::hash::Hash + indexmap::Equivalent<String> + ?Sized,
{
self.members.get(name).map(Box::as_ref)
}
Expand Down Expand Up @@ -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(());
}
Expand Down
6 changes: 3 additions & 3 deletions humility-doppel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ impl Counters {
self.counts.values().map(CounterVariant::total).sum()
}

pub fn sort_unstable_by(
pub fn sort_by(
&mut self,
cmp: &mut impl FnMut(
&String,
Expand All @@ -494,10 +494,10 @@ impl Counters {
) {
for v in self.counts.values_mut() {
if let CounterVariant::Nested(ref mut c) = v {
c.sort_unstable_by(cmp);
c.sort_by(cmp);
}
}
self.counts.sort_unstable_by(cmp);
self.counts.sort_by(cmp);
}

pub fn display_padded<'a>(
Expand Down
2 changes: 1 addition & 1 deletion humility-dump-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl DumpAgentCore {
&mut self,
headers: Vec<DumpAreaHeader>,
total: u32,
dump: &Vec<u8>,
dump: &[u8],
task: Option<DumpTask>,
) -> Result<DumpBreakdown> {
let header = headers[0];
Expand Down
16 changes: 8 additions & 8 deletions humility-idol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<u8>> {
if value.starts_with('[') && value.ends_with(']') {
// use double ended iterator to drop first and last chars
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.72.1"
channel = "1.81.0"
components = ["clippy"]
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
Expand Down
26 changes: 13 additions & 13 deletions tests/cmd/counters-arg/counters-arg.counters.0.stdout

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions tests/cmd/counters-arg/counters-arg.host-panic.0.stdout

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions tests/cmd/counters-arg/counters-arg.host-panic.1.stdout

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 53c6f8a

Please sign in to comment.