internal: refactor BreakOutsideOfLoop diagnostic

This commit is contained in:
Aleksey Kladov 2021-06-13 19:51:19 +03:00
parent 7166e8549b
commit 886b66cd03
4 changed files with 36 additions and 32 deletions

View file

@ -4,6 +4,7 @@
//! macro-expanded files, but we need to present them to the users in terms of
//! original files. So we need to map the ranges.
mod break_outside_of_loop;
mod inactive_code;
mod macro_error;
mod missing_fields;
@ -218,6 +219,7 @@ pub(crate) fn diagnostics(
for diag in diags {
#[rustfmt::skip]
let d = match diag {
AnyDiagnostic::BreakOutsideOfLoop(d) => break_outside_of_loop::break_outside_of_loop(&ctx, &d),
AnyDiagnostic::MacroError(d) => macro_error::macro_error(&ctx, &d),
AnyDiagnostic::MissingFields(d) => missing_fields::missing_fields(&ctx, &d),
AnyDiagnostic::NoSuchField(d) => no_such_field::no_such_field(&ctx, &d),
@ -711,16 +713,6 @@ mod foo;
);
}
#[test]
fn break_outside_of_loop() {
check_diagnostics(
r#"
fn foo() { break; }
//^^^^^ break outside of loop
"#,
);
}
#[test]
fn missing_unsafe_diagnostic_with_raw_ptr() {
check_diagnostics(