Remove host_triple() method from Context
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Fri, 13 Apr 2018 17:48:16 +0000 (19:48 +0200)
committerDirkjan Ochtman <dirkjan@ochtman.nl>
Fri, 13 Apr 2018 18:03:20 +0000 (20:03 +0200)
Favor accessing cx.build_config directly.

src/cargo/core/compiler/context/mod.rs
src/cargo/core/compiler/custom_build.rs

index 8caf02dc5e3d5b4e0a84caea55ca60ede45a0d6b..db78623a3ee47cf467c4ba6ffc52045febc2a7fe 100644 (file)
@@ -401,18 +401,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
         self.files.as_mut().unwrap()
     }
 
-    /// Return the host triple for this context
-    pub fn host_triple(&self) -> &str {
-        &self.build_config.host_triple
-    }
-
     /// Return the target triple which this context is targeting.
     pub fn target_triple(&self) -> &str {
         self.build_config
             .requested_target
             .as_ref()
             .map(|s| &s[..])
-            .unwrap_or_else(|| self.host_triple())
+            .unwrap_or_else(|| &self.build_config.host_triple)
     }
 
     /// Return the filenames that the given target for the given profile will
@@ -456,7 +451,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
             None => return true,
         };
         let (name, info) = match kind {
-            Kind::Host => (self.host_triple(), &self.host_info),
+            Kind::Host => (self.build_config.host_triple.as_ref(), &self.host_info),
             Kind::Target => (self.target_triple(), &self.target_info),
         };
         platform.matches(name, info.cfg())
index e007c998b94fe9442e6030a34e233169e436ae4b..35d9e79bc899cab6502f15e65271e6c45883d1dd 100644 (file)
@@ -127,7 +127,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
         .env(
             "TARGET",
             &match unit.kind {
-                Kind::Host => cx.host_triple(),
+                Kind::Host => &cx.build_config.host_triple,
                 Kind::Target => cx.target_triple(),
             },
         )
@@ -141,7 +141,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
                 "debug"
             },
         )
-        .env("HOST", cx.host_triple())
+        .env("HOST", &cx.build_config.host_triple)
         .env("RUSTC", &cx.config.rustc()?.path)
         .env("RUSTDOC", &*cx.config.rustdoc()?)
         .inherit_jobserver(&cx.jobserver);