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

@ -307,7 +307,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
let mut initial_command = Some(String::new());
let mut readline = Err(ReadlineError::Eof);
while let Some(ref cmd) = initial_command {
readline = rl.readline_with_initial(&prompt, (&cmd, ""));
readline = rl.readline_with_initial(&prompt, (cmd, ""));
initial_command = None;
}
@ -479,7 +479,7 @@ pub fn parse_and_eval(line: &str, ctx: &EvaluationContext) -> Result<String, She
// TODO ensure the command whose examples we're testing is actually in the pipeline
ctx.scope.enter_scope();
let (classified_block, err) = nu_parser::parse(&line, 0, &ctx.scope);
let (classified_block, err) = nu_parser::parse(line, 0, &ctx.scope);
if let Some(err) = err {
ctx.scope.exit_scope();
return Err(err.into());

View File

@ -270,12 +270,11 @@ pub fn completion_location(line: &str, block: &Block, pos: usize) -> Vec<Complet
}
if line[start..pos].contains(BEFORE_COMMAND_CHARS) {
locations.push(LocationType::Command.spanned(Span::new(pos, pos)));
locations
} else {
// TODO this should be able to be mapped to a command
locations.push(LocationType::Argument(command, None).spanned(Span::new(pos, pos)));
locations
}
locations
} else {
// Cursor is before any possible completion location, so must be a command
vec![LocationType::Command.spanned(Span::unknown())]

View File

@ -60,7 +60,7 @@ impl rustyline::completion::Completer for Helper {
impl rustyline::hint::Hinter for Helper {
type Hint = String;
fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context<'_>) -> Option<String> {
self.hinter.as_ref().and_then(|h| h.hint(line, pos, &ctx))
self.hinter.as_ref().and_then(|h| h.hint(line, pos, ctx))
}
}
@ -166,7 +166,7 @@ mod tests {
let helper = Helper::new(EvaluationContext::basic(), None);
helper.update(&mut buffer, "cd ".len(), &replacement);
helper.update(&mut buffer, "cd ".len(), replacement);
assert_eq!(
buffer.as_str(),
@ -186,7 +186,7 @@ mod tests {
let helper = Helper::new(EvaluationContext::basic(), None);
helper.update(&mut buffer, "cd ".len(), &replacement);
helper.update(&mut buffer, "cd ".len(), replacement);
assert_eq!(
buffer.as_str(),

View File

@ -326,7 +326,7 @@ fn get_result_shape_of_math_expr(
for expr in &[&bin.left, &bin.right] {
let shape = match &expr.expr {
Expression::Binary(deep_binary) => {
get_result_shape_of_math_expr(&deep_binary, (pipeline_idx, pipeline), scope)?
get_result_shape_of_math_expr(deep_binary, (pipeline_idx, pipeline), scope)?
}
_ => get_shape_of_expr(expr),
};
@ -537,19 +537,19 @@ impl VarSyntaxShapeDeductor {
}
Expression::Block(b) => {
trace!("Inferring vars in block");
self.infer_shape(&b, scope)?;
self.infer_shape(b, scope)?;
}
Expression::FullColumnPath(path) => {
trace!("Inferring vars in path");
match &path.head.expr {
//PathMember can't be var yet (?)
//TODO Iterate over path parts and find var when implemented
Expression::Subexpression(b) => self.infer_shape(&b, scope)?,
Expression::Subexpression(b) => self.infer_shape(b, scope)?,
Expression::Variable(var_name, span) => {
self.checked_insert(
&VarUsage::new(var_name, span),
VarShapeDeduction::from_usage_with_alternatives(
&span,
span,
&get_shapes_allowed_in_path(),
),
)?;
@ -573,9 +573,9 @@ impl VarSyntaxShapeDeductor {
if let Some(range_right) = &range.right {
if let Expression::Variable(var_name, span) = &range_right.expr {
self.checked_insert(
&VarUsage::new(&var_name, &spanned_expr.span),
&VarUsage::new(var_name, &spanned_expr.span),
VarShapeDeduction::from_usage_with_alternatives(
&span,
span,
&get_shapes_allowed_in_range(),
),
)?;
@ -745,7 +745,7 @@ impl VarSyntaxShapeDeductor {
let shapes = get_shapes_decay_able_to_bool();
// shapes.push(SyntaxShape::Math);
self.checked_insert(
&var,
var,
VarShapeDeduction::from_usage_with_alternatives(&var.span, &shapes),
)?;
}
@ -765,7 +765,7 @@ impl VarSyntaxShapeDeductor {
let shapes_in_list = self.get_shapes_in_list_or_insert_dependency(
var,
bin_spanned,
&list,
list,
(pipeline_idx, pipeline),
);
match shapes_in_list {
@ -879,7 +879,7 @@ impl VarSyntaxShapeDeductor {
var,
VarShapeDeduction::from_usage_with_alternatives(
&var.span,
&MULT_DIV_LOOKUP_TABLE
MULT_DIV_LOOKUP_TABLE
.get(&(op, var_side, shape))
.expect("shape is unit, number or int. Would have failed in parsing stage otherwise")
),
@ -971,7 +971,7 @@ impl VarSyntaxShapeDeductor {
let mut new_deductions = new_deductions;
new_deductions.sort_unstable_by(|a, b| (a.deduction as i32).cmp(&(b.deduction as i32)));
let (insert_k, insert_v) = match self.inferences.get_key_value(&var_usage) {
let (insert_k, insert_v) = match self.inferences.get_key_value(var_usage) {
Some((k, existing_deductions)) => {
let Deduction::VarShapeDeduction(existing_deductions) = existing_deductions;