update tests and fix lints in clippy
This commit is contained in:
parent
6396a7a425
commit
e1a78ae528
@ -51,6 +51,5 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidRef {
|
||||
span_help_and_lint(cx, INVALID_REF, expr.span, msg, HELP);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1648,16 +1648,15 @@ fn lint_unnecessary_fold(cx: &LateContext<'_, '_>, expr: &hir::Expr, fold_args:
|
||||
);
|
||||
|
||||
// Check if the first argument to .fold is a suitable literal
|
||||
match fold_args[1].node {
|
||||
hir::ExprKind::Lit(ref lit) => match lit.node {
|
||||
if let hir::ExprKind::Lit(ref lit) = fold_args[1].node {
|
||||
match lit.node {
|
||||
ast::LitKind::Bool(false) => check_fold_with_op(cx, fold_args, hir::BinOpKind::Or, "any", true),
|
||||
ast::LitKind::Bool(true) => check_fold_with_op(cx, fold_args, hir::BinOpKind::And, "all", true),
|
||||
ast::LitKind::Int(0, _) => check_fold_with_op(cx, fold_args, hir::BinOpKind::Add, "sum", false),
|
||||
ast::LitKind::Int(1, _) => check_fold_with_op(cx, fold_args, hir::BinOpKind::Mul, "product", false),
|
||||
_ => return,
|
||||
},
|
||||
_ => return,
|
||||
};
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn lint_iter_nth<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &hir::Expr, iter_args: &'tcx [hir::Expr], is_mut: bool) {
|
||||
|
@ -169,7 +169,9 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
|
||||
.any(|id| id.name == ident.name)
|
||||
{
|
||||
return;
|
||||
} else if let Some(scope) = &mut self.0.single_char_names.last_mut() {
|
||||
}
|
||||
|
||||
if let Some(scope) = &mut self.0.single_char_names.last_mut() {
|
||||
scope.push(ident);
|
||||
}
|
||||
}
|
||||
|
@ -95,8 +95,6 @@ fn find_sugg_for_if_let<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr,
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,8 +159,6 @@ fn find_sugg_for_match<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, o
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,11 +141,11 @@ fn run_ui_toml() {
|
||||
|
||||
let res = run_ui_toml_tests(&config, tests);
|
||||
match res {
|
||||
Ok(true) => {},
|
||||
Ok(true) => {}
|
||||
Ok(false) => panic!("Some tests failed"),
|
||||
Err(e) => {
|
||||
println!("I/O failure during tests: {:?}", e);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ fn explore_directory(dir: &Path) -> Vec<String> {
|
||||
if file_stem != current_file {
|
||||
missing_files.push(path.to_str().unwrap().to_string());
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => continue,
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
#![warn(clippy::needless_return)]
|
||||
|
||||
macro_rules! the_answer {
|
||||
() => (42)
|
||||
() => {
|
||||
42
|
||||
};
|
||||
}
|
||||
|
||||
fn test_end_of_fn() -> bool {
|
||||
@ -56,6 +58,13 @@ fn test_void_if_fun(b: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
fn test_void_match(x: u32) {
|
||||
match x {
|
||||
0 => (),
|
||||
_ => return,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = test_end_of_fn();
|
||||
let _ = test_no_semicolon();
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:12:5
|
||||
--> $DIR/needless_return.rs:14:5
|
||||
|
|
||||
LL | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
@ -7,70 +7,70 @@ LL | return true;
|
||||
= note: `-D clippy::needless-return` implied by `-D warnings`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:16:5
|
||||
--> $DIR/needless_return.rs:18:5
|
||||
|
|
||||
LL | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:21:9
|
||||
--> $DIR/needless_return.rs:23:9
|
||||
|
|
||||
LL | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:23:9
|
||||
--> $DIR/needless_return.rs:25:9
|
||||
|
|
||||
LL | return false;
|
||||
| ^^^^^^^^^^^^^ help: remove `return` as shown: `false`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:29:17
|
||||
--> $DIR/needless_return.rs:31:17
|
||||
|
|
||||
LL | true => return false,
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `false`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:31:13
|
||||
--> $DIR/needless_return.rs:33:13
|
||||
|
|
||||
LL | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:38:9
|
||||
--> $DIR/needless_return.rs:40:9
|
||||
|
|
||||
LL | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:40:16
|
||||
--> $DIR/needless_return.rs:42:16
|
||||
|
|
||||
LL | let _ = || return true;
|
||||
| ^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:44:5
|
||||
|
|
||||
LL | return the_answer!();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:48:5
|
||||
--> $DIR/needless_return.rs:50:5
|
||||
|
|
||||
LL | return;
|
||||
| ^^^^^^^ help: remove `return`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:53:9
|
||||
|
|
||||
LL | return;
|
||||
| ^^^^^^^ help: remove `return`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:55:9
|
||||
|
|
||||
LL | return;
|
||||
| ^^^^^^^ help: remove `return`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:57:9
|
||||
|
|
||||
LL | return;
|
||||
| ^^^^^^^ help: remove `return`
|
||||
|
||||
error: unneeded return statement
|
||||
--> $DIR/needless_return.rs:64:14
|
||||
|
|
||||
LL | _ => return,
|
||||
| ^^^^^^ help: replace `return` with the unit type `()`: `()`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user