Fix review comments

This commit is contained in:
bjorn3
2025-06-06 14:20:48 +00:00
parent dff8ee5b01
commit e4c4c4c677
5 changed files with 11 additions and 14 deletions

View File

@@ -3640,6 +3640,7 @@ dependencies = [
"rustc_macros", "rustc_macros",
"rustc_serialize", "rustc_serialize",
"rustc_span", "rustc_span",
"smallvec",
"tracing", "tracing",
"unic-langid", "unic-langid",
] ]

View File

@@ -16,6 +16,7 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_macros = { path = "../rustc_macros" } rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" } rustc_serialize = { path = "../rustc_serialize" }
rustc_span = { path = "../rustc_span" } rustc_span = { path = "../rustc_span" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
tracing = "0.1" tracing = "0.1"
unic-langid = { version = "0.9.0", features = ["macros"] } unic-langid = { version = "0.9.0", features = ["macros"] }
# tidy-alphabetical-end # tidy-alphabetical-end

View File

@@ -21,6 +21,7 @@ use intl_memoizer::concurrent::IntlLangMemoizer;
use rustc_data_structures::sync::IntoDynSyncSend; use rustc_data_structures::sync::IntoDynSyncSend;
use rustc_macros::{Decodable, Encodable}; use rustc_macros::{Decodable, Encodable};
use rustc_span::Span; use rustc_span::Span;
use smallvec::SmallVec;
use tracing::{instrument, trace}; use tracing::{instrument, trace};
pub use unic_langid::{LanguageIdentifier, langid}; pub use unic_langid::{LanguageIdentifier, langid};
@@ -106,8 +107,7 @@ impl From<Vec<FluentError>> for TranslationBundleError {
/// (overriding any conflicting messages). /// (overriding any conflicting messages).
#[instrument(level = "trace")] #[instrument(level = "trace")]
pub fn fluent_bundle( pub fn fluent_bundle(
sysroot: PathBuf, sysroot_candidates: SmallVec<[PathBuf; 2]>,
default_sysroot: PathBuf,
requested_locale: Option<LanguageIdentifier>, requested_locale: Option<LanguageIdentifier>,
additional_ftl_path: Option<&Path>, additional_ftl_path: Option<&Path>,
with_directionality_markers: bool, with_directionality_markers: bool,
@@ -141,7 +141,7 @@ pub fn fluent_bundle(
// If the user requests the default locale then don't try to load anything. // If the user requests the default locale then don't try to load anything.
if let Some(requested_locale) = requested_locale { if let Some(requested_locale) = requested_locale {
let mut found_resources = false; let mut found_resources = false;
for mut sysroot in [sysroot, default_sysroot] { for mut sysroot in sysroot_candidates {
sysroot.push("share"); sysroot.push("share");
sysroot.push("locale"); sysroot.push("locale");
sysroot.push(requested_locale.to_string()); sysroot.push(requested_locale.to_string());

View File

@@ -18,7 +18,7 @@ use rustc_parse::parser::attr::AllowLeadingUnsafe;
use rustc_query_impl::QueryCtxt; use rustc_query_impl::QueryCtxt;
use rustc_query_system::query::print_query_stack; use rustc_query_system::query::print_query_stack;
use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName}; use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName};
use rustc_session::filesearch::get_or_default_sysroot; use rustc_session::filesearch::sysroot_with_fallback;
use rustc_session::parse::ParseSess; use rustc_session::parse::ParseSess;
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, lint}; use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, lint};
use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs}; use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs};
@@ -442,8 +442,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from); let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
let bundle = match rustc_errors::fluent_bundle( let bundle = match rustc_errors::fluent_bundle(
config.opts.sysroot.clone(), sysroot_with_fallback(&config.opts.sysroot),
get_or_default_sysroot(),
config.opts.unstable_opts.translate_lang.clone(), config.opts.unstable_opts.translate_lang.clone(),
config.opts.unstable_opts.translate_additional_ftl.as_deref(), config.opts.unstable_opts.translate_additional_ftl.as_deref(),
config.opts.unstable_opts.translate_directionality_markers, config.opts.unstable_opts.translate_directionality_markers,

View File

@@ -345,14 +345,10 @@ pub fn rustc_path<'a>() -> Option<&'a Path> {
} }
fn get_rustc_path_inner(bin_path: &str) -> Option<PathBuf> { fn get_rustc_path_inner(bin_path: &str) -> Option<PathBuf> {
Some(filesearch::get_or_default_sysroot()).iter().find_map(|sysroot| { let candidate = filesearch::get_or_default_sysroot()
let candidate = sysroot.join(bin_path).join(if cfg!(target_os = "windows") { .join(bin_path)
"rustc.exe" .join(if cfg!(target_os = "windows") { "rustc.exe" } else { "rustc" });
} else { candidate.exists().then_some(candidate)
"rustc"
});
candidate.exists().then_some(candidate)
})
} }
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable