Skip to content

Commit cb6460f

Browse files
Pass src_path to rustdoc_json tidy check
1 parent f8ed2e1 commit cb6460f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn main() {
110110
check!(rustdoc_css_themes, &librustdoc_path);
111111
check!(rustdoc_templates, &librustdoc_path);
112112
check!(rustdoc_js, &librustdoc_path, &tools_path, &src_path);
113-
check!(rustdoc_json);
113+
check!(rustdoc_json, &src_path);
114114
check!(known_bug, &crashes_path);
115115
check!(unknown_revision, &tests_path);
116116

src/tools/tidy/src/rustdoc_json.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
//! Tidy check to ensure that `FORMAT_VERSION` was correctly updated if `rustdoc-json-types` was
22
//! updated as well.
33
4+
use std::ffi::OsStr;
5+
use std::path::Path;
46
use std::process::Command;
57

68
use build_helper::ci::CiEnv;
79
use build_helper::git::{GitConfig, get_closest_upstream_commit};
810
use build_helper::stage0_parser::parse_stage0_file;
911

10-
fn git_diff(base_commit: &str, extra_arg: &str) -> Option<String> {
12+
fn git_diff<S: AsRef<OsStr>>(base_commit: &str, extra_arg: S) -> Option<String> {
1113
let output = Command::new("git").arg("diff").arg(base_commit).arg(extra_arg).output().ok()?;
1214
Some(String::from_utf8_lossy(&output.stdout).into())
1315
}
1416

15-
pub fn check(bad: &mut bool) {
17+
pub fn check(src_path: &Path, bad: &mut bool) {
1618
println!("Checking tidy rustdoc_json...");
1719
let stage0 = parse_stage0_file();
1820
let base_commit = match get_closest_upstream_commit(
@@ -46,6 +48,7 @@ pub fn check(bad: &mut bool) {
4648
.any(|line| line.starts_with("M") && line.contains("src/rustdoc-json-types"))
4749
{
4850
// `rustdoc-json-types` was not modified so nothing more to check here.
51+
println!("`rustdoc-json-types` was not modified.");
4952
return;
5053
}
5154
}
@@ -56,7 +59,7 @@ pub fn check(bad: &mut bool) {
5659
}
5760
}
5861
// Then we check that if `FORMAT_VERSION` was updated, the `Latest feature:` was also updated.
59-
match git_diff(&base_commit, "src/rustdoc-json-types") {
62+
match git_diff(&base_commit, src_path.join("rustdoc-json-types")) {
6063
Some(output) => {
6164
let mut format_version_updated = false;
6265
let mut latest_feature_comment_updated = false;

0 commit comments

Comments
 (0)