Skip to content

Commit 98c9ee8

Browse files
authored
Rollup merge of #94537 - est31:master, r=notriddle
Use ? operator in one instance instead of manual match As suggested [here](#94139 (comment)). r? `@notriddle`
2 parents 250e7e1 + fe78bd4 commit 98c9ee8

File tree

1 file changed

+48
-51
lines changed

1 file changed

+48
-51
lines changed

src/librustdoc/doctest.rs

+48-51
Original file line numberDiff line numberDiff line change
@@ -111,58 +111,55 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
111111
let externs = options.externs.clone();
112112
let json_unused_externs = options.json_unused_externs;
113113

114-
let res = interface::run_compiler(config, |compiler| {
115-
compiler.enter(|queries| {
116-
let mut global_ctxt = queries.global_ctxt()?.take();
117-
118-
let collector = global_ctxt.enter(|tcx| {
119-
let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID);
120-
121-
let opts = scrape_test_config(crate_attrs);
122-
let enable_per_target_ignores = options.enable_per_target_ignores;
123-
let mut collector = Collector::new(
124-
tcx.crate_name(LOCAL_CRATE),
125-
options,
126-
false,
127-
opts,
128-
Some(compiler.session().parse_sess.clone_source_map()),
129-
None,
130-
enable_per_target_ignores,
131-
);
132-
133-
let mut hir_collector = HirCollector {
134-
sess: compiler.session(),
135-
collector: &mut collector,
136-
map: tcx.hir(),
137-
codes: ErrorCodes::from(
138-
compiler.session().opts.unstable_features.is_nightly_build(),
139-
),
140-
tcx,
141-
};
142-
hir_collector.visit_testable(
143-
"".to_string(),
144-
CRATE_HIR_ID,
145-
tcx.hir().span(CRATE_HIR_ID),
146-
|this| tcx.hir().walk_toplevel_module(this),
147-
);
148-
149-
collector
150-
});
151-
if compiler.session().diagnostic().has_errors_or_lint_errors() {
152-
FatalError.raise();
153-
}
114+
let (tests, unused_extern_reports, compiling_test_count) =
115+
interface::run_compiler(config, |compiler| {
116+
compiler.enter(|queries| {
117+
let mut global_ctxt = queries.global_ctxt()?.take();
118+
119+
let collector = global_ctxt.enter(|tcx| {
120+
let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID);
121+
122+
let opts = scrape_test_config(crate_attrs);
123+
let enable_per_target_ignores = options.enable_per_target_ignores;
124+
let mut collector = Collector::new(
125+
tcx.crate_name(LOCAL_CRATE),
126+
options,
127+
false,
128+
opts,
129+
Some(compiler.session().parse_sess.clone_source_map()),
130+
None,
131+
enable_per_target_ignores,
132+
);
133+
134+
let mut hir_collector = HirCollector {
135+
sess: compiler.session(),
136+
collector: &mut collector,
137+
map: tcx.hir(),
138+
codes: ErrorCodes::from(
139+
compiler.session().opts.unstable_features.is_nightly_build(),
140+
),
141+
tcx,
142+
};
143+
hir_collector.visit_testable(
144+
"".to_string(),
145+
CRATE_HIR_ID,
146+
tcx.hir().span(CRATE_HIR_ID),
147+
|this| tcx.hir().walk_toplevel_module(this),
148+
);
149+
150+
collector
151+
});
152+
if compiler.session().diagnostic().has_errors_or_lint_errors() {
153+
FatalError.raise();
154+
}
154155

155-
let unused_extern_reports = collector.unused_extern_reports.clone();
156-
let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst);
157-
let ret: Result<_, ErrorGuaranteed> =
158-
Ok((collector.tests, unused_extern_reports, compiling_test_count));
159-
ret
160-
})
161-
});
162-
let (tests, unused_extern_reports, compiling_test_count) = match res {
163-
Ok(res) => res,
164-
Err(ErrorGuaranteed) => return Err(ErrorGuaranteed),
165-
};
156+
let unused_extern_reports = collector.unused_extern_reports.clone();
157+
let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst);
158+
let ret: Result<_, ErrorGuaranteed> =
159+
Ok((collector.tests, unused_extern_reports, compiling_test_count));
160+
ret
161+
})
162+
})?;
166163

167164
run_tests(test_args, nocapture, tests);
168165

0 commit comments

Comments
 (0)