Skip to content

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Sep 15, 2025

For some reason, tidy prints a bunch of stuff even when there's nothing to complain about. That's not great, it means there's a bunch of text one has to parse to understand if there's any errors hidden inside those messages.

With this patch, the output for me is

fmt check
fmt: checked modified file src/tools/tidy/src/error_codes.rs
fmt: checked modified file src/tools/tidy/src/rustdoc_json.rs
tidy check
Checking tidy rustdoc_json...
x.py completions check

Do these lines saying what is being checked make sense? I kept them for now because it may be that the error messages are hard to parse without that context, though ideally the errors would all establish this context themselves.

Do we really need to list all files that are being formatted?

@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Sep 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 15, 2025

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@jieyouxu
Copy link
Member

See also #146316

@jieyouxu
Copy link
Member

I think I would be very much in favor of somehow making this easier to tell what's "INFO"-level versus what's "WARN"/"ERROR"-level.

r? Kobzol (won't get to this during weekday)

@rustbot rustbot assigned Kobzol and unassigned jieyouxu Sep 15, 2025
@RalfJung RalfJung mentioned this pull request Sep 15, 2025
@Kobzol
Copy link
Member

Kobzol commented Sep 15, 2025

It's funny that we have just discussed this exact thing last week in #146316 😆 As was noted there, the output that something was (or was not) checked is actually useful, because tidy can do various optional things and it's not always obvious if it did check something successfully or if that check was actually skipped.

I think that an ideal solution would be to use some more comprehensive logging system in tidy, which would make it obvious where the individual checks start and end, and what is their conclusion. But that would be more work, ofc.

A temporary solution might be to print a big green "EVERYTHING IS FINE" message when tidy ends successfully. Would that help you understand what is the outcome of tidy execution?

@RalfJung
Copy link
Member Author

RalfJung commented Sep 15, 2025

This PR doesn't remove the lines that say "checking x...". But it removes the lines saying "X was not changed", which is an entirely pointless thing to say IMO. We also don't list all the files that did not get changed and hence don't have their format checked (for obvious reasons, but the same reasons apply for the other checks as well IMO).

This seems separate from the question of how to format the various "checking foo..." messages -- I think the output of our test harness is a good template for that, but obviously making that all consistent is a bunch of work.

@Kobzol
Copy link
Member

Kobzol commented Sep 15, 2025

That specific message is there because tidy has essentially three modes for doing optional checks - don't check, check always, and check only if the input files were modified. So ideally, it should print something like "check disabled" vs "check skipped" to make it clear that the files weren't completely ignored.

@GuillaumeGomez Do you find the information that the rustdoc files were not modified valuable enough to keep it in tidy, even though it's a bit spammy?

@RalfJung
Copy link
Member Author

Everyone is seeing those messages, and 99% of the time people aren't even aware what those rustdoc files do.

In which sense is that check even optional? I didn't enable it, it seems to be on-by-default.

If you want to know when it ran on a file, have it print the files it works on (similar to what fmt already does). That way it's only verbose in the rare case that someone actually changed the file.

@Kobzol
Copy link
Member

Kobzol commented Sep 15, 2025

Implemented #146592 to solve this in a more structured way.

@RalfJung
Copy link
Member Author

Wow, that's huge! I'll close this one then. Thanks a ton :-)

@RalfJung RalfJung closed this Sep 15, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 15, 2025
@GuillaumeGomez
Copy link
Member

@GuillaumeGomez Do you find the information that the rustdoc files were not modified valuable enough to keep it in tidy, even though it's a bit spammy?

I need to know that it was at least checked that there was nothing to check (ie, no rustdoc file modified). Otherwise it's hard to know whether the files are now ignored by tidy or if they're actually ignored for a good reason.

@RalfJung
Copy link
Member Author

RalfJung commented Sep 18, 2025

I don't see why rustdoc would be so special that everyone needs to be constantly reminded that they did, in fact, not change rustdoc. We also don't do this for all the other things tidy checks.

@GuillaumeGomez
Copy link
Member

I don't think that rustdoc is special but that the others that aren't checked all the time should also mention that there is nothing to be checked for them.

@RalfJung
Copy link
Member Author

RalfJung commented Sep 18, 2025

No, they shouldn't. That just doesn't scale. We can fill entire screens with all the things we are not checking.

Why would tidy forget to check these files when they do get changed? Are you expecting someone to break tidy's logic or so? We have tests and reviews for that. But nowhere else do we give such a detailed trace of what something does out of paranoia that it might change one day. Again, just imagine rustc or Miri or clippy worked like that. They'd be entirely unusable.

@GuillaumeGomez
Copy link
Member

Well, considering how many times these tests broke because files were moved/renamed, I don't think it's paranoia, just carefulness. You'll note that we don't display each rustdoc file that is ignored, just that a rustdoc tidy check was skipped. A few lines of output is fine.

@RalfJung
Copy link
Member Author

RalfJung commented Sep 18, 2025

A few lines of output is fine.

Tragedy of the commons. A few lines of output in your own pet tool only you use is fine. A few lines of output in large shared infrastructure, multiplied by a dozen projects each adding a few lines of output, is a mess. The only reason it's not a mess yet is that everyone else kept their checks quiet.

The fact that two team members independently went so far as to actually make a PR to cut down the output should make it clear that there's a real concern here.

@GuillaumeGomez
Copy link
Member

Sure, but how many lines are we talking about exactly here?

@Kobzol
Copy link
Member

Kobzol commented Sep 19, 2025

I think that a reasonable compromise might be to only print this line if the auto mode was used for JS files, which should be easily doable after #146592 lands. I think that could alleviate both concerns.

@GuillaumeGomez
Copy link
Member

That sounds like an acceptable compromise indeed. 👍

@RalfJung
Copy link
Member Author

I'm looking forward to #146592. :)

bors added a commit that referenced this pull request Sep 21, 2025
Implement a simple diagnostic system for tidy

In #146316 and #146580, contributors independently wanted to reduce the verbose output of tidy. But before, the output was quite ad-hoc, so it was not easy to control it.

In this PR, I implemented a simple diagnostic system for tidy, which allows us to:
1) Only print certain information in verbose mode (`-v`)
2) Associate each (error) output to a specific check, so that it is easier to find out what exactly has failed and which check you might want to examine (not fully done, there are some random `println`s left, but most output should be scoped to a specific check)
3) Print output with colors, based on the message level (message, warning, error)
4) Show the start/end execution of each check in verbose mode, for better progress indication

Failure output:
<img width="1134" height="157" alt="image" src="https://github.com/user-attachments/assets/578a9302-e1c2-47e5-9370-a3556c49d9fc" />

Success output:
<img width="388" height="113" alt="image" src="https://github.com/user-attachments/assets/cf27faf8-3d8b-49e3-88d0-fac27a9c36a8" />

Verbose output (shortened):
<img width="380" height="158" alt="image" src="https://github.com/user-attachments/assets/ce7102b8-c2f3-42a8-a2ec-ca30389be91e" />

CC `@nnethercote` `@RalfJung` `@GuillaumeGomez`

The first two commits and the last commit are interesting, the rest is just mechanical port of the code from `bad: &mut bool` to `DiagCtx` and `RunningCheck`.

The `extra_checks` check could be further split, but I'd leave that for another PR.

r? `@jieyouxu`
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Sep 24, 2025
Implement a simple diagnostic system for tidy

In rust-lang#146316 and rust-lang#146580, contributors independently wanted to reduce the verbose output of tidy. But before, the output was quite ad-hoc, so it was not easy to control it.

In this PR, I implemented a simple diagnostic system for tidy, which allows us to:
1) Only print certain information in verbose mode (`-v`)
2) Associate each (error) output to a specific check, so that it is easier to find out what exactly has failed and which check you might want to examine (not fully done, there are some random `println`s left, but most output should be scoped to a specific check)
3) Print output with colors, based on the message level (message, warning, error)
4) Show the start/end execution of each check in verbose mode, for better progress indication

Failure output:
<img width="1134" height="157" alt="image" src="https://github.com/user-attachments/assets/578a9302-e1c2-47e5-9370-a3556c49d9fc" />

Success output:
<img width="388" height="113" alt="image" src="https://github.com/user-attachments/assets/cf27faf8-3d8b-49e3-88d0-fac27a9c36a8" />

Verbose output (shortened):
<img width="380" height="158" alt="image" src="https://github.com/user-attachments/assets/ce7102b8-c2f3-42a8-a2ec-ca30389be91e" />

CC `@nnethercote` `@RalfJung` `@GuillaumeGomez`

The first two commits and the last commit are interesting, the rest is just mechanical port of the code from `bad: &mut bool` to `DiagCtx` and `RunningCheck`.

The `extra_checks` check could be further split, but I'd leave that for another PR.

r? `@jieyouxu`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tidy Area: The tidy tool T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants