Skip to content

Commit c62d3c6

Browse files
committed
lint: fix clippy::used_underscore_binding
1 parent ccf0ae4 commit c62d3c6

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_stdout = "warn"
1818
non_std_lazy_statics = "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
@@ -1233,11 +1233,11 @@ pub(crate) fn run_sys_op(op: SysOp, env: &mut Uiua) -> UiuaResult {
12331233
}
12341234
SysOp::WebcamCapture => {
12351235
let index = env.pop(1)?.as_nat(env, "Webcam index must be an integer")?;
1236-
let _image = (env.rt.backend)
1236+
let image = (env.rt.backend)
12371237
.webcam_capture(index)
12381238
.map_err(|e| env.error(e))?;
12391239
#[cfg(feature = "image")]
1240-
env.push(crate::media::rgb_image_to_array(_image));
1240+
env.push(crate::media::rgb_image_to_array(image));
12411241
#[cfg(not(feature = "image"))]
12421242
return Err(env.error("Webcam capture is not supported in this environment"));
12431243
}

src/sys/native.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ enum TslConnection {
158158
}
159159

160160
impl Read for &TlsSocket {
161-
fn read(&mut self, _buf: &mut [u8]) -> std::io::Result<usize> {
161+
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
162162
#[cfg(feature = "tls")]
163163
{
164164
match &mut *self.conn.lock() {
165165
TslConnection::Client(conn) => {
166-
rustls::Stream::new(conn, &mut &self.stream).read(_buf)
166+
rustls::Stream::new(conn, &mut &self.stream).read(buf)
167167
}
168168
TslConnection::Server(conn) => {
169-
rustls::Stream::new(conn, &mut &self.stream).read(_buf)
169+
rustls::Stream::new(conn, &mut &self.stream).read(buf)
170170
}
171171
}
172172
}
@@ -176,15 +176,15 @@ impl Read for &TlsSocket {
176176
}
177177

178178
impl Write for &TlsSocket {
179-
fn write(&mut self, _buf: &[u8]) -> std::io::Result<usize> {
179+
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
180180
#[cfg(feature = "tls")]
181181
{
182182
match &mut *self.conn.lock() {
183183
TslConnection::Client(conn) => {
184-
rustls::Stream::new(conn, &mut &self.stream).write(_buf)
184+
rustls::Stream::new(conn, &mut &self.stream).write(buf)
185185
}
186186
TslConnection::Server(conn) => {
187-
rustls::Stream::new(conn, &mut &self.stream).write(_buf)
187+
rustls::Stream::new(conn, &mut &self.stream).write(buf)
188188
}
189189
}
190190
}
@@ -663,8 +663,8 @@ impl SysBackend for NativeSys {
663663
}
664664
#[allow(clippy::print_stdout)]
665665
#[cfg(all(feature = "terminal_image", feature = "image"))]
666-
fn show_image(&self, image: image::DynamicImage, _label: Option<&str>) -> Result<(), String> {
667-
let (_width, _height) = if let Some((w, h)) = terminal_size() {
666+
fn show_image(&self, image: image::DynamicImage, label: Option<&str>) -> Result<(), String> {
667+
let (width, height) = if let Some((w, h)) = terminal_size() {
668668
let (tw, th) = (w as u32, h.saturating_sub(1) as u32);
669669
let (iw, ih) = (image.width(), (image.height() / 2).max(1));
670670
let scaled_to_height = (iw * th / ih.max(1), th);
@@ -701,15 +701,15 @@ impl SysBackend for NativeSys {
701701
return crate::window::Request::Show(crate::media::SmartOutput::Png(
702702
crate::media::image_to_bytes(&image, image::ImageFormat::Png)
703703
.map_err(|e| e.to_string())?,
704-
_label.map(Into::into),
704+
label.map(Into::into),
705705
))
706706
.send();
707707
}
708708
viuer::print(
709709
&image,
710710
&viuer::Config {
711-
width: _width,
712-
height: _height,
711+
width,
712+
height,
713713
absolute_offset: false,
714714
transparent: true,
715715
..Default::default()
@@ -720,12 +720,12 @@ impl SysBackend for NativeSys {
720720
}
721721
}
722722
#[cfg(all(feature = "gif", feature = "invoke"))]
723-
fn show_gif(&self, gif_bytes: Vec<u8>, _label: Option<&str>) -> Result<(), String> {
723+
fn show_gif(&self, gif_bytes: Vec<u8>, label: Option<&str>) -> Result<(), String> {
724724
#[cfg(feature = "window")]
725725
if crate::window::use_window() {
726726
return crate::window::Request::Show(crate::media::SmartOutput::Gif(
727727
gif_bytes,
728-
_label.map(Into::into),
728+
label.map(Into::into),
729729
))
730730
.send();
731731
}
@@ -774,13 +774,13 @@ impl SysBackend for NativeSys {
774774
.map_err(|e| e.to_string())
775775
}
776776
#[cfg(feature = "audio")]
777-
fn play_audio(&self, wav_bytes: Vec<u8>, _label: Option<&str>) -> Result<(), String> {
777+
fn play_audio(&self, wav_bytes: Vec<u8>, label: Option<&str>) -> Result<(), String> {
778778
use hodaun::*;
779779
#[cfg(feature = "window")]
780780
if crate::window::use_window() {
781781
return crate::window::Request::Show(crate::media::SmartOutput::Wav(
782782
wav_bytes,
783-
_label.map(Into::into),
783+
label.map(Into::into),
784784
))
785785
.send();
786786
}

src/value.rs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -451,99 +451,99 @@ impl Value {
451451
pub(crate) fn generic_bin_into<T, E>(
452452
self,
453453
other: Self,
454-
n: impl FnOnce(Array<f64>, Array<f64>) -> Result<T, E>,
455-
_b: impl FnOnce(Array<u8>, Array<u8>) -> Result<T, E>,
456-
_co: impl FnOnce(Array<Complex>, Array<Complex>) -> Result<T, E>,
457-
ch: impl FnOnce(Array<char>, Array<char>) -> Result<T, E>,
458-
f: impl FnOnce(Array<Boxed>, Array<Boxed>) -> Result<T, E>,
454+
num: impl FnOnce(Array<f64>, Array<f64>) -> Result<T, E>,
455+
byte: impl FnOnce(Array<u8>, Array<u8>) -> Result<T, E>,
456+
comp: impl FnOnce(Array<Complex>, Array<Complex>) -> Result<T, E>,
457+
char: impl FnOnce(Array<char>, Array<char>) -> Result<T, E>,
458+
bx: impl FnOnce(Array<Boxed>, Array<Boxed>) -> Result<T, E>,
459459
err: impl FnOnce(Self, Self) -> E,
460460
) -> Result<T, E> {
461461
match (self, other) {
462-
(Self::Num(a), Self::Num(b)) => n(a, b),
463-
(Self::Byte(a), Self::Byte(b)) => _b(a, b),
464-
(Self::Byte(a), Self::Num(b)) => n(a.convert(), b),
465-
(Self::Num(a), Self::Byte(b)) => n(a, b.convert()),
466-
(Self::Complex(a), Self::Complex(b)) => _co(a, b),
467-
(Self::Complex(a), Self::Num(b)) => _co(a, b.convert()),
468-
(Self::Num(a), Self::Complex(b)) => _co(a.convert(), b),
469-
(Self::Complex(a), Self::Byte(b)) => _co(a, b.convert()),
470-
(Self::Byte(a), Self::Complex(b)) => _co(a.convert(), b),
471-
(Self::Char(a), Self::Char(b)) => ch(a, b),
472-
(Self::Box(a), Self::Box(b)) => f(a, b),
473-
(Self::Box(a), b) => f(a, b.coerce_to_boxes()),
474-
(a, Self::Box(b)) => f(a.coerce_to_boxes(), b),
462+
(Self::Num(a), Self::Num(b)) => num(a, b),
463+
(Self::Byte(a), Self::Byte(b)) => byte(a, b),
464+
(Self::Byte(a), Self::Num(b)) => num(a.convert(), b),
465+
(Self::Num(a), Self::Byte(b)) => num(a, b.convert()),
466+
(Self::Complex(a), Self::Complex(b)) => comp(a, b),
467+
(Self::Complex(a), Self::Num(b)) => comp(a, b.convert()),
468+
(Self::Num(a), Self::Complex(b)) => comp(a.convert(), b),
469+
(Self::Complex(a), Self::Byte(b)) => comp(a, b.convert()),
470+
(Self::Byte(a), Self::Complex(b)) => comp(a.convert(), b),
471+
(Self::Char(a), Self::Char(b)) => char(a, b),
472+
(Self::Box(a), Self::Box(b)) => bx(a, b),
473+
(Self::Box(a), b) => bx(a, b.coerce_to_boxes()),
474+
(a, Self::Box(b)) => bx(a.coerce_to_boxes(), b),
475475
(a, b) => Err(err(a, b)),
476476
}
477477
}
478478
#[allow(clippy::too_many_arguments)]
479479
pub(crate) fn generic_bin_ref<T, E>(
480480
&self,
481481
other: &Self,
482-
n: impl FnOnce(&Array<f64>, &Array<f64>) -> Result<T, E>,
483-
_b: impl FnOnce(&Array<u8>, &Array<u8>) -> Result<T, E>,
484-
_co: impl FnOnce(&Array<Complex>, &Array<Complex>) -> Result<T, E>,
485-
ch: impl FnOnce(&Array<char>, &Array<char>) -> Result<T, E>,
486-
f: impl FnOnce(&Array<Boxed>, &Array<Boxed>) -> Result<T, E>,
482+
num: impl FnOnce(&Array<f64>, &Array<f64>) -> Result<T, E>,
483+
byte: impl FnOnce(&Array<u8>, &Array<u8>) -> Result<T, E>,
484+
comp: impl FnOnce(&Array<Complex>, &Array<Complex>) -> Result<T, E>,
485+
char: impl FnOnce(&Array<char>, &Array<char>) -> Result<T, E>,
486+
bx: impl FnOnce(&Array<Boxed>, &Array<Boxed>) -> Result<T, E>,
487487
err: impl FnOnce(&Self, &Self) -> E,
488488
) -> Result<T, E> {
489489
match (self, other) {
490-
(Self::Num(a), Self::Num(b)) => n(a, b),
491-
(Self::Byte(a), Self::Byte(b)) => _b(a, b),
492-
(Self::Byte(a), Self::Num(b)) => n(&a.convert_ref(), b),
493-
(Self::Num(a), Self::Byte(b)) => n(a, &b.convert_ref()),
494-
(Self::Complex(a), Self::Complex(b)) => _co(a, b),
495-
(Self::Complex(a), Self::Num(b)) => _co(a, &b.convert_ref()),
496-
(Self::Num(a), Self::Complex(b)) => _co(&a.convert_ref(), b),
497-
(Self::Complex(a), Self::Byte(b)) => _co(a, &b.convert_ref()),
498-
(Self::Byte(a), Self::Complex(b)) => _co(&a.convert_ref(), b),
499-
(Self::Char(a), Self::Char(b)) => ch(a, b),
500-
(Self::Box(a), Self::Box(b)) => f(a, b),
501-
(Self::Box(a), b) => f(a, &b.coerce_as_boxes()),
502-
(a, Self::Box(b)) => f(&a.coerce_as_boxes(), b),
490+
(Self::Num(a), Self::Num(b)) => num(a, b),
491+
(Self::Byte(a), Self::Byte(b)) => byte(a, b),
492+
(Self::Byte(a), Self::Num(b)) => num(&a.convert_ref(), b),
493+
(Self::Num(a), Self::Byte(b)) => num(a, &b.convert_ref()),
494+
(Self::Complex(a), Self::Complex(b)) => comp(a, b),
495+
(Self::Complex(a), Self::Num(b)) => comp(a, &b.convert_ref()),
496+
(Self::Num(a), Self::Complex(b)) => comp(&a.convert_ref(), b),
497+
(Self::Complex(a), Self::Byte(b)) => comp(a, &b.convert_ref()),
498+
(Self::Byte(a), Self::Complex(b)) => comp(&a.convert_ref(), b),
499+
(Self::Char(a), Self::Char(b)) => char(a, b),
500+
(Self::Box(a), Self::Box(b)) => bx(a, b),
501+
(Self::Box(a), b) => bx(a, &b.coerce_as_boxes()),
502+
(a, Self::Box(b)) => bx(&a.coerce_as_boxes(), b),
503503
(a, b) => Err(err(a, b)),
504504
}
505505
}
506506
#[allow(clippy::too_many_arguments)]
507507
pub(crate) fn generic_bin_mut<T, E>(
508508
&mut self,
509509
other: Self,
510-
n: impl FnOnce(&mut Array<f64>, Array<f64>) -> Result<T, E>,
511-
_b: impl FnOnce(&mut Array<u8>, Array<u8>) -> Result<T, E>,
512-
_co: impl FnOnce(&mut Array<Complex>, Array<Complex>) -> Result<T, E>,
513-
ch: impl FnOnce(&mut Array<char>, Array<char>) -> Result<T, E>,
514-
f: impl FnOnce(&mut Array<Boxed>, Array<Boxed>) -> Result<T, E>,
510+
num: impl FnOnce(&mut Array<f64>, Array<f64>) -> Result<T, E>,
511+
byte: impl FnOnce(&mut Array<u8>, Array<u8>) -> Result<T, E>,
512+
comp: impl FnOnce(&mut Array<Complex>, Array<Complex>) -> Result<T, E>,
513+
char: impl FnOnce(&mut Array<char>, Array<char>) -> Result<T, E>,
514+
bx: impl FnOnce(&mut Array<Boxed>, Array<Boxed>) -> Result<T, E>,
515515
err: impl FnOnce(&Self, &Self) -> E,
516516
) -> Result<T, E> {
517517
match (&mut *self, other) {
518-
(Self::Num(a), Self::Num(b)) => n(a, b),
519-
(Self::Byte(a), Self::Byte(b)) => _b(a, b),
518+
(Self::Num(a), Self::Num(b)) => num(a, b),
519+
(Self::Byte(a), Self::Byte(b)) => byte(a, b),
520520
(Self::Byte(a), Self::Num(b)) => {
521521
let mut a_num = a.convert_ref();
522-
let res = n(&mut a_num, b);
522+
let res = num(&mut a_num, b);
523523
*self = a_num.into();
524524
res
525525
}
526-
(Self::Num(a), Self::Byte(b)) => n(a, b.convert_ref()),
527-
(Self::Complex(a), Self::Complex(b)) => _co(a, b),
528-
(Self::Complex(a), Self::Num(b)) => _co(a, b.convert_ref()),
526+
(Self::Num(a), Self::Byte(b)) => num(a, b.convert_ref()),
527+
(Self::Complex(a), Self::Complex(b)) => comp(a, b),
528+
(Self::Complex(a), Self::Num(b)) => comp(a, b.convert_ref()),
529529
(Self::Num(a), Self::Complex(b)) => {
530530
let mut a_comp = a.convert_ref();
531-
let res = _co(&mut a_comp, b);
531+
let res = comp(&mut a_comp, b);
532532
*self = a_comp.into();
533533
res
534534
}
535-
(Self::Complex(a), Self::Byte(b)) => _co(a, b.convert_ref()),
535+
(Self::Complex(a), Self::Byte(b)) => comp(a, b.convert_ref()),
536536
(Self::Byte(a), Self::Complex(b)) => {
537537
let mut a_comp = a.convert_ref();
538-
let res = _co(&mut a_comp, b);
538+
let res = comp(&mut a_comp, b);
539539
*self = a_comp.into();
540540
res
541541
}
542-
(Self::Char(a), Self::Char(b)) => ch(a, b),
543-
(Self::Box(a), b) => f(a, b.coerce_to_boxes()),
542+
(Self::Char(a), Self::Char(b)) => char(a, b),
543+
(Self::Box(a), b) => bx(a, b.coerce_to_boxes()),
544544
(a, Self::Box(b)) => {
545545
let mut a_box = take(a).coerce_to_boxes();
546-
let res = f(&mut a_box, b);
546+
let res = bx(&mut a_box, b);
547547
*self = a_box.into();
548548
res
549549
}

0 commit comments

Comments
 (0)