Move share_generics getter onto options directly
This commit is contained in:
parent
5fcef251d3
commit
a9093a4dd8
7 changed files with 25 additions and 25 deletions
|
|
@ -653,6 +653,24 @@ impl Options {
|
|||
!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
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use dep_graph::DepGraph;
|
|||
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 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -770,7 +770,7 @@ fn should_monomorphize_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance:
|
|||
// 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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue