提交 a9093a4d 编写于 作者: M Mark Rousskov

Move share_generics getter onto options directly

上级 5fcef251
......@@ -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
......
......@@ -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 {
......
......@@ -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 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
}
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册