Prefer debug! to never! and add regression test

This commit is contained in:
Nadrieril 2024-02-11 23:46:05 +01:00
parent b04e0df1ce
commit 43caf8323a
2 changed files with 20 additions and 1 deletions

View File

@ -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;
@ -475,7 +476,7 @@ impl<'p> TypeCx for MatchCheckCtx<'p> {
}
fn bug(&self, fmt: fmt::Arguments<'_>) {
never!("{}", fmt)
debug!("{}", fmt)
}
}

View File

@ -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);