Skip to content

Commit 8f09140

Browse files
committed
Migrate the fluent_period check to diagnostics
1 parent f9881c8 commit 8f09140

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/tools/tidy/src/fluent_period.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::path::Path;
44

55
use fluent_syntax::ast::{Entry, PatternElement};
66

7+
use crate::diagnostics::{CheckId, DiagCtx, RunningCheck};
78
use crate::walk::{filter_dirs, walk};
89

910
fn filter_fluent(path: &Path) -> bool {
@@ -20,7 +21,7 @@ const ALLOWLIST: &[&str] = &[
2021
"incremental_corrupt_file",
2122
];
2223

23-
fn check_period(filename: &str, contents: &str, bad: &mut bool) {
24+
fn check_period(filename: &str, contents: &str, check: &mut RunningCheck) {
2425
if filename.contains("codegen") {
2526
// FIXME: Too many codegen messages have periods right now...
2627
return;
@@ -40,7 +41,7 @@ fn check_period(filename: &str, contents: &str, bad: &mut bool) {
4041
if value.ends_with(".") && !value.ends_with("...") {
4142
let ll = find_line(contents, value);
4243
let name = m.id.name;
43-
tidy_error!(bad, "{filename}:{ll}: message `{name}` ends in a period");
44+
check.error(format!("{filename}:{ll}: message `{name}` ends in a period"));
4445
}
4546
}
4647

@@ -56,7 +57,7 @@ fn check_period(filename: &str, contents: &str, bad: &mut bool) {
5657
{
5758
let ll = find_line(contents, value);
5859
let name = attr.id.name;
59-
tidy_error!(bad, "{filename}:{ll}: attr `{name}` ends in a period");
60+
check.error(format!("{filename}:{ll}: attr `{name}` ends in a period"));
6061
}
6162
}
6263
}
@@ -74,12 +75,14 @@ fn find_line(haystack: &str, needle: &str) -> usize {
7475
1
7576
}
7677

77-
pub fn check(path: &Path, bad: &mut bool) {
78+
pub fn check(path: &Path, diag_ctx: DiagCtx) {
79+
let mut check = diag_ctx.start_check(CheckId::new("fluent_period").path(path));
80+
7881
walk(
7982
path,
8083
|path, is_dir| filter_dirs(path) || (!is_dir && filter_fluent(path)),
8184
&mut |ent, contents| {
82-
check_period(ent.path().to_str().unwrap(), contents, bad);
85+
check_period(ent.path().to_str().unwrap(), contents, &mut check);
8386
},
8487
);
8588
}

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn main() {
120120
// Checks that only make sense for the compiler.
121121
check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], &ci_info);
122122
check!(fluent_alphabetical, &compiler_path, bless);
123-
// check!(fluent_period, &compiler_path);
123+
check!(fluent_period, &compiler_path);
124124
// check!(fluent_lowercase, &compiler_path);
125125
// check!(target_policy, &root_path);
126126
// check!(gcc_submodule, &root_path, &compiler_path);

0 commit comments

Comments
 (0)