about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-10-07 16:20:20 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-10-19 08:09:40 +1100
commitec409f95bf52c5891084e309fed91fa9b6ce10b4 (patch)
tree894c71ba5a5c5d0b185990e08036efe0d1ea9929 /compiler/rustc_interface/src
parentb6ae1453cbe677deea362628c69efa501b4faa4b (diff)
downloadrust-ec409f95bf52c5891084e309fed91fa9b6ce10b4.tar.gz
rust-ec409f95bf52c5891084e309fed91fa9b6ce10b4.zip
Apply `Lrc` later to `sess` and `codegen_backend`.
This avoids the need for a degenerate `Lrc::get_mut` call.
Diffstat (limited to 'compiler/rustc_interface/src')
-rw-r--r--compiler/rustc_interface/src/interface.rs10
-rw-r--r--compiler/rustc_interface/src/util.rs5
2 files changed, 5 insertions, 10 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs
index 59b89ce01a6..a3bf7cde9ff 100644
--- a/compiler/rustc_interface/src/interface.rs
+++ b/compiler/rustc_interface/src/interface.rs
@@ -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,
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs
index c07d562332b..afc43745b18 100644
--- a/compiler/rustc_interface/src/util.rs
+++ b/compiler/rustc_interface/src/util.rs
@@ -5,7 +5,6 @@ use rustc_codegen_ssa::traits::CodegenBackend;
 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;