mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
31 lines
731 B
Rust
31 lines
731 B
Rust
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() {}
|