mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
redundant closure for functions restricted to FnDefs
This commit is contained in:
parent
0d9ef393b8
commit
aa9cf07d56
3 changed files with 13 additions and 0 deletions
|
@ -65,6 +65,9 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
|
|||
if !(is_adjusted(cx, ex) || args.iter().any(|arg| is_adjusted(cx, arg)));
|
||||
|
||||
let fn_ty = cx.tables.expr_ty(caller);
|
||||
|
||||
if let ty::FnDef(_, _) = fn_ty.sty;
|
||||
|
||||
if !type_is_unsafe_function(cx, fn_ty);
|
||||
|
||||
if compare_inputs(&mut iter_input_pats(decl, body), &mut args.into_iter());
|
||||
|
|
|
@ -133,3 +133,8 @@ fn divergent(_: u8) -> ! {
|
|||
fn generic<T>(_: T) -> u8 {
|
||||
0
|
||||
}
|
||||
|
||||
fn passes_fn_mut(mut x: Box<dyn FnMut()>) {
|
||||
requires_fn_once(|| x());
|
||||
}
|
||||
fn requires_fn_once<T: FnOnce()>(_: T) {}
|
||||
|
|
|
@ -133,3 +133,8 @@ fn divergent(_: u8) -> ! {
|
|||
fn generic<T>(_: T) -> u8 {
|
||||
0
|
||||
}
|
||||
|
||||
fn passes_fn_mut(mut x: Box<dyn FnMut()>) {
|
||||
requires_fn_once(|| x());
|
||||
}
|
||||
fn requires_fn_once<T: FnOnce()>(_: T) {}
|
||||
|
|
Loading…
Add table
Reference in a new issue