Skip to content

Commit 35b8c5d

Browse files
committed
Fix clippy warnings
1 parent fcf5e87 commit 35b8c5d

File tree

14 files changed

+46
-37
lines changed

14 files changed

+46
-37
lines changed

src/bridge/api_info.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl From<&str> for ApiInfoParseError {
2626
}
2727
}
2828

29+
#[allow(unused)]
2930
#[derive(Debug)]
3031
pub struct ApiVersion {
3132
pub major: u64,
@@ -48,10 +49,11 @@ impl ApiVersion {
4849
|| (actual_major == major && actual_minor > minor)
4950
|| (actual_major == major && actual_minor == minor && actual_patch >= patch);
5051
log::trace!("has desired nvim version: {ret}");
51-
return ret;
52+
ret
5253
}
5354
}
5455

56+
#[allow(unused)]
5557
#[derive(Debug)]
5658
pub struct ApiFunction {
5759
pub name: String,
@@ -76,6 +78,7 @@ impl PartialEq for ApiFunction {
7678

7779
impl Eq for ApiFunction {}
7880

81+
#[allow(unused)]
7982
#[derive(Debug)]
8083
pub enum ApiParameterType {
8184
Nil,
@@ -133,12 +136,14 @@ impl ApiParameterType {
133136
}
134137
}
135138

139+
#[allow(unused)]
136140
#[derive(Debug)]
137141
pub struct ApiParameter {
138142
pub name: String,
139143
pub parameter_type: ApiParameterType,
140144
}
141145

146+
#[allow(unused)]
142147
#[derive(Debug)]
143148
pub struct ApiEvent {
144149
pub name: String,
@@ -160,6 +165,7 @@ impl PartialEq for ApiEvent {
160165

161166
impl Eq for ApiEvent {}
162167

168+
#[allow(unused)]
163169
#[derive(Debug)]
164170
pub struct ApiInformation {
165171
pub channel: u64,

src/bridge/events.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ impl MessageKind {
9999
}
100100
}
101101

102+
#[allow(unused)]
102103
#[derive(Clone, Debug)]
103104
pub enum GuiOption {
104105
ArabicShape(bool),
@@ -208,9 +209,11 @@ pub enum RedrawEvent {
208209
anchor_grid: u64,
209210
anchor_row: f64,
210211
anchor_column: f64,
212+
#[allow(unused)]
211213
focusable: bool,
212214
sort_order: Option<u64>,
213215
},
216+
#[allow(unused)]
214217
WindowExternalPosition {
215218
grid: u64,
216219
},
@@ -224,14 +227,20 @@ pub enum RedrawEvent {
224227
grid: u64,
225228
row: u64,
226229
scrolled: bool,
230+
#[allow(unused)]
227231
separator_character: String,
228232
},
229233
WindowViewport {
230234
grid: u64,
235+
#[allow(unused)]
231236
top_line: f64,
237+
#[allow(unused)]
232238
bottom_line: f64,
239+
#[allow(unused)]
233240
current_line: f64,
241+
#[allow(unused)]
234242
current_column: f64,
243+
#[allow(unused)]
235244
line_count: Option<f64>,
236245
scroll_delta: Option<f64>,
237246
},
@@ -242,6 +251,7 @@ pub enum RedrawEvent {
242251
left: u64,
243252
right: u64,
244253
},
254+
#[allow(unused)]
245255
CommandLineShow {
246256
content: StyledContent,
247257
position: u64,
@@ -250,38 +260,49 @@ pub enum RedrawEvent {
250260
indent: u64,
251261
level: u64,
252262
},
263+
#[allow(unused)]
253264
CommandLinePosition {
254265
position: u64,
255266
level: u64,
256267
},
268+
#[allow(unused)]
257269
CommandLineSpecialCharacter {
258270
character: String,
259271
shift: bool,
260272
level: u64,
261273
},
274+
#[allow(unused)]
262275
CommandLineHide,
276+
#[allow(unused)]
263277
CommandLineBlockShow {
264278
lines: Vec<StyledContent>,
265279
},
280+
#[allow(unused)]
266281
CommandLineBlockAppend {
267282
line: StyledContent,
268283
},
284+
#[allow(unused)]
269285
CommandLineBlockHide,
286+
#[allow(unused)]
270287
MessageShow {
271288
kind: MessageKind,
272289
content: StyledContent,
273290
replace_last: bool,
274291
},
275292
MessageClear,
293+
#[allow(unused)]
276294
MessageShowMode {
277295
content: StyledContent,
278296
},
297+
#[allow(unused)]
279298
MessageShowCommand {
280299
content: StyledContent,
281300
},
301+
#[allow(unused)]
282302
MessageRuler {
283303
content: StyledContent,
284304
},
305+
#[allow(unused)]
285306
MessageHistoryShow {
286307
entries: Vec<(MessageKind, StyledContent)>,
287308
},

src/cmd_line.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ fn get_styles() -> Styles {
2323
}
2424

2525
fn is_tty_str() -> &'static str {
26-
is_tty().then_some("1").unwrap_or("0")
26+
if is_tty() {
27+
"1"
28+
} else {
29+
"0"
30+
}
2731
}
2832

2933
#[derive(Clone, Debug, Parser)]

src/editor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl Editor {
426426
anchor_type: WindowAnchor::NorthWest,
427427
anchor_left: 0.0,
428428
anchor_top: grid_top as f64,
429-
sort_order: std::u64::MAX,
429+
sort_order: u64::MAX,
430430
};
431431

432432
if let Some(window) = self.windows.get_mut(&grid) {

src/error_handling.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,6 @@ impl<T, E: ToString> ResultPanicExplanation<T, E> for Result<T, E> {
5252
}
5353
}
5454

55-
pub trait OptionPanicExplanation<T> {
56-
fn unwrap_or_explained_panic(self, explanation: &str) -> T;
57-
}
58-
59-
impl<T> OptionPanicExplanation<T> for Option<T> {
60-
fn unwrap_or_explained_panic(self, explanation: &str) -> T {
61-
match self {
62-
None => {
63-
show_error(explanation);
64-
}
65-
Some(content) => content,
66-
}
67-
}
68-
}
69-
7055
fn format_and_log_error_message(err: Error) -> String {
7156
let msg = format!("\
7257
Neovide just crashed :(

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ fn setup(
194194
let window_size = determine_window_size(window_settings.as_ref());
195195
let grid_size = match window_size {
196196
WindowSize::Grid(grid_size) => Some(grid_size),
197+
// Clippy wrongly suggests to use unwrap or default here
198+
#[allow(clippy::manual_unwrap_or_default)]
197199
_ => match window_settings {
198200
Some(PersistentWindowSettings::Windowed { grid_size, .. }) => grid_size,
199201
_ => None,

src/renderer/animation_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub fn ease_in_expo(t: f32) -> f32 {
5858

5959
#[allow(dead_code)]
6060
pub fn ease_out_expo(t: f32) -> f32 {
61-
if (t - 1.0).abs() < std::f32::EPSILON {
61+
if (t - 1.0).abs() < f32::EPSILON {
6262
1.0
6363
} else {
6464
1.0 - 2.0f32.powf(-10.0 * t)
@@ -103,7 +103,7 @@ impl CriticallyDampedSpringAnimation {
103103
self.scroll_t = 0.0;
104104
}
105105

106-
if 1.0 - self.scroll_t < std::f32::EPSILON {
106+
if self.scroll_t > 1.0 - f32::EPSILON {
107107
// We are at destination, move t out of 0-1 range to stop the animation.
108108
self.scroll_t = 2.0;
109109
} else {

src/renderer/cursor_renderer/cursor_vfx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl CursorVfx for PointHighlight {
134134
grid_renderer: &mut GridRenderer,
135135
cursor: &Cursor,
136136
) {
137-
if (self.t - 1.0).abs() < std::f32::EPSILON {
137+
if (self.t - 1.0).abs() < f32::EPSILON {
138138
return;
139139
}
140140

src/renderer/cursor_renderer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl Corner {
111111
}
112112

113113
// Check first if animation's over
114-
if (self.t - 1.0).abs() < std::f32::EPSILON {
114+
if (self.t - 1.0).abs() < f32::EPSILON {
115115
return false;
116116
}
117117

@@ -147,14 +147,14 @@ impl Corner {
147147

148148
let direction_alignment = travel_direction.dot(corner_direction);
149149

150-
if (self.t - 1.0).abs() < std::f32::EPSILON {
150+
if (self.t - 1.0).abs() < f32::EPSILON {
151151
// We are at destination, move t out of 0-1 range to stop the animation
152152
self.t = 2.0;
153153
} else {
154154
let corner_dt = dt
155155
* lerp(
156156
1.0,
157-
(1.0 - settings.trail_size).max(0.0).min(1.0),
157+
(1.0 - settings.trail_size).clamp(0.0, 1.0),
158158
-direction_alignment,
159159
);
160160
self.t =

src/renderer/fonts/font_options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl FontOptions {
185185
Some(style.into_iter().unique().sorted().join(" "))
186186
};
187187
for font in font_options.normal.iter_mut() {
188-
font.style = style.clone();
188+
font.style.clone_from(&style);
189189
}
190190

191191
Ok(font_options)
@@ -255,7 +255,7 @@ impl PartialEq for FontOptions {
255255
&& self.bold_italic == other.bold_italic
256256
&& self.features == other.features
257257
&& self.edging == other.edging
258-
&& (self.size - other.size).abs() < std::f32::EPSILON
258+
&& (self.size - other.size).abs() < f32::EPSILON
259259
&& self.hinting == other.hinting
260260
}
261261
}

src/renderer/grid_renderer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub struct GridRenderer {
2121
pub default_style: Arc<Style>,
2222
pub em_size: f32,
2323
pub font_dimensions: Dimensions,
24-
pub scale_factor: f64,
2524
pub is_ready: bool,
2625
}
2726

@@ -47,7 +46,6 @@ impl GridRenderer {
4746
default_style,
4847
em_size,
4948
font_dimensions,
50-
scale_factor,
5149
is_ready: false,
5250
}
5351
}

src/renderer/profiler.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::renderer::animation_utils::lerp;
22
use crate::settings::SETTINGS;
33
use std::collections::VecDeque;
44
use std::sync::Arc;
5-
use std::time::Instant;
65

76
use crate::{
87
profiling::tracy_zone,
@@ -16,7 +15,6 @@ pub struct Profiler {
1615
pub font: Arc<FontPair>,
1716
pub position: Point,
1817
pub size: Size,
19-
pub last_draw: Instant,
2018
pub frametimes: VecDeque<f32>,
2119
}
2220

@@ -29,7 +27,6 @@ impl Profiler {
2927
font,
3028
position: Point::new(32.0, 32.0),
3129
size: Size::new(200.0, 120.0),
32-
last_draw: Instant::now(),
3330
frametimes: VecDeque::with_capacity(FRAMETIMES_COUNT),
3431
}
3532
}

src/renderer/rendered_window.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ struct Line {
8080
}
8181

8282
pub struct RenderedWindow {
83-
pub vertical_position: f32,
84-
8583
pub id: u64,
8684
pub hidden: bool,
8785
pub anchor_info: Option<AnchorInfo>,
@@ -108,7 +106,6 @@ pub struct RenderedWindow {
108106
pub struct WindowDrawDetails {
109107
pub id: u64,
110108
pub region: Rect,
111-
pub floating_order: Option<u64>,
112109
}
113110

114111
impl WindowDrawDetails {
@@ -124,7 +121,6 @@ impl WindowDrawDetails {
124121
impl RenderedWindow {
125122
pub fn new(id: u64, grid_position: Point, grid_size: Dimensions) -> RenderedWindow {
126123
RenderedWindow {
127-
vertical_position: 0.0,
128124
id,
129125
hidden: false,
130126
anchor_info: None,
@@ -214,7 +210,7 @@ impl RenderedWindow {
214210
) -> bool {
215211
let mut animating = false;
216212

217-
if 1.0 - self.position_t < std::f32::EPSILON {
213+
if self.position_t > 1.0 - f32::EPSILON {
218214
// We are at destination, move t out of 0-1 range to stop the animation.
219215
self.position_t = 2.0;
220216
} else {
@@ -477,7 +473,6 @@ impl RenderedWindow {
477473
WindowDrawDetails {
478474
id: self.id,
479475
region: pixel_region,
480-
floating_order: self.anchor_info.as_ref().map(|v| v.sort_order),
481476
}
482477
}
483478

src/window/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pub fn create_event_loop() -> EventLoop<UserEvent> {
123123
let event_loop = builder.build().expect("Failed to create winit event loop");
124124
#[cfg(target_os = "macos")]
125125
crate::window::macos::register_file_handler();
126+
#[allow(clippy::let_and_return)]
126127
event_loop
127128
}
128129

0 commit comments

Comments
 (0)