Skip to content

Commit 53c6f8a

Browse files
authored
Bump to Rust 1.81.0 (#513)
* Update to Rust 1.81 * Fix clippy complaints * Make sorting stable and update trycmd tests
1 parent ac2272f commit 53c6f8a

40 files changed

+338
-342
lines changed

.cargo/config.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[alias]
2+
xtask = "run --package xtask --"
3+
4+
[profile.release]
5+
overflow-checks = true

cmd/counters/src/lib.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,12 @@ fn counters_dump_csv(
512512
) {
513513
// Sort the counters.
514514
match opts.sort {
515-
Some(Order::Value) => counters.sort_unstable_by(
515+
Some(Order::Value) => counters.sort_by(
516516
&mut |_, a: &CounterVariant, _, b: &CounterVariant| {
517517
a.total().cmp(&b.total()).reverse()
518518
},
519519
),
520-
Some(Order::Alpha) => {
521-
counters.sort_unstable_by(&mut |a, _, b, _| a.cmp(b))
522-
}
520+
Some(Order::Alpha) => counters.sort_by(&mut |a, _, b, _| a.cmp(b)),
523521
_ => {}
524522
}
525523

@@ -574,13 +572,13 @@ fn counter_dump(counters: &mut Counters, opts: &Options, pad: &str) {
574572
// Therefore, sort by value by default, so the highest-valued counters
575573
// are shown first.
576574
Options { sort: Some(Order::Value), .. }
577-
| Options { sort: None, full: false, .. } => counters.sort_unstable_by(
575+
| Options { sort: None, full: false, .. } => counters.sort_by(
578576
&mut |_, a: &CounterVariant, _, b: &CounterVariant| {
579577
a.total().cmp(&b.total()).reverse()
580578
},
581579
),
582580
Options { sort: Some(Order::Alpha), .. } => {
583-
counters.sort_unstable_by(&mut |a, _, b, _| a.cmp(b))
581+
counters.sort_by(&mut |a, _, b, _| a.cmp(b))
584582
}
585583
}
586584

cmd/dashboard/src/lib.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl StatefulList {
7979

8080
fn previous(&mut self) {
8181
self.state.select(match self.state.selected() {
82-
Some(ndx) if ndx == 0 => Some(self.n - 1),
82+
Some(0) => Some(self.n - 1),
8383
Some(ndx) => Some(ndx - 1),
8484
None => Some(0),
8585
});
@@ -114,8 +114,6 @@ trait Attributes {
114114
fn decrease(&mut self, _ndx: usize) -> Option<u8> {
115115
None
116116
}
117-
118-
fn clear(&mut self) {}
119117
}
120118

121119
struct TempGraph;
@@ -185,12 +183,6 @@ impl Attributes for FanGraph {
185183
self.0[ndx] = if nval >= 0 { nval as u8 } else { 0 };
186184
Some(self.0[ndx])
187185
}
188-
189-
fn clear(&mut self) {
190-
for val in self.0.iter_mut() {
191-
*val = 0;
192-
}
193-
}
194186
}
195187

196188
struct CurrentGraph;

cmd/monorail/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ fn monorail_status(
756756
Value::Enum(m) => {
757757
let mode = m.disc().to_uppercase();
758758
let speed = m.contents().and_then(|speed| match speed {
759-
Value::Tuple(t) => t.get(0).map(|t| match t {
759+
Value::Tuple(t) => t.first().map(|t| match t {
760760
Value::Enum(t) => t.disc().replace("Speed", ""),
761761
v => panic!("Expected enum, got {:?}", v),
762762
}),

cmd/net/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! - Sidecar
1515
//! - PSC
1616
//! - `gimletlet-mgmt`
17+
//!
1718
//! These PCAs have the KSZ8463 switch + VSC85x2 PHY which is our standard
1819
//! management network interface.
1920
//!

cmd/probe/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fn probecmd(context: &mut ExecutionContext) -> Result<()> {
270270
Ok("progressing")
271271
}
272272
})
273-
.map_or_else(|_| "unable to step", |s| s)
273+
.unwrap_or("unable to step")
274274
.to_string();
275275
core.run()?;
276276
rval

cmd/ringbuf/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ fn ringbuf_dump(
161161
// system, and can't easily be compared. Therefore, sort them by the
162162
// value of the counter, so the most frequently recorded variants
163163
// are displayed first.
164-
counters.sort_unstable_by(
164+
counters.sort_by(
165165
&mut |_, a: &CounterVariant, _, b: &CounterVariant| {
166166
a.total().cmp(&b.total()).reverse()
167167
},

cmd/rpc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn rpc_listen_one(
157157
interface: u32,
158158
port: u32,
159159
) -> Result<BTreeSet<Target>> {
160-
let socket = match UdpSocket::bind(&format!("[::]:{port}")) {
160+
let socket = match UdpSocket::bind(format!("[::]:{port}")) {
161161
Ok(s) => s,
162162
Err(e) => {
163163
if e.kind() == std::io::ErrorKind::PermissionDenied {

humility-core/src/core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ impl GDBCore {
10401040
//
10411041
let val = u64::from_le_bytes(buf[..].try_into().unwrap());
10421042

1043-
if val > std::u32::MAX.into() {
1043+
if val > u32::MAX.into() {
10441044
Err(anyhow!("bad 64-bit return on cmd {}: {}", cmd, rstr))
10451045
} else {
10461046
Ok(val as u32)

humility-core/src/hubris.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ impl HubrisArchive {
799799
// is less than our base.
800800
//
801801
for (&(addr, _depth), (len, goff, origin)) in
802-
self.inlined.range(..=(pc, std::isize::MAX)).rev()
802+
self.inlined.range(..=(pc, isize::MAX)).rev()
803803
{
804804
if addr + len < base {
805805
break;
@@ -3046,7 +3046,7 @@ impl HubrisArchive {
30463046
return Ok(v.size);
30473047
}
30483048

3049-
if self.ptrtypes.get(&goff).is_some() {
3049+
if self.ptrtypes.contains_key(&goff) {
30503050
return Ok(4);
30513051
}
30523052

@@ -3970,7 +3970,7 @@ impl HubrisObjectLoader {
39703970
// If this is a zero-sized symbol or not against an allocated
39713971
// section (e.g., .idolatry), we don't want to keep track of it.
39723972
//
3973-
if sym.st_size == 0 || allocs.get(&sym.st_shndx).is_none() {
3973+
if sym.st_size == 0 || !allocs.contains(&sym.st_shndx) {
39743974
continue;
39753975
}
39763976

humility-core/src/reflect.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
//! The derived `Load` impls do not require _exact_ type match. In particular,
6464
//!
6565
//! - A struct will match even if it contains more fields than your Rust
66-
//! version, and
66+
//! version, and
6767
//! - An enum will match even if you define variants that don't exist in the
68-
//! program.
68+
//! program.
6969
//!
7070
//! This is deliberate, and is intended to help interpret programs across ABI
7171
//! changes. If you implement a `Load` impl by hand, you should try to emulate
@@ -508,9 +508,9 @@ impl Struct {
508508

509509
/// Returns a reference to the value of the member named `name`, if it
510510
/// exists, or `None`, if no member with that name exists.
511-
pub fn get<Q: ?Sized>(&self, name: &Q) -> Option<&Value>
511+
pub fn get<Q>(&self, name: &Q) -> Option<&Value>
512512
where
513-
Q: std::hash::Hash + indexmap::Equivalent<String>,
513+
Q: std::hash::Hash + indexmap::Equivalent<String> + ?Sized,
514514
{
515515
self.members.get(name).map(Box::as_ref)
516516
}
@@ -600,7 +600,7 @@ impl Format for Tuple {
600600
// Is this a bitflags-generated type? If so, just format it as a binary
601601
// value.
602602
if self.name().contains("InternalBitFlags") {
603-
if let Some(flags) = self.1.get(0).and_then(|v| v.as_base().ok()) {
603+
if let Some(flags) = self.1.first().and_then(|v| v.as_base().ok()) {
604604
write!(out, "{flags:#b}")?;
605605
return Ok(());
606606
}

humility-doppel/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl Counters {
483483
self.counts.values().map(CounterVariant::total).sum()
484484
}
485485

486-
pub fn sort_unstable_by(
486+
pub fn sort_by(
487487
&mut self,
488488
cmp: &mut impl FnMut(
489489
&String,
@@ -494,10 +494,10 @@ impl Counters {
494494
) {
495495
for v in self.counts.values_mut() {
496496
if let CounterVariant::Nested(ref mut c) = v {
497-
c.sort_unstable_by(cmp);
497+
c.sort_by(cmp);
498498
}
499499
}
500-
self.counts.sort_unstable_by(cmp);
500+
self.counts.sort_by(cmp);
501501
}
502502

503503
pub fn display_padded<'a>(

humility-dump-agent/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl DumpAgentCore {
203203
&mut self,
204204
headers: Vec<DumpAreaHeader>,
205205
total: u32,
206-
dump: &Vec<u8>,
206+
dump: &[u8],
207207
task: Option<DumpTask>,
208208
) -> Result<DumpBreakdown> {
209209
let header = headers[0];

humility-idol/src/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,15 @@ fn lookup<'a>(
366366
///
367367
/// The humility hiffy cmd accepts multiple encodings of array arguments:
368368
/// - When passed a string of characters like `--arguments array=5432` the
369-
/// string is passed to the operation 'as_bytes'. An idol op that takes a
370-
/// 4 byte array will receive [ 53, 52, 51, 50 ] given the argument string
371-
/// above. This is intended as a mechanism for passing ASCII characters to a
372-
/// task.
369+
/// string is passed to the operation 'as_bytes'. An idol op that takes a
370+
/// 4 byte array will receive [ 53, 52, 51, 50 ] given the argument string
371+
/// above. This is intended as a mechanism for passing ASCII characters to a
372+
/// task.
373373
/// - To pass an array that's interpreted as the decimal representation of
374-
/// bytes instead of ASCII, provide the array as a string enclosed in square
375-
/// brackets with each array element separated by a space. The argument string
376-
/// `--argument array=[37 1 255 127]` will result in the task receiving the
377-
/// byte array `[ 37, 1, 255, 127 ]`.
374+
/// bytes instead of ASCII, provide the array as a string enclosed in square
375+
/// brackets with each array element separated by a space. The argument string
376+
/// `--argument array=[37 1 255 127]` will result in the task receiving the
377+
/// byte array `[ 37, 1, 255, 127 ]`.
378378
fn bytes_from_str(value: &str) -> Result<Vec<u8>> {
379379
if value.starts_with('[') && value.ends_with(']') {
380380
// use double ended iterator to drop first and last chars

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.72.1"
2+
channel = "1.81.0"
33
components = ["clippy"]

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod cmd;
1919
mod cmd_repl;
2020

2121
fn main() -> Result<()> {
22-
let (commands, m, args) = match parse_args(&mut std::env::args_os()) {
22+
let (commands, m, args) = match parse_args(std::env::args_os()) {
2323
Some(s) => s,
2424
None => std::process::exit(1),
2525
};

tests/cmd/counters-arg/counters-arg.counters.0.stdout

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/cmd/counters-arg/counters-arg.host-panic.0.stdout

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/cmd/counters-arg/counters-arg.host-panic.1.stdout

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)