Skip to content

Commit

Permalink
use thread-safe struct in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
SparrowLii committed Apr 23, 2023
1 parent add456b commit c170de7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_error_messages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
fluent-bundle = "0.15.2"
fluent-syntax = "0.11"
intl-memoizer = "0.5.1"
rustc_baked_icu_data = { path = "../rustc_baked_icu_data" }
rustc_baked_icu_data = { path = "../rustc_baked_icu_data", features = ["rustc_use_parallel_compiler"] }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_serialize = { path = "../rustc_serialize" }
Expand All @@ -22,4 +22,4 @@ icu_locid = "1.1.0"
icu_provider_adapters = "1.1.0"

[features]
rustc_use_parallel_compiler = ['rustc_baked_icu_data/rustc_use_parallel_compiler']
rustc_use_parallel_compiler = []
21 changes: 0 additions & 21 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ use std::fs;
use std::io;
use std::path::{Path, PathBuf};

#[cfg(not(parallel_compiler))]
use std::cell::LazyCell as Lazy;
#[cfg(parallel_compiler)]
use std::sync::LazyLock as Lazy;

#[cfg(parallel_compiler)]
use intl_memoizer::concurrent::IntlLangMemoizer;
#[cfg(not(parallel_compiler))]
use intl_memoizer::IntlLangMemoizer;

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

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

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

#[cfg(not(parallel_compiler))]
fn new_bundle(locales: Vec<LanguageIdentifier>) -> FluentBundle {
FluentBundle::new(locales)
}

#[derive(Debug)]
pub enum TranslationBundleError {
/// Failed to read from `.ftl` file.
Expand Down Expand Up @@ -547,15 +535,6 @@ pub fn fluent_value_from_str_list_sep_by_and(l: Vec<Cow<'_, str>>) -> FluentValu
Cow::Owned(result)
}

#[cfg(not(parallel_compiler))]
fn as_string_threadsafe(
&self,
_intls: &intl_memoizer::concurrent::IntlLangMemoizer,
) -> Cow<'static, str> {
unreachable!("`as_string_threadsafe` is not used in non-parallel rustc")
}

#[cfg(parallel_compiler)]
fn as_string_threadsafe(
&self,
intls: &intl_memoizer::concurrent::IntlLangMemoizer,
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_errors/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ fn make_dummy(ftl: &'static str) -> Dummy {

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

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

#[cfg(not(parallel_compiler))]
let mut bundle = FluentBundle::new(vec![langid_en]);

bundle.add_resource(resource).expect("Failed to add FTL resources to the bundle.");

Dummy { bundle }
Expand Down

0 comments on commit c170de7

Please sign in to comment.