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

@@ -197,7 +197,7 @@ fn resolve_deeper_event_set(c: &mut Criterion) {
/////////////////////////////////////////////////////////////////////*/
struct TestStore<E: Event>(HashMap<OwnedEventId, E>);
#[allow(unused)]
#[expect(unused)]
impl<E: Event> TestStore<E> {
fn get_event(&self, room_id: &RoomId, event_id: &EventId) -> Result<E> {
self.0
@@ -278,7 +278,7 @@ impl<E: Event> TestStore<E> {
}
impl TestStore<PduEvent> {
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
fn set_up(
&mut self,
) -> (StateMap<OwnedEventId>, StateMap<OwnedEventId>, StateMap<OwnedEventId>) {
@@ -463,7 +463,7 @@ where
}
// all graphs start with these input events
#[allow(non_snake_case)]
#[expect(non_snake_case)]
fn INITIAL_EVENTS() -> HashMap<OwnedEventId, PduEvent> {
vec![
to_pdu_event::<&EventId>(
@@ -545,7 +545,7 @@ fn INITIAL_EVENTS() -> HashMap<OwnedEventId, PduEvent> {
}
// all graphs start with these input events
#[allow(non_snake_case)]
#[expect(non_snake_case)]
fn BAN_STATE_SET() -> HashMap<OwnedEventId, PduEvent> {
vec![
to_pdu_event(

View File

@@ -22,7 +22,6 @@ pub fn reload(old: &Config, new: &Config) -> Result {
Ok(())
}
#[allow(clippy::cognitive_complexity)]
pub fn check(config: &Config) -> Result {
if cfg!(debug_assertions) {
warn!("Note: tuwunel was built without optimisations (i.e. debug build)");

View File

@@ -107,7 +107,7 @@ fn load(&self, handle: &mut [Option<Arc<Config>>]) -> &'static Arc<Config> {
skip_all,
fields(%index, ?config)
)]
#[allow(clippy::transmute_ptr_to_ptr)]
#[expect(clippy::transmute_ptr_to_ptr)]
fn load_miss(
handle: &mut [Option<Arc<Config>>],
index: usize,

View File

@@ -33,8 +33,8 @@ use crate::{
};
/// All the config options for tuwunel.
#[allow(clippy::struct_excessive_bools)]
#[allow(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
#[expect(clippy::struct_excessive_bools)]
#[expect(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
#[derive(Clone, Debug, Deserialize)]
#[config_example_generator(
filename = "tuwunel-example.toml",
@@ -97,7 +97,7 @@ pub struct Config {
#[serde(default = "default_new_user_displayname_suffix")]
pub new_user_displayname_suffix: String,
#[allow(clippy::doc_link_with_quotes)]
#[expect(clippy::doc_link_with_quotes)]
/// The default address (IPv4 or IPv6) tuwunel will listen on.
///
/// If you are using Docker or a container NAT networking setup, this must
@@ -821,7 +821,7 @@ pub struct Config {
#[serde(default)]
pub proxy: ProxyConfig,
#[allow(clippy::doc_link_with_quotes)]
#[expect(clippy::doc_link_with_quotes)]
/// Servers listed here will be used to gather public keys of other servers
/// (notary trusted key servers).
///
@@ -1007,7 +1007,7 @@ pub struct Config {
#[serde(default)]
pub turn_password: String,
#[allow(clippy::doc_link_with_quotes)]
#[expect(clippy::doc_link_with_quotes)]
/// Vector list of TURN URIs/servers to use.
///
/// Replace "example.turn.uri" with your TURN domain, such as the coturn
@@ -1045,7 +1045,7 @@ pub struct Config {
#[serde(default = "default_turn_ttl")]
pub turn_ttl: u64,
#[allow(clippy::doc_link_with_quotes)]
#[expect(clippy::doc_link_with_quotes)]
/// List/vector of room IDs or room aliases that tuwunel will make newly
/// registered users join. The rooms specified must be rooms that you have
/// joined at least once on the server, and must be public.
@@ -1624,7 +1624,7 @@ pub struct Config {
#[serde(default, with = "serde_regex")]
pub forbidden_remote_room_directory_server_names: RegexSet,
#[allow(clippy::doc_link_with_quotes)]
#[expect(clippy::doc_link_with_quotes)]
/// Vector list of IPv4 and IPv6 CIDR ranges / subnets *in quotes* that you
/// do not want tuwunel to send outbound requests to. Defaults to
/// RFC1918, unroutable, loopback, multicast, and testnet addresses for
@@ -1842,7 +1842,7 @@ pub struct Config {
#[serde(default)]
pub admin_console_automatic: bool,
#[allow(clippy::doc_link_with_quotes)]
#[expect(clippy::doc_link_with_quotes)]
/// List of admin commands to execute on startup.
///
/// This option can also be configured with the `--execute` tuwunel
@@ -2229,7 +2229,7 @@ pub struct Config {
pub identity_provider: HashSet<IdentityProvider>,
#[serde(flatten)]
#[allow(clippy::zero_sized_map_values)]
#[expect(clippy::zero_sized_map_values)]
// this is a catchall, the map shouldn't be zero at runtime
catchall: BTreeMap<String, IgnoredAny>,
}
@@ -2252,7 +2252,7 @@ pub struct TlsConfig {
pub dual_protocol: bool,
}
#[allow(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
#[expect(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
#[derive(Clone, Debug, Deserialize, Default)]
#[config_example_generator(
filename = "tuwunel-example.toml",
@@ -2317,7 +2317,7 @@ pub struct WellKnownConfig {
}
#[derive(Clone, Copy, Debug, Deserialize, Default)]
#[allow(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
#[expect(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
#[config_example_generator(
filename = "tuwunel-example.toml",
section = "global.blurhashing"
@@ -3129,13 +3129,13 @@ fn default_rocksdb_compression_algo() -> String {
/// Default RocksDB compression level is 32767, which is internally read by
/// RocksDB as the default magic number and translated to the library's default
/// compression level as they all differ. See their `kDefaultCompressionLevel`.
#[allow(clippy::doc_markdown)]
#[expect(clippy::doc_markdown)]
fn default_rocksdb_compression_level() -> i32 { 32767 }
/// Default RocksDB compression level is 32767, which is internally read by
/// RocksDB as the default magic number and translated to the library's default
/// compression level as they all differ. See their `kDefaultCompressionLevel`.
#[allow(clippy::doc_markdown)]
#[expect(clippy::doc_markdown)]
fn default_rocksdb_bottommost_compression_level() -> i32 { 32767 }
fn default_rocksdb_stats_level() -> u8 { 1 }
@@ -3198,7 +3198,7 @@ fn default_admin_log_capture() -> String {
fn default_admin_room_tag() -> String { "m.server_notice".to_owned() }
#[allow(clippy::as_conversions, clippy::cast_precision_loss)]
#[expect(clippy::as_conversions, clippy::cast_precision_loss)]
fn parallelism_scaled_f64(val: f64) -> f64 { val * (sys::available_parallelism() as f64) }
fn parallelism_scaled_u32(val: u32) -> u32 {

View File

@@ -127,7 +127,7 @@ impl WildCardedDomain {
impl std::str::FromStr for WildCardedDomain {
type Err = std::convert::Infallible;
#[allow(clippy::string_slice)]
#[expect(clippy::string_slice)]
fn from_str(s: &str) -> Result<Self, Self::Err> {
// maybe do some domain validation?
Ok(if s.starts_with("*.") {

View File

@@ -1,5 +1,3 @@
#![allow(clippy::disallowed_macros)]
use std::{any::Any, env, panic, sync::LazyLock};
use tracing::Level;
@@ -73,7 +71,6 @@ fn set_panic_trap() {
#[cold]
#[inline(never)]
#[allow(deprecated_in_future)]
pub fn panic_handler(info: &panic::PanicHookInfo<'_>, next: &dyn Fn(&panic::PanicHookInfo<'_>)) {
trap();
next(info);

View File

@@ -239,7 +239,7 @@ impl<T> From<PoisonError<T>> for Error {
fn from(e: PoisonError<T>) -> Self { Self::Poison(e.to_string().into()) }
}
#[allow(clippy::fallible_impl_from)]
#[expect(clippy::fallible_impl_from)]
impl From<Infallible> for Error {
#[cold]
#[inline(never)]
@@ -257,5 +257,5 @@ pub fn infallible(_e: &Infallible) {
/// Convenience functor for fundamental Error::sanitized_message(); see member.
#[inline]
#[must_use]
#[allow(clippy::needless_pass_by_value)]
#[expect(clippy::needless_pass_by_value)]
pub fn sanitized_message(e: Error) -> String { e.sanitized_message() }

View File

@@ -1,5 +1,3 @@
#![allow(clippy::disallowed_macros)]
pub mod capture;
pub mod color;
pub mod console;

View File

@@ -1,4 +1,4 @@
#![allow(
#![expect(
clippy::cast_possible_wrap,
clippy::cast_sign_loss,
clippy::as_conversions

View File

@@ -22,11 +22,9 @@ impl<E: Event> RoomCreateEvent<E> {
pub fn new(event: E) -> Self { Self(event) }
/// The version of the room.
#[allow(dead_code)]
pub fn room_version(&self) -> Result<RoomVersionId> {
#[derive(Deserialize)]
struct RoomCreateContentRoomVersion {
#[allow(dead_code)]
room_version: Option<RoomVersionId>,
}

View File

@@ -146,7 +146,7 @@ where
Ok(0)
}
#[allow(clippy::redundant_closure)]
#[expect(clippy::redundant_closure)]
#[tracing::instrument(level = "trace", skip_all)]
async fn get_power_levels_auth_event<Fetch, Fut, Pdu>(
event: &Pdu,

View File

@@ -652,7 +652,7 @@ async fn join_rule_with_auth_chain() {
do_check(&join_rule.values().cloned().collect::<Vec<_>>(), edges, expected_state_ids).await;
}
#[allow(non_snake_case)]
#[expect(non_snake_case)]
fn BAN_STATE_SET() -> HashMap<OwnedEventId, PduEvent> {
vec![
to_pdu_event(
@@ -697,7 +697,7 @@ fn BAN_STATE_SET() -> HashMap<OwnedEventId, PduEvent> {
.collect()
}
#[allow(non_snake_case)]
#[expect(non_snake_case)]
fn JOIN_RULE() -> HashMap<OwnedEventId, PduEvent> {
vec![
to_pdu_event(
@@ -726,7 +726,7 @@ fn JOIN_RULE() -> HashMap<OwnedEventId, PduEvent> {
macro_rules! state_set {
($($kind:expr => $key:expr => $id:expr),* $(,)?) => {{
#[allow(unused_mut)]
#[expect(unused_mut)]
let mut x = StateMap::new();
$(
x.insert(($kind, $key.into()), $id);

View File

@@ -75,7 +75,7 @@ impl PartialOrd for TieBreaker<'_> {
graph = graph.len(),
)
)]
#[allow(clippy::implicit_hasher)]
#[expect(clippy::implicit_hasher)]
pub async fn topological_sort<Query, Fut>(
graph: &HashMap<OwnedEventId, HashSet<OwnedEventId>>,
query: &Query,

View File

@@ -248,7 +248,7 @@ pub(super) async fn do_check(
assert_eq!(expected_state, end_state);
}
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
pub(super) struct TestStore(pub(super) HashMap<OwnedEventId, PduEvent>);
impl TestStore {
@@ -286,7 +286,7 @@ impl TestStore {
}
// A StateStore implementation for testing
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
impl TestStore {
pub(super) fn set_up(
&mut self,
@@ -646,7 +646,7 @@ pub(super) fn room_create_hydra_pdu_event(
}
// all graphs start with these input events
#[allow(non_snake_case)]
#[expect(non_snake_case)]
pub(super) fn INITIAL_EVENTS() -> HashMap<OwnedEventId, PduEvent> {
vec![
to_pdu_event::<&EventId>(
@@ -729,7 +729,7 @@ pub(super) fn INITIAL_EVENTS() -> HashMap<OwnedEventId, PduEvent> {
/// Batch of initial events to use for incoming events from room version
/// `org.matrix.hydra.11` onwards.
#[allow(non_snake_case)]
#[expect(non_snake_case)]
pub(super) fn INITIAL_HYDRA_EVENTS() -> HashMap<OwnedEventId, PduEvent> {
vec![
room_create_hydra_pdu_event(
@@ -807,7 +807,7 @@ pub(super) fn INITIAL_HYDRA_EVENTS() -> HashMap<OwnedEventId, PduEvent> {
}
// all graphs start with these input events
#[allow(non_snake_case)]
#[expect(non_snake_case)]
pub(super) fn INITIAL_EVENTS_CREATE_ROOM() -> HashMap<OwnedEventId, PduEvent> {
vec![to_pdu_event::<&EventId>(
"CREATE",
@@ -823,7 +823,7 @@ pub(super) fn INITIAL_EVENTS_CREATE_ROOM() -> HashMap<OwnedEventId, PduEvent> {
.collect()
}
#[allow(non_snake_case)]
#[expect(non_snake_case)]
pub(super) fn INITIAL_EDGES() -> Vec<OwnedEventId> {
vec!["START", "IMC", "IMB", "IJR", "IPOWER", "IMA", "CREATE"]
.into_iter()

View File

@@ -24,5 +24,5 @@ pub(crate) fn check_and_reset() -> bool { STATIC_DTORS.swap(0, ORDERING) == 0 }
/// Called by Module::unload() after unload to verify static destruction took
/// place. A call to prepare() must be made prior to Module::unload() and making
/// this call.
#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) fn check() -> bool { STATIC_DTORS.load(ORDERING) == 0 }

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::*;