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

Display help message when fluent arg was referenced incorrectly #104217

Merged
merged 1 commit into from
Nov 11, 2022

Conversation

Noratrieb
Copy link
Member

@Noratrieb Noratrieb commented Nov 9, 2022

The fluent argument syntax is a little special and easy to get wrong, so we emit a small help message when someone gets it wrong.

Example:

parser_mismatched_closing_delimiter = mismatched closing delimiter: `${delimiter}`

panics with

thread 'rustc' panicked at 'Encountered errors while formatting message for `parser_mismatched_closing_delimiter`
help: Argument `delimiter` exists but was not referenced correctly. Try using `{$delimiter}` instead
attr: `None`
args: `FluentArgs([("delimiter", String("}"))])`
errors: `[ResolverError(Reference(Message { id: "delimiter", attribute: None }))]`', compiler/rustc_errors/src/translation.rs:123:21

fixes #103539

The fluent argument syntax is a little special and easy to get wrong, so
we emit a small help message when someone gets it wrong.

Example:
```
parser_mismatched_closing_delimiter = mismatched closing delimiter: `${delimiter}`
```
panics with
```
thread 'rustc' panicked at 'Encountered errors while formatting message for `parser_mismatched_closing_delimiter`
help: Argument `delimiter` exists but was not referenced correctly. Try using `{$delimiter}` instead
attr: `None`
args: `FluentArgs([("delimiter", String("}"))])`
errors: `[ResolverError(Reference(Message { id: "delimiter", attribute: None }))]`', compiler/rustc_errors/src/translation.rs:123:21
```
@rustbot
Copy link
Collaborator

rustbot commented Nov 9, 2022

r? @TaKO8Ki

(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 Nov 9, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 9, 2022

rustc_errors::translation was changed

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

rustc_error_messages was changed

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

@TaKO8Ki
Copy link
Member

TaKO8Ki commented Nov 11, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 11, 2022

📌 Commit bd3c4fb has been approved by TaKO8Ki

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 Nov 11, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Nov 11, 2022
…aKO8Ki

Display help message when fluent arg was referenced incorrectly

The fluent argument syntax is a little special and easy to get wrong, so we emit a small help message when someone gets it wrong.

Example:
```
parser_mismatched_closing_delimiter = mismatched closing delimiter: `${delimiter}`
```
panics with
```
thread 'rustc' panicked at 'Encountered errors while formatting message for `parser_mismatched_closing_delimiter`
help: Argument `delimiter` exists but was not referenced correctly. Try using `{$delimiter}` instead
attr: `None`
args: `FluentArgs([("delimiter", String("}"))])`
errors: `[ResolverError(Reference(Message { id: "delimiter", attribute: None }))]`', compiler/rustc_errors/src/translation.rs:123:21
```

fixes rust-lang#103539
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 11, 2022
Rollup of 9 pull requests

Successful merges:

 - rust-lang#100633 (Consider `#[must_use]` annotation on `async fn` as also affecting the `Future::Output`)
 - rust-lang#103445 (`#[test]`: Point at return type if `Termination` bound is unsatisfied)
 - rust-lang#103924 (Fix broken link in description of error code E0706)
 - rust-lang#104146 (Retry binding TCP Socket in remote-test-server)
 - rust-lang#104169 (Migrate `:target` rules to use CSS variables)
 - rust-lang#104202 (Fix ICE rust-lang#103748)
 - rust-lang#104216 (Don't ICE on operator trait methods with generic methods)
 - rust-lang#104217 (Display help message when fluent arg was referenced incorrectly)
 - rust-lang#104245 (Reduce default configuration's dependency upon static libstdcpp library (rust-lang#103606))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6026785 into rust-lang:master Nov 11, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 11, 2022
@Noratrieb Noratrieb deleted the funny-dollar-syntax branch November 11, 2022 22:04
@Noratrieb Noratrieb restored the funny-dollar-syntax branch December 3, 2022 19:44
@Noratrieb Noratrieb deleted the funny-dollar-syntax branch December 23, 2022 21:04
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 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.

ICE when missing $ in front of a fluent variable
4 participants