about summary refs log tree commit diff
path: root/compiler/rustc_error_messages/src
AgeCommit message (Collapse)AuthorLines
2022-04-13errors: lazily load fallback fluent bundleDavid Wood-11/+29
Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-12sess: try sysroot candidates for fluent bundleDavid Wood-30/+39
Instead of checking only the user provided sysroot or the default (when no sysroot is provided), search user provided sysroot and then check default sysroots for locale requested by the user. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: support fluent + parallel compilerDavid Wood-3/+18
Conditional on the parallel compiler being enabled, use a different `IntlLangMemoizer` which supports being sent between threads in `FluentBundle`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: use `impl Into<FluentId>`David Wood-5/+2
`FluentId` is the type alias that is used everywhere else so it should be used here too so that this doesn't need updated if the alias changes. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05session: opt for enabling directionality markersDavid Wood-3/+6
Add an option for enabling and disabling Fluent's directionality isolation markers in output. Disabled by default as these can render in some terminals and applications. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: add links to fluent documentationDavid Wood-1/+5
Add some links to the Fluent documentation to `DiagnosticMessage::FluentIdentifier` which explain what a Fluent message and attribute are. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: don't try load default locale from sysrootDavid Wood-3/+9
If the user requests a diagnostic locale of "en-US" then it doesn't make sense to try and load that from the `$sysroot` because it is just the default built-in locale. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: disable directionality isolation markersDavid Wood-0/+9
Fluent diagnostics can insert directionality isolation markers around interpolated variables indicating that there may be a shift from right-to-left to left-to-right text (or vice-versa). These are disabled because they are sometimes visible in the error output, but may be worth investigating in future (for example: if type names are left-to-right and the surrounding diagnostic messages are right-to-left, then these might be helpful). Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement sysroot/testing bundle loadingDavid Wood-11/+156
Extend loading of Fluent bundles so that bundles can be loaded from the sysroot based on the language requested by the user, or using a nightly flag. Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement fallback diagnostic translationDavid Wood-17/+57
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05span: move `MultiSpan`David Wood-0/+171
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>