]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/externalfiles.rs
Simplify Cache wrapper to single type, impl Deref on it, fix all compilation errors...
[rust.git] / src / librustdoc / externalfiles.rs
index 5d953eec31ec36eeba4ffc15f7177948da79d135..7945850ef08ac84cc69b5da597218893b52ff9dc 100644 (file)
@@ -2,12 +2,10 @@
 use std::path::Path;
 use std::str;
 use errors;
-use crate::syntax::feature_gate::UnstableFeatures;
+use rustc_feature::UnstableFeatures;
 use crate::syntax::edition::Edition;
 use crate::html::markdown::{IdMap, ErrorCodes, Markdown, Playground};
 
-use std::cell::RefCell;
-
 #[derive(Clone, Debug)]
 pub struct ExternalHtml {
     /// Content that will be included inline in the <head> section of a
@@ -27,34 +25,20 @@ pub fn load(in_header: &[String], before_content: &[String], after_content: &[St
                 id_map: &mut IdMap, edition: Edition, playground: &Option<Playground>)
             -> Option<ExternalHtml> {
         let codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());
-        load_external_files(in_header, diag)
-            .and_then(|ih|
-                load_external_files(before_content, diag)
-                    .map(|bc| (ih, bc))
-            )
-            .and_then(|(ih, bc)|
-                load_external_files(md_before_content, diag)
-                    .map(|m_bc| (ih,
-                            format!("{}{}", bc, Markdown(&m_bc, &[], RefCell::new(id_map),
-                                    codes, edition, playground).to_string())))
-            )
-            .and_then(|(ih, bc)|
-                load_external_files(after_content, diag)
-                    .map(|ac| (ih, bc, ac))
-            )
-            .and_then(|(ih, bc, ac)|
-                load_external_files(md_after_content, diag)
-                    .map(|m_ac| (ih, bc,
-                            format!("{}{}", ac, Markdown(&m_ac, &[], RefCell::new(id_map),
-                                    codes, edition, playground).to_string())))
-            )
-            .map(|(ih, bc, ac)|
-                ExternalHtml {
-                    in_header: ih,
-                    before_content: bc,
-                    after_content: ac,
-                }
-            )
+        let ih = load_external_files(in_header, diag)?;
+        let bc = load_external_files(before_content, diag)?;
+        let m_bc = load_external_files(md_before_content, diag)?;
+        let bc = format!("{}{}", bc, Markdown(&m_bc, &[], id_map,
+                                    codes, edition, playground).to_string());
+        let ac = load_external_files(after_content, diag)?;
+        let m_ac = load_external_files(md_after_content, diag)?;
+        let ac = format!("{}{}", ac, Markdown(&m_ac, &[], id_map,
+                                    codes, edition, playground).to_string());
+        Some(ExternalHtml {
+            in_header: ih,
+            before_content: bc,
+            after_content: ac,
+        })
     }
 }