redundant closure for functions restricted to FnDefs

This commit is contained in:
Grzegorz 2019-03-31 14:10:17 +02:00
parent 0d9ef393b8
commit aa9cf07d56
3 changed files with 13 additions and 0 deletions

View File

@ -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());

View File

@ -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) {}

View File

@ -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) {}