File tree 3 files changed +36
-3
lines changed
3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change
1
+ // run-rustfix
2
+ #![allow(dead_code)]
3
+
4
+ fn fn_pointer_static() -> usize {
5
+ static FN: fn() -> usize = || 1;
6
+
7
+ FN() + 1
8
+ }
9
+
10
+ fn fn_pointer_const() -> usize {
11
+ const FN: fn() -> usize = || 1;
12
+
13
+ FN() + 1
14
+ }
15
+
16
+ fn deref_to_dyn_fn() -> usize {
17
+ struct Derefs;
18
+ impl std::ops::Deref for Derefs {
19
+ type Target = dyn Fn() -> usize;
20
+
21
+ fn deref(&self) -> &Self::Target {
22
+ &|| 2
23
+ }
24
+ }
25
+ static FN: Derefs = Derefs;
26
+
27
+ FN() + 1
28
+ }
29
+
30
+ fn main() {}
Original file line number Diff line number Diff line change
1
+ // run-rustfix
2
+ #![ allow( dead_code) ]
3
+
1
4
fn fn_pointer_static ( ) -> usize {
2
5
static FN : fn ( ) -> usize = || 1 ;
3
6
let res = FN ( ) + 1 ;
Original file line number Diff line number Diff line change 1
1
error: returning the result of a `let` binding from a block
2
- --> $DIR/ice-8850.rs:4 :5
2
+ --> $DIR/ice-8850.rs:7 :5
3
3
|
4
4
LL | let res = FN() + 1;
5
5
| ------------------- unnecessary `let` binding
@@ -14,7 +14,7 @@ LL ~ FN() + 1
14
14
|
15
15
16
16
error: returning the result of a `let` binding from a block
17
- --> $DIR/ice-8850.rs:10 :5
17
+ --> $DIR/ice-8850.rs:13 :5
18
18
|
19
19
LL | let res = FN() + 1;
20
20
| ------------------- unnecessary `let` binding
@@ -28,7 +28,7 @@ LL ~ FN() + 1
28
28
|
29
29
30
30
error: returning the result of a `let` binding from a block
31
- --> $DIR/ice-8850.rs:24 :5
31
+ --> $DIR/ice-8850.rs:27 :5
32
32
|
33
33
LL | let res = FN() + 1;
34
34
| ------------------- unnecessary `let` binding
You can’t perform that action at this time.
0 commit comments