Uh oh!
There was an error while loading. Please reload this page.
Add new optional tidy check to check if ftl error messages are unused - #147191
Add new optional tidy check to check if ftl error messages are unused#147191GuillaumeGomez wants to merge 3 commits into
Conversation
rustbot
commented
Sep 30, 2025
Some changes occurred in compiler/rustc_attr_parsing Some changes occurred to the CTFE machinery
|
bjorn3
commented
Sep 30, 2025
rust/compiler/rustc_attr_parsing/messages.ftl Lines 208 to 210 in a2db928 |
GuillaumeGomez
commented
Sep 30, 2025
Now I'm worried. 👀 |
GuillaumeGomez
commented
Sep 30, 2025
Ah the message error ID you displayed is |
bjorn3
commented
Sep 30, 2025
I would expect the |
GuillaumeGomez
commented
Sep 30, 2025
Oh I see. Definitely didn't expect that. Ok, gonna remove the warning then. |
fee0716 to
13bd4c7CompareYeah 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.
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
|
GuillaumeGomez
commented
Sep 30, 2025
It definitely seems to check what this PR does, except it apparently doesn't work? Well, if confirmed then I'll remove |
lolbinarycat
commented
Sep 30, 2025
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 |
Kobzol
commented
Sep 30, 2025
Yeah I think that this can be just a normal check that runs everytime. Unless it's super expensive for some reason. |
GuillaumeGomez
commented
Sep 30, 2025
Well, it run a regex on all compiler source code, so takes ~2 seconds on my machine. |
lolbinarycat
commented
Sep 30, 2025
just call |
GuillaumeGomez
commented
Sep 30, 2025
😮 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 🤔 |
mu001999
commented
Sep 30, 2025
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 |
RalfJung
commented
Oct 1, 2025
Yeah, apparently. Looks like @mu001999 did that. :) |
GuillaumeGomez
commented
Oct 1, 2025
Let's close this PR once the fix for the existing code is open then. :) |
Tidy: revert `flt` to `ftl` As was explained here #147191 (comment), this reverting this change because `flt` is incorrect format Also maybe there is existed PR for that? I didn't found one Follow up #147191 cc `@GuillaumeGomez`
Kivooeo
commented
Oct 5, 2025
Fix just landed, so it should be possible to continue working on it |
bors
commented
Oct 5, 2025
☔ The latest upstream changes (presumably #147345) made this pull request unmergeable. Please resolve the merge conflicts. |
GuillaumeGomez
commented
Oct 6, 2025
Seems like your fix covers everything I did here so even better: closing it. :) |
…ments, r=kobzol Fluent tidy improvements Follow-up of rust-lang#147345 and of rust-lang#147191. It uses `fluent_syntax` to parse `fluent` files (but not for blessing, not even sure how the current one works). I also added an `assert` to ensure we never go to previous situation where the `fluent` files were actually not checked at all. cc `@Kivooeo` r? kobzol
…ments, r=kobzol Fluent tidy improvements Follow-up of rust-lang#147345 and of rust-lang#147191. It uses `fluent_syntax` to parse `fluent` files (but not for blessing, not even sure how the current one works). I also added an `assert` to ensure we never go to previous situation where the `fluent` files were actually not checked at all. cc ``@Kivooeo`` r? kobzol
davidtwco
commented
Oct 7, 2025
My recollection is that for anything that derives |
Rollup merge of #147396 - GuillaumeGomez:fluent-tidy-improvements, r=kobzol Fluent tidy improvements Follow-up of #147345 and of #147191. It uses `fluent_syntax` to parse `fluent` files (but not for blessing, not even sure how the current one works). I also added an `assert` to ensure we never go to previous situation where the `fluent` files were actually not checked at all. cc ``@Kivooeo`` r? kobzol
…kobzol Fluent tidy improvements Follow-up of rust-lang/rust#147345 and of rust-lang/rust#147191. It uses `fluent_syntax` to parse `fluent` files (but not for blessing, not even sure how the current one works). I also added an `assert` to ensure we never go to previous situation where the `fluent` files were actually not checked at all. cc ``@Kivooeo`` r? kobzol
…kobzol Fluent tidy improvements Follow-up of rust-lang/rust#147345 and of rust-lang/rust#147191. It uses `fluent_syntax` to parse `fluent` files (but not for blessing, not even sure how the current one works). I also added an `assert` to ensure we never go to previous situation where the `fluent` files were actually not checked at all. cc ``@Kivooeo`` r? kobzol
Tidy: revert `flt` to `ftl` As was explained here rust-lang/rust#147191 (comment), this reverting this change because `flt` is incorrect format Also maybe there is existed PR for that? I didn't found one Follow up rust-lang/rust#147191 cc `@GuillaumeGomez`
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
ftlfiles, 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