Skip to content
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

Unused Fluent messages lint #110754

Open
davidtwco opened this issue Apr 24, 2023 · 6 comments
Open

Unused Fluent messages lint #110754

davidtwco opened this issue Apr 24, 2023 · 6 comments
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@davidtwco
Copy link
Member

davidtwco commented Apr 24, 2023

Inspired by #110597 - we should add a check for unused Fluent messages.

@davidtwco davidtwco added the A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic label Apr 24, 2023
@est31
Copy link
Member

est31 commented Apr 24, 2023

@rustbot claim

Basically, one would need to: traverse the directories, parse the ftl files, and for each ftl file found, determine if the fluent messages contained are either used internally, or used somewhere else inside the compiler. This can work on a simple token/word level, as using syn in tidy isn't really an option, as the compiler uses unstable syntax.

@tgross35
Copy link
Contributor

Something like this was noticed in #127935 - we had two labels called .note and only one was printing.

@est31
Copy link
Member

est31 commented Jul 20, 2024

Unassigning myself as I didn't find the time for it.

@tgross35
Copy link
Contributor

tgross35 commented Jul 20, 2024

An easier way might be to accept a BOOTSTRAP_FLUENT_OUTPUT_PATH env and, if set, the proc macros append the used keys with spans to that file after completing (just a simple JSON template or something). Then tidy can just diff what's there against the fluent files.

Possibly less robust I guess, but bootstrap has pretty good control over the environment. And tracked_env / tracked_path help.

@jieyouxu
Copy link
Member

cc #132181

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. labels Dec 25, 2024
@clubby789
Copy link
Contributor

iirc I did work on this previously by just making the fluent constants pub(crate). I dropped it as there were a couple of diagnostic messages used cross-crate that I didn't want to rework, but at the time there were no violations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants