Skip to content

Commit b6ae145

Browse files
committed
Inline and remove create_compiler_and_run.
It has a single call site.
1 parent dcc194e commit b6ae145

File tree

1 file changed

+51
-53
lines changed

1 file changed

+51
-53
lines changed

compiler/rustc_interface/src/interface.rs

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -275,66 +275,64 @@ pub struct Config {
275275
pub registry: Registry,
276276
}
277277

278-
fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R) -> R {
279-
crate::callbacks::setup_callbacks();
280-
281-
let registry = &config.registry;
282-
let (mut sess, codegen_backend) = util::create_session(
283-
config.opts,
284-
config.crate_cfg,
285-
config.crate_check_cfg,
286-
config.file_loader,
287-
config.input_path.clone(),
288-
config.lint_caps,
289-
config.make_codegen_backend,
290-
registry.clone(),
291-
);
292-
293-
if let Some(parse_sess_created) = config.parse_sess_created {
294-
parse_sess_created(
295-
&mut Lrc::get_mut(&mut sess)
296-
.expect("create_session() should never share the returned session")
297-
.parse_sess,
298-
);
299-
}
300-
301-
let temps_dir = sess.opts.unstable_opts.temps_dir.as_ref().map(|o| PathBuf::from(&o));
302-
303-
let compiler = Compiler {
304-
sess,
305-
codegen_backend,
306-
input: config.input,
307-
input_path: config.input_path,
308-
output_dir: config.output_dir,
309-
output_file: config.output_file,
310-
temps_dir,
311-
register_lints: config.register_lints,
312-
override_queries: config.override_queries,
313-
};
314-
315-
rustc_span::with_source_map(compiler.sess.parse_sess.clone_source_map(), move || {
316-
let r = {
317-
let _sess_abort_error = OnDrop(|| {
318-
compiler.sess.finish_diagnostics(registry);
319-
});
320-
321-
f(&compiler)
322-
};
323-
324-
let prof = compiler.sess.prof.clone();
325-
prof.generic_activity("drop_compiler").run(move || drop(compiler));
326-
r
327-
})
328-
}
329-
330278
// JUSTIFICATION: before session exists, only config
331279
#[allow(rustc::bad_opt_access)]
332280
pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
333281
trace!("run_compiler");
334282
util::run_in_thread_pool_with_globals(
335283
config.opts.edition,
336284
config.opts.unstable_opts.threads,
337-
|| create_compiler_and_run(config, f),
285+
|| {
286+
crate::callbacks::setup_callbacks();
287+
288+
let registry = &config.registry;
289+
let (mut sess, codegen_backend) = util::create_session(
290+
config.opts,
291+
config.crate_cfg,
292+
config.crate_check_cfg,
293+
config.file_loader,
294+
config.input_path.clone(),
295+
config.lint_caps,
296+
config.make_codegen_backend,
297+
registry.clone(),
298+
);
299+
300+
if let Some(parse_sess_created) = config.parse_sess_created {
301+
parse_sess_created(
302+
&mut Lrc::get_mut(&mut sess)
303+
.expect("create_session() should never share the returned session")
304+
.parse_sess,
305+
);
306+
}
307+
308+
let temps_dir = sess.opts.unstable_opts.temps_dir.as_ref().map(|o| PathBuf::from(&o));
309+
310+
let compiler = Compiler {
311+
sess,
312+
codegen_backend,
313+
input: config.input,
314+
input_path: config.input_path,
315+
output_dir: config.output_dir,
316+
output_file: config.output_file,
317+
temps_dir,
318+
register_lints: config.register_lints,
319+
override_queries: config.override_queries,
320+
};
321+
322+
rustc_span::with_source_map(compiler.sess.parse_sess.clone_source_map(), move || {
323+
let r = {
324+
let _sess_abort_error = OnDrop(|| {
325+
compiler.sess.finish_diagnostics(registry);
326+
});
327+
328+
f(&compiler)
329+
};
330+
331+
let prof = compiler.sess.prof.clone();
332+
prof.generic_activity("drop_compiler").run(move || drop(compiler));
333+
r
334+
})
335+
},
338336
)
339337
}
340338

0 commit comments

Comments
 (0)