mirror of
https://github.com/nushell/nushell.git
synced 2025-02-18 03:21:05 +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.
|
// Push the rest to names vector.
|
||||||
if pos < input.len() {
|
if pos < input.len() {
|
||||||
vec_names.push((&input[pos..]).to_owned());
|
vec_names.push(input[pos..].to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
for name in &vec_names {
|
for name in &vec_names {
|
||||||
|
@ -662,9 +662,7 @@ pub fn eval_string_with_input(
|
|||||||
(output, working_set.render())
|
(output, working_set.render())
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = engine_state.merge_delta(delta) {
|
engine_state.merge_delta(delta)?;
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let input_as_pipeline_data = match input {
|
let input_as_pipeline_data = match input {
|
||||||
Some(input) => PipelineData::Value(input, None),
|
Some(input) => PipelineData::Value(input, None),
|
||||||
|
@ -104,9 +104,7 @@ pub fn merge_input(
|
|||||||
(block, working_set.render())
|
(block, working_set.render())
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = engine_state.merge_delta(delta) {
|
engine_state.merge_delta(delta)?;
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert!(eval_block(
|
assert!(eval_block(
|
||||||
engine_state,
|
engine_state,
|
||||||
|
@ -215,8 +215,8 @@ fn histogram_impl(
|
|||||||
const MAX_FREQ_COUNT: f64 = 100.0;
|
const MAX_FREQ_COUNT: f64 = 100.0;
|
||||||
for (val, count) in counter.into_iter() {
|
for (val, count) in counter.into_iter() {
|
||||||
let quantile = match calc_method {
|
let quantile = match calc_method {
|
||||||
PercentageCalcMethod::Normalize => (count as f64 / total_cnt as f64),
|
PercentageCalcMethod::Normalize => count as f64 / total_cnt as f64,
|
||||||
PercentageCalcMethod::Relative => (count as f64 / max_cnt as f64),
|
PercentageCalcMethod::Relative => count as f64 / max_cnt as f64,
|
||||||
};
|
};
|
||||||
|
|
||||||
let percentage = format!("{:.2}%", quantile * 100_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])
|
// primitive values([X Y W Z])
|
||||||
for row in table.chunks(2) {
|
for row in table.chunks(2) {
|
||||||
if row.len() == 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?
|
// TODO: else error?
|
||||||
}
|
}
|
||||||
|
@ -154,10 +154,7 @@ impl Command for Mv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(Ok(_filename)) = some_if_source_is_destination {
|
if let Some(Ok(_filename)) = some_if_source_is_destination {
|
||||||
sources = sources
|
sources.retain(|f| matches!(f, Ok(f) if !destination.starts_with(f)));
|
||||||
.into_iter()
|
|
||||||
.filter(|f| matches!(f, Ok(f) if !destination.starts_with(f)))
|
|
||||||
.collect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let span = call.head;
|
let span = call.head;
|
||||||
|
@ -110,7 +110,7 @@ fn fragment(input: Value, pretty: bool, config: &Config) -> String {
|
|||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
|
|
||||||
if headers.len() == 1 {
|
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(),
|
"h1" => "# ".to_string(),
|
||||||
"h2" => "## ".to_string(),
|
"h2" => "## ".to_string(),
|
||||||
"h3" => "### ".to_string(),
|
"h3" => "### ".to_string(),
|
||||||
|
@ -427,7 +427,7 @@ fn helper(
|
|||||||
// primitive values ([key1 val1 key2 val2])
|
// primitive values ([key1 val1 key2 val2])
|
||||||
for row in table.chunks(2) {
|
for row in table.chunks(2) {
|
||||||
if row.len() == 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])
|
// primitive values ([key1 val1 key2 val2])
|
||||||
for row in table.chunks(2) {
|
for row in table.chunks(2) {
|
||||||
if row.len() == 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
|
// The header with the INDEX is removed from the table headers since
|
||||||
// it is added to the natural table index
|
// it is added to the natural table index
|
||||||
headers = headers
|
headers.retain(|header| header != INDEX_COLUMN_NAME);
|
||||||
.into_iter()
|
|
||||||
.filter(|header| header != INDEX_COLUMN_NAME)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
// Vec of Vec of String1, String2 where String1 is datatype and String2 is value
|
// Vec of Vec of String1, String2 where String1 is datatype and String2 is value
|
||||||
let mut data: Vec<Vec<(String, String)>> = Vec::new();
|
let mut data: Vec<Vec<(String, String)>> = Vec::new();
|
||||||
@ -408,7 +405,7 @@ fn convert_to_table(
|
|||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(value) => row.push((
|
Ok(value) => row.push((
|
||||||
(&value.get_type()).to_string(),
|
value.get_type().to_string(),
|
||||||
value.into_abbreviated_string(config),
|
value.into_abbreviated_string(config),
|
||||||
)),
|
)),
|
||||||
Err(_) => row.push(("empty".to_string(), "❎".into())),
|
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
|
// make sure that the pattern is valid first, else early return with error
|
||||||
if let Err(err) = Pattern::new(pattern) {
|
Pattern::new(pattern)?;
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut components = Path::new(pattern).components().peekable();
|
let mut components = Path::new(pattern).components().peekable();
|
||||||
while let Some(&Component::Prefix(..)) | Some(&Component::RootDir) = components.peek() {
|
while let Some(&Component::Prefix(..)) | Some(&Component::RootDir) = components.peek() {
|
||||||
|
Loading…
Reference in New Issue
Block a user