about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorCaleb Cartwright <calebcartwright@users.noreply.github.com>2019-10-02 09:56:20 -0500
committerSeiichi Uchida <seuchida@gmail.com>2019-10-02 23:56:20 +0900
commitf4bc4941531fbdfde423779b60946060b7f7cae6 (patch)
tree4e77de1e6eb1540d7b3ea3dd50c5ca407e7718e0 /src
parent72e44c429b71d3b9f3311c19ed28d1a9b01075f7 (diff)
add --offline mode fallback to cargo fmt (#3813)
Diffstat (limited to 'src')
-rw-r--r--src/cargo-fmt/main.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cargo-fmt/main.rs b/src/cargo-fmt/main.rs
index c06df111566..acaf81e0665 100644
--- a/src/cargo-fmt/main.rs
+++ b/src/cargo-fmt/main.rs
@@ -519,9 +519,16 @@ fn get_cargo_metadata(
     if let Some(manifest_path) = manifest_path {
         cmd.manifest_path(manifest_path);
     }
+
     match cmd.exec() {
         Ok(metadata) => Ok(metadata),
-        Err(error) => Err(io::Error::new(io::ErrorKind::Other, error.to_string())),
+        Err(_) => {
+            cmd.other_options(&[String::from("--offline")]);
+            match cmd.exec() {
+                Ok(metadata) => Ok(metadata),
+                Err(error) => Err(io::Error::new(io::ErrorKind::Other, error.to_string())),
+            }
+        }
     }
 }