Skip to content

Commit bc295af

Browse files
committed
lint: fix clippy::used_underscore_binding
1 parent bbf486f commit bc295af

File tree

8 files changed

+86
-87
lines changed

8 files changed

+86
-87
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ print_stderr = "allow"
1818
dbg_macro = "warn"
1919
pedantic = {level = "warn", priority = -1}
2020
inline_always = "allow" # TODO: benchmark inlines
21-
missing_panics_doc = "allow" # 37
22-
used_underscore_binding = "allow" # 39
21+
missing_panics_doc = "allow" # TODO
2322
float_cmp = "allow" # 40
2423
map_unwrap_or = "allow" # 59
2524
return_self_not_must_use = "allow" # 61

src/algorithm/encode.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Value {
7171
let json_value: serde_json::Value = json5::from_str(json).map_err(|e| env.error(e))?;
7272
Self::from_json_value(json_value, env)
7373
}
74-
pub(crate) fn from_json_value(json_value: serde_json::Value, _env: &Uiua) -> UiuaResult<Self> {
74+
pub(crate) fn from_json_value(json_value: serde_json::Value, env: &Uiua) -> UiuaResult<Self> {
7575
Ok(match json_value {
7676
serde_json::Value::Null => f64::NAN.into(),
7777
serde_json::Value::Bool(b) => b.into(),
@@ -90,7 +90,7 @@ impl Value {
9090
serde_json::Value::Array(arr) => {
9191
let mut rows = Vec::with_capacity(arr.len());
9292
for value in arr {
93-
let mut value = Value::from_json_value(value, _env)?;
93+
let mut value = Value::from_json_value(value, env)?;
9494
if value.meta.map_keys.is_some() {
9595
value = Boxed(value).into();
9696
}
@@ -112,7 +112,7 @@ impl Value {
112112
let mut values = Vec::with_capacity(map.len());
113113
for (k, v) in map {
114114
keys.push(Boxed(k.into()));
115-
let mut value = Value::from_json_value(v, _env)?;
115+
let mut value = Value::from_json_value(v, env)?;
116116
if value.meta.map_keys.is_some() {
117117
value = Boxed(value).into();
118118
}
@@ -125,7 +125,7 @@ impl Value {
125125
} else {
126126
Array::from(values.into_iter().map(Boxed).collect::<EcoVec<_>>()).into()
127127
};
128-
values.map(keys.into(), _env)?;
128+
values.map(keys.into(), env)?;
129129
values
130130
}
131131
})
@@ -275,15 +275,15 @@ impl Value {
275275
})
276276
}
277277
}
278-
pub(crate) fn from_xlsx(_xlsx: &[u8], env: &mut Uiua) -> UiuaResult<Self> {
278+
pub(crate) fn from_xlsx(xlsx: &[u8], env: &mut Uiua) -> UiuaResult<Self> {
279279
#[cfg(not(feature = "calamine"))]
280280
return Err(env.error("XLSX decoding is not enabled in this environment"));
281281
#[cfg(feature = "calamine")]
282282
{
283283
use calamine::*;
284284

285285
let mut workbook: Xlsx<_> =
286-
open_workbook_from_rs(std::io::Cursor::new(_xlsx)).map_err(|e| env.error(e))?;
286+
open_workbook_from_rs(std::io::Cursor::new(xlsx)).map_err(|e| env.error(e))?;
287287
let sheet_names = workbook.sheet_names();
288288
let fill = env
289289
.value_fill()

src/algorithm/reduce.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(crate) fn reduce_impl(f: SigNode, depth: usize, env: &mut Uiua) -> UiuaResul
6060
return generic_reduce(f, Value::Complex(nums), depth, env);
6161
}
6262
}
63-
(Some((prim, _flipped)), Value::Byte(bytes)) => {
63+
(Some((prim, flipped)), Value::Byte(bytes)) => {
6464
let fill = env.scalar_fill::<f64>().ok().map(|fv| fv.value);
6565
if fill.is_none() && env.value_fill().is_some() {
6666
return generic_reduce(f, Value::Byte(bytes), depth, env);
@@ -71,7 +71,7 @@ pub(crate) fn reduce_impl(f: SigNode, depth: usize, env: &mut Uiua) -> UiuaResul
7171
.into()
7272
}
7373
#[cfg(feature = "opt")]
74-
Primitive::Sub if _flipped => fast_reduce_different(
74+
Primitive::Sub if flipped => fast_reduce_different(
7575
bytes,
7676
0.0,
7777
fill,

src/array.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,17 @@ where
401401

402402
#[track_caller]
403403
#[inline(always)]
404-
pub(crate) fn validate_shape(_shape: &[usize], _len: usize) {
404+
pub(crate) fn validate_shape(shape: &[usize], len: usize) {
405405
#[cfg(debug_assertions)]
406406
{
407-
let elems = if _shape.contains(&0) {
407+
let elems = if shape.contains(&0) {
408408
0
409409
} else {
410-
_shape.iter().product()
410+
shape.iter().product()
411411
};
412412
assert_eq!(
413-
elems, _len,
414-
"shape {_shape:?} does not match data length {_len}"
413+
elems, len,
414+
"shape {shape:?} does not match data length {len}"
415415
)
416416
}
417417
}

src/run.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ impl Uiua {
15001500
}
15011501
}
15021502
/// Spawn a thread
1503-
pub(crate) fn spawn(&mut self, _pool: bool, f: SigNode) -> UiuaResult {
1503+
pub(crate) fn spawn(&mut self, pool: bool, f: SigNode) -> UiuaResult {
15041504
if !self.rt.backend.allow_thread_spawning() {
15051505
return Err(self.error("Thread spawning is not allowed in this environment"));
15061506
}
@@ -1555,7 +1555,7 @@ impl Uiua {
15551555
#[cfg(not(target_arch = "wasm32"))]
15561556
let recv = {
15571557
let (send, recv) = crossbeam_channel::unbounded();
1558-
if _pool {
1558+
if pool {
15591559
let max_threads = std::thread::available_parallelism()
15601560
.map(|p| p.get())
15611561
.unwrap_or(1);

src/sys/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,11 +1181,11 @@ pub(crate) fn run_sys_op(op: SysOp, env: &mut Uiua) -> UiuaResult {
11811181
#[cfg_attr(not(feature = "image"), expect(clippy::let_unit_value))]
11821182
SysOp::WebcamCapture => {
11831183
let index = env.pop(1)?.as_nat(env, "Webcam index must be an integer")?;
1184-
let _image = (env.rt.backend)
1184+
let image = (env.rt.backend)
11851185
.webcam_capture(index)
11861186
.map_err(|e| env.error(e))?;
11871187
#[cfg(feature = "image")]
1188-
env.push(crate::media::rgb_image_to_array(_image));
1188+
env.push(crate::media::rgb_image_to_array(image));
11891189
#[cfg(not(feature = "image"))]
11901190
return Err(env.error("Webcam capture is not supported in this environment"));
11911191
}

src/sys/native.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ enum TslConnection {
152152
}
153153

154154
impl Read for &TlsSocket {
155-
fn read(&mut self, _buf: &mut [u8]) -> std::io::Result<usize> {
155+
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
156156
#[cfg(feature = "tls")]
157157
{
158158
match &mut *self.conn.lock() {
159159
TslConnection::Client(conn) => {
160-
rustls::Stream::new(conn, &mut &self.stream).read(_buf)
160+
rustls::Stream::new(conn, &mut &self.stream).read(buf)
161161
}
162162
TslConnection::Server(conn) => {
163-
rustls::Stream::new(conn, &mut &self.stream).read(_buf)
163+
rustls::Stream::new(conn, &mut &self.stream).read(buf)
164164
}
165165
}
166166
}
@@ -170,15 +170,15 @@ impl Read for &TlsSocket {
170170
}
171171

172172
impl Write for &TlsSocket {
173-
fn write(&mut self, _buf: &[u8]) -> std::io::Result<usize> {
173+
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
174174
#[cfg(feature = "tls")]
175175
{
176176
match &mut *self.conn.lock() {
177177
TslConnection::Client(conn) => {
178-
rustls::Stream::new(conn, &mut &self.stream).write(_buf)
178+
rustls::Stream::new(conn, &mut &self.stream).write(buf)
179179
}
180180
TslConnection::Server(conn) => {
181-
rustls::Stream::new(conn, &mut &self.stream).write(_buf)
181+
rustls::Stream::new(conn, &mut &self.stream).write(buf)
182182
}
183183
}
184184
}
@@ -643,8 +643,8 @@ impl SysBackend for NativeSys {
643643
}
644644
#[allow(clippy::print_stdout)]
645645
#[cfg(all(feature = "terminal_image", feature = "image"))]
646-
fn show_image(&self, image: image::DynamicImage, _label: Option<&str>) -> Result<(), String> {
647-
let (_width, _height) = if let Some((w, h)) = terminal_size() {
646+
fn show_image(&self, image: image::DynamicImage, label: Option<&str>) -> Result<(), String> {
647+
let (width, height) = if let Some((w, h)) = terminal_size() {
648648
let (tw, th) = (w as u32, h.saturating_sub(1) as u32);
649649
let (iw, ih) = (image.width(), (image.height() / 2).max(1));
650650
let scaled_to_height = (iw * th / ih.max(1), th);
@@ -681,15 +681,15 @@ impl SysBackend for NativeSys {
681681
return crate::window::Request::Show(crate::media::SmartOutput::Png(
682682
crate::media::image_to_bytes(&image, image::ImageFormat::Png)
683683
.map_err(|e| e.to_string())?,
684-
_label.map(Into::into),
684+
label.map(Into::into),
685685
))
686686
.send();
687687
}
688688
viuer::print(
689689
&image,
690690
&viuer::Config {
691-
width: _width,
692-
height: _height,
691+
width,
692+
height,
693693
absolute_offset: false,
694694
transparent: true,
695695
..Default::default()
@@ -700,12 +700,12 @@ impl SysBackend for NativeSys {
700700
}
701701
}
702702
#[cfg(all(feature = "gif", feature = "invoke"))]
703-
fn show_gif(&self, gif_bytes: Vec<u8>, _label: Option<&str>) -> Result<(), String> {
703+
fn show_gif(&self, gif_bytes: Vec<u8>, label: Option<&str>) -> Result<(), String> {
704704
#[cfg(feature = "window")]
705705
if crate::window::use_window() {
706706
return crate::window::Request::Show(crate::media::SmartOutput::Gif(
707707
gif_bytes,
708-
_label.map(Into::into),
708+
label.map(Into::into),
709709
))
710710
.send();
711711
}
@@ -754,13 +754,13 @@ impl SysBackend for NativeSys {
754754
.map_err(|e| e.to_string())
755755
}
756756
#[cfg(feature = "audio")]
757-
fn play_audio(&self, wav_bytes: Vec<u8>, _label: Option<&str>) -> Result<(), String> {
757+
fn play_audio(&self, wav_bytes: Vec<u8>, label: Option<&str>) -> Result<(), String> {
758758
use hodaun::*;
759759
#[cfg(feature = "window")]
760760
if crate::window::use_window() {
761761
return crate::window::Request::Show(crate::media::SmartOutput::Wav(
762762
wav_bytes,
763-
_label.map(Into::into),
763+
label.map(Into::into),
764764
))
765765
.send();
766766
}

src/value.rs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -473,99 +473,99 @@ impl Value {
473473
pub(crate) fn generic_bin_into<T, E>(
474474
self,
475475
other: Self,
476-
n: impl FnOnce(Array<f64>, Array<f64>) -> Result<T, E>,
477-
_b: impl FnOnce(Array<u8>, Array<u8>) -> Result<T, E>,
478-
_co: impl FnOnce(Array<Complex>, Array<Complex>) -> Result<T, E>,
479-
ch: impl FnOnce(Array<char>, Array<char>) -> Result<T, E>,
480-
f: impl FnOnce(Array<Boxed>, Array<Boxed>) -> Result<T, E>,
476+
num: impl FnOnce(Array<f64>, Array<f64>) -> Result<T, E>,
477+
byte: impl FnOnce(Array<u8>, Array<u8>) -> Result<T, E>,
478+
comp: impl FnOnce(Array<Complex>, Array<Complex>) -> Result<T, E>,
479+
char: impl FnOnce(Array<char>, Array<char>) -> Result<T, E>,
480+
bx: impl FnOnce(Array<Boxed>, Array<Boxed>) -> Result<T, E>,
481481
err: impl FnOnce(Self, Self) -> E,
482482
) -> Result<T, E> {
483483
match (self, other) {
484-
(Self::Num(a), Self::Num(b)) => n(a, b),
485-
(Self::Byte(a), Self::Byte(b)) => _b(a, b),
486-
(Self::Byte(a), Self::Num(b)) => n(a.convert(), b),
487-
(Self::Num(a), Self::Byte(b)) => n(a, b.convert()),
488-
(Self::Complex(a), Self::Complex(b)) => _co(a, b),
489-
(Self::Complex(a), Self::Num(b)) => _co(a, b.convert()),
490-
(Self::Num(a), Self::Complex(b)) => _co(a.convert(), b),
491-
(Self::Complex(a), Self::Byte(b)) => _co(a, b.convert()),
492-
(Self::Byte(a), Self::Complex(b)) => _co(a.convert(), b),
493-
(Self::Char(a), Self::Char(b)) => ch(a, b),
494-
(Self::Box(a), Self::Box(b)) => f(a, b),
495-
(Self::Box(a), b) => f(a, b.coerce_to_boxes()),
496-
(a, Self::Box(b)) => f(a.coerce_to_boxes(), b),
484+
(Self::Num(a), Self::Num(b)) => num(a, b),
485+
(Self::Byte(a), Self::Byte(b)) => byte(a, b),
486+
(Self::Byte(a), Self::Num(b)) => num(a.convert(), b),
487+
(Self::Num(a), Self::Byte(b)) => num(a, b.convert()),
488+
(Self::Complex(a), Self::Complex(b)) => comp(a, b),
489+
(Self::Complex(a), Self::Num(b)) => comp(a, b.convert()),
490+
(Self::Num(a), Self::Complex(b)) => comp(a.convert(), b),
491+
(Self::Complex(a), Self::Byte(b)) => comp(a, b.convert()),
492+
(Self::Byte(a), Self::Complex(b)) => comp(a.convert(), b),
493+
(Self::Char(a), Self::Char(b)) => char(a, b),
494+
(Self::Box(a), Self::Box(b)) => bx(a, b),
495+
(Self::Box(a), b) => bx(a, b.coerce_to_boxes()),
496+
(a, Self::Box(b)) => bx(a.coerce_to_boxes(), b),
497497
(a, b) => Err(err(a, b)),
498498
}
499499
}
500500
#[allow(clippy::too_many_arguments)]
501501
pub(crate) fn generic_bin_ref<T, E>(
502502
&self,
503503
other: &Self,
504-
n: impl FnOnce(&Array<f64>, &Array<f64>) -> Result<T, E>,
505-
_b: impl FnOnce(&Array<u8>, &Array<u8>) -> Result<T, E>,
506-
_co: impl FnOnce(&Array<Complex>, &Array<Complex>) -> Result<T, E>,
507-
ch: impl FnOnce(&Array<char>, &Array<char>) -> Result<T, E>,
508-
f: impl FnOnce(&Array<Boxed>, &Array<Boxed>) -> Result<T, E>,
504+
num: impl FnOnce(&Array<f64>, &Array<f64>) -> Result<T, E>,
505+
byte: impl FnOnce(&Array<u8>, &Array<u8>) -> Result<T, E>,
506+
comp: impl FnOnce(&Array<Complex>, &Array<Complex>) -> Result<T, E>,
507+
char: impl FnOnce(&Array<char>, &Array<char>) -> Result<T, E>,
508+
bx: impl FnOnce(&Array<Boxed>, &Array<Boxed>) -> Result<T, E>,
509509
err: impl FnOnce(&Self, &Self) -> E,
510510
) -> Result<T, E> {
511511
match (self, other) {
512-
(Self::Num(a), Self::Num(b)) => n(a, b),
513-
(Self::Byte(a), Self::Byte(b)) => _b(a, b),
514-
(Self::Byte(a), Self::Num(b)) => n(&a.convert_ref(), b),
515-
(Self::Num(a), Self::Byte(b)) => n(a, &b.convert_ref()),
516-
(Self::Complex(a), Self::Complex(b)) => _co(a, b),
517-
(Self::Complex(a), Self::Num(b)) => _co(a, &b.convert_ref()),
518-
(Self::Num(a), Self::Complex(b)) => _co(&a.convert_ref(), b),
519-
(Self::Complex(a), Self::Byte(b)) => _co(a, &b.convert_ref()),
520-
(Self::Byte(a), Self::Complex(b)) => _co(&a.convert_ref(), b),
521-
(Self::Char(a), Self::Char(b)) => ch(a, b),
522-
(Self::Box(a), Self::Box(b)) => f(a, b),
523-
(Self::Box(a), b) => f(a, &b.coerce_as_boxes()),
524-
(a, Self::Box(b)) => f(&a.coerce_as_boxes(), b),
512+
(Self::Num(a), Self::Num(b)) => num(a, b),
513+
(Self::Byte(a), Self::Byte(b)) => byte(a, b),
514+
(Self::Byte(a), Self::Num(b)) => num(&a.convert_ref(), b),
515+
(Self::Num(a), Self::Byte(b)) => num(a, &b.convert_ref()),
516+
(Self::Complex(a), Self::Complex(b)) => comp(a, b),
517+
(Self::Complex(a), Self::Num(b)) => comp(a, &b.convert_ref()),
518+
(Self::Num(a), Self::Complex(b)) => comp(&a.convert_ref(), b),
519+
(Self::Complex(a), Self::Byte(b)) => comp(a, &b.convert_ref()),
520+
(Self::Byte(a), Self::Complex(b)) => comp(&a.convert_ref(), b),
521+
(Self::Char(a), Self::Char(b)) => char(a, b),
522+
(Self::Box(a), Self::Box(b)) => bx(a, b),
523+
(Self::Box(a), b) => bx(a, &b.coerce_as_boxes()),
524+
(a, Self::Box(b)) => bx(&a.coerce_as_boxes(), b),
525525
(a, b) => Err(err(a, b)),
526526
}
527527
}
528528
#[allow(clippy::too_many_arguments)]
529529
pub(crate) fn generic_bin_mut<T, E>(
530530
&mut self,
531531
other: Self,
532-
n: impl FnOnce(&mut Array<f64>, Array<f64>) -> Result<T, E>,
533-
_b: impl FnOnce(&mut Array<u8>, Array<u8>) -> Result<T, E>,
534-
_co: impl FnOnce(&mut Array<Complex>, Array<Complex>) -> Result<T, E>,
535-
ch: impl FnOnce(&mut Array<char>, Array<char>) -> Result<T, E>,
536-
f: impl FnOnce(&mut Array<Boxed>, Array<Boxed>) -> Result<T, E>,
532+
num: impl FnOnce(&mut Array<f64>, Array<f64>) -> Result<T, E>,
533+
byte: impl FnOnce(&mut Array<u8>, Array<u8>) -> Result<T, E>,
534+
comp: impl FnOnce(&mut Array<Complex>, Array<Complex>) -> Result<T, E>,
535+
char: impl FnOnce(&mut Array<char>, Array<char>) -> Result<T, E>,
536+
bx: impl FnOnce(&mut Array<Boxed>, Array<Boxed>) -> Result<T, E>,
537537
err: impl FnOnce(&Self, &Self) -> E,
538538
) -> Result<T, E> {
539539
match (&mut *self, other) {
540-
(Self::Num(a), Self::Num(b)) => n(a, b),
541-
(Self::Byte(a), Self::Byte(b)) => _b(a, b),
540+
(Self::Num(a), Self::Num(b)) => num(a, b),
541+
(Self::Byte(a), Self::Byte(b)) => byte(a, b),
542542
(Self::Byte(a), Self::Num(b)) => {
543543
let mut a_num = a.convert_ref();
544-
let res = n(&mut a_num, b);
544+
let res = num(&mut a_num, b);
545545
*self = a_num.into();
546546
res
547547
}
548-
(Self::Num(a), Self::Byte(b)) => n(a, b.convert_ref()),
549-
(Self::Complex(a), Self::Complex(b)) => _co(a, b),
550-
(Self::Complex(a), Self::Num(b)) => _co(a, b.convert_ref()),
548+
(Self::Num(a), Self::Byte(b)) => num(a, b.convert_ref()),
549+
(Self::Complex(a), Self::Complex(b)) => comp(a, b),
550+
(Self::Complex(a), Self::Num(b)) => comp(a, b.convert_ref()),
551551
(Self::Num(a), Self::Complex(b)) => {
552552
let mut a_comp = a.convert_ref();
553-
let res = _co(&mut a_comp, b);
553+
let res = comp(&mut a_comp, b);
554554
*self = a_comp.into();
555555
res
556556
}
557-
(Self::Complex(a), Self::Byte(b)) => _co(a, b.convert_ref()),
557+
(Self::Complex(a), Self::Byte(b)) => comp(a, b.convert_ref()),
558558
(Self::Byte(a), Self::Complex(b)) => {
559559
let mut a_comp = a.convert_ref();
560-
let res = _co(&mut a_comp, b);
560+
let res = comp(&mut a_comp, b);
561561
*self = a_comp.into();
562562
res
563563
}
564-
(Self::Char(a), Self::Char(b)) => ch(a, b),
565-
(Self::Box(a), b) => f(a, b.coerce_to_boxes()),
564+
(Self::Char(a), Self::Char(b)) => char(a, b),
565+
(Self::Box(a), b) => bx(a, b.coerce_to_boxes()),
566566
(a, Self::Box(b)) => {
567567
let mut a_box = take(a).coerce_to_boxes();
568-
let res = f(&mut a_box, b);
568+
let res = bx(&mut a_box, b);
569569
*self = a_box.into();
570570
res
571571
}

0 commit comments

Comments
 (0)