mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Skip match diagnostics for partially unknown types
This commit is contained in:
parent
bbb441ec6d
commit
cd2347e132
2 changed files with 18 additions and 5 deletions
|
@ -182,7 +182,7 @@ impl ExprValidator {
|
|||
db: &dyn HirDatabase,
|
||||
) {
|
||||
let scrut_ty = &self.infer[scrutinee_expr];
|
||||
if scrut_ty.is_unknown() {
|
||||
if scrut_ty.contains_unknown() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -267,6 +267,9 @@ impl ExprValidator {
|
|||
};
|
||||
let Some(initializer) = initializer else { continue };
|
||||
let ty = &self.infer[initializer];
|
||||
if ty.contains_unknown() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut have_errors = false;
|
||||
let deconstructed_pat = self.lower_pattern(&cx, pat, db, &mut have_errors);
|
||||
|
|
|
@ -597,21 +597,19 @@ fn bang(never: !) {
|
|||
|
||||
#[test]
|
||||
fn unknown_type() {
|
||||
cov_mark::check_count!(validate_match_bailed_out, 1);
|
||||
|
||||
check_diagnostics(
|
||||
check_diagnostics_no_bails(
|
||||
r#"
|
||||
enum Option<T> { Some(T), None }
|
||||
|
||||
#[allow(unused)]
|
||||
fn main() {
|
||||
// `Never` is deliberately not defined so that it's an uninferred type.
|
||||
// We ignore these to avoid triggering bugs in the analysis.
|
||||
match Option::<Never>::None {
|
||||
None => (),
|
||||
Some(never) => match never {},
|
||||
}
|
||||
match Option::<Never>::None {
|
||||
//^^^^^^^^^^^^^^^^^^^^^ error: missing match arm: `None` not covered
|
||||
Option::Some(_never) => {},
|
||||
}
|
||||
}
|
||||
|
@ -619,6 +617,18 @@ fn main() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arity_mismatch_issue_16746() {
|
||||
check_diagnostics_with_disabled(
|
||||
r#"
|
||||
fn main() {
|
||||
let (a, ) = (0, 0);
|
||||
}
|
||||
"#,
|
||||
&["E0308"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuple_of_bools_with_ellipsis_at_end_missing_arm() {
|
||||
check_diagnostics_no_bails(
|
||||
|
|
Loading…
Reference in a new issue