Fix a bunch of future clippy warnings (#3586)

* Fix a bunch of future clippy warnings

* Fix a bunch of future clippy warnings
This commit is contained in:
JT
2021-06-10 07:08:12 +12:00
committed by GitHub
parent e8a2250ef8
commit 383e874166
86 changed files with 237 additions and 258 deletions

View File

@ -242,7 +242,7 @@ where
match value {
Ok(v) => current = v.clone(),
Err(e) => return Err(get_error(&current, &p, e)),
Err(e) => return Err(get_error(&current, p, e)),
}
}
@ -260,7 +260,7 @@ where
let fields = path.clone();
let to_replace =
get_data_by_column_path(&value, path, move |obj_source, column_path_tried, error| {
get_data_by_column_path(value, path, move |obj_source, column_path_tried, error| {
let path_members_span = fields.maybe_span().unwrap_or_else(Span::unknown);
match &obj_source.value {
@ -274,7 +274,7 @@ where
let suggestions: IndexSet<_> = rows
.iter()
.filter_map(|r| {
nu_protocol::did_you_mean(&r, column_path_tried.as_string())
nu_protocol::did_you_mean(r, column_path_tried.as_string())
})
.map(|s| s[0].to_owned())
.collect();
@ -345,7 +345,7 @@ where
let primary_label = format!("There isn't a column named '{}'", &column);
if let Some(suggestions) =
nu_protocol::did_you_mean(&obj_source, column_path_tried.as_string())
nu_protocol::did_you_mean(obj_source, column_path_tried.as_string())
{
return ShellError::labeled_error_with_secondary(
"Unknown column",
@ -380,7 +380,7 @@ where
}
if let Some(suggestions) =
nu_protocol::did_you_mean(&obj_source, column_path_tried.as_string())
nu_protocol::did_you_mean(obj_source, column_path_tried.as_string())
{
return ShellError::labeled_error(
"Unknown column",
@ -396,7 +396,7 @@ where
let replacement = callback(&old_value)?;
value
.replace_data_at_column_path(&path, replacement)
.replace_data_at_column_path(path, replacement)
.ok_or_else(|| {
ShellError::labeled_error("missing column-path", "missing column-path", value.tag.span)
})
@ -560,14 +560,14 @@ pub fn forgiving_insert_data_at_column_path(
.get_data_by_column_path(&cp, Box::new(move |_, _, err| err))
.is_ok()
{
return insert_data_at_column_path(&value, &cp, candidate);
return insert_data_at_column_path(value, &cp, candidate);
} else if let Some((last, front)) = cp.split_last() {
let mut current: &mut Value = &mut original;
for member in front {
let type_name = current.spanned_type_name();
current = get_mut_data_by_member(current, &member).ok_or_else(|| {
current = get_mut_data_by_member(current, member).ok_or_else(|| {
ShellError::missing_property(
member.plain_string(std::usize::MAX).spanned(member.span),
type_name,
@ -575,7 +575,7 @@ pub fn forgiving_insert_data_at_column_path(
})?
}
insert_data_at_member(current, &last, candidate)?;
insert_data_at_member(current, last, candidate)?;
return Ok(original);
} else {
@ -585,7 +585,7 @@ pub fn forgiving_insert_data_at_column_path(
}
}
insert_data_at_column_path(&value, split_path, new_value)
insert_data_at_column_path(value, split_path, new_value)
}
pub fn insert_data_at_column_path(
@ -601,7 +601,7 @@ pub fn insert_data_at_column_path(
for member in front {
let type_name = current.spanned_type_name();
current = get_mut_data_by_member(current, &member).ok_or_else(|| {
current = get_mut_data_by_member(current, member).ok_or_else(|| {
ShellError::missing_property(
member.plain_string(std::usize::MAX).spanned(member.span),
type_name,
@ -609,7 +609,7 @@ pub fn insert_data_at_column_path(
})?
}
insert_data_at_member(current, &last, new_value)?;
insert_data_at_member(current, last, new_value)?;
Ok(original)
} else {
@ -801,7 +801,7 @@ pub(crate) fn get_mut_data_by_member<'value>(
) -> Option<&'value mut Value> {
match &mut value.value {
UntaggedValue::Row(o) => match &name.unspanned {
UnspannedPathMember::String(string) => o.get_mut_data_by_key(&string),
UnspannedPathMember::String(string) => o.get_mut_data_by_key(string),
UnspannedPathMember::Int(_) => None,
},
UntaggedValue::Table(l) => match &name.unspanned {
@ -812,7 +812,7 @@ pub(crate) fn get_mut_data_by_member<'value>(
..
} = item
{
if let Some(v) = o.get_mut_data_by_key(&string) {
if let Some(v) = o.get_mut_data_by_key(string) {
return Some(v);
}
}