Skip to content

Commit e079ac7

Browse files
committed
Migrate the pal check to diagnostics
1 parent 7c6309b commit e079ac7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/tools/tidy/src/pal.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
3333
use std::path::Path;
3434

35+
use crate::diagnostics::{CheckId, DiagCtx, RunningCheck};
3536
use crate::walk::{filter_dirs, walk};
3637

3738
// Paths that may contain platform-specific code.
@@ -66,7 +67,9 @@ const EXCEPTION_PATHS: &[&str] = &[
6667
"library/std/src/io/error.rs", // Repr unpacked needed for UEFI
6768
];
6869

69-
pub fn check(path: &Path, bad: &mut bool) {
70+
pub fn check(path: &Path, diag_ctx: DiagCtx) {
71+
let mut check = diag_ctx.start_check(CheckId::new("pal").path(path));
72+
7073
// Sanity check that the complex parsing here works.
7174
let mut saw_target_arch = false;
7275
let mut saw_cfg_bang = false;
@@ -87,7 +90,7 @@ pub fn check(path: &Path, bad: &mut bool) {
8790
return;
8891
}
8992

90-
check_cfgs(contents, file, bad, &mut saw_target_arch, &mut saw_cfg_bang);
93+
check_cfgs(contents, file, &mut check, &mut saw_target_arch, &mut saw_cfg_bang);
9194
});
9295

9396
assert!(saw_target_arch);
@@ -97,7 +100,7 @@ pub fn check(path: &Path, bad: &mut bool) {
97100
fn check_cfgs(
98101
contents: &str,
99102
file: &Path,
100-
bad: &mut bool,
103+
check: &mut RunningCheck,
101104
saw_target_arch: &mut bool,
102105
saw_cfg_bang: &mut bool,
103106
) {
@@ -114,7 +117,7 @@ fn check_cfgs(
114117
Ok(_) => unreachable!(),
115118
Err(i) => i + 1,
116119
};
117-
tidy_error!(bad, "{}:{}: platform-specific cfg: {}", file.display(), line, cfg);
120+
check.error(format!("{}:{line}: platform-specific cfg: {cfg}", file.display()));
118121
};
119122

120123
for (idx, cfg) in cfgs {

0 commit comments

Comments
 (0)