Skip to content

Commit 853f452

Browse files
authored
Unrolled build for #142875
Rollup merge of #142875 - GuillaumeGomez:rustdoc-json-types-version-update, r=Kobzol Check rustdoc-json-types FORMAT_VERSION is correctly updated Follow-up of #142677. ``@nnethercote`` suggested that we should also ensure that the `FORMAT_VERSION` was only increased by 1 and we should check for it, this PR does it. cc ``@aDotInTheVoid`` r? ghost
2 parents 58d5e11 + 1a3cba8 commit 853f452

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/tools/tidy/src/rustdoc_json.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use std::ffi::OsStr;
55
use std::path::Path;
66
use std::process::Command;
7+
use std::str::FromStr;
78

89
use build_helper::ci::CiEnv;
910
use build_helper::git::{GitConfig, get_closest_upstream_commit};
@@ -71,9 +72,22 @@ pub fn check(src_path: &Path, bad: &mut bool) {
7172
Some(output) => {
7273
let mut format_version_updated = false;
7374
let mut latest_feature_comment_updated = false;
75+
let mut new_version = None;
76+
let mut old_version = None;
7477
for line in output.lines() {
7578
if line.starts_with("+pub const FORMAT_VERSION: u32 =") {
7679
format_version_updated = true;
80+
new_version = line
81+
.split('=')
82+
.nth(1)
83+
.and_then(|s| s.trim().split(';').next())
84+
.and_then(|s| u32::from_str(s.trim()).ok());
85+
} else if line.starts_with("-pub const FORMAT_VERSION: u32 =") {
86+
old_version = line
87+
.split('=')
88+
.nth(1)
89+
.and_then(|s| s.trim().split(';').next())
90+
.and_then(|s| u32::from_str(s.trim()).ok());
7791
} else if line.starts_with("+// Latest feature:") {
7892
latest_feature_comment_updated = true;
7993
}
@@ -92,6 +106,17 @@ pub fn check(src_path: &Path, bad: &mut bool) {
92106
);
93107
}
94108
}
109+
match (new_version, old_version) {
110+
(Some(new_version), Some(old_version)) if new_version != old_version + 1 => {
111+
*bad = true;
112+
eprintln!(
113+
"error in `rustdoc_json` tidy check: invalid `FORMAT_VERSION` increase in \
114+
`{RUSTDOC_JSON_TYPES}/lib.rs`, should be `{}`, found `{new_version}`",
115+
old_version + 1,
116+
);
117+
}
118+
_ => {}
119+
}
95120
}
96121
None => {
97122
*bad = true;

0 commit comments

Comments
 (0)