X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustdoc%2Ftest.rs;h=d89dc2adafeb36734717150496fa46b4e3fc7396;hb=7f8a61d96c5a628ffb88304eb84a85140479ecad;hp=cc5359b53d17c9eca0f785b32f5d7f00ec71797f;hpb=ac8acd856e6f376183a4a6ed2bc9bb0fd6f63b32;p=rust.git diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index cc5359b53d1..d89dc2adafe 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -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()); @@ -300,7 +304,6 @@ fn drop(&mut self) { eprint!("{}", self.0); } } - let out = str::from_utf8(&output.stderr).unwrap(); let _bomb = Bomb(&out); match (output.status.success(), compile_fail) { @@ -310,7 +313,7 @@ fn drop(&mut self) { (true, false) => {} (false, true) => { if !error_codes.is_empty() { - error_codes.retain(|err| !out.contains(err)); + error_codes.retain(|err| !out.contains(&format!("error[{}]: ", err))); if !error_codes.is_empty() { return Err(TestFailure::MissingErrorCodes(error_codes)); @@ -705,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, @@ -906,8 +909,8 @@ fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { } fn visit_item(&mut self, item: &'hir hir::Item) { - let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.kind { - self.map.hir_to_pretty_string(ty.hir_id) + let name = if let hir::ItemKind::Impl { ref self_ty, .. } = item.kind { + self.map.hir_to_pretty_string(self_ty.hir_id) } else { item.ident.to_string() };