clippy allow -> expect

This commit is contained in:
dasha_uwu
2026-01-22 21:48:41 +05:00
committed by Jason Volk
parent fbedd713ca
commit 0c9a3abb71
91 changed files with 126 additions and 166 deletions

View File

@@ -28,7 +28,7 @@ pub trait BoolExt {
fn into_option(self) -> Option<()>;
#[allow(clippy::result_unit_err)]
#[expect(clippy::result_unit_err)]
fn into_result(self) -> Result<(), ()>;
#[must_use]

View File

@@ -60,7 +60,7 @@ impl<T: fmt::Debug> fmt::Debug for TruncatedSlice<'_, T> {
}
impl fmt::Debug for TruncatedStr<'_> {
#[allow(clippy::string_slice)]
#[expect(clippy::string_slice)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.inner.len() <= self.max_len {
write!(f, "{:?}", self.inner)

View File

@@ -1,5 +1,5 @@
//! Extended external extensions to futures::FutureExt
#![allow(clippy::many_single_char_names, clippy::impl_trait_in_params)]
#![expect(clippy::many_single_char_names, clippy::impl_trait_in_params)]
use std::marker::Unpin;

View File

@@ -1,4 +1,4 @@
#![allow(clippy::wrong_self_convention)]
#![expect(clippy::wrong_self_convention)]
use futures::{Future, FutureExt, future::OptionFuture};

View File

@@ -1,4 +1,4 @@
#![allow(clippy::wrong_self_convention)]
#![expect(clippy::wrong_self_convention)]
use futures::Future;

View File

@@ -1,8 +1,8 @@
//! Extended external extensions to futures::TryFutureExt
#![allow(clippy::type_complexity)]
#![expect(clippy::type_complexity)]
// is_ok() has to consume *self rather than borrow. This extension is for a
// caller only ever caring about result status while discarding all contents.
#![allow(clippy::wrong_self_convention)]
#![expect(clippy::wrong_self_convention)]
use std::marker::Unpin;
@@ -22,7 +22,7 @@ where
where
Self: Sized;
#[allow(clippy::wrong_self_convention)]
#[expect(clippy::wrong_self_convention)]
fn is_ok(
self,
) -> MapOkOrElse<Self, impl FnOnce(Self::Ok) -> bool, impl FnOnce(Self::Error) -> bool>

View File

@@ -42,7 +42,7 @@ macro_rules! expected {
#[collapse_debuginfo(yes)]
macro_rules! validated {
($($input:tt)+) => {
//#[allow(clippy::arithmetic_side_effects)] {
//#[expect(clippy::arithmetic_side_effects)] {
//Some($($input)*)
// .ok_or_else(|| $crate::err!(Arithmetic("this error should never been seen")))
//}
@@ -62,7 +62,6 @@ macro_rules! validated {
}
#[inline]
#[allow(clippy::as_conversions)]
pub fn usize_from_f64(val: f64) -> Result<usize, Error> {
if val < 0.0 {
return Err!(Arithmetic("Converting negative float to unsigned integer"));
@@ -92,7 +91,7 @@ pub fn ruma_from_usize(val: usize) -> ruma::UInt {
#[inline]
#[must_use]
#[allow(clippy::as_conversions, clippy::cast_possible_truncation)]
#[expect(clippy::as_conversions, clippy::cast_possible_truncation)]
pub fn usize_from_u64_truncated(val: u64) -> usize { val as usize }
#[inline]

View File

@@ -1,4 +1,4 @@
#![allow(clippy::wrong_self_convention)]
#![expect(clippy::wrong_self_convention)]
use super::Result;

View File

@@ -1,5 +1,5 @@
//! Synchronous combinator extensions to futures::Stream
#![allow(clippy::type_complexity)]
#![expect(clippy::type_complexity)]
use futures::{
future::{FutureExt, Ready, ready},
@@ -198,7 +198,7 @@ where
}
#[inline]
#[allow(clippy::unit_arg)]
#[expect(clippy::unit_arg)]
fn ready_for_each<F>(
self,
mut f: F,

View File

@@ -1,5 +1,5 @@
//! Synchronous combinator extensions to futures::TryStream
#![allow(clippy::type_complexity)]
#![expect(clippy::type_complexity)]
use futures::{
future::{Ready, ready},

View File

@@ -1,5 +1,5 @@
//! TryStreamTools for futures::TryStream
#![allow(clippy::type_complexity)]
#![expect(clippy::type_complexity)]
use futures::{TryStream, TryStreamExt, future, future::Ready, stream::TryTakeWhile};

View File

@@ -65,7 +65,7 @@ pub fn camel_to_snake_string(s: &str) -> String {
}
#[inline]
#[allow(clippy::unbuffered_bytes)] // these are allocated string utilities, not file I/O utils
#[expect(clippy::unbuffered_bytes)] // these are allocated string utilities, not file I/O utils
pub fn camel_to_snake_case<I, O>(output: &mut O, input: I) -> Result
where
I: std::io::Read,
@@ -95,7 +95,7 @@ where
/// common_prefix(&input) == "con";
/// ```
#[must_use]
#[allow(clippy::string_slice)]
#[expect(clippy::string_slice)]
pub fn common_prefix<T: AsRef<str>>(choice: &[T]) -> &str {
choice.first().map_or(EMPTY, move |best| {
choice
@@ -114,7 +114,7 @@ pub fn common_prefix<T: AsRef<str>>(choice: &[T]) -> &str {
#[inline]
#[must_use]
#[allow(clippy::arithmetic_side_effects)]
#[expect(clippy::arithmetic_side_effects)]
pub fn truncate_deterministic(str: &str, range: Option<Range<usize>>) -> &str {
let range = range.unwrap_or(0..str.len());
let len = str

View File

@@ -34,7 +34,7 @@ impl<'a> From<&'a str> for &'a Unquoted {
//SAFETY: This is a pattern I lifted from ruma-identifiers for strong-type strs
// by wrapping in a tuple-struct.
#[allow(clippy::transmute_ptr_to_ptr)]
#[expect(clippy::transmute_ptr_to_ptr)]
unsafe {
std::mem::transmute(s)
}

View File

@@ -179,7 +179,7 @@ pub fn name_from_path(path: &Path) -> Result<String> {
}
/// Get the (major, minor) of the block device on which Path is mounted.
#[allow(
#[expect(
clippy::useless_conversion,
clippy::unnecessary_fallible_conversions
)]

View File

@@ -1,4 +1,4 @@
#![allow(clippy::disallowed_methods)]
#![expect(clippy::disallowed_methods)]
use crate::utils;
@@ -109,7 +109,7 @@ async fn mutex_map_contend() {
}
#[test]
#[allow(clippy::iter_on_single_items, clippy::many_single_char_names)]
#[expect(clippy::iter_on_single_items, clippy::many_single_char_names)]
fn set_intersection_none() {
use utils::set::intersection;
@@ -139,7 +139,7 @@ fn set_intersection_none() {
}
#[test]
#[allow(clippy::iter_on_single_items, clippy::many_single_char_names)]
#[expect(clippy::iter_on_single_items, clippy::many_single_char_names)]
fn set_intersection_all() {
use utils::set::intersection;
@@ -167,7 +167,7 @@ fn set_intersection_all() {
}
#[test]
#[allow(clippy::iter_on_single_items, clippy::many_single_char_names)]
#[expect(clippy::iter_on_single_items, clippy::many_single_char_names)]
fn set_intersection_some() {
use utils::set::intersection;
@@ -189,7 +189,7 @@ fn set_intersection_some() {
}
#[test]
#[allow(clippy::iter_on_single_items, clippy::many_single_char_names)]
#[expect(clippy::iter_on_single_items, clippy::many_single_char_names)]
fn set_intersection_sorted_some() {
use utils::set::intersection_sorted;
@@ -211,7 +211,7 @@ fn set_intersection_sorted_some() {
}
#[test]
#[allow(clippy::iter_on_single_items, clippy::many_single_char_names)]
#[expect(clippy::iter_on_single_items, clippy::many_single_char_names)]
fn set_intersection_sorted_all() {
use utils::set::intersection_sorted;

View File

@@ -6,7 +6,7 @@ use crate::{Result, err};
#[inline]
#[must_use]
#[allow(clippy::as_conversions, clippy::cast_possible_truncation)]
#[expect(clippy::as_conversions, clippy::cast_possible_truncation)]
pub fn now_millis() -> u64 { now().as_millis() as u64 }
#[inline]
@@ -87,7 +87,7 @@ pub fn format(ts: SystemTime, str: &str) -> String {
}
#[must_use]
#[allow(
#[expect(
clippy::as_conversions,
clippy::cast_possible_truncation,
clippy::cast_sign_loss
@@ -113,7 +113,7 @@ pub fn pretty(d: Duration) -> String {
/// part is the largest Unit containing a non-zero value, the frac part is a
/// rational remainder left over.
#[must_use]
#[allow(clippy::as_conversions, clippy::cast_precision_loss)]
#[expect(clippy::as_conversions, clippy::cast_precision_loss)]
pub fn whole_and_frac(d: Duration) -> (Unit, f64) {
use Unit::*;