mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-25 11:17:13 +00:00
fix: Skip pattern analysis on type mismatches
This commit is contained in:
parent
7230ded9c7
commit
8682c1b9b4
@ -324,6 +324,9 @@ impl ExprValidator {
|
||||
let &Statement::Let { pat, initializer, else_branch: None, .. } = stmt else {
|
||||
continue;
|
||||
};
|
||||
if self.infer.type_mismatch_for_pat(pat).is_some() {
|
||||
continue;
|
||||
}
|
||||
let Some(initializer) = initializer else { continue };
|
||||
let ty = &self.infer[initializer];
|
||||
if ty.contains_unknown() {
|
||||
|
@ -1243,4 +1243,18 @@ fn foo(v: &Enum) {
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_19844() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
fn main() {
|
||||
struct S {}
|
||||
enum E { V() }
|
||||
let E::V() = &S {};
|
||||
// ^^^^^^ error: expected S, found E
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user