From 409090e74cd76de35d5ae5ddd7a1e353a9c161f6 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Sun, 16 Aug 2020 12:15:44 -0400 Subject: Chalk 0.23 --- crates/hir_ty/Cargo.toml | 6 +++--- crates/hir_ty/src/traits.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml index 83b5013a9..a319b0ce8 100644 --- a/crates/hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml @@ -16,9 +16,9 @@ ena = "0.14.0" log = "0.4.8" rustc-hash = "1.1.0" scoped-tls = "1" -chalk-solve = { version = "0.21.0" } -chalk-ir = { version = "0.21.0" } -chalk-recursive = { version = "0.21.0" } +chalk-solve = { version = "0.23.0" } +chalk-ir = { version = "0.23.0" } +chalk-recursive = { version = "0.23.0" } stdx = { path = "../stdx" } hir_def = { path = "../hir_def" } diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 1c3abb18f..14cd3a2b4 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs @@ -170,11 +170,11 @@ fn solve( let mut solve = || { if is_chalk_print() { let logging_db = LoggingRustIrDatabase::new(context); - let solution = solver.solve_limited(&logging_db, goal, should_continue); + let solution = solver.solve_limited(&logging_db, goal, &should_continue); log::debug!("chalk program:\n{}", logging_db); solution } else { - solver.solve_limited(&context, goal, should_continue) + solver.solve_limited(&context, goal, &should_continue) } }; -- cgit v1.2.3 From 2eaf79cfbb447156151cb5435eff5f14f41c40f7 Mon Sep 17 00:00:00 2001 From: CAD97 Date: Mon, 17 Aug 2020 13:19:15 -0400 Subject: Document missing match arm false positive This should already be guarded against (https://github.com/rust-analyzer/rust-analyzer/blob/d2212a49f6d447a14cdc87a9de2a4844e78b6905/crates/hir_ty/src/diagnostics/expr.rs#L225-L230) but it isn't preventing this false positive for some reason. --- crates/hir_ty/src/diagnostics/match_check.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs index 7f007f1d6..1602c3fb4 100644 --- a/crates/hir_ty/src/diagnostics/match_check.rs +++ b/crates/hir_ty/src/diagnostics/match_check.rs @@ -1335,6 +1335,25 @@ fn panic(a: Category, b: Category) { ); } + #[test] + fn unknown_type() { + check_diagnostics( + r#" +enum Option { Some(T), None } + +fn main() { + // FIXME: This is a false positive, as the `Never` type is not known here. + // `Never` is deliberately not defined so that it's an uninferred type. + match Option::::None { + None => (), + Some(never) => match never {}, + // ^^^^^ Missing match arm + } +} +"#, + ); + } + mod false_negatives { //! The implementation of match checking here is a work in progress. As we roll this out, we //! prefer false negatives to false positives (ideally there would be no false positives). This -- cgit v1.2.3 From c822bb68ce78171e4017938a66118fc4ccf077d5 Mon Sep 17 00:00:00 2001 From: CAD97 Date: Mon, 17 Aug 2020 13:27:12 -0400 Subject: Fix missing match arm false error on unknown type --- crates/hir_ty/src/diagnostics/expr.rs | 4 ++-- crates/hir_ty/src/diagnostics/match_check.rs | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index fb76e2e4e..278a4b947 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -223,10 +223,10 @@ impl<'a, 'b> ExprValidator<'a, 'b> { db.body_with_source_map(self.owner.into()); let match_expr_ty = match infer.type_of_expr.get(match_expr) { - Some(ty) => ty, // If we can't resolve the type of the match expression // we cannot perform exhaustiveness checks. - None => return, + None | Some(Ty::Unknown) => return, + Some(ty) => ty, }; let cx = MatchCheckCtx { match_expr, body, infer: infer.clone(), db }; diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs index 1602c3fb4..5bd03f2ac 100644 --- a/crates/hir_ty/src/diagnostics/match_check.rs +++ b/crates/hir_ty/src/diagnostics/match_check.rs @@ -1342,12 +1342,10 @@ fn panic(a: Category, b: Category) { enum Option { Some(T), None } fn main() { - // FIXME: This is a false positive, as the `Never` type is not known here. // `Never` is deliberately not defined so that it's an uninferred type. match Option::::None { None => (), Some(never) => match never {}, - // ^^^^^ Missing match arm } } "#, -- cgit v1.2.3