diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-06-20 15:02:15 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-06-20 15:49:47 +0200 |
| commit | 636769490445a477746a1242e40fa11b633388a5 (patch) | |
| tree | c83bdc4996c4df69287a0ae66bd854913c96583a | |
| parent | bbe8a2ad19c0486986a535c103e57fabfbb81441 (diff) | |
| download | rust-636769490445a477746a1242e40fa11b633388a5.tar.gz rust-636769490445a477746a1242e40fa11b633388a5.zip | |
Pass `src_path` to rustdoc_json tidy check
| -rw-r--r-- | src/tools/tidy/src/main.rs | 2 | ||||
| -rw-r--r-- | src/tools/tidy/src/rustdoc_json.rs | 22 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 420260a97a0..0b66017b865 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -110,7 +110,7 @@ fn main() { check!(rustdoc_css_themes, &librustdoc_path); check!(rustdoc_templates, &librustdoc_path); check!(rustdoc_js, &librustdoc_path, &tools_path, &src_path); - check!(rustdoc_json); + check!(rustdoc_json, &src_path); check!(known_bug, &crashes_path); check!(unknown_revision, &tests_path); diff --git a/src/tools/tidy/src/rustdoc_json.rs b/src/tools/tidy/src/rustdoc_json.rs index 3f78d565deb..808341fbd06 100644 --- a/src/tools/tidy/src/rustdoc_json.rs +++ b/src/tools/tidy/src/rustdoc_json.rs @@ -1,18 +1,20 @@ //! Tidy check to ensure that `FORMAT_VERSION` was correctly updated if `rustdoc-json-types` was //! updated as well. +use std::ffi::OsStr; +use std::path::Path; use std::process::Command; use build_helper::ci::CiEnv; use build_helper::git::{GitConfig, get_closest_upstream_commit}; use build_helper::stage0_parser::parse_stage0_file; -fn git_diff(base_commit: &str, extra_arg: &str) -> Option<String> { +fn git_diff<S: AsRef<OsStr>>(base_commit: &str, extra_arg: S) -> Option<String> { let output = Command::new("git").arg("diff").arg(base_commit).arg(extra_arg).output().ok()?; Some(String::from_utf8_lossy(&output.stdout).into()) } -pub fn check(bad: &mut bool) { +pub fn check(src_path: &Path, bad: &mut bool) { println!("Checking tidy rustdoc_json..."); let stage0 = parse_stage0_file(); let base_commit = match get_closest_upstream_commit( @@ -26,13 +28,13 @@ pub fn check(bad: &mut bool) { Ok(Some(commit)) => commit, Ok(None) => { *bad = true; - eprintln!("No base commit found, skipping rustdoc_json check"); + eprintln!("error: no base commit found for rustdoc_json check"); return; } Err(error) => { *bad = true; eprintln!( - "Failed to retrieve base commit for rustdoc_json check because of `{error}`, skipping it" + "error: failed to retrieve base commit for rustdoc_json check because of `{error}`" ); return; } @@ -46,17 +48,18 @@ pub fn check(bad: &mut bool) { .any(|line| line.starts_with("M") && line.contains("src/rustdoc-json-types")) { // `rustdoc-json-types` was not modified so nothing more to check here. + println!("`rustdoc-json-types` was not modified."); return; } } None => { *bad = true; - eprintln!("Failed to run `git diff`"); + eprintln!("error: failed to run `git diff` in rustdoc_json check"); return; } } // Then we check that if `FORMAT_VERSION` was updated, the `Latest feature:` was also updated. - match git_diff(&base_commit, "src/rustdoc-json-types") { + match git_diff(&base_commit, src_path.join("rustdoc-json-types")) { Some(output) => { let mut format_version_updated = false; let mut latest_feature_comment_updated = false; @@ -71,19 +74,18 @@ pub fn check(bad: &mut bool) { *bad = true; if latest_feature_comment_updated { eprintln!( - "`Latest feature` comment was updated whereas `FORMAT_VERSION` wasn't" + "error: `Latest feature` comment was updated whereas `FORMAT_VERSION` wasn't" ); } else { eprintln!( - "`Latest feature` comment was not updated whereas `FORMAT_VERSION` was" + "error: `Latest feature` comment was not updated whereas `FORMAT_VERSION` was" ); } } } None => { *bad = true; - eprintln!("Failed to run `git diff`"); - return; + eprintln!("error: failed to run `git diff` in rustdoc_json check"); } } } |
