Skip to content

Commit a9093a4

Browse files
Move share_generics getter onto options directly
1 parent 5fcef25 commit a9093a4

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

src/librustc/session/config.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,24 @@ impl Options {
653653
!self.debugging_opts.parse_only && // The file is just being parsed
654654
!self.debugging_opts.ls // The file is just being queried
655655
}
656+
657+
#[inline]
658+
pub fn share_generics(&self) -> bool {
659+
match self.debugging_opts.share_generics {
660+
Some(setting) => setting,
661+
None => {
662+
self.incremental.is_some() ||
663+
match self.optimize {
664+
OptLevel::No |
665+
OptLevel::Less |
666+
OptLevel::Size |
667+
OptLevel::SizeMin => true,
668+
OptLevel::Default |
669+
OptLevel::Aggressive => false,
670+
}
671+
}
672+
}
673+
}
656674
}
657675

658676
// The type of entry function, so

src/librustc/ty/context.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use dep_graph::DepGraph;
1414
use dep_graph::{DepNode, DepConstructor};
1515
use errors::DiagnosticBuilder;
1616
use session::Session;
17-
use session::config::{BorrowckMode, OutputFilenames, OptLevel};
17+
use session::config::{BorrowckMode, OutputFilenames};
1818
use session::config::CrateType;
1919
use middle;
2020
use hir::{TraitCandidate, HirId, ItemLocalId};
@@ -1469,27 +1469,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14691469
self.use_mir_borrowck()
14701470
}
14711471

1472-
#[inline]
1473-
pub fn share_generics(self) -> bool {
1474-
match self.sess.opts.debugging_opts.share_generics {
1475-
Some(setting) => setting,
1476-
None => {
1477-
self.sess.opts.incremental.is_some() ||
1478-
match self.sess.opts.optimize {
1479-
OptLevel::No |
1480-
OptLevel::Less |
1481-
OptLevel::Size |
1482-
OptLevel::SizeMin => true,
1483-
OptLevel::Default |
1484-
OptLevel::Aggressive => false,
1485-
}
1486-
}
1487-
}
1488-
}
1489-
14901472
#[inline]
14911473
pub fn local_crate_exports_generics(self) -> bool {
1492-
debug_assert!(self.share_generics());
1474+
debug_assert!(self.sess.opts.share_generics());
14931475

14941476
self.sess.crate_types.borrow().iter().any(|crate_type| {
14951477
match crate_type {

src/librustc_codegen_llvm/back/symbol_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
242242
symbols.push((exported_symbol, SymbolExportLevel::Rust));
243243
}
244244

245-
if tcx.share_generics() && tcx.local_crate_exports_generics() {
245+
if tcx.sess.opts.share_generics() && tcx.local_crate_exports_generics() {
246246
use rustc::mir::mono::{Linkage, Visibility, MonoItem};
247247
use rustc::ty::InstanceDef;
248248

src/librustc_codegen_llvm/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn get_fn(
133133
// This is a monomorphization. Its expected visibility depends
134134
// on whether we are in share-generics mode.
135135

136-
if cx.tcx.share_generics() {
136+
if cx.tcx.sess.opts.share_generics() {
137137
// We are in share_generics mode.
138138

139139
if instance_def_id.is_local() {

src/librustc_codegen_utils/symbol_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn get_symbol_hash<'a, 'tcx>(
201201

202202
if avoid_cross_crate_conflicts {
203203
let instantiating_crate = if is_generic {
204-
if !def_id.is_local() && tcx.share_generics() {
204+
if !def_id.is_local() && tcx.sess.opts.share_generics() {
205205
// If we are re-using a monomorphization from another crate,
206206
// we have to compute the symbol hash accordingly.
207207
let upstream_monomorphizations = tcx.upstream_monomorphizations_for(def_id);

src/librustc_mir/monomorphize/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ fn should_monomorphize_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance:
770770
// If we are not in share generics mode, we don't link to upstream
771771
// monomorphizations but always instantiate our own internal versions
772772
// instead.
773-
if !tcx.share_generics() {
773+
if !tcx.sess.opts.share_generics() {
774774
return false
775775
}
776776

src/librustc_mir/monomorphize/partitioning.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ fn place_root_mono_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
304304
// available to downstream crates. This depends on whether we are in
305305
// share-generics mode and whether the current crate can even have
306306
// downstream crates.
307-
let export_generics = tcx.share_generics() &&
307+
let export_generics = tcx.sess.opts.share_generics() &&
308308
tcx.local_crate_exports_generics();
309309

310310
for mono_item in mono_items {

0 commit comments

Comments
 (0)