Rollup merge of #94537 - est31:master, r=notriddle

Use ? operator in one instance instead of manual match

As suggested [here](https://github.com/rust-lang/rust/pull/94139#discussion_r818102403).

r? `@notriddle`
This commit is contained in:
Matthias Krüger 2022-03-03 11:02:55 +01:00 committed by GitHub
commit 98c9ee8917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,58 +111,55 @@
let externs = options.externs.clone(); let externs = options.externs.clone();
let json_unused_externs = options.json_unused_externs; let json_unused_externs = options.json_unused_externs;
let res = interface::run_compiler(config, |compiler| { let (tests, unused_extern_reports, compiling_test_count) =
compiler.enter(|queries| { interface::run_compiler(config, |compiler| {
let mut global_ctxt = queries.global_ctxt()?.take(); compiler.enter(|queries| {
let mut global_ctxt = queries.global_ctxt()?.take();
let collector = global_ctxt.enter(|tcx| { let collector = global_ctxt.enter(|tcx| {
let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID); let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID);
let opts = scrape_test_config(crate_attrs); let opts = scrape_test_config(crate_attrs);
let enable_per_target_ignores = options.enable_per_target_ignores; let enable_per_target_ignores = options.enable_per_target_ignores;
let mut collector = Collector::new( let mut collector = Collector::new(
tcx.crate_name(LOCAL_CRATE), tcx.crate_name(LOCAL_CRATE),
options, options,
false, false,
opts, opts,
Some(compiler.session().parse_sess.clone_source_map()), Some(compiler.session().parse_sess.clone_source_map()),
None, None,
enable_per_target_ignores, enable_per_target_ignores,
); );
let mut hir_collector = HirCollector { let mut hir_collector = HirCollector {
sess: compiler.session(), sess: compiler.session(),
collector: &mut collector, collector: &mut collector,
map: tcx.hir(), map: tcx.hir(),
codes: ErrorCodes::from( codes: ErrorCodes::from(
compiler.session().opts.unstable_features.is_nightly_build(), compiler.session().opts.unstable_features.is_nightly_build(),
), ),
tcx, tcx,
}; };
hir_collector.visit_testable( hir_collector.visit_testable(
"".to_string(), "".to_string(),
CRATE_HIR_ID, CRATE_HIR_ID,
tcx.hir().span(CRATE_HIR_ID), tcx.hir().span(CRATE_HIR_ID),
|this| tcx.hir().walk_toplevel_module(this), |this| tcx.hir().walk_toplevel_module(this),
); );
collector collector
}); });
if compiler.session().diagnostic().has_errors_or_lint_errors() { if compiler.session().diagnostic().has_errors_or_lint_errors() {
FatalError.raise(); FatalError.raise();
} }
let unused_extern_reports = collector.unused_extern_reports.clone(); let unused_extern_reports = collector.unused_extern_reports.clone();
let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst); let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst);
let ret: Result<_, ErrorGuaranteed> = let ret: Result<_, ErrorGuaranteed> =
Ok((collector.tests, unused_extern_reports, compiling_test_count)); Ok((collector.tests, unused_extern_reports, compiling_test_count));
ret ret
}) })
}); })?;
let (tests, unused_extern_reports, compiling_test_count) = match res {
Ok(res) => res,
Err(ErrorGuaranteed) => return Err(ErrorGuaranteed),
};
run_tests(test_args, nocapture, tests); run_tests(test_args, nocapture, tests);