diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2025-06-19 13:02:04 -0500 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2025-06-19 13:02:04 -0500 |
| commit | 07b9bb1855596ac84a80d898b40c4b403f1dcc3f (patch) | |
| tree | ddcf02a1bb7f17cdfa8c0b638977c28ca6acef0c /compiler/rustc_session/src/parse.rs | |
| parent | 8de4c7234dd9b97c9d76b58671343fdbbc9a433e (diff) | |
| download | rust-07b9bb1855596ac84a80d898b40c4b403f1dcc3f.tar.gz rust-07b9bb1855596ac84a80d898b40c4b403f1dcc3f.zip | |
Extract Translator struct
Diffstat (limited to 'compiler/rustc_session/src/parse.rs')
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 87c848cf857..30a61cb411b 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -9,9 +9,10 @@ use rustc_ast::node_id::NodeId; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::sync::{AppendOnlyVec, Lock}; use rustc_errors::emitter::{HumanEmitter, SilentEmitter, stderr_destination}; +use rustc_errors::translation::Translator; use rustc_errors::{ ColorConfig, Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, EmissionGuarantee, MultiSpan, - StashKey, fallback_fluent_bundle, + StashKey, }; use rustc_feature::{GateIssue, UnstableFeatures, find_feature_issue}; use rustc_span::edition::Edition; @@ -242,10 +243,10 @@ pub struct ParseSess { impl ParseSess { /// Used for testing. pub fn new(locale_resources: Vec<&'static str>) -> Self { - let fallback_bundle = fallback_fluent_bundle(locale_resources, false); + let translator = Translator::with_fallback_bundle(locale_resources, false); let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); let emitter = Box::new( - HumanEmitter::new(stderr_destination(ColorConfig::Auto), fallback_bundle) + HumanEmitter::new(stderr_destination(ColorConfig::Auto), translator) .sm(Some(Arc::clone(&sm))), ); let dcx = DiagCtxt::new(emitter); @@ -277,12 +278,13 @@ impl ParseSess { pub fn with_silent_emitter( locale_resources: Vec<&'static str>, fatal_note: String, + emit_fatal_diagnostic: bool, ) -> Self { - let fallback_bundle = fallback_fluent_bundle(locale_resources, false); + let translator = Translator::with_fallback_bundle(locale_resources, false); let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); let fatal_emitter = - Box::new(HumanEmitter::new(stderr_destination(ColorConfig::Auto), fallback_bundle)); + Box::new(HumanEmitter::new(stderr_destination(ColorConfig::Auto), translator)); let dcx = DiagCtxt::new(Box::new(SilentEmitter { fatal_emitter, fatal_note: Some(fatal_note), |
