summary refs log tree commit diff
path: root/compiler/rustc_error_messages
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-06-05 16:53:12 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-06-05 16:54:10 +0000
commitdff8ee5b01b7251937860da41afd55958c13456a (patch)
tree282ebea0dfc1d9000d1cbbab71a6b1d8359978de /compiler/rustc_error_messages
parent387dae9092414888e9291efd9317068458250a49 (diff)
downloadrust-dff8ee5b01b7251937860da41afd55958c13456a.tar.gz
rust-dff8ee5b01b7251937860da41afd55958c13456a.zip
Replace all uses of sysroot_candidates with get_or_default_sysroot
Before this change we had two different ways to attempt to locate the
sysroot which are inconsistently used:
* get_or_default_sysroot which tries to locate based on the 0th cli
  argument and if that doesn't work falls back to locating it using the
  librustc_driver.so location and returns a single path.,
* sysroot_candidates which takes the former and additionally does
  another attempt at locating using librustc_driver.so except without
  linux multiarch handling and then returns both paths.,

The latter was originally introduced to be able to locate the codegen
backend back when cg_llvm was dynamically linked even for a custom
driver when the --sysroot passed in does not contain a copy of cg_llvm.
Back then get_or_default_sysroot did not attempt to locate the sysroot
based on the location of librustc_driver.so yet. Because that is now
done, the only case where removing sysroot_candidates can break things
is if you have a custom driver inside what looks like a sysroot
including the lib/rustlib directory, but which is missing some parts of
the full sysroot like eg rust-lld.
Diffstat (limited to 'compiler/rustc_error_messages')
-rw-r--r--compiler/rustc_error_messages/src/lib.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs
index 3c6df147b1b..a1f787b00d9 100644
--- a/compiler/rustc_error_messages/src/lib.rs
+++ b/compiler/rustc_error_messages/src/lib.rs
@@ -107,7 +107,7 @@ impl From<Vec<FluentError>> for TranslationBundleError {
 #[instrument(level = "trace")]
 pub fn fluent_bundle(
     sysroot: PathBuf,
-    sysroot_candidates: Vec<PathBuf>,
+    default_sysroot: PathBuf,
     requested_locale: Option<LanguageIdentifier>,
     additional_ftl_path: Option<&Path>,
     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 let Some(requested_locale) = requested_locale {
         let mut found_resources = false;
-        for mut sysroot in Some(sysroot).into_iter().chain(sysroot_candidates.into_iter()) {
+        for mut sysroot in [sysroot, default_sysroot] {
             sysroot.push("share");
             sysroot.push("locale");
             sysroot.push(requested_locale.to_string());