mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Support function pointer MIR lowering
This commit is contained in:
parent
1b85b43e6f
commit
a063f000ff
14 changed files with 468 additions and 164 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue