Skip to content

Commit 0db0acd

Browse files
Remove the fallback bundle
1 parent 2289e6c commit 0db0acd

15 files changed

Lines changed: 25 additions & 56 deletions

File tree

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,9 @@ use crate::session_diagnostics::{
108108
};
109109

110110
pub fn default_translator() -> Translator {
111-
Translator::with_fallback_bundle(DEFAULT_LOCALE_RESOURCES.to_vec(), false)
111+
Translator::new()
112112
}
113113

114-
pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[];
115-
116114
/// Exit status code used for successful compilation and help output.
117115
pub const EXIT_SUCCESS: i32 = 0;
118116

@@ -219,7 +217,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
219217
output_dir: odir,
220218
ice_file,
221219
file_loader: None,
222-
locale_resources: DEFAULT_LOCALE_RESOURCES.to_vec(),
223220
lint_caps: Default::default(),
224221
psess_created: None,
225222
hash_untracked_state: None,
@@ -1528,7 +1525,7 @@ fn report_ice(
15281525
extra_info: fn(&DiagCtxt),
15291526
using_internal_features: &AtomicBool,
15301527
) {
1531-
let translator = default_translator();
1528+
let translator = Translator::new();
15321529
let emitter =
15331530
Box::new(rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter::new(
15341531
stderr_destination(rustc_errors::ColorConfig::Auto),

compiler/rustc_errors/src/json/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
4545
rustc_span::create_default_session_globals_then(|| {
4646
let sm = Arc::new(SourceMap::new(FilePathMapping::empty()));
4747
sm.new_source_file(filename(&sm, "test.rs"), code.to_owned());
48-
let translator = Translator::with_fallback_bundle(vec![], false);
48+
let translator = Translator::new();
4949

5050
let output = Arc::new(Mutex::new(Vec::new()));
5151
let je = JsonEmitter::new(

compiler/rustc_errors/src/translation.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,11 @@ pub struct Translator {
3434
/// Localized diagnostics for the locale requested by the user. If no language was requested by
3535
/// the user then this will be `None` and `fallback_fluent_bundle` should be used.
3636
pub fluent_bundle: Option<Arc<FluentBundle>>,
37-
/// Return `FluentBundle` with localized diagnostics for the default locale of the compiler.
38-
/// Used when the user has not requested a specific language or when a localized diagnostic is
39-
/// unavailable for the requested locale.
40-
pub fallback_fluent_bundle: LazyFallbackBundle,
4137
}
4238

4339
impl Translator {
44-
pub fn with_fallback_bundle(
45-
resources: Vec<&'static str>,
46-
with_directionality_markers: bool,
47-
) -> Translator {
48-
Translator {
49-
fluent_bundle: None,
50-
fallback_fluent_bundle: crate::fallback_fluent_bundle(
51-
resources,
52-
with_directionality_markers,
53-
),
54-
}
40+
pub fn new() -> Translator {
41+
Translator { fluent_bundle: None }
5542
}
5643

5744
/// Convert `DiagMessage`s to a string, performing translation if necessary.

compiler/rustc_interface/src/interface.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,6 @@ pub struct Config {
332332
/// bjorn3 for "hooking rust-analyzer's VFS into rustc at some point for
333333
/// running rustc without having to save". (See #102759.)
334334
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
335-
/// The list of fluent resources, used for lints declared with
336-
/// [`Diagnostic`](rustc_errors::Diagnostic) and [`LintDiagnostic`](rustc_errors::LintDiagnostic).
337-
pub locale_resources: Vec<&'static str>,
338335

339336
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
340337

@@ -458,7 +455,6 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
458455
temps_dir,
459456
},
460457
bundle,
461-
config.locale_resources,
462458
config.lint_caps,
463459
target,
464460
util::rustc_version_str().unwrap_or("unknown"),

compiler/rustc_interface/src/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ where
7272
sessopts,
7373
io,
7474
None,
75-
vec![],
7675
Default::default(),
7776
target,
7877
"",

compiler/rustc_parse/src/parser/tests.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn string_to_parser(psess: &ParseSess, source_str: String) -> Parser<'_> {
4242
fn create_test_handler(theme: OutputTheme) -> (DiagCtxt, Arc<SourceMap>, Arc<Mutex<Vec<u8>>>) {
4343
let output = Arc::new(Mutex::new(Vec::new()));
4444
let source_map = Arc::new(SourceMap::new(FilePathMapping::empty()));
45-
let translator = Translator::with_fallback_bundle(vec![], false);
45+
let translator = Translator::new();
4646
let shared: Box<dyn Write + Send> = Box::new(Shared { data: output.clone() });
4747
let auto_stream = AutoStream::never(shared);
4848
let dcx = DiagCtxt::new(Box::new(
@@ -89,7 +89,7 @@ where
8989

9090
/// Maps a string to tts, using a made-up filename.
9191
pub(crate) fn string_to_stream(source_str: String) -> TokenStream {
92-
let psess = ParseSess::new(vec![]);
92+
let psess = ParseSess::new();
9393
unwrap_or_emit_fatal(source_str_to_stream(
9494
&psess,
9595
filename(psess.source_map(), "bogofile"),
@@ -2239,12 +2239,12 @@ fn sp(a: u32, b: u32) -> Span {
22392239

22402240
/// Parses a string, return an expression.
22412241
fn string_to_expr(source_str: String) -> Box<ast::Expr> {
2242-
with_error_checking_parse(source_str, &ParseSess::new(vec![]), |p| p.parse_expr())
2242+
with_error_checking_parse(source_str, &ParseSess::new(), |p| p.parse_expr())
22432243
}
22442244

22452245
/// Parses a string, returns an item.
22462246
fn string_to_item(source_str: String) -> Option<Box<ast::Item>> {
2247-
with_error_checking_parse(source_str, &ParseSess::new(vec![]), |p| {
2247+
with_error_checking_parse(source_str, &ParseSess::new(), |p| {
22482248
p.parse_item(ForceCollect::No, AllowConstBlockItems::Yes)
22492249
})
22502250
}
@@ -2480,7 +2480,7 @@ let mut fflags: c_int = wb();
24802480
#[test]
24812481
fn crlf_doc_comments() {
24822482
create_default_session_globals_then(|| {
2483-
let psess = ParseSess::new(vec![]);
2483+
let psess = ParseSess::new();
24842484

24852485
let name_1 = FileName::Custom("crlf_source_1".to_string());
24862486
let source = "/// doc comment\r\nfn foo() {}".to_string();
@@ -2515,7 +2515,7 @@ fn ttdelim_span() {
25152515
}
25162516

25172517
create_default_session_globals_then(|| {
2518-
let psess = ParseSess::new(vec![]);
2518+
let psess = ParseSess::new();
25192519
let expr = parse_expr_from_source_str(
25202520
filename(psess.source_map(), "foo"),
25212521
"foo!( fn main() { body } )".to_string(),
@@ -2551,7 +2551,7 @@ fn look_ahead() {
25512551
let sym_S = Symbol::intern("S");
25522552
let raw_no = IdentIsRaw::No;
25532553

2554-
let psess = ParseSess::new(vec![]);
2554+
let psess = ParseSess::new();
25552555
let mut p = string_to_parser(&psess, "fn f(x: u32) { x } struct S;".to_string());
25562556

25572557
// Current position is the `fn`.
@@ -2626,7 +2626,7 @@ fn look_ahead_non_outermost_stream() {
26262626
let sym_S = Symbol::intern("S");
26272627
let raw_no = IdentIsRaw::No;
26282628

2629-
let psess = ParseSess::new(vec![]);
2629+
let psess = ParseSess::new();
26302630
let mut p = string_to_parser(&psess, "mod m { fn f(x: u32) { x } struct S; }".to_string());
26312631

26322632
// Move forward to the `fn`, which is not within the outermost token
@@ -2658,7 +2658,7 @@ fn look_ahead_non_outermost_stream() {
26582658
#[test]
26592659
fn debug_lookahead() {
26602660
create_default_session_globals_then(|| {
2661-
let psess = ParseSess::new(vec![]);
2661+
let psess = ParseSess::new();
26622662
let mut p = string_to_parser(&psess, "fn f(x: u32) { x } struct S;".to_string());
26632663

26642664
// Current position is the `fn`.
@@ -2879,7 +2879,7 @@ fn debug_lookahead() {
28792879
#[test]
28802880
fn out_of_line_mod() {
28812881
create_default_session_globals_then(|| {
2882-
let psess = ParseSess::new(vec![]);
2882+
let psess = ParseSess::new();
28832883
let item = parse_item_from_source_str(
28842884
filename(psess.source_map(), "foo"),
28852885
"mod foo { struct S; mod this_does_not_exist; }".to_owned(),

compiler/rustc_session/src/parse.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ pub struct ParseSess {
280280

281281
impl ParseSess {
282282
/// Used for testing.
283-
pub fn new(locale_resources: Vec<&'static str>) -> Self {
284-
let translator = Translator::with_fallback_bundle(locale_resources, false);
283+
pub fn new() -> Self {
284+
let translator = Translator::new();
285285
let sm = Arc::new(SourceMap::new(FilePathMapping::empty()));
286286
let emitter = Box::new(
287287
AnnotateSnippetEmitter::new(stderr_destination(ColorConfig::Auto), translator)
@@ -314,7 +314,7 @@ impl ParseSess {
314314
}
315315

316316
pub fn emitter_with_note(note: String) -> Self {
317-
let translator = Translator::with_fallback_bundle(vec![], false);
317+
let translator = Translator::new();
318318
let sm = Arc::new(SourceMap::new(FilePathMapping::empty()));
319319
let emitter = Box::new(AnnotateSnippetEmitter::new(
320320
stderr_destination(ColorConfig::Auto),

compiler/rustc_session/src/session.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_errors::timings::TimingSectionHandler;
1919
use rustc_errors::translation::Translator;
2020
use rustc_errors::{
2121
Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, ErrorGuaranteed, FatalAbort,
22-
TerminalUrl, fallback_fluent_bundle,
22+
TerminalUrl,
2323
};
2424
use rustc_hir::limit::Limit;
2525
use rustc_macros::HashStable_Generic;
@@ -967,7 +967,6 @@ pub fn build_session(
967967
sopts: config::Options,
968968
io: CompilerIO,
969969
fluent_bundle: Option<Arc<rustc_errors::FluentBundle>>,
970-
fluent_resources: Vec<&'static str>,
971970
driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
972971
target: Target,
973972
cfg_version: &'static str,
@@ -985,13 +984,7 @@ pub fn build_session(
985984
let cap_lints_allow = sopts.lint_cap.is_some_and(|cap| cap == lint::Allow);
986985
let can_emit_warnings = !(warnings_allow || cap_lints_allow);
987986

988-
let translator = Translator {
989-
fluent_bundle,
990-
fallback_fluent_bundle: fallback_fluent_bundle(
991-
fluent_resources,
992-
sopts.unstable_opts.translate_directionality_markers,
993-
),
994-
};
987+
let translator = Translator { fluent_bundle };
995988
let source_map = rustc_span::source_map::get_source_map().unwrap();
996989
let emitter = default_emitter(&sopts, Arc::clone(&source_map), translator);
997990

@@ -1430,7 +1423,7 @@ impl EarlyDiagCtxt {
14301423
fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
14311424
// FIXME(#100717): early errors aren't translated at the moment, so this is fine, but it will
14321425
// need to reference every crate that might emit an early error for translation to work.
1433-
let translator = Translator::with_fallback_bundle(vec![], false);
1426+
let translator = Translator::new();
14341427
let emitter: Box<DynEmitter> = match output {
14351428
config::ErrorOutputType::HumanReadable { kind, color_config } => match kind {
14361429
HumanReadableErrorType { short, unicode } => Box::new(

src/librustdoc/clean/render_macro_matchers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option<String
6363
let snippet = source_map.span_to_snippet(span).ok()?;
6464

6565
// Create a Parser.
66-
let psess = ParseSess::new(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec());
66+
let psess = ParseSess::new();
6767
let file_name = FileName::macro_expansion_source_code(&snippet);
6868
let mut parser = match rustc_parse::new_parser_from_source_str(
6969
&psess,

src/librustdoc/core.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ pub(crate) fn create_config(
289289
output_file: None,
290290
output_dir: None,
291291
file_loader: None,
292-
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
293292
lint_caps,
294293
psess_created: None,
295294
hash_untracked_state: None,

0 commit comments

Comments
 (0)