File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,8 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
61
61
match fn_ty. sty {
62
62
// Is it an unsafe function? They don't implement the closure traits
63
63
ty:: TyFnDef ( _, _, fn_ty) | ty:: TyFnPtr ( fn_ty) => {
64
- if fn_ty. unsafety == Unsafety :: Unsafe {
64
+ if fn_ty. unsafety == Unsafety :: Unsafe ||
65
+ fn_ty. sig . skip_binder ( ) . output == ty:: FnOutput :: FnDiverging {
65
66
return ;
66
67
}
67
68
}
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ fn main() {
22
22
Some ( 1u8 ) . map ( |a| unsafe_fn ( a) ) ; // unsafe fn
23
23
}
24
24
25
+ // See #815
26
+ let e = Some ( 1u8 ) . map ( |a| divergent ( a) ) ;
27
+ let e = Some ( 1u8 ) . map ( |a| generic ( a) ) ;
28
+ //~^ ERROR redundant closure found
29
+ //~| HELP remove closure as shown
30
+ //~| SUGGESTION map(generic);
31
+ let e = Some ( 1u8 ) . map ( generic) ;
32
+
25
33
// See #515
26
34
let a: Option < Box < :: std:: ops:: Deref < Target = [ i32 ] > > > =
27
35
Some ( vec ! [ 1i32 , 2 ] ) . map ( |v| -> Box < :: std:: ops:: Deref < Target = [ i32 ] > > { Box :: new ( v) } ) ;
@@ -47,3 +55,11 @@ where F: Fn(&X, &X) -> bool {
47
55
fn below ( x : & u8 , y : & u8 ) -> bool { x < y }
48
56
49
57
unsafe fn unsafe_fn ( _: u8 ) { }
58
+
59
+ fn divergent ( _: u8 ) -> ! {
60
+ unimplemented ! ( )
61
+ }
62
+
63
+ fn generic < T > ( _: T ) -> u8 {
64
+ 0
65
+ }
You can’t perform that action at this time.
0 commit comments