Skip to content

Commit 0020965

Browse files
committed
style: giant lint warning killing spree
Got annoying to search for the important error messages in a jungle of rustc and clippy warnings
1 parent 742a0cc commit 0020965

File tree

13 files changed

+57
-35
lines changed

13 files changed

+57
-35
lines changed

core/src/config/style.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl ContainerStyle {
138138
mod clap_parse {
139139
use iced::{Color, Padding};
140140

141-
use crate::config::style::{ColorDescriptor, StyleOverride};
141+
use crate::config::style::ColorDescriptor;
142142

143143
pub fn padding(value: &str) -> anyhow::Result<Padding> {
144144
let vec: Vec<f32> = value
@@ -160,7 +160,7 @@ mod clap_parse {
160160
pub fn color(value: &str) -> Result<ColorDescriptor, csscolorparser::ParseColorError> {
161161
Ok(match value.strip_prefix('$') {
162162
Some(name) => ColorDescriptor::ThemeColor(name.to_string()),
163-
None => ColorDescriptor::Color(Color::from(csscolorparser::parse(&value)?.to_array())),
163+
None => ColorDescriptor::Color(Color::from(csscolorparser::parse(value)?.to_array())),
164164
})
165165
}
166166
}

core/src/daemon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ async fn handle_client(mut stream: UnixStream, mut sender: Sender<Message>) -> a
9797
}
9898

9999
pub fn exit_cleanup(socket_path: &Path, pid_path: &Path) {
100-
if let Err(e) = fs::remove_file(&socket_path) {
100+
if let Err(e) = fs::remove_file(socket_path) {
101101
error!("Could not remove socket file at {socket_path:?}: {e}");
102102
}
103-
if let Err(e) = fs::remove_file(&pid_path) {
103+
if let Err(e) = fs::remove_file(pid_path) {
104104
error!("Could not remove PID file at {pid_path:?}: {e}");
105105
}
106106
}

core/src/helpers/merge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ where
1919
let opt_right = right.into_opt();
2020
if let Some(right) = opt_right {
2121
match opt_left {
22-
Some(left) => left.extend(right.into_iter()),
22+
Some(left) => left.extend(right),
2323
None => *left = AcceptOption::from_opt(Some(right)),
2424
}
2525
}

core/src/helpers/task_constructor.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ use iced::Task;
44

55
use crate::message::Message;
66

7+
#[allow(clippy::type_complexity)]
78
/// Used to create a [Task] using a type [T] that is not in the scope. When the type [T] comes into
89
/// scope, the [TaskConstructor] can be build into a [Task].
910
pub struct TaskConstructor<T, M = Message> {
1011
constructors: Vec<Box<dyn FnOnce(&mut T) -> Task<M>>>,
1112
_phantom: PhantomData<(T, M)>,
1213
}
1314

15+
impl<T> Default for TaskConstructor<T> {
16+
fn default() -> Self {
17+
Self::new()
18+
}
19+
}
20+
1421
impl<T, M> TaskConstructor<T, M>
1522
where
1623
M: 'static,

core/src/ipc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub enum IpcRequest {
4040
#[derive(Subcommand, Debug, Deserialize, Serialize)]
4141
pub enum WindowRequest {
4242
/// Open a new window
43-
Open(WindowRuntimeOptions),
43+
Open(Box<WindowRuntimeOptions>),
4444
/// Close a window
4545
Close {
4646
#[arg(short = 'A', long)]

core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod message;
1111
pub mod module;
1212
pub mod registry;
1313
mod state;
14-
mod subscription;
14+
pub mod subscription;
1515
pub mod template_engine;
1616
pub mod window;
1717

core/src/message.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ impl Debug for UpdateFn {
2121
}
2222
}
2323

24+
#[allow(clippy::type_complexity)]
2425
/// Capturing closure that is executed with read access to [T]
2526
pub struct ReadFn<T>(Arc<Box<dyn FnOnce(&T) + Send + Sync>>);
2627
impl<T> Debug for ReadFn<T> {

core/src/module.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub trait Module: Downcast + Debug + Send + Sync {
1818
true
1919
}
2020

21-
fn view(&self, variant: &str, anchor: &Anchor, context: &Context) -> Element;
21+
fn view(&self, variant: &str, anchor: &Anchor, context: &Context) -> Element<'_>;
2222

2323
#[allow(unused_variables)]
2424
fn sources(&self, variant: &str) -> Vec<&String> {
@@ -57,10 +57,10 @@ mod dummy {
5757
}
5858
fn view(
5959
&self,
60-
variant: &str,
61-
anchor: &smithay_client_toolkit::shell::wlr_layer::Anchor,
62-
context: &super::Context,
63-
) -> Element {
60+
_variant: &str,
61+
_anchor: &smithay_client_toolkit::shell::wlr_layer::Anchor,
62+
_context: &super::Context,
63+
) -> Element<'_> {
6464
text!("This is a dummy module!").into()
6565
}
6666
}
@@ -82,9 +82,9 @@ mod custom {
8282
}
8383

8484
struct CustomModule {
85-
sources: Vec<String>,
85+
_sources: Vec<String>,
8686
style: ContainerStyle,
87-
config: Table,
87+
_config: Table,
8888
token: Box<dyn Token<Message> + Send + Sync>,
8989
}
9090

@@ -103,7 +103,7 @@ mod custom {
103103
variant: &str,
104104
anchor: &smithay_client_toolkit::shell::wlr_layer::Anchor,
105105
context: &super::Context,
106-
) -> Element {
106+
) -> Element<'_> {
107107
let Some(custom) = self.modules.get(variant) else {
108108
log::error!("Invalid variant name of custom module: {variant}");
109109
return "Invalid variant name".into();
@@ -127,10 +127,10 @@ mod custom {
127127
self.modules.insert(
128128
String::from(variant),
129129
CustomModule {
130-
sources: vec![],
130+
_sources: vec![],
131131
style,
132132
token: engine.render_token(format),
133-
config,
133+
_config: config,
134134
},
135135
);
136136
}

core/src/registry.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ impl Registry {
5252
self.try_get_module_mut().unwrap()
5353
}
5454

55-
pub fn get_modules<'a, I>(
55+
pub fn get_modules<'a, 'b, I>(
5656
&'a self,
5757
enabled: I,
58-
) -> impl Iterator<Item = (&'a String, &Box<dyn Module>)>
58+
) -> impl Iterator<Item = (&'b String, &'a Box<dyn Module>)>
5959
where
60-
I: Iterator<Item = &'a String>,
60+
I: Iterator<Item = &'b String>,
6161
{
6262
enabled.filter_map(|id| {
6363
self.module_names
@@ -103,6 +103,6 @@ impl Registry {
103103
}
104104

105105
pub fn module_names(&self) -> impl Iterator<Item = &String> {
106-
self.module_names.iter().map(|(name, _)| name)
106+
self.module_names.keys()
107107
}
108108
}

core/src/state.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ use smithay_client_toolkit::{
2626
};
2727
use tokio::time::sleep;
2828

29+
pub type Outputs = Vec<(WlOutput, Option<OutputInfo>)>;
30+
2931
#[derive(Debug, Default)]
3032
pub struct State {
3133
pub socket_path: PathBuf,
3234
pid_path: PathBuf,
33-
outputs: HashMap<WlOutput, Option<OutputInfo>>,
35+
outputs: Outputs,
3436
/// If false, we have to wait for new Outputs before opening a window
3537
outputs_ready: bool,
3638
pub windows: HashMap<Id, Window>,
@@ -115,7 +117,7 @@ impl State {
115117
wayland::OutputEvent::Created(info_maybe) => {
116118
let first_output = self.outputs.is_empty();
117119
log::debug!("got new output: {info_maybe:#?}");
118-
self.outputs.insert(wl_output, info_maybe);
120+
self.outputs.push((wl_output, info_maybe));
119121
if !self.outputs_ready && first_output {
120122
return Task::future(async {
121123
sleep(Duration::from_millis(500)).await;
@@ -124,10 +126,17 @@ impl State {
124126
}
125127
}
126128
wayland::OutputEvent::InfoUpdate(info) => {
127-
self.outputs.insert(wl_output, Some(info));
129+
if let Some((_, info_maybe)) =
130+
self.outputs.iter_mut().find(|(wlo, _)| wlo == &wl_output)
131+
{
132+
*info_maybe = Some(info);
133+
}
128134
}
129135
wayland::OutputEvent::Removed => {
130-
self.outputs.remove(&wl_output);
136+
let pos = self.outputs.iter().position(|(wlo, _)| wlo == &wl_output);
137+
if let Some(pos) = pos {
138+
self.outputs.remove(pos);
139+
}
131140
}
132141
},
133142
OutputsReady => {
@@ -163,7 +172,7 @@ impl State {
163172
WindowRequest::Open(opts) => {
164173
info!("Opening new window");
165174
let naive_id;
166-
(task, naive_id) = self.open_window(opts);
175+
(task, naive_id) = self.open_window(*opts);
167176
IpcResponse::Window {
168177
id: vec![naive_id],
169178
event: WindowResponse::Opened,
@@ -281,7 +290,7 @@ impl State {
281290
)
282291
}
283292

284-
pub fn view(&self, id: Id) -> Element {
293+
pub fn view(&self, id: Id) -> Element<'_> {
285294
match self.windows.get(&id) {
286295
Some(window) => window.view(&self.registry),
287296
None => "Invalid window ID".into(),

0 commit comments

Comments
 (0)