mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 18:03:51 +01:00
Clippy with the current stable toolchain (#6615)
Fix lints that are coming with rust 1.64 Passes with the earlier toolchain from `rust-toolchain.toml` as well.
This commit is contained in:
parent
f44473d510
commit
f7647584a3
@ -422,7 +422,7 @@ fn search_alias(input: &[u8], working_set: &StateWorkingSet) -> Option<MatchedAl
|
||||
}
|
||||
// Push the rest to names vector.
|
||||
if pos < input.len() {
|
||||
vec_names.push((&input[pos..]).to_owned());
|
||||
vec_names.push(input[pos..].to_owned());
|
||||
}
|
||||
|
||||
for name in &vec_names {
|
||||
|
@ -662,9 +662,7 @@ pub fn eval_string_with_input(
|
||||
(output, working_set.render())
|
||||
};
|
||||
|
||||
if let Err(err) = engine_state.merge_delta(delta) {
|
||||
return Err(err);
|
||||
}
|
||||
engine_state.merge_delta(delta)?;
|
||||
|
||||
let input_as_pipeline_data = match input {
|
||||
Some(input) => PipelineData::Value(input, None),
|
||||
|
@ -104,9 +104,7 @@ pub fn merge_input(
|
||||
(block, working_set.render())
|
||||
};
|
||||
|
||||
if let Err(err) = engine_state.merge_delta(delta) {
|
||||
return Err(err);
|
||||
}
|
||||
engine_state.merge_delta(delta)?;
|
||||
|
||||
assert!(eval_block(
|
||||
engine_state,
|
||||
|
@ -215,8 +215,8 @@ fn histogram_impl(
|
||||
const MAX_FREQ_COUNT: f64 = 100.0;
|
||||
for (val, count) in counter.into_iter() {
|
||||
let quantile = match calc_method {
|
||||
PercentageCalcMethod::Normalize => (count as f64 / total_cnt as f64),
|
||||
PercentageCalcMethod::Relative => (count as f64 / max_cnt as f64),
|
||||
PercentageCalcMethod::Normalize => count as f64 / total_cnt as f64,
|
||||
PercentageCalcMethod::Relative => count as f64 / max_cnt as f64,
|
||||
};
|
||||
|
||||
let percentage = format!("{:.2}%", quantile * 100_f64);
|
||||
|
2
crates/nu-command/src/env/with_env.rs
vendored
2
crates/nu-command/src/env/with_env.rs
vendored
@ -110,7 +110,7 @@ fn with_env(
|
||||
// primitive values([X Y W Z])
|
||||
for row in table.chunks(2) {
|
||||
if row.len() == 2 {
|
||||
env.insert(row[0].as_string()?, (&row[1]).clone());
|
||||
env.insert(row[0].as_string()?, row[1].clone());
|
||||
}
|
||||
// TODO: else error?
|
||||
}
|
||||
|
@ -154,10 +154,7 @@ impl Command for Mv {
|
||||
}
|
||||
|
||||
if let Some(Ok(_filename)) = some_if_source_is_destination {
|
||||
sources = sources
|
||||
.into_iter()
|
||||
.filter(|f| matches!(f, Ok(f) if !destination.starts_with(f)))
|
||||
.collect();
|
||||
sources.retain(|f| matches!(f, Ok(f) if !destination.starts_with(f)));
|
||||
}
|
||||
|
||||
let span = call.head;
|
||||
|
@ -110,7 +110,7 @@ fn fragment(input: Value, pretty: bool, config: &Config) -> String {
|
||||
let mut out = String::new();
|
||||
|
||||
if headers.len() == 1 {
|
||||
let markup = match (&headers[0]).to_ascii_lowercase().as_ref() {
|
||||
let markup = match headers[0].to_ascii_lowercase().as_ref() {
|
||||
"h1" => "# ".to_string(),
|
||||
"h2" => "## ".to_string(),
|
||||
"h3" => "### ".to_string(),
|
||||
|
@ -427,7 +427,7 @@ fn helper(
|
||||
// primitive values ([key1 val1 key2 val2])
|
||||
for row in table.chunks(2) {
|
||||
if row.len() == 2 {
|
||||
custom_headers.insert(row[0].as_string()?, (&row[1]).clone());
|
||||
custom_headers.insert(row[0].as_string()?, row[1].clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ fn helper(
|
||||
// primitive values ([key1 val1 key2 val2])
|
||||
for row in table.chunks(2) {
|
||||
if row.len() == 2 {
|
||||
custom_headers.insert(row[0].as_string()?, (&row[1]).clone());
|
||||
custom_headers.insert(row[0].as_string()?, row[1].clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -357,10 +357,7 @@ fn convert_to_table(
|
||||
|
||||
// The header with the INDEX is removed from the table headers since
|
||||
// it is added to the natural table index
|
||||
headers = headers
|
||||
.into_iter()
|
||||
.filter(|header| header != INDEX_COLUMN_NAME)
|
||||
.collect();
|
||||
headers.retain(|header| header != INDEX_COLUMN_NAME);
|
||||
|
||||
// Vec of Vec of String1, String2 where String1 is datatype and String2 is value
|
||||
let mut data: Vec<Vec<(String, String)>> = Vec::new();
|
||||
@ -408,7 +405,7 @@ fn convert_to_table(
|
||||
|
||||
match result {
|
||||
Ok(value) => row.push((
|
||||
(&value.get_type()).to_string(),
|
||||
value.get_type().to_string(),
|
||||
value.into_abbreviated_string(config),
|
||||
)),
|
||||
Err(_) => row.push(("empty".to_string(), "❎".into())),
|
||||
|
@ -199,9 +199,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Result<Paths, PatternE
|
||||
}
|
||||
|
||||
// make sure that the pattern is valid first, else early return with error
|
||||
if let Err(err) = Pattern::new(pattern) {
|
||||
return Err(err);
|
||||
}
|
||||
Pattern::new(pattern)?;
|
||||
|
||||
let mut components = Path::new(pattern).components().peekable();
|
||||
while let Some(&Component::Prefix(..)) | Some(&Component::RootDir) = components.peek() {
|
||||
|
Loading…
Reference in New Issue
Block a user