Skip to content

Commit c170de7

Browse files
committed
use thread-safe struct in error messages
1 parent add456b commit c170de7

File tree

3 files changed

+2
-27
lines changed

3 files changed

+2
-27
lines changed

compiler/rustc_error_messages/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
fluent-bundle = "0.15.2"
1010
fluent-syntax = "0.11"
1111
intl-memoizer = "0.5.1"
12-
rustc_baked_icu_data = { path = "../rustc_baked_icu_data" }
12+
rustc_baked_icu_data = { path = "../rustc_baked_icu_data", features = ["rustc_use_parallel_compiler"] }
1313
rustc_data_structures = { path = "../rustc_data_structures" }
1414
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1515
rustc_serialize = { path = "../rustc_serialize" }
@@ -22,4 +22,4 @@ icu_locid = "1.1.0"
2222
icu_provider_adapters = "1.1.0"
2323

2424
[features]
25-
rustc_use_parallel_compiler = ['rustc_baked_icu_data/rustc_use_parallel_compiler']
25+
rustc_use_parallel_compiler = []

compiler/rustc_error_messages/src/lib.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@ use std::fs;
2222
use std::io;
2323
use std::path::{Path, PathBuf};
2424

25-
#[cfg(not(parallel_compiler))]
26-
use std::cell::LazyCell as Lazy;
27-
#[cfg(parallel_compiler)]
2825
use std::sync::LazyLock as Lazy;
2926

30-
#[cfg(parallel_compiler)]
3127
use intl_memoizer::concurrent::IntlLangMemoizer;
32-
#[cfg(not(parallel_compiler))]
33-
use intl_memoizer::IntlLangMemoizer;
3428

3529
pub use fluent_bundle::{self, types::FluentType, FluentArgs, FluentError, FluentValue};
3630
pub use unic_langid::{langid, LanguageIdentifier};
@@ -39,16 +33,10 @@ fluent_messages! { "../messages.ftl" }
3933

4034
pub type FluentBundle = fluent_bundle::bundle::FluentBundle<FluentResource, IntlLangMemoizer>;
4135

42-
#[cfg(parallel_compiler)]
4336
fn new_bundle(locales: Vec<LanguageIdentifier>) -> FluentBundle {
4437
FluentBundle::new_concurrent(locales)
4538
}
4639

47-
#[cfg(not(parallel_compiler))]
48-
fn new_bundle(locales: Vec<LanguageIdentifier>) -> FluentBundle {
49-
FluentBundle::new(locales)
50-
}
51-
5240
#[derive(Debug)]
5341
pub enum TranslationBundleError {
5442
/// Failed to read from `.ftl` file.
@@ -547,15 +535,6 @@ pub fn fluent_value_from_str_list_sep_by_and(l: Vec<Cow<'_, str>>) -> FluentValu
547535
Cow::Owned(result)
548536
}
549537

550-
#[cfg(not(parallel_compiler))]
551-
fn as_string_threadsafe(
552-
&self,
553-
_intls: &intl_memoizer::concurrent::IntlLangMemoizer,
554-
) -> Cow<'static, str> {
555-
unreachable!("`as_string_threadsafe` is not used in non-parallel rustc")
556-
}
557-
558-
#[cfg(parallel_compiler)]
559538
fn as_string_threadsafe(
560539
&self,
561540
intls: &intl_memoizer::concurrent::IntlLangMemoizer,

compiler/rustc_errors/src/tests.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@ fn make_dummy(ftl: &'static str) -> Dummy {
2626

2727
let langid_en = langid!("en-US");
2828

29-
#[cfg(parallel_compiler)]
3029
let mut bundle = FluentBundle::new_concurrent(vec![langid_en]);
3130

32-
#[cfg(not(parallel_compiler))]
33-
let mut bundle = FluentBundle::new(vec![langid_en]);
34-
3531
bundle.add_resource(resource).expect("Failed to add FTL resources to the bundle.");
3632

3733
Dummy { bundle }

0 commit comments

Comments
 (0)