errors: implement sysroot/testing bundle loading
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>
This commit is contained in:
parent
7f91697b50
commit
d5119c5b9f
23 changed files with 322 additions and 46 deletions
|
@ -21,6 +21,7 @@ use rustc_span::SourceFile;
|
|||
/// Generates diagnostics using annotate-snippet
|
||||
pub struct AnnotateSnippetEmitterWriter {
|
||||
source_map: Option<Lrc<SourceMap>>,
|
||||
fluent_bundle: Option<Lrc<FluentBundle>>,
|
||||
fallback_bundle: Lrc<FluentBundle>,
|
||||
|
||||
/// If true, hides the longer explanation text
|
||||
|
@ -63,7 +64,7 @@ impl Emitter for AnnotateSnippetEmitterWriter {
|
|||
}
|
||||
|
||||
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
|
||||
None
|
||||
self.fluent_bundle.as_ref()
|
||||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &Lrc<FluentBundle> {
|
||||
|
@ -99,11 +100,19 @@ fn annotation_type_for_level(level: Level) -> AnnotationType {
|
|||
impl AnnotateSnippetEmitterWriter {
|
||||
pub fn new(
|
||||
source_map: Option<Lrc<SourceMap>>,
|
||||
fluent_bundle: Option<Lrc<FluentBundle>>,
|
||||
fallback_bundle: Lrc<FluentBundle>,
|
||||
short_message: bool,
|
||||
macro_backtrace: bool,
|
||||
) -> Self {
|
||||
Self { source_map, fallback_bundle, short_message, ui_testing: false, macro_backtrace }
|
||||
Self {
|
||||
source_map,
|
||||
fluent_bundle,
|
||||
fallback_bundle,
|
||||
short_message,
|
||||
ui_testing: false,
|
||||
macro_backtrace,
|
||||
}
|
||||
}
|
||||
|
||||
/// Allows to modify `Self` to enable or disable the `ui_testing` flag.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue