Skip to content

Commit

Permalink
Prefer debug! to never! and add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Feb 11, 2024
1 parent b04e0df commit 43caf83
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Interface with `rustc_pattern_analysis`.
use std::fmt;
use tracing::debug;

use hir_def::{DefWithBodyId, EnumVariantId, HasModule, LocalFieldId, ModuleId, VariantId};
use rustc_hash::FxHashMap;
Expand Down Expand Up @@ -475,7 +476,7 @@ impl<'p> TypeCx for MatchCheckCtx<'p> {
}

fn bug(&self, fmt: fmt::Arguments<'_>) {
never!("{}", fmt)
debug!("{}", fmt)
}
}

Expand Down
18 changes: 18 additions & 0 deletions crates/ide-diagnostics/src/handlers/missing_match_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,24 @@ fn main() {
);
}

#[test]
fn mismatched_types_issue_15883() {
// Check we don't panic.
check_diagnostics_no_bails(
r#"
//- minicore: option
fn main() {
match Some((true, false)) {
Some(true) | Some(false) => {}
// ^^^^ error: expected (bool, bool), found bool
// ^^^^^ error: expected (bool, bool), found bool
None => {}
}
}
"#,
);
}

#[test]
fn mismatched_types_in_or_patterns() {
cov_mark::check_count!(validate_match_bailed_out, 2);
Expand Down

0 comments on commit 43caf83

Please sign in to comment.