Skip to content

Commit

Permalink
Move share_generics getter onto options directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Aug 4, 2018
1 parent 5fcef25 commit a9093a4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
18 changes: 18 additions & 0 deletions src/librustc/session/config.rs
Expand Up @@ -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
Expand Down
22 changes: 2 additions & 20 deletions src/librustc/ty/context.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/back/symbol_export.rs
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/callee.rs
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_utils/symbol_names.rs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/monomorphize/collector.rs
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/monomorphize/partitioning.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit a9093a4

Please sign in to comment.