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

Validate fluent variable references in tests #111269

Merged
merged 3 commits into from
Jun 28, 2023

Conversation

clubby789
Copy link
Contributor

@clubby789 clubby789 commented May 5, 2023

Closes #101109

Under cfg(test), the fluent_messages macro will emit a list of variables referenced by each message and its attributes. The derive attribute will now emit a #[test] that checks that each referenced variable exists in the structure it's applied to.

@rustbot
Copy link
Collaborator

rustbot commented May 5, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 5, 2023
@rustbot
Copy link
Collaborator

rustbot commented May 5, 2023

rustc_macros::diagnostics was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @TaKO8Ki

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@clubby789
Copy link
Contributor Author

clubby789 commented May 5, 2023

Hmm, doesn't work right now if the message is part of a subdiagnostic that defines the variable.
I'll exclude structs with subdiagnostics for now, then fix and add tests for the existing errors

@clubby789 clubby789 force-pushed the validate-fluent-variables branch 2 times, most recently from f9cf57c to f4b9a1a Compare May 5, 2023 23:40
@rust-log-analyzer

This comment has been minimized.

@clubby789 clubby789 added the D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. label May 17, 2023
@cjgillot
Copy link
Contributor

Why gate on debug_assertions? The only code changes are in macros and generated unit tests, so there is nothing that make the runtime slower.

@clubby789
Copy link
Contributor Author

I didn't want to have the macro always generate code that would only be used in tests. I guess I could instead just make sure that everything emitted by the macro is cfg(test)'d

@bors

This comment was marked as resolved.

@rust-cloud-vms rust-cloud-vms bot force-pushed the validate-fluent-variables branch 2 times, most recently from 3360cb5 to 003ae4c Compare May 26, 2023 10:44
@clubby789 clubby789 changed the title Validate fluent variable references with debug_assertions Validate fluent variable references in tests May 26, 2023
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay in reviewing here - I like this, but is it possible to add a test for these new tests? Something that confirms a diagnostic struct without the correct variables will have an error?

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 27, 2023

📌 Commit 8969d97 has been approved by davidtwco

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 27, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 28, 2023
…s, r=davidtwco

Validate fluent variable references in tests

Closes rust-lang#101109

Under `cfg(test)`, the `fluent_messages` macro will emit a list of variables referenced by each message and its attributes. The derive attribute will now emit a `#[test]` that checks that each referenced variable exists in the structure it's applied to.
@bors
Copy link
Contributor

bors commented Jun 28, 2023

⌛ Testing commit 8969d97 with merge 08fd6f7...

@bors
Copy link
Contributor

bors commented Jun 28, 2023

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing 08fd6f7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 28, 2023
@bors bors merged commit 08fd6f7 into rust-lang:master Jun 28, 2023
11 checks passed
@rustbot rustbot added this to the 1.72.0 milestone Jun 28, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (08fd6f7): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.3% [1.3%, 1.3%] 1
Regressions ❌
(secondary)
2.8% [2.8%, 2.8%] 1
Improvements ✅
(primary)
-3.5% [-4.5%, -2.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.9% [-4.5%, 1.3%] 3

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.9% [1.1%, 3.2%] 4
Regressions ❌
(secondary)
5.2% [2.4%, 9.4%] 12
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.9% [1.1%, 3.2%] 4

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 662s -> 662.942s (0.14%)

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. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add check for variables in Diagnostic
8 participants