about summary refs log tree commit diff
path: root/compiler/rustc_session
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2023-08-08 18:28:20 +0800
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2023-08-09 14:17:54 +0800
commit0b89aac08d7190961544ced9e868cc20ce24d786 (patch)
tree0aa4c283516f8f45d12396e9641f196149b55c8a /compiler/rustc_session
parent8838c73e866aa85b40463640ff6f5af268507812 (diff)
downloadrust-0b89aac08d7190961544ced9e868cc20ce24d786.tar.gz
rust-0b89aac08d7190961544ced9e868cc20ce24d786.zip
rustc: Move `crate_types` from `Session` to `GlobalCtxt`
Removes a piece of mutable state.
Follow up to #114578.
Diffstat (limited to 'compiler/rustc_session')
-rw-r--r--compiler/rustc_session/src/session.rs42
1 files changed, 0 insertions, 42 deletions
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index b25a6299125..a1f995ad279 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -152,7 +152,6 @@ pub struct Session {
     /// Input, input file path and output file path to this compilation process.
     pub io: CompilerIO,
 
-    crate_types: OnceCell<Vec<CrateType>>,
     /// The `stable_crate_id` is constructed out of the crate name and all the
     /// `-C metadata` arguments passed to the compiler. Its value forms a unique
     /// global identifier for the crate. It is used to allow multiple crates
@@ -314,51 +313,11 @@ impl Session {
         self.stable_crate_id.get().copied().unwrap()
     }
 
-    pub fn crate_types(&self) -> &[CrateType] {
-        self.crate_types.get().unwrap().as_slice()
-    }
-
     /// Returns true if the crate is a testing one.
     pub fn is_test_crate(&self) -> bool {
         self.opts.test
     }
 
-    pub fn needs_crate_hash(&self) -> bool {
-        // Why is the crate hash needed for these configurations?
-        // - debug_assertions: for the "fingerprint the result" check in
-        //   `rustc_query_system::query::plumbing::execute_job`.
-        // - incremental: for query lookups.
-        // - needs_metadata: for putting into crate metadata.
-        // - instrument_coverage: for putting into coverage data (see
-        //   `hash_mir_source`).
-        cfg!(debug_assertions)
-            || self.opts.incremental.is_some()
-            || self.needs_metadata()
-            || self.instrument_coverage()
-    }
-
-    pub fn metadata_kind(&self) -> MetadataKind {
-        self.crate_types()
-            .iter()
-            .map(|ty| match *ty {
-                CrateType::Executable | CrateType::Staticlib | CrateType::Cdylib => {
-                    MetadataKind::None
-                }
-                CrateType::Rlib => MetadataKind::Uncompressed,
-                CrateType::Dylib | CrateType::ProcMacro => MetadataKind::Compressed,
-            })
-            .max()
-            .unwrap_or(MetadataKind::None)
-    }
-
-    pub fn needs_metadata(&self) -> bool {
-        self.metadata_kind() != MetadataKind::None
-    }
-
-    pub fn init_crate_types(&self, crate_types: Vec<CrateType>) {
-        self.crate_types.set(crate_types).expect("`crate_types` was initialized twice")
-    }
-
     #[rustc_lint_diagnostics]
     #[track_caller]
     pub fn struct_span_warn<S: Into<MultiSpan>>(
@@ -1516,7 +1475,6 @@ pub fn build_session(
         parse_sess,
         sysroot,
         io,
-        crate_types: OnceCell::new(),
         stable_crate_id: OnceCell::new(),
         features: OnceCell::new(),
         incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),