mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Partially support "overloaded deref" MIR lowering
This commit is contained in:
parent
bf0f99f15d
commit
af90ec8096
14 changed files with 546 additions and 297 deletions
|
@ -529,6 +529,7 @@ fn f(x: [(i32, u8); 10]) {
|
|||
|
||||
#[test]
|
||||
fn overloaded_deref() {
|
||||
// FIXME: check for false negative
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- minicore: deref_mut
|
||||
|
@ -547,9 +548,42 @@ impl DerefMut for Foo {
|
|||
}
|
||||
}
|
||||
fn f() {
|
||||
// FIXME: remove this mut and detect error
|
||||
let x = Foo;
|
||||
let y = &*x;
|
||||
let x = Foo;
|
||||
let mut x = Foo;
|
||||
let y = &mut *x;
|
||||
let y: &mut i32 = &mut x;
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn or_pattern() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- minicore: option
|
||||
fn f(_: i32) {}
|
||||
fn main() {
|
||||
let ((Some(mut x), None) | (_, Some(mut x))) = (None, Some(7));
|
||||
//^^^^^ 💡 weak: remove this `mut`
|
||||
f(x);
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn respect_allow_unused_mut() {
|
||||
// FIXME: respect
|
||||
check_diagnostics(
|
||||
r#"
|
||||
fn f(_: i32) {}
|
||||
fn main() {
|
||||
#[allow(unused_mut)]
|
||||
let mut x = 2;
|
||||
//^^^^^ 💡 weak: remove this `mut`
|
||||
f(x);
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue