blob: 4569b9e8793e23610677b6d1d2a99ed0bb8a102d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
fn fn_pointer_static() -> usize {
static FN: fn() -> usize = || 1;
FN() + 1
//~^ ERROR: returning the result of a `let` binding from a block
//~| NOTE: `-D clippy::let-and-return` implied by `-D warnings`
}
fn fn_pointer_const() -> usize {
const FN: fn() -> usize = || 1;
FN() + 1
//~^ ERROR: returning the result of a `let` binding from a block
}
fn deref_to_dyn_fn() -> usize {
struct Derefs;
impl std::ops::Deref for Derefs {
type Target = dyn Fn() -> usize;
fn deref(&self) -> &Self::Target {
&|| 2
}
}
static FN: Derefs = Derefs;
FN() + 1
//~^ ERROR: returning the result of a `let` binding from a block
}
fn main() {}
|