Skip to content

Commit fcce644

Browse files
committed
Auto merge of #88530 - bjorn3:shrink_session, r=cjgillot
Shrink Session a bit Remove a couple of unnecessary fields from `Session` and remove a `Lock<T>` for a field that is never mutated anyway.
2 parents 6492931 + 74c7f12 commit fcce644

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

Diff for: compiler/rustc_codegen_cranelift/src/driver/aot.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,13 @@ fn reuse_workproduct_for_cgu(
6868
cgu: &CodegenUnit<'_>,
6969
work_products: &mut FxHashMap<WorkProductId, WorkProduct>,
7070
) -> CompiledModule {
71-
let incr_comp_session_dir = tcx.sess.incr_comp_session_dir();
7271
let mut object = None;
7372
let work_product = cgu.work_product(tcx);
7473
if let Some(saved_file) = &work_product.saved_file {
7574
let obj_out =
7675
tcx.output_filenames(()).temp_path(OutputType::Object, Some(&cgu.name().as_str()));
7776
object = Some(obj_out.clone());
78-
let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
77+
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &saved_file);
7978
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
8079
tcx.sess.err(&format!(
8180
"unable to copy {} to {}: {}",

Diff for: compiler/rustc_driver/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,10 @@ fn run_compiler(
423423
sess.print_perf_stats();
424424
}
425425

426-
if sess.print_fuel_crate.is_some() {
426+
if sess.opts.debugging_opts.print_fuel.is_some() {
427427
eprintln!(
428428
"Fuel used by {}: {}",
429-
sess.print_fuel_crate.as_ref().unwrap(),
429+
sess.opts.debugging_opts.print_fuel.as_ref().unwrap(),
430430
sess.print_fuel.load(SeqCst)
431431
);
432432
}

Diff for: compiler/rustc_session/src/session.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,9 @@ pub struct Session {
170170
/// Data about code being compiled, gathered during compilation.
171171
pub code_stats: CodeStats,
172172

173-
/// If `-zfuel=crate=n` is specified, `Some(crate)`.
174-
optimization_fuel_crate: Option<String>,
175-
176173
/// Tracks fuel info if `-zfuel=crate=n` is specified.
177174
optimization_fuel: Lock<OptimizationFuel>,
178175

179-
// The next two are public because the driver needs to read them.
180-
/// If `-zprint-fuel=crate`, `Some(crate)`.
181-
pub print_fuel_crate: Option<String>,
182176
/// Always set to zero and incremented so that we can print fuel expended by a crate.
183177
pub print_fuel: AtomicU64,
184178

@@ -196,6 +190,9 @@ pub struct Session {
196190
/// Tracks the current behavior of the CTFE engine when an error occurs.
197191
/// Options range from returning the error without a backtrace to returning an error
198192
/// and immediately printing the backtrace to stderr.
193+
/// The `Lock` is only used by miri to allow setting `ctfe_backtrace` after analysis when
194+
/// `MIRI_BACKTRACE` is set. This makes it only apply to miri's errors and not to all CTFE
195+
/// errors.
199196
pub ctfe_backtrace: Lock<CtfeBacktrace>,
200197

201198
/// This tracks where `-Zunleash-the-miri-inside-of-you` was used to get around a
@@ -890,7 +887,7 @@ impl Session {
890887
/// This expends fuel if applicable, and records fuel if applicable.
891888
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
892889
let mut ret = true;
893-
if let Some(ref c) = self.optimization_fuel_crate {
890+
if let Some(c) = self.opts.debugging_opts.fuel.as_ref().map(|i| &i.0) {
894891
if c == crate_name {
895892
assert_eq!(self.threads(), 1);
896893
let mut fuel = self.optimization_fuel.lock();
@@ -903,7 +900,7 @@ impl Session {
903900
}
904901
}
905902
}
906-
if let Some(ref c) = self.print_fuel_crate {
903+
if let Some(ref c) = self.opts.debugging_opts.print_fuel {
907904
if c == crate_name {
908905
assert_eq!(self.threads(), 1);
909906
self.print_fuel.fetch_add(1, SeqCst);
@@ -1261,12 +1258,10 @@ pub fn build_session(
12611258
let local_crate_source_file =
12621259
local_crate_source_file.map(|path| file_path_mapping.map_prefix(path).0);
12631260

1264-
let optimization_fuel_crate = sopts.debugging_opts.fuel.as_ref().map(|i| i.0.clone());
12651261
let optimization_fuel = Lock::new(OptimizationFuel {
12661262
remaining: sopts.debugging_opts.fuel.as_ref().map_or(0, |i| i.1),
12671263
out_of_fuel: false,
12681264
});
1269-
let print_fuel_crate = sopts.debugging_opts.print_fuel.clone();
12701265
let print_fuel = AtomicU64::new(0);
12711266

12721267
let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {
@@ -1314,9 +1309,7 @@ pub fn build_session(
13141309
normalize_projection_ty: AtomicUsize::new(0),
13151310
},
13161311
code_stats: Default::default(),
1317-
optimization_fuel_crate,
13181312
optimization_fuel,
1319-
print_fuel_crate,
13201313
print_fuel,
13211314
jobserver: jobserver::client(),
13221315
driver_lint_caps,

0 commit comments

Comments
 (0)