Skip to content

Commit

Permalink
all: use expect attribute where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Sep 6, 2024
1 parent c3b50dc commit e377470
Show file tree
Hide file tree
Showing 134 changed files with 241 additions and 296 deletions.
2 changes: 1 addition & 1 deletion algorithms/src/rect/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ pub fn rects_to_bands(rects_tmp: &[RectRaw]) -> Container {
let mut res = Container::new();

for &[y1, y2] in ys.array_windows_ext::<2>() {
#[allow(clippy::never_loop)]
#[expect(clippy::never_loop)]
loop {
macro_rules! check_rect {
($rect:expr) => {{
Expand Down
4 changes: 2 additions & 2 deletions build/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
std::{env, io::Write},
};

#[allow(unused_macros)]
#[expect(unused_macros)]
#[macro_use]
#[path = "../src/macros.rs"]
mod macros;
Expand Down Expand Up @@ -43,7 +43,7 @@ fn get_enum_ty(variants: Vec<i128>) -> anyhow::Result<u64> {
fn write_ty<W: Write>(f: &mut W, vals: &[i32], ty: &str) -> anyhow::Result<()> {
let variants: Vec<_> = vals.iter().cloned().map(|v| v as i128).collect();
let size = get_enum_ty(variants)?;
writeln!(f, "#[allow(dead_code)]")?;
writeln!(f, "#[allow(clippy::allow_attributes, dead_code)]")?;
writeln!(f, "pub type {} = i{};", ty, size)?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion build/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl<'a> Tokenizer<'a> {

#[derive(Debug)]
pub struct Lined<T> {
#[allow(dead_code)]
#[expect(dead_code)]
pub line: u32,
pub val: T,
}
4 changes: 2 additions & 2 deletions build/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl<'a> Tokenizer<'a> {

#[derive(Debug)]
struct Lined<T> {
#[allow(dead_code)]
#[expect(dead_code)]
line: u32,
val: T,
}
Expand Down Expand Up @@ -755,7 +755,7 @@ fn write_request_handler<W: Write>(
parser = "crate::wl_usr::UsrCon";
error = "crate::wl_usr::UsrConError";
param = "ev";
writeln!(f, " #[allow(dead_code)]")?;
writeln!(f, " #[allow(clippy::allow_attributes, dead_code)]")?;
}
}
writeln!(
Expand Down
4 changes: 2 additions & 2 deletions build/wire_ei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {

#[derive(Debug)]
struct Lined<T> {
#[allow(dead_code)]
#[expect(dead_code)]
line: u32,
val: T,
}
Expand Down Expand Up @@ -637,7 +637,7 @@ fn write_interface_versions<W: Write>(f: &mut W, obj_names: &[String]) -> Result
writeln!(f, " }}")?;
for obj_name in obj_names {
writeln!(f)?;
writeln!(f, " #[allow(dead_code)]")?;
writeln!(f, " #[allow(clippy::allow_attributes, dead_code)]")?;
writeln!(f, " pub fn {obj_name}(&self) -> EiVersion {{")?;
writeln!(f, " self.{obj_name}.version.get()")?;
writeln!(f, " }}")?;
Expand Down
2 changes: 1 addition & 1 deletion build/wire_xcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ struct Extension {
#[derive(Debug)]
enum NamedType {
Struct(Rc<Struct>),
Bitmask(#[allow(dead_code)] Rc<Bitmask>),
Bitmask(#[expect(dead_code)] Rc<Bitmask>),
Enum(Rc<Enum>),
}

Expand Down
2 changes: 0 additions & 2 deletions jay-config/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ macro_rules! config {

macro_rules! try_get {
() => {{
#[allow(unused_unsafe)]
unsafe {
let client = crate::_private::client::CLIENT.with(|client| client.get());
if client.is_null() {
Expand All @@ -35,7 +34,6 @@ macro_rules! get {
get!(Default::default())
}};
($def:expr) => {{
#[allow(unused_unsafe)]
let client = unsafe {
let client = crate::_private::client::CLIENT.with(|client| client.get());
if client.is_null() {
Expand Down
2 changes: 1 addition & 1 deletion src/acceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Acceptor {
&self.socket.name
}

#[cfg_attr(not(feature = "it"), allow(dead_code))]
#[cfg_attr(not(feature = "it"), expect(dead_code))]
pub fn secure_path(&self) -> &Ustr {
self.socket.secure_path.as_ustr()
}
Expand Down
2 changes: 1 addition & 1 deletion src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait BufferObject {

pub trait MappedBuffer {
unsafe fn data(&self) -> &[u8];
#[cfg_attr(not(test), allow(dead_code))]
#[cfg_attr(not(feature = "it"), expect(dead_code))]
fn data_ptr(&self) -> *mut u8;
fn stride(&self) -> i32;
}
4 changes: 2 additions & 2 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub trait Backend {
fn clear(&self) {
// nothing
}
#[cfg_attr(not(feature = "it"), allow(dead_code))]
#[cfg_attr(not(feature = "it"), expect(dead_code))]
fn into_any(self: Rc<Self>) -> Rc<dyn Any>;

fn switch_to(&self, vtnr: u32) {
Expand Down Expand Up @@ -430,7 +430,7 @@ pub enum InputEvent {
}

pub enum DrmEvent {
#[allow(dead_code)]
#[expect(dead_code)]
Removed,
GfxApiChanged,
}
Expand Down
2 changes: 1 addition & 1 deletion src/backends/x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ impl XBackend {
if changed {
let images = self.create_images(output.window, width, height).await?;
for (new, old) in images.iter().zip(output.images.iter()) {
#[allow(clippy::let_underscore_future)]
#[expect(clippy::let_underscore_future)]
let _ = self.c.call(&FreePixmap {
pixmap: old.pixmap.get(),
});
Expand Down
4 changes: 1 addition & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ impl ClientId {
self.0
}

#[cfg_attr(not(feature = "it"), allow(dead_code))]
pub fn from_raw(val: u64) -> Self {
Self(val)
}
Expand Down Expand Up @@ -105,7 +104,7 @@ impl Clients {
ClientId(self.next_client_id.fetch_add(1))
}

#[allow(dead_code)]
#[cfg_attr(not(feature = "it"), expect(dead_code))]
pub fn get(&self, id: ClientId) -> Result<Rc<Client>, ClientError> {
let clients = self.clients.borrow();
match clients.get(&id) {
Expand Down Expand Up @@ -443,7 +442,6 @@ impl Client {
self.add_obj(obj, true)
}

#[allow(dead_code)]
pub fn add_server_obj<T: WaylandObject>(&self, obj: &Rc<T>) {
self.add_obj(obj, false).expect("add_server_obj failed")
}
Expand Down
7 changes: 5 additions & 2 deletions src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ async fn start_compositor3(state: Rc<State>, test_future: Option<TestFuture>) {
state.ring.stop();
}

fn load_config(state: &Rc<State>, #[allow(unused_variables)] for_test: bool) -> ConfigProxy {
fn load_config(
state: &Rc<State>,
#[allow(clippy::allow_attributes, unused_variables)] for_test: bool,
) -> ConfigProxy {
#[cfg(feature = "it")]
if for_test {
return ConfigProxy::for_test(state);
Expand Down Expand Up @@ -365,7 +368,7 @@ fn start_global_event_handlers(

async fn create_backend(
state: &Rc<State>,
#[allow(unused_variables)] test_future: Option<TestFuture>,
#[allow(clippy::allow_attributes, unused_variables)] test_future: Option<TestFuture>,
) -> Option<Rc<dyn Backend>> {
#[cfg(feature = "it")]
if let Some(tf) = test_future {
Expand Down
2 changes: 1 addition & 1 deletion src/cursor_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl CursorUser {
}
}

#[cfg_attr(not(feature = "it"), allow(dead_code))]
#[cfg_attr(not(feature = "it"), expect(dead_code))]
pub fn desired_known_cursor(&self) -> Option<KnownCursor> {
self.desired_known_cursor.get()
}
Expand Down
1 change: 0 additions & 1 deletion src/damage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ impl DamageVisualizer {
}
}

#[allow(dead_code)]
pub fn add(&self, rect: Rect) {
if !self.enabled.get() {
return;
Expand Down
18 changes: 9 additions & 9 deletions src/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,23 +274,23 @@ const MSG_ERROR: u8 = 3;
const MSG_SIGNAL: u8 = 4;

const NO_REPLY_EXPECTED: u8 = 0x1;
#[allow(dead_code)]
#[expect(dead_code)]
const NO_AUTO_START: u8 = 0x2;
#[allow(dead_code)]
#[expect(dead_code)]
const ALLOW_INTERACTIVE_AUTHORIZATION: u8 = 0x4;

#[allow(dead_code)]
#[expect(dead_code)]
pub const DBUS_NAME_FLAG_ALLOW_REPLACEMENT: u32 = 0x1;
#[allow(dead_code)]
#[expect(dead_code)]
pub const DBUS_NAME_FLAG_REPLACE_EXISTING: u32 = 0x2;
pub const DBUS_NAME_FLAG_DO_NOT_QUEUE: u32 = 0x4;

pub const DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER: u32 = 1;
#[allow(dead_code)]
#[expect(dead_code)]
pub const DBUS_REQUEST_NAME_REPLY_IN_QUEUE: u32 = 2;
#[allow(dead_code)]
#[expect(dead_code)]
pub const DBUS_REQUEST_NAME_REPLY_EXISTS: u32 = 3;
#[allow(dead_code)]
#[expect(dead_code)]
pub const DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER: u32 = 4;

pub const BUS_DEST: &str = "org.freedesktop.DBus";
Expand Down Expand Up @@ -698,7 +698,7 @@ pub struct PendingReply<T> {
}

impl<T> PendingReply<T> {
#[allow(dead_code)]
#[expect(dead_code)]
pub fn reply_expected(&self) -> bool {
self.reply_expected
}
Expand All @@ -720,7 +720,7 @@ where
}
}

#[allow(dead_code)]
#[expect(dead_code)]
pub fn complete<'a>(&self, res: Result<&T::Generic<'a>, &str>) {
match res {
Ok(m) => self.ok(m),
Expand Down
2 changes: 1 addition & 1 deletion src/dbus/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Incoming {
self.incoming
.fill_msg_buf(remaining as usize, msg_buf)
.await?;
#[allow(dropping_references)]
#[expect(dropping_references)]
drop(msg_buf);
let msg_buf = unsafe { msg_buf_data.get().deref().deref() };
let headers = &msg_buf[FIXED_HEADER_SIZE..FIXED_HEADER_SIZE + headers_len as usize];
Expand Down
2 changes: 1 addition & 1 deletion src/dbus/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl DbusSocket {
}
}

#[allow(dead_code)]
#[expect(dead_code)]
pub fn get<T, F>(&self, destination: &str, path: &str, f: F)
where
T: Property,
Expand Down
2 changes: 1 addition & 1 deletion src/dbus/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ unsafe impl<'a, K: DbusType<'a>, V: DbusType<'a>> DbusType<'a> for DictEntry<K,

macro_rules! tuple {
($($p:ident),*) => {
#[allow(non_snake_case)]
#[expect(non_snake_case)]
unsafe impl<'a, $($p: DbusType<'a>),*> DbusType<'a> for ($($p,)*) {
const ALIGNMENT: usize = 8;
const IS_POD: bool = false;
Expand Down
Loading

0 comments on commit e377470

Please sign in to comment.