rust-clippy/tests/ui/crashes/ice-8850.rs
2023-08-22 17:18:11 +02:00

31 lines
773 B
Rust

fn fn_pointer_static() -> usize {
static FN: fn() -> usize = || 1;
let res = FN() + 1;
res
//~^ 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;
let res = FN() + 1;
res
//~^ 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;
let res = FN() + 1;
res
//~^ ERROR: returning the result of a `let` binding from a block
}
fn main() {}