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

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

index 2d317f8c15a2af53df33959f288765e840e25f3f..8caf02dc5e3d5b4e0a84caea55ca60ede45a0d6b 100644 (file)
@@ -346,8 +346,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
     fn probe_target_info(&mut self) -> CargoResult<()> {
         let _p = profile::start("Context::probe_target_info");
         debug!("probe_target_info");
-        let host_target_same = match self.requested_target() {
-            Some(s) if s != self.config.rustc()?.host => false,
+        let host_target_same = match self.build_config.requested_target {
+            Some(ref s) if s != &self.config.rustc()?.host => false,
             _ => true,
         };
 
@@ -408,15 +408,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
 
     /// Return the target triple which this context is targeting.
     pub fn target_triple(&self) -> &str {
-        self.requested_target()
+        self.build_config
+            .requested_target
+            .as_ref()
+            .map(|s| &s[..])
             .unwrap_or_else(|| self.host_triple())
     }
 
-    /// Requested (not actual) target for the build
-    pub fn requested_target(&self) -> Option<&str> {
-        self.build_config.requested_target.as_ref().map(|s| &s[..])
-    }
-
     /// Return the filenames that the given target for the given profile will
     /// generate as a list of 3-tuples (filename, link_dst, linkable)
     ///
index 47c1237a145ac3b0f396abc21a786aeb27968e87..ce4cdf2acfe00e581f75018c070ef2559fcfc5e2 100644 (file)
@@ -601,7 +601,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
     add_path_args(cx, unit, &mut rustdoc);
 
     if unit.kind != Kind::Host {
-        if let Some(target) = cx.requested_target() {
+        if let Some(ref target) = cx.build_config.requested_target {
             rustdoc.arg("--target").arg(target);
         }
     }
@@ -862,7 +862,10 @@ fn build_base_args<'a, 'cfg>(
             cmd,
             "--target",
             "",
-            cx.requested_target().map(|s| s.as_ref()),
+            cx.build_config
+                .requested_target
+                .as_ref()
+                .map(|s| s.as_ref()),
         );
     }