Support function pointer MIR lowering

This commit is contained in:
hkalbasi 2023-03-11 21:43:53 +03:30
parent 1b85b43e6f
commit a063f000ff
14 changed files with 468 additions and 164 deletions

View file

@ -631,6 +631,31 @@ fn f(inp: (Foo, Foo, Foo, Foo)) {
);
}
#[test]
fn fn_traits() {
check_diagnostics(
r#"
//- minicore: fn
fn fn_ref(mut x: impl Fn(u8) -> u8) -> u8 {
//^^^^^ 💡 weak: variable does not need to be mutable
x(2)
}
fn fn_mut(x: impl FnMut(u8) -> u8) -> u8 {
x(2)
//^ 💡 error: cannot mutate immutable variable `x`
}
fn fn_borrow_mut(mut x: &mut impl FnMut(u8) -> u8) -> u8 {
//^^^^^ 💡 weak: variable does not need to be mutable
x(2)
}
fn fn_once(mut x: impl FnOnce(u8) -> u8) -> u8 {
//^^^^^ 💡 weak: variable does not need to be mutable
x(2)
}
"#,
);
}
#[test]
fn respect_allow_unused_mut() {
// FIXME: respect