@@ -26,7 +26,7 @@ use std::{fmt, fs, io};
2626use build_helper:: git:: get_git_untracked_files;
2727
2828use crate :: diagnostics:: DiagCtx ;
29- use crate :: { CiInfo , TidyFlags } ;
29+ use crate :: { CiInfo , TidyCtx } ;
3030
3131mod rustdoc_js;
3232
@@ -56,7 +56,7 @@ pub fn check(
5656 cargo : & Path ,
5757 extra_checks : Option < & str > ,
5858 pos_args : & [ String ] ,
59- tidy_flags : TidyFlags ,
59+ tidy_ctx : Option < & TidyCtx > ,
6060 diag_ctx : DiagCtx ,
6161) {
6262 let mut check = diag_ctx. start_check ( "extra_checks" ) ;
@@ -71,7 +71,7 @@ pub fn check(
7171 cargo,
7272 extra_checks,
7373 pos_args,
74- tidy_flags ,
74+ tidy_ctx ,
7575 ) {
7676 check. error ( e) ;
7777 }
@@ -87,10 +87,11 @@ fn check_impl(
8787 cargo : & Path ,
8888 extra_checks : Option < & str > ,
8989 pos_args : & [ String ] ,
90- tidy_flags : TidyFlags ,
90+ tidy_ctx : Option < & TidyCtx > ,
9191) -> Result < ( ) , Error > {
9292 let show_diff =
9393 std:: env:: var ( "TIDY_PRINT_DIFF" ) . is_ok_and ( |v| v. eq_ignore_ascii_case ( "true" ) || v == "1" ) ;
94+ let bless = tidy_ctx. map ( |flags| flags. bless ) . unwrap_or ( false ) ;
9495
9596 // Split comma-separated args up
9697 let mut lint_args = match extra_checks {
@@ -130,7 +131,7 @@ fn check_impl(
130131 }
131132
132133 let rerun_with_bless = |mode : & str , action : & str | {
133- if !tidy_flags . bless {
134+ if !bless {
134135 eprintln ! ( "rerun tidy with `--extra-checks={mode} --bless` to {action}" ) ;
135136 }
136137 } ;
@@ -159,7 +160,7 @@ fn check_impl(
159160
160161 if python_lint {
161162 let py_path = py_path. as_ref ( ) . unwrap ( ) ;
162- let args: & [ & OsStr ] = if tidy_flags . bless {
163+ let args: & [ & OsStr ] = if bless {
163164 eprintln ! ( "linting python files and applying suggestions" ) ;
164165 & [ "check" . as_ref ( ) , "--fix" . as_ref ( ) ]
165166 } else {
@@ -169,7 +170,7 @@ fn check_impl(
169170
170171 let res = run_ruff ( root_path, outdir, py_path, & cfg_args, & file_args, args) ;
171172
172- if res. is_err ( ) && show_diff && !tidy_flags . bless {
173+ if res. is_err ( ) && show_diff && !bless {
173174 eprintln ! ( "\n python linting failed! Printing diff suggestions:" ) ;
174175
175176 let diff_res = run_ruff (
@@ -191,7 +192,7 @@ fn check_impl(
191192
192193 if python_fmt {
193194 let mut args: Vec < & OsStr > = vec ! [ "format" . as_ref( ) ] ;
194- if tidy_flags . bless {
195+ if bless {
195196 eprintln ! ( "formatting python files" ) ;
196197 } else {
197198 eprintln ! ( "checking python file formatting" ) ;
@@ -201,7 +202,7 @@ fn check_impl(
201202 let py_path = py_path. as_ref ( ) . unwrap ( ) ;
202203 let res = run_ruff ( root_path, outdir, py_path, & cfg_args, & file_args, & args) ;
203204
204- if res. is_err ( ) && !tidy_flags . bless {
205+ if res. is_err ( ) && !bless {
205206 if show_diff {
206207 eprintln ! ( "\n python formatting does not match! Printing diff:" ) ;
207208
@@ -227,7 +228,7 @@ fn check_impl(
227228 let config_path = root_path. join ( ".clang-format" ) ;
228229 let config_file_arg = format ! ( "file:{}" , config_path. display( ) ) ;
229230 cfg_args_clang_format. extend ( & [ "--style" . as_ref ( ) , config_file_arg. as_ref ( ) ] ) ;
230- if tidy_flags . bless {
231+ if bless {
231232 eprintln ! ( "formatting C++ files" ) ;
232233 cfg_args_clang_format. push ( "-i" . as_ref ( ) ) ;
233234 } else {
@@ -247,7 +248,7 @@ fn check_impl(
247248 let args = merge_args ( & cfg_args_clang_format, & file_args_clang_format) ;
248249 let res = py_runner ( py_path. as_ref ( ) . unwrap ( ) , false , None , "clang-format" , & args) ;
249250
250- if res. is_err ( ) && show_diff && !tidy_flags . bless {
251+ if res. is_err ( ) && show_diff && !bless {
251252 eprintln ! ( "\n clang-format linting failed! Printing diff suggestions:" ) ;
252253
253254 let mut cfg_args_clang_format_diff = cfg_args. clone ( ) ;
@@ -312,7 +313,7 @@ fn check_impl(
312313
313314 args. extend_from_slice ( SPELLCHECK_DIRS ) ;
314315
315- if tidy_flags . bless {
316+ if bless {
316317 eprintln ! ( "spellchecking files and fixing typos" ) ;
317318 args. push ( "--write-changes" ) ;
318319 } else {
@@ -330,17 +331,17 @@ fn check_impl(
330331 }
331332
332333 if js_lint {
333- if tidy_flags . bless {
334+ if bless {
334335 eprintln ! ( "linting javascript files" ) ;
335336 } else {
336337 eprintln ! ( "linting javascript files and applying suggestions" ) ;
337338 }
338- let res = rustdoc_js:: lint ( outdir, librustdoc_path, tools_path, tidy_flags ) ;
339+ let res = rustdoc_js:: lint ( outdir, librustdoc_path, tools_path, tidy_ctx ) ;
339340 if res. is_err ( ) {
340341 rerun_with_bless ( "js:lint" , "apply eslint suggestions" ) ;
341342 }
342343 res?;
343- rustdoc_js:: es_check ( outdir, librustdoc_path, tidy_flags ) ?;
344+ rustdoc_js:: es_check ( outdir, librustdoc_path, tidy_ctx ) ?;
344345 }
345346
346347 if js_typecheck {
0 commit comments