]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/rustbook/src/main.rs
Ignore unused variable for non-linux builds
[rust.git] / src / tools / rustbook / src / main.rs
index ecba45058e22ad51a9d00d201176062c0c04bcea..d9b16780107be150448232868a47d4f049f9ba73 100644 (file)
 
 use mdbook::MDBook;
 use mdbook::errors::{Result as Result3};
+
+#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
 use mdbook::renderer::RenderContext;
 
-use mdbook_linkcheck;
-use mdbook_linkcheck::errors::BrokenLinks;
+#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
+use mdbook_linkcheck::{self, errors::BrokenLinks};
 use failure::Error;
 
+#[cfg(not(all(target_arch = "x86_64", target_os = "linux")))]
+use failure::bail;
 
 fn main() {
     let d_message = "-d, --dest-dir=[dest-dir]
@@ -77,9 +81,12 @@ fn main() {
             if let Err(err) = linkcheck(sub_matches) {
                 eprintln!("Error: {}", err);
 
-                if let Ok(broken_links) = err.downcast::<BrokenLinks>() {
-                    for cause in broken_links.links().iter() {
-                        eprintln!("\tCaused By: {}", cause);
+                #[cfg(all(target_arch = "x86_64", target_os = "linux"))]
+                {
+                    if let Ok(broken_links) = err.downcast::<BrokenLinks>() {
+                        for cause in broken_links.links().iter() {
+                            eprintln!("\tCaused By: {}", cause);
+                        }
                     }
                 }
 
@@ -90,6 +97,7 @@ fn main() {
     };
 }
 
+#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
 pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> {
     let book_dir = get_book_dir(args);
     let book = MDBook::load(&book_dir).unwrap();
@@ -99,6 +107,11 @@ pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> {
     mdbook_linkcheck::check_links(&render_ctx)
 }
 
+#[cfg(not(all(target_arch = "x86_64", target_os = "linux")))]
+pub fn linkcheck(_args: &ArgMatches<'_>) -> Result<(), Error> {
+    bail!("mdbook-linkcheck only works on x86_64 linux targets.");
+}
+
 // Build command implementation
 pub fn build_1(args: &ArgMatches<'_>) -> Result1<()> {
     let book_dir = get_book_dir(args);