]> git.lizzy.rs Git - rust.git/commitdiff
Move share_generics getter onto options directly
authorMark Rousskov <mark.simulacrum@gmail.com>
Thu, 26 Jul 2018 19:20:47 +0000 (13:20 -0600)
committerMark Rousskov <mark.simulacrum@gmail.com>
Sat, 4 Aug 2018 12:54:36 +0000 (06:54 -0600)
src/librustc/session/config.rs
src/librustc/ty/context.rs
src/librustc_codegen_llvm/back/symbol_export.rs
src/librustc_codegen_llvm/callee.rs
src/librustc_codegen_utils/symbol_names.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/monomorphize/partitioning.rs

index f5a2b3730d51c49c812c19757eba1fe86f5d0904..3111777f4ad5a212d4ba9fd1fbf468de09c99acd 100644 (file)
@@ -653,6 +653,24 @@ pub fn will_create_output_file(&self) -> bool {
         !self.debugging_opts.parse_only && // The file is just being parsed
             !self.debugging_opts.ls // The file is just being queried
     }
+
+    #[inline]
+    pub fn share_generics(&self) -> bool {
+        match self.debugging_opts.share_generics {
+            Some(setting) => setting,
+            None => {
+                self.incremental.is_some() ||
+                match self.optimize {
+                    OptLevel::No   |
+                    OptLevel::Less |
+                    OptLevel::Size |
+                    OptLevel::SizeMin => true,
+                    OptLevel::Default    |
+                    OptLevel::Aggressive => false,
+                }
+            }
+        }
+    }
 }
 
 // The type of entry function, so
index 03a84021a0da6d5c8551e89f5e8734b214d762e1..0cfdea68e881c80ee4625ec52eda3175a0cb2fa6 100644 (file)
@@ -14,7 +14,7 @@
 use dep_graph::{DepNode, DepConstructor};
 use errors::DiagnosticBuilder;
 use session::Session;
-use session::config::{BorrowckMode, OutputFilenames, OptLevel};
+use session::config::{BorrowckMode, OutputFilenames};
 use session::config::CrateType;
 use middle;
 use hir::{TraitCandidate, HirId, ItemLocalId};
@@ -1469,27 +1469,9 @@ pub fn emit_end_regions(self) -> bool {
             self.use_mir_borrowck()
     }
 
-    #[inline]
-    pub fn share_generics(self) -> bool {
-        match self.sess.opts.debugging_opts.share_generics {
-            Some(setting) => setting,
-            None => {
-                self.sess.opts.incremental.is_some() ||
-                match self.sess.opts.optimize {
-                    OptLevel::No   |
-                    OptLevel::Less |
-                    OptLevel::Size |
-                    OptLevel::SizeMin => true,
-                    OptLevel::Default    |
-                    OptLevel::Aggressive => false,
-                }
-            }
-        }
-    }
-
     #[inline]
     pub fn local_crate_exports_generics(self) -> bool {
-        debug_assert!(self.share_generics());
+        debug_assert!(self.sess.opts.share_generics());
 
         self.sess.crate_types.borrow().iter().any(|crate_type| {
             match crate_type {
index 5ce0d45a9bc5a7b82ca11b252f8a07a72d7aee88..02434b7be0bda22aa1d024d96f6e0d14c694dc83 100644 (file)
@@ -242,7 +242,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         symbols.push((exported_symbol, SymbolExportLevel::Rust));
     }
 
-    if tcx.share_generics() && tcx.local_crate_exports_generics() {
+    if tcx.sess.opts.share_generics() && tcx.local_crate_exports_generics() {
         use rustc::mir::mono::{Linkage, Visibility, MonoItem};
         use rustc::ty::InstanceDef;
 
index e64dedac55a247e343d0c86f5962bd104c323301..3594351802fe91cabf67112f5c7b2f6ebae108ba 100644 (file)
@@ -133,7 +133,7 @@ pub fn get_fn(
                 // This is a monomorphization. Its expected visibility depends
                 // on whether we are in share-generics mode.
 
-                if cx.tcx.share_generics() {
+                if cx.tcx.sess.opts.share_generics() {
                     // We are in share_generics mode.
 
                     if instance_def_id.is_local() {
index ac71ecff96457b59e579ab0e7606360dd2b222bf..d834a6502b280fa8f9f4b391df546ccbf532f35a 100644 (file)
@@ -201,7 +201,7 @@ fn get_symbol_hash<'a, 'tcx>(
 
         if avoid_cross_crate_conflicts {
             let instantiating_crate = if is_generic {
-                if !def_id.is_local() && tcx.share_generics() {
+                if !def_id.is_local() && tcx.sess.opts.share_generics() {
                     // If we are re-using a monomorphization from another crate,
                     // we have to compute the symbol hash accordingly.
                     let upstream_monomorphizations = tcx.upstream_monomorphizations_for(def_id);
index 7f5851734fe858ea1d2e2d4d5b1ec89219b83810..230d6f0472edde6f538b447f779b1adbdc057275 100644 (file)
@@ -770,7 +770,7 @@ fn is_available_upstream_generic<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         // If we are not in share generics mode, we don't link to upstream
         // monomorphizations but always instantiate our own internal versions
         // instead.
-        if !tcx.share_generics() {
+        if !tcx.sess.opts.share_generics() {
             return false
         }
 
index bd0b2c6c278b131c526b0eb25605857e92e7c8c7..8d6d01633a12ef8d5faa6bb52f12bef0475ec9fa 100644 (file)
@@ -304,7 +304,7 @@ fn place_root_mono_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     // available to downstream crates. This depends on whether we are in
     // share-generics mode and whether the current crate can even have
     // downstream crates.
-    let export_generics = tcx.share_generics() &&
+    let export_generics = tcx.sess.opts.share_generics() &&
                           tcx.local_crate_exports_generics();
 
     for mono_item in mono_items {