summaryrefslogtreecommitdiff
path: root/compiler/rustc_driver
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2022-03-26 07:27:43 +0000
committerDavid Wood <david.wood@huawei.com>2022-04-05 07:01:02 +0100
commit7f91697b5035f8620df4de47057024c3539b55a6 (patch)
treea7f6e303b30ec5b3d675c362d474e1de0f3419ad /compiler/rustc_driver
parentc45f29595df6f6a178b7998bc33c76099f3c12b7 (diff)
downloadrust-7f91697b5035f8620df4de47057024c3539b55a6.tar.gz
errors: implement fallback diagnostic translation
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.
Diffstat (limited to 'compiler/rustc_driver')
-rw-r--r--compiler/rustc_driver/src/lib.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs
index 69f96d07f90..c95c59904d1 100644
--- a/compiler/rustc_driver/src/lib.rs
+++ b/compiler/rustc_driver/src/lib.rs
@@ -1172,9 +1172,11 @@ static DEFAULT_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send +
/// When `install_ice_hook` is called, this function will be called as the panic
/// hook.
pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
+ let fallback_bundle = rustc_errors::fallback_fluent_bundle();
let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
rustc_errors::ColorConfig::Auto,
None,
+ fallback_bundle,
false,
false,
None,
@@ -1209,7 +1211,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
}
for note in &xs {
- handler.note_without_error(note);
+ handler.note_without_error(note.as_ref());
}
// If backtraces are enabled, also print the query stack