]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/test.rs
rustdoc: Fix handling of compile errors when running `rustdoc --test`
[rust.git] / src / librustdoc / test.rs
index b5731ff0fec21cafc04f668f810958eeffe1c522..1048083c9227d658e65bd1855fc81ed5b74ac00e 100644 (file)
@@ -43,7 +43,7 @@ pub fn run(options: Options) -> i32 {
     let crate_types = if options.proc_macro_crate {
         vec![config::CrateType::ProcMacro]
     } else {
-        vec![config::CrateType::Dylib]
+        vec![config::CrateType::Rlib]
     };
 
     let sessopts = config::Options {
@@ -117,12 +117,16 @@ pub fn run(options: Options) -> i32 {
                     intravisit::walk_crate(this, krate);
                 });
             });
+            compiler.session().abort_if_errors();
 
             let ret: Result<_, ErrorReported> = Ok(collector.tests);
             ret
         })
-    })
-    .expect("compiler aborted in rustdoc!");
+    });
+    let tests = match tests {
+        Ok(tests) => tests,
+        Err(ErrorReported) => return 1,
+    };
 
     test_args.insert(0, "rustdoctest".to_string());
 
@@ -704,7 +708,7 @@ fn add_test(&mut self, test: String, config: LangString, line: usize) {
         debug!("creating test {}: {}", name, test);
         self.tests.push(testing::TestDescAndFn {
             desc: testing::TestDesc {
-                name: testing::DynTestName(name.clone()),
+                name: testing::DynTestName(name),
                 ignore: match config.ignore {
                     Ignore::All => true,
                     Ignore::None => false,