diff options
| author | est31 <MTest31@outlook.com> | 2022-03-02 22:10:35 +0100 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2022-03-02 22:10:35 +0100 |
| commit | fe78bd49207ec302cdb1898cdb56bc4194aa24fb (patch) | |
| tree | c283ee3a3c6df9cd249a2320af9abfe02aa76f3d | |
| parent | 08504c64aa7c4163a51c1982ed10075bb89cec0e (diff) | |
| download | rust-fe78bd49207ec302cdb1898cdb56bc4194aa24fb.tar.gz rust-fe78bd49207ec302cdb1898cdb56bc4194aa24fb.zip | |
Use ? operator in one instance instead of manual match
| -rw-r--r-- | src/librustdoc/doctest.rs | 99 |
1 files changed, 48 insertions, 51 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index dad04588703..63a8e85f7c5 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -111,58 +111,55 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> { let externs = options.externs.clone(); let json_unused_externs = options.json_unused_externs; - let res = interface::run_compiler(config, |compiler| { - compiler.enter(|queries| { - let mut global_ctxt = queries.global_ctxt()?.take(); - - let collector = global_ctxt.enter(|tcx| { - let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID); - - let opts = scrape_test_config(crate_attrs); - let enable_per_target_ignores = options.enable_per_target_ignores; - let mut collector = Collector::new( - tcx.crate_name(LOCAL_CRATE), - options, - false, - opts, - Some(compiler.session().parse_sess.clone_source_map()), - None, - enable_per_target_ignores, - ); - - let mut hir_collector = HirCollector { - sess: compiler.session(), - collector: &mut collector, - map: tcx.hir(), - codes: ErrorCodes::from( - compiler.session().opts.unstable_features.is_nightly_build(), - ), - tcx, - }; - hir_collector.visit_testable( - "".to_string(), - CRATE_HIR_ID, - tcx.hir().span(CRATE_HIR_ID), - |this| tcx.hir().walk_toplevel_module(this), - ); - - collector - }); - if compiler.session().diagnostic().has_errors_or_lint_errors() { - FatalError.raise(); - } + let (tests, unused_extern_reports, compiling_test_count) = + interface::run_compiler(config, |compiler| { + compiler.enter(|queries| { + let mut global_ctxt = queries.global_ctxt()?.take(); + + let collector = global_ctxt.enter(|tcx| { + let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID); + + let opts = scrape_test_config(crate_attrs); + let enable_per_target_ignores = options.enable_per_target_ignores; + let mut collector = Collector::new( + tcx.crate_name(LOCAL_CRATE), + options, + false, + opts, + Some(compiler.session().parse_sess.clone_source_map()), + None, + enable_per_target_ignores, + ); + + let mut hir_collector = HirCollector { + sess: compiler.session(), + collector: &mut collector, + map: tcx.hir(), + codes: ErrorCodes::from( + compiler.session().opts.unstable_features.is_nightly_build(), + ), + tcx, + }; + hir_collector.visit_testable( + "".to_string(), + CRATE_HIR_ID, + tcx.hir().span(CRATE_HIR_ID), + |this| tcx.hir().walk_toplevel_module(this), + ); + + collector + }); + if compiler.session().diagnostic().has_errors_or_lint_errors() { + FatalError.raise(); + } - let unused_extern_reports = collector.unused_extern_reports.clone(); - let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst); - let ret: Result<_, ErrorGuaranteed> = - Ok((collector.tests, unused_extern_reports, compiling_test_count)); - ret - }) - }); - let (tests, unused_extern_reports, compiling_test_count) = match res { - Ok(res) => res, - Err(ErrorGuaranteed) => return Err(ErrorGuaranteed), - }; + let unused_extern_reports = collector.unused_extern_reports.clone(); + let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst); + let ret: Result<_, ErrorGuaranteed> = + Ok((collector.tests, unused_extern_reports, compiling_test_count)); + ret + }) + })?; run_tests(test_args, nocapture, tests); |
