-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Add new optional tidy check to check if ftl error messages are unused #147191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in compiler/rustc_attr_parsing Some changes occurred to the CTFE machinery
|
rust/compiler/rustc_attr_parsing/messages.ftl Lines 208 to 210 in a2db928
|
Now I'm worried. 👀 |
Ah the message error ID you displayed is |
I would expect the |
Oh I see. Definitely didn't expect that. Ok, gonna remove the warning then. |
fee0716
to
13bd4c7
Compare
Yeah the process for naming these "attributes" is quite surprising. It is partially documented at https://rustc-dev-guide.rust-lang.org/diagnostics/translation.html but nothing really explains how fluent message names are looked up, I think. IIRC it was something like, given Maybe @davidtwco can explain the rules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks all fluent messages, right? Many of them are not errors but lints. So something like "fluent_messages" or so is probably a better name for this module.
EDIT: There's already several checks called fluent_something
so fluent_messages
is probably not specific enough.
Also, what about the existing check in
|
It definitely seems to check what this PR does, except it apparently doesn't work? Well, if confirmed then I'll remove |
There's a few issues with this being an extra check:
the only advantage I see of this being an extra check is that it gets to be part of the same also, if this is to be an extra-check, it should have kind |
Yeah I think that this can be just a normal check that runs everytime. Unless it's super expensive for some reason. |
Well, it run a regex on all compiler source code, so takes ~2 seconds on my machine. |
just call |
😮 TIL, that'd be SO MUCH more efficient. Thanks for the tip! |
It tried to do the same thing and will check whether fluent msg is used only once or not. The rule is simple, if a fluent msg only appeared once in .flt files, it must be unused in rust. So based on this, there will be some false-negatives like using the fluent msg in the comment. But it should work at least for the first removed msg in this PR, I check it manually and it only appears once in .flt files. It's weird 🤔 |
Oh, I print the input of |
Found what is wrong 💥 #143724 changed the fluent file extension checking but had a typo 😂 cc @hkBst So After fixing this, things got fine, I got correct errors on my machine:
|
@mu001999 Oops, good catch. Strange that the extension for fluent is "ftl" and not "flt"... Apparently: "FTL stands for Fluent Translation List." -- https://github.com/projectfluent/fluent?tab=readme-ov-file#fluent-syntax-ftl |
Yeah, apparently. Looks like @mu001999 did that. :) |
Let's close this PR once the fix for the existing code is open then. :) |
I realized recently while removing a rustdoc feature that error messages could be unused and we apparently had no checks for that. This PR fills this void.
There is one unresolved question (likely due to my ignorance rather than an actual issue): we have (a lot of) error message IDs that are actually not anywhere in
ftl
files, likeattr_parsing_remove_neg_sugg
. Is it expected or not?In any case, there were unused error message IDs so I removed them in this PR as well.
cc @davidtwco
r? @Kobzol