|
4 | 4 | use std::path::Path; |
5 | 5 | use std::str::FromStr; |
6 | 6 |
|
| 7 | +use crate::diagnostics::{CheckId, DiagCtx}; |
| 8 | + |
7 | 9 | const RUSTDOC_JSON_TYPES: &str = "src/rustdoc-json-types"; |
8 | 10 |
|
9 | | -pub fn check(src_path: &Path, ci_info: &crate::CiInfo, bad: &mut bool) { |
10 | | - println!("Checking tidy rustdoc_json..."); |
| 11 | +pub fn check(src_path: &Path, ci_info: &crate::CiInfo, diag_ctx: DiagCtx) { |
| 12 | + let mut check = diag_ctx.start_check(CheckId::new("rustdoc_json").path(src_path)); |
| 13 | + |
11 | 14 | let Some(base_commit) = &ci_info.base_commit else { |
12 | | - eprintln!("No base commit, skipping rustdoc_json check"); |
| 15 | + check.verbose_msg("No base commit, skipping rustdoc_json check"); |
13 | 16 | return; |
14 | 17 | }; |
15 | 18 |
|
16 | 19 | // First we check that `src/rustdoc-json-types` was modified. |
17 | 20 | if !crate::files_modified(ci_info, |p| p == RUSTDOC_JSON_TYPES) { |
18 | 21 | // `rustdoc-json-types` was not modified so nothing more to check here. |
19 | | - println!("`rustdoc-json-types` was not modified."); |
| 22 | + check.verbose_msg("`rustdoc-json-types` was not modified."); |
20 | 23 | return; |
21 | 24 | } |
22 | 25 | // Then we check that if `FORMAT_VERSION` was updated, the `Latest feature:` was also updated. |
@@ -45,34 +48,29 @@ pub fn check(src_path: &Path, ci_info: &crate::CiInfo, bad: &mut bool) { |
45 | 48 | } |
46 | 49 | } |
47 | 50 | if format_version_updated != latest_feature_comment_updated { |
48 | | - *bad = true; |
49 | | - if latest_feature_comment_updated { |
50 | | - eprintln!( |
51 | | - "error in `rustdoc_json` tidy check: `Latest feature` comment was updated \ |
52 | | - whereas `FORMAT_VERSION` wasn't in `{RUSTDOC_JSON_TYPES}/lib.rs`" |
53 | | - ); |
| 51 | + let msg = if latest_feature_comment_updated { |
| 52 | + format!( |
| 53 | + "`Latest feature` comment was updated whereas `FORMAT_VERSION` wasn't in `{RUSTDOC_JSON_TYPES}/lib.rs`" |
| 54 | + ) |
54 | 55 | } else { |
55 | | - eprintln!( |
56 | | - "error in `rustdoc_json` tidy check: `Latest feature` comment was not \ |
57 | | - updated whereas `FORMAT_VERSION` was in `{RUSTDOC_JSON_TYPES}/lib.rs`" |
58 | | - ); |
59 | | - } |
| 56 | + format!( |
| 57 | + "`Latest feature` comment was not updated whereas `FORMAT_VERSION` was in `{RUSTDOC_JSON_TYPES}/lib.rs`" |
| 58 | + ) |
| 59 | + }; |
| 60 | + check.error(msg); |
60 | 61 | } |
61 | 62 | match (new_version, old_version) { |
62 | 63 | (Some(new_version), Some(old_version)) if new_version != old_version + 1 => { |
63 | | - *bad = true; |
64 | | - eprintln!( |
65 | | - "error in `rustdoc_json` tidy check: invalid `FORMAT_VERSION` increase in \ |
66 | | - `{RUSTDOC_JSON_TYPES}/lib.rs`, should be `{}`, found `{new_version}`", |
| 64 | + check.error(format!( |
| 65 | + "invalid `FORMAT_VERSION` increase in `{RUSTDOC_JSON_TYPES}/lib.rs`, should be `{}`, found `{new_version}`", |
67 | 66 | old_version + 1, |
68 | | - ); |
| 67 | + )); |
69 | 68 | } |
70 | 69 | _ => {} |
71 | 70 | } |
72 | 71 | } |
73 | 72 | None => { |
74 | | - *bad = true; |
75 | | - eprintln!("error: failed to run `git diff` in rustdoc_json check"); |
| 73 | + check.error("failed to run `git diff` in rustdoc_json check"); |
76 | 74 | } |
77 | 75 | } |
78 | 76 | } |
0 commit comments