Fix clippy warnings (upcoming) (#9282)

# Description

Fixes the clippy warnings we're about to get hit with next time we
upgrade Rust.

The big one was shrinking ShellError and related under 128 bytes.

# User-Facing Changes

Shouldn't notice much difference. In theory, we could see a tiny perf
improvement, but I didn't notice one.

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
This commit is contained in:
JT
2023-05-25 10:58:18 +12:00
committed by GitHub
parent 7ead89844a
commit fa113172da
11 changed files with 124 additions and 137 deletions

View File

@ -2174,9 +2174,9 @@ impl Value {
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2211,9 +2211,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2292,9 +2292,9 @@ impl Value {
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2402,9 +2402,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2539,9 +2539,9 @@ impl Value {
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2675,9 +2675,9 @@ impl Value {
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2698,9 +2698,9 @@ impl Value {
{
return Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
});
}
@ -2713,9 +2713,9 @@ impl Value {
} else {
Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
})
}
@ -2741,9 +2741,9 @@ impl Value {
{
return Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
});
}
@ -2755,9 +2755,9 @@ impl Value {
})
.ok_or(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
})
}
@ -2782,9 +2782,9 @@ impl Value {
{
return Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
});
}
@ -2796,9 +2796,9 @@ impl Value {
})
.ok_or(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
})
}
@ -2823,9 +2823,9 @@ impl Value {
{
return Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
});
}
@ -2837,9 +2837,9 @@ impl Value {
}),
None => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2862,9 +2862,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2888,9 +2888,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -2946,9 +2946,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3003,9 +3003,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3079,9 +3079,9 @@ impl Value {
),
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3098,9 +3098,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3117,9 +3117,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3136,9 +3136,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3155,9 +3155,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3174,9 +3174,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3193,9 +3193,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3212,9 +3212,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3268,9 +3268,9 @@ impl Value {
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3287,9 +3287,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3306,9 +3306,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3325,9 +3325,9 @@ impl Value {
}
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}
@ -3360,9 +3360,9 @@ impl Value {
_ => Err(ShellError::OperatorMismatch {
op_span: op,
lhs_ty: self.get_type(),
lhs_ty: self.get_type().to_string(),
lhs_span: self.span()?,
rhs_ty: rhs.get_type(),
rhs_ty: rhs.get_type().to_string(),
rhs_span: rhs.span()?,
}),
}