refactor: bump 'msrv' to 1.81 and update deprecated code (#1615)

* refactor: ignore warning for deprecated panic hook from Rust 1.82.0

* refactor: bump 'msrv' to 1.81 and update deprecated code

* some more cleanup

* even more cleanup
This commit is contained in:
Clement Tsang 2024-11-01 13:51:12 -04:00 committed by GitHub
parent f2e329b00a
commit 776f8cb3d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 57 additions and 59 deletions

View file

@ -38,7 +38,7 @@ exclude = [
"rustfmt.toml",
]
# The oldest version I've tested that should still build - note this is not an official MSRV!
rust-version = "1.74.0"
rust-version = "1.81.0"
[[bin]]
name = "btm"

View file

@ -1,4 +1,4 @@
#[allow(dead_code)]
#[expect(dead_code)]
#[path = "src/options/args.rs"]
mod args;

View file

@ -206,8 +206,10 @@ impl DataCollection {
self.timed_data_vec.shrink_to_fit();
}
// Clippy allow to avoid warning on certain platforms (e.g. 32-bit).
#[allow(clippy::boxed_local)]
#[allow(
clippy::boxed_local,
reason = "Clippy allow to avoid warning on certain platforms (e.g. 32-bit)."
)]
pub fn eat_data(&mut self, harvested_data: Box<Data>) {
let harvested_time = harvested_data.collection_time;
let mut new_entry = TimedData::default();

View file

@ -19,7 +19,7 @@ type ColumnMappings = (u32, BTreeMap<LineSegment, ColumnRowMappings>);
impl BottomLayout {
pub fn get_movement_mappings(&mut self) {
#[allow(clippy::suspicious_operation_groupings)] // Have to enable this, clippy really doesn't like me doing this with tuples...
#[expect(clippy::suspicious_operation_groupings)] // Have to enable this, clippy really doesn't like me doing this with tuples...
fn is_intersecting(a: LineSegment, b: LineSegment) -> bool {
a.0 >= b.0 && a.1 <= b.1
|| a.1 >= b.1 && a.0 <= b.0

View file

@ -126,7 +126,7 @@ impl<DataType: DataToCell<H>, H: ColumnHeader, S: SortType, C: DataTableColumn<H
}
/// Updates the scroll position to a selected index.
#[allow(clippy::comparison_chain)]
#[expect(clippy::comparison_chain)]
pub fn set_position(&mut self, new_index: usize) {
let new_index = new_index.clamp_upper(self.data.len().saturating_sub(1));
if self.state.current_index < new_index {

View file

@ -29,7 +29,6 @@ struct FileSystem {
pub fn get_io_usage() -> CollectionResult<IoHarvest> {
// TODO: Should this (and other I/O collectors) fail fast? In general, should
// collection ever fail fast?
#[allow(unused_mut)]
let mut io_harvest: HashMap<String, Option<IoData>> =
get_disk_info().map(|storage_system_information| {
storage_system_information

View file

@ -88,7 +88,7 @@ impl FileSystem {
matches!(self, FileSystem::Other(..))
}
#[allow(dead_code)]
#[expect(dead_code)]
#[inline]
/// Returns a string literal identifying this filesystem.
pub fn as_str(&self) -> &str {

View file

@ -138,7 +138,7 @@ impl FromStr for Partition {
}
}
#[allow(dead_code)]
#[expect(dead_code)]
/// Returns a [`Vec`] containing all partitions.
pub(crate) fn partitions() -> anyhow::Result<Vec<Partition>> {
const PROC_MOUNTS: &str = "/proc/mounts";

View file

@ -12,24 +12,24 @@ use core_foundation::{
use libc::c_char;
use mach2::{kern_return::kern_return_t, port::MACH_PORT_NULL};
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
pub type io_object_t = mach_port_t;
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
pub type io_iterator_t = io_object_t;
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
pub type io_registry_entry_t = io_object_t;
pub type IOOptionBits = u32;
/// See https://github.com/1kc/librazermacos/pull/27#issuecomment-1042368531.
#[allow(non_upper_case_globals)]
#[expect(non_upper_case_globals)]
pub const kIOMasterPortDefault: mach_port_t = MACH_PORT_NULL;
#[allow(non_upper_case_globals)]
#[expect(non_upper_case_globals)]
pub const kIOServicePlane: &str = "IOService\0";
#[allow(non_upper_case_globals)]
#[expect(non_upper_case_globals)]
pub const kIOMediaClass: &str = "IOMedia\0";
// See [here](https://developer.apple.com/documentation/iokit) for more details.

View file

@ -84,7 +84,7 @@ fn partitions_iter() -> anyhow::Result<impl Iterator<Item = Partition>> {
}))
}
#[allow(dead_code)]
#[expect(dead_code)]
/// Returns a [`Vec`] containing all partitions.
pub(crate) fn partitions() -> anyhow::Result<Vec<Partition>> {
partitions_iter().map(|iter| iter.collect())

View file

@ -2,7 +2,7 @@ pub struct Usage(libc::statvfs);
// Note that x86 returns `u32` values while x86-64 returns `u64`s, so we convert
// everything to `u64` for consistency.
#[allow(clippy::useless_conversion)]
#[expect(clippy::useless_conversion)]
impl Usage {
pub(crate) fn new(vfs: libc::statvfs) -> Self {
Self(vfs)
@ -19,7 +19,7 @@ impl Usage {
u64::from(self.0.f_bfree) * u64::from(self.0.f_frsize)
}
#[allow(dead_code)]
#[expect(dead_code)]
/// Returns the total number of bytes used. Equal to `total - available` on
/// Unix.
pub fn used(&self) -> u64 {

View file

@ -360,7 +360,7 @@ pub(crate) fn linux_process_data(
let pid = process.pid;
let prev_proc_details = pid_mapping.entry(pid).or_default();
#[allow(unused_mut)]
#[cfg_attr(not(feature = "gpu"), expect(unused_mut))]
if let Ok((mut process_harvest, new_process_times)) =
read_proc(prev_proc_details, process, args, user_table)
{

View file

@ -12,14 +12,12 @@ use mach2::vm_types::user_addr_t;
use crate::data_collection::Pid;
#[allow(non_camel_case_types)]
#[repr(C)]
pub(crate) struct kinfo_proc {
pub kp_proc: extern_proc,
pub kp_eproc: eproc,
}
#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct p_st1 {
@ -28,7 +26,6 @@ pub struct p_st1 {
p_back: user_addr_t,
}
#[allow(non_camel_case_types)]
#[repr(C)]
pub union p_un {
pub p_st1: p_st1,
@ -39,7 +36,6 @@ pub union p_un {
/// Exported fields for kern sysctl. See
/// [`proc.h`](https://opensource.apple.com/source/xnu/xnu-201/bsd/sys/proc.h)
#[allow(non_camel_case_types)]
#[repr(C)]
pub(crate) struct extern_proc {
pub p_un: p_un,
@ -170,19 +166,18 @@ const WMESGLEN: usize = 7;
const COMAPT_MAXLOGNAME: usize = 12;
/// See `_caddr_t.h`.
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
type caddr_t = *const libc::c_char;
/// See `types.h`.
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
type segsz_t = i32;
/// See `types.h`.
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
type fixpt_t = u32;
/// See [`proc.h`](https://opensource.apple.com/source/xnu/xnu-201/bsd/sys/proc.h)
#[allow(non_camel_case_types)]
#[repr(C)]
pub(crate) struct pcred {
pub pc_lock: [c_char; 72],
@ -195,7 +190,6 @@ pub(crate) struct pcred {
}
/// See `vm.h`.
#[allow(non_camel_case_types)]
#[repr(C)]
pub(crate) struct vmspace {
pub dummy: i32,
@ -205,7 +199,6 @@ pub(crate) struct vmspace {
}
/// See [`sysctl.h`](https://opensource.apple.com/source/xnu/xnu-344/bsd/sys/sysctl.h).
#[allow(non_camel_case_types)]
#[repr(C)]
pub(crate) struct eproc {
/// Address of proc. We just cheat and use a c_void pointer since we aren't

View file

@ -27,7 +27,7 @@ pub mod widgets;
use std::{
boxed::Box,
io::{stderr, stdout, Write},
panic::{self, PanicInfo},
panic::{self, PanicHookInfo},
sync::{
mpsc::{self, Receiver, Sender},
Arc,
@ -51,7 +51,7 @@ use event::{handle_key_event_or_break, handle_mouse_event, BottomEvent, Collecti
use options::{args, get_or_create_config, init_app};
use tui::{backend::CrosstermBackend, Terminal};
use utils::cancellation_token::CancellationToken;
#[allow(unused_imports)]
#[allow(unused_imports, reason = "this is needed if logging is enabled")]
use utils::logging::*;
// Used for heap allocation debugging purposes.
@ -103,7 +103,7 @@ fn check_if_terminal() {
/// A panic hook to properly restore the terminal in the case of a panic.
/// Originally based on [spotify-tui's implementation](https://github.com/Rigellute/spotify-tui/blob/master/src/main.rs).
fn panic_hook(panic_info: &PanicInfo<'_>) {
fn panic_hook(panic_info: &PanicHookInfo<'_>) {
let mut stdout = stdout();
let msg = match panic_info.payload().downcast_ref::<&'static str>() {

View file

@ -811,10 +811,8 @@ fn get_default_widget_and_count(
}
}
#[allow(unused_variables)]
fn get_use_battery(args: &BottomArgs, config: &Config) -> bool {
#[cfg(feature = "battery")]
{
fn get_use_battery(args: &BottomArgs, config: &Config) -> bool {
// TODO: Move this so it's dynamic in the app itself and automatically hide if
// there are no batteries?
if let Ok(battery_manager) = Manager::new() {
@ -832,8 +830,12 @@ fn get_use_battery(args: &BottomArgs, config: &Config) -> bool {
return battery;
}
}
false
}
#[cfg(not(feature = "battery"))]
fn get_use_battery(_args: &BottomArgs, _config: &Config) -> bool {
false
}
@ -855,10 +857,8 @@ fn get_enable_gpu(_: &BottomArgs, _: &Config) -> bool {
false
}
#[allow(unused_variables)]
fn get_enable_cache_memory(args: &BottomArgs, config: &Config) -> bool {
#[cfg(not(target_os = "windows"))]
{
fn get_enable_cache_memory(args: &BottomArgs, config: &Config) -> bool {
if args.memory.enable_cache_memory {
return true;
} else if let Some(flags) = &config.flags {
@ -866,8 +866,12 @@ fn get_enable_cache_memory(args: &BottomArgs, config: &Config) -> bool {
return enable_cache_memory;
}
}
false
}
#[cfg(target_os = "windows")]
fn get_enable_cache_memory(_args: &BottomArgs, _config: &Config) -> bool {
false
}