2023-07-27 11:40:22 +00:00
|
|
|
fn fn_pointer_static() -> usize {
|
|
|
|
static FN: fn() -> usize = || 1;
|
|
|
|
|
|
|
|
FN() + 1
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: returning the result of a `let` binding from a block
|
|
|
|
//~| NOTE: `-D clippy::let-and-return` implied by `-D warnings`
|
2023-07-27 11:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn fn_pointer_const() -> usize {
|
|
|
|
const FN: fn() -> usize = || 1;
|
|
|
|
|
|
|
|
FN() + 1
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: returning the result of a `let` binding from a block
|
2023-07-27 11:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: returning the result of a `let` binding from a block
|
2023-07-27 11:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|