Apply Lrc
later to sess
and codegen_backend
.
This avoids the need for a degenerate `Lrc::get_mut` call.
This commit is contained in:
parent
b6ae1453cb
commit
ec409f95bf
@ -298,18 +298,14 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
||||
);
|
||||
|
||||
if let Some(parse_sess_created) = config.parse_sess_created {
|
||||
parse_sess_created(
|
||||
&mut Lrc::get_mut(&mut sess)
|
||||
.expect("create_session() should never share the returned session")
|
||||
.parse_sess,
|
||||
);
|
||||
parse_sess_created(&mut sess.parse_sess);
|
||||
}
|
||||
|
||||
let temps_dir = sess.opts.unstable_opts.temps_dir.as_ref().map(|o| PathBuf::from(&o));
|
||||
|
||||
let compiler = Compiler {
|
||||
sess,
|
||||
codegen_backend,
|
||||
sess: Lrc::new(sess),
|
||||
codegen_backend: Lrc::new(codegen_backend),
|
||||
input: config.input,
|
||||
input_path: config.input_path,
|
||||
output_dir: config.output_dir,
|
||||
|
@ -5,7 +5,6 @@
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
#[cfg(parallel_compiler)]
|
||||
use rustc_data_structures::jobserver;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::registry::Registry;
|
||||
#[cfg(parallel_compiler)]
|
||||
use rustc_middle::ty::tls;
|
||||
@ -72,7 +71,7 @@ pub fn create_session(
|
||||
Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>,
|
||||
>,
|
||||
descriptions: Registry,
|
||||
) -> (Lrc<Session>, Lrc<Box<dyn CodegenBackend>>) {
|
||||
) -> (Session, Box<dyn CodegenBackend>) {
|
||||
let codegen_backend = if let Some(make_codegen_backend) = make_codegen_backend {
|
||||
make_codegen_backend(&sopts)
|
||||
} else {
|
||||
@ -119,7 +118,7 @@ pub fn create_session(
|
||||
sess.parse_sess.config = cfg;
|
||||
sess.parse_sess.check_config = check_cfg;
|
||||
|
||||
(Lrc::new(sess), Lrc::new(codegen_backend))
|
||||
(sess, codegen_backend)
|
||||
}
|
||||
|
||||
const STACK_SIZE: usize = 8 * 1024 * 1024;
|
||||
|
Loading…
Reference in New Issue
Block a user