Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d6ad04e

Browse files
committedAug 18, 2024
Remove -Zfuel.
1 parent 7521bda commit d6ad04e

26 files changed

+18
-283
lines changed
 

‎compiler/rustc_driver_impl/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,6 @@ fn run_compiler(
463463
linker.link(sess, codegen_backend)?
464464
}
465465

466-
if sess.opts.unstable_opts.print_fuel.is_some() {
467-
eprintln!(
468-
"Fuel used by {}: {}",
469-
sess.opts.unstable_opts.print_fuel.as_ref().unwrap(),
470-
sess.print_fuel.load(Ordering::SeqCst)
471-
);
472-
}
473-
474466
Ok(())
475467
})
476468
}

‎compiler/rustc_interface/src/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ fn test_unstable_options_tracking_hash() {
780780
tracked!(fixed_x18, true);
781781
tracked!(flatten_format_args, false);
782782
tracked!(force_unstable_if_unmarked, true);
783-
tracked!(fuel, Some(("abc".to_string(), 99)));
784783
tracked!(function_return, FunctionReturn::ThunkExtern);
785784
tracked!(function_sections, Some(false));
786785
tracked!(human_readable_cgu_names, true);
@@ -825,7 +824,6 @@ fn test_unstable_options_tracking_hash() {
825824
tracked!(plt, Some(true));
826825
tracked!(polonius, Polonius::Legacy);
827826
tracked!(precise_enum_drop_elaboration, false);
828-
tracked!(print_fuel, Some("abc".to_string()));
829827
tracked!(profile, true);
830828
tracked!(profile_emit, Some(PathBuf::from("abc")));
831829
tracked!(profile_sample_use, Some(PathBuf::from("abc")));

‎compiler/rustc_middle/src/ty/context.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,10 +1529,6 @@ impl<'tcx> TyCtxt<'tcx> {
15291529
}
15301530
}
15311531

1532-
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {
1533-
self.sess.consider_optimizing(|| self.crate_name(LOCAL_CRATE), msg)
1534-
}
1535-
15361532
/// Obtain all lang items of this crate and all dependencies (recursively)
15371533
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
15381534
self.get_lang_items(())

‎compiler/rustc_middle/src/ty/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,11 +1570,6 @@ impl<'tcx> TyCtxt<'tcx> {
15701570
flags.insert(ReprFlags::RANDOMIZE_LAYOUT);
15711571
}
15721572

1573-
// This is here instead of layout because the choice must make it into metadata.
1574-
if !self.consider_optimizing(|| format!("Reorder fields of {:?}", self.def_path_str(did))) {
1575-
flags.insert(ReprFlags::IS_LINEAR);
1576-
}
1577-
15781573
ReprOptions { int: size, align: max_align, pack: min_pack, flags, field_shuffle_seed }
15791574
}
15801575

‎compiler/rustc_mir_transform/src/dest_prop.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,6 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
225225
else {
226226
continue;
227227
};
228-
if !tcx.consider_optimizing(|| {
229-
format!("{} round {}", tcx.def_path_str(def_id), round_count)
230-
}) {
231-
break;
232-
}
233228

234229
// Replace `src` by `dest` everywhere.
235230
merges.insert(*src, *dest);

‎compiler/rustc_mir_transform/src/early_otherwise_branch.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
107107
let parent = BasicBlock::from_usize(i);
108108
let Some(opt_data) = evaluate_candidate(tcx, body, parent) else { continue };
109109

110-
if !tcx.consider_optimizing(|| format!("EarlyOtherwiseBranch {opt_data:?}")) {
111-
break;
112-
}
113-
114110
trace!("SUCCESS: found optimization possibility to apply: {opt_data:?}");
115111

116112
should_cleanup = true;

‎compiler/rustc_mir_transform/src/inline.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,6 @@ impl<'tcx> Inliner<'tcx> {
210210
let callee_body = try_instance_mir(self.tcx, callsite.callee.def)?;
211211
self.check_mir_body(callsite, callee_body, callee_attrs, cross_crate_inlinable)?;
212212

213-
if !self.tcx.consider_optimizing(|| {
214-
format!("Inline {:?} into {:?}", callsite.callee, caller_body.source)
215-
}) {
216-
return Err("optimization fuel exhausted");
217-
}
218-
219213
let Ok(callee_body) = callsite.callee.try_instantiate_mir_and_normalize_erasing_regions(
220214
self.tcx,
221215
self.param_env,

‎compiler/rustc_mir_transform/src/instsimplify.rs

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use rustc_middle::bug;
66
use rustc_middle::mir::*;
77
use rustc_middle::ty::layout::ValidityRequirement;
88
use rustc_middle::ty::{self, layout, GenericArgsRef, ParamEnv, Ty, TyCtxt};
9-
use rustc_span::sym;
109
use rustc_span::symbol::Symbol;
10+
use rustc_span::{sym, DUMMY_SP};
1111
use rustc_target::spec::abi::Abi;
1212

1313
use crate::simplify::simplify_duplicate_switch_targets;
@@ -49,12 +49,12 @@ impl<'tcx> MirPass<'tcx> for InstSimplify {
4949
match statement.kind {
5050
StatementKind::Assign(box (_place, ref mut rvalue)) => {
5151
if !preserve_ub_checks {
52-
ctx.simplify_ub_check(&statement.source_info, rvalue);
52+
ctx.simplify_ub_check(rvalue);
5353
}
54-
ctx.simplify_bool_cmp(&statement.source_info, rvalue);
55-
ctx.simplify_ref_deref(&statement.source_info, rvalue);
56-
ctx.simplify_len(&statement.source_info, rvalue);
57-
ctx.simplify_ptr_aggregate(&statement.source_info, rvalue);
54+
ctx.simplify_bool_cmp(rvalue);
55+
ctx.simplify_ref_deref(rvalue);
56+
ctx.simplify_len(rvalue);
57+
ctx.simplify_ptr_aggregate(rvalue);
5858
ctx.simplify_cast(rvalue);
5959
}
6060
_ => {}
@@ -76,23 +76,8 @@ struct InstSimplifyContext<'tcx, 'a> {
7676
}
7777

7878
impl<'tcx> InstSimplifyContext<'tcx, '_> {
79-
fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
80-
self.should_simplify_custom(source_info, "Rvalue", rvalue)
81-
}
82-
83-
fn should_simplify_custom(
84-
&self,
85-
source_info: &SourceInfo,
86-
label: &str,
87-
value: impl std::fmt::Debug,
88-
) -> bool {
89-
self.tcx.consider_optimizing(|| {
90-
format!("InstSimplify - {label}: {value:?} SourceInfo: {source_info:?}")
91-
})
92-
}
93-
9479
/// Transform boolean comparisons into logical operations.
95-
fn simplify_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
80+
fn simplify_bool_cmp(&self, rvalue: &mut Rvalue<'tcx>) {
9681
match rvalue {
9782
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
9883
let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
@@ -123,9 +108,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
123108
_ => None,
124109
};
125110

126-
if let Some(new) = new
127-
&& self.should_simplify(source_info, rvalue)
128-
{
111+
if let Some(new) = new {
129112
*rvalue = new;
130113
}
131114
}
@@ -140,17 +123,13 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
140123
}
141124

142125
/// Transform `&(*a)` ==> `a`.
143-
fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
126+
fn simplify_ref_deref(&self, rvalue: &mut Rvalue<'tcx>) {
144127
if let Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) = rvalue {
145128
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
146129
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
147130
return;
148131
}
149132

150-
if !self.should_simplify(source_info, rvalue) {
151-
return;
152-
}
153-
154133
*rvalue = Rvalue::Use(Operand::Copy(Place {
155134
local: base.local,
156135
projection: self.tcx.mk_place_elems(base.projection),
@@ -160,36 +139,24 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
160139
}
161140

162141
/// Transform `Len([_; N])` ==> `N`.
163-
fn simplify_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
142+
fn simplify_len(&self, rvalue: &mut Rvalue<'tcx>) {
164143
if let Rvalue::Len(ref place) = *rvalue {
165144
let place_ty = place.ty(self.local_decls, self.tcx).ty;
166145
if let ty::Array(_, len) = *place_ty.kind() {
167-
if !self.should_simplify(source_info, rvalue) {
168-
return;
169-
}
170-
171146
let const_ = Const::from_ty_const(len, self.tcx.types.usize, self.tcx);
172-
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
147+
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
173148
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
174149
}
175150
}
176151
}
177152

178153
/// Transform `Aggregate(RawPtr, [p, ()])` ==> `Cast(PtrToPtr, p)`.
179-
fn simplify_ptr_aggregate(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
154+
fn simplify_ptr_aggregate(&self, rvalue: &mut Rvalue<'tcx>) {
180155
if let Rvalue::Aggregate(box AggregateKind::RawPtr(pointee_ty, mutability), fields) = rvalue
181156
{
182157
let meta_ty = fields.raw[1].ty(self.local_decls, self.tcx);
183158
if meta_ty.is_unit() {
184159
// The mutable borrows we're holding prevent printing `rvalue` here
185-
if !self.should_simplify_custom(
186-
source_info,
187-
"Aggregate::RawPtr",
188-
(&pointee_ty, *mutability, &fields),
189-
) {
190-
return;
191-
}
192-
193160
let mut fields = std::mem::take(fields);
194161
let _meta = fields.pop().unwrap();
195162
let data = fields.pop().unwrap();
@@ -199,10 +166,10 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
199166
}
200167
}
201168

202-
fn simplify_ub_check(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
169+
fn simplify_ub_check(&self, rvalue: &mut Rvalue<'tcx>) {
203170
if let Rvalue::NullaryOp(NullOp::UbChecks, _) = *rvalue {
204171
let const_ = Const::from_bool(self.tcx, self.tcx.sess.ub_checks());
205-
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
172+
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
206173
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
207174
}
208175
}
@@ -290,16 +257,6 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
290257
return;
291258
}
292259

293-
if !self.tcx.consider_optimizing(|| {
294-
format!(
295-
"InstSimplify - Call: {:?} SourceInfo: {:?}",
296-
(fn_def_id, fn_args),
297-
terminator.source_info
298-
)
299-
}) {
300-
return;
301-
}
302-
303260
let Ok([arg]) = take_array(args) else { return };
304261
let Some(arg_place) = arg.node.place() else { return };
305262

‎compiler/rustc_mir_transform/src/match_branches.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
2525
for i in 0..body.basic_blocks.len() {
2626
let bbs = &*body.basic_blocks;
2727
let bb_idx = BasicBlock::from_usize(i);
28-
if !tcx.consider_optimizing(|| format!("MatchBranchSimplification {def_id:?} ")) {
29-
continue;
30-
}
31-
3228
match bbs[bb_idx].terminator().kind {
3329
TerminatorKind::SwitchInt {
3430
discr: ref _discr @ (Operand::Copy(_) | Operand::Move(_)),

‎compiler/rustc_mir_transform/src/multiple_return_terminators.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
1414
sess.mir_opt_level() >= 4
1515
}
1616

17-
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
17+
fn run_pass(&self, _: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
1818
// find basic blocks with no statement and a return terminator
1919
let mut bbs_simple_returns = BitSet::new_empty(body.basic_blocks.len());
20-
let def_id = body.source.def_id();
2120
let bbs = body.basic_blocks_mut();
2221
for idx in bbs.indices() {
2322
if bbs[idx].statements.is_empty()
@@ -28,10 +27,6 @@ impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
2827
}
2928

3029
for bb in bbs {
31-
if !tcx.consider_optimizing(|| format!("MultipleReturnTerminators {def_id:?} ")) {
32-
break;
33-
}
34-
3530
if let TerminatorKind::Goto { target } = bb.terminator().kind {
3631
if bbs_simple_returns.contains(target) {
3732
bb.terminator_mut().kind = TerminatorKind::Return;

‎compiler/rustc_mir_transform/src/nrvo.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
4646
return;
4747
};
4848

49-
if !tcx.consider_optimizing(|| format!("RenameReturnPlace {def_id:?}")) {
50-
return;
51-
}
52-
5349
debug!(
5450
"`{:?}` was eligible for NRVO, making {:?} the return place",
5551
def_id, returned_local

‎compiler/rustc_mir_transform/src/remove_unneeded_drops.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
2626
if ty.ty.needs_drop(tcx, param_env) {
2727
continue;
2828
}
29-
if !tcx.consider_optimizing(|| format!("RemoveUnneededDrops {did:?} ")) {
30-
continue;
31-
}
3229
debug!("SUCCESS: replacing `drop` with goto({:?})", target);
3330
terminator.kind = TerminatorKind::Goto { target };
3431
should_simplify = true;

‎compiler/rustc_mir_transform/src/remove_zsts.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ impl<'tcx> MirPass<'tcx> for RemoveZsts {
1717
return;
1818
}
1919

20-
if !tcx.consider_optimizing(|| format!("RemoveZsts - {:?}", body.source.def_id())) {
21-
return;
22-
}
23-
2420
let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id());
2521
let local_decls = &body.local_decls;
2622
let mut replacer = Replacer { tcx, param_env, local_decls };
@@ -94,16 +90,12 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
9490
}
9591
}
9692

97-
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) {
93+
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _: Location) {
9894
if let Operand::Constant(_) = operand {
9995
return;
10096
}
10197
let op_ty = operand.ty(self.local_decls, self.tcx);
102-
if self.known_to_be_zst(op_ty)
103-
&& self.tcx.consider_optimizing(|| {
104-
format!("RemoveZsts - Operand: {operand:?} Location: {loc:?}")
105-
})
106-
{
98+
if self.known_to_be_zst(op_ty) {
10799
*operand = Operand::Constant(Box::new(self.make_zst(op_ty)))
108100
}
109101
}

‎compiler/rustc_mir_transform/src/unreachable_prop.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ impl MirPass<'_> for UnreachablePropagation {
4242
}
4343
}
4444

45-
if !tcx
46-
.consider_optimizing(|| format!("UnreachablePropagation {:?} ", body.source.def_id()))
47-
{
48-
return;
49-
}
50-
5145
patch.apply(body);
5246

5347
// We do want do keep some unreachable blocks, but make them empty.

‎compiler/rustc_session/messages.ftl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ session_not_supported = not supported
8080
8181
session_octal_float_literal_not_supported = octal float literal is not supported
8282
83-
session_optimization_fuel_exhausted = optimization-fuel-exhausted: {$msg}
84-
8583
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist
8684
8785
session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist

‎compiler/rustc_session/src/config.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,14 +2436,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
24362436
early_dcx.early_fatal("value for threads must be a positive non-zero integer");
24372437
}
24382438

2439-
let fuel = unstable_opts.fuel.is_some() || unstable_opts.print_fuel.is_some();
2440-
if fuel && unstable_opts.threads > 1 {
2441-
early_dcx.early_fatal("optimization fuel is incompatible with multiple threads");
2442-
}
2443-
if fuel && cg.incremental.is_some() {
2444-
early_dcx.early_fatal("optimization fuel is incompatible with incremental compilation");
2445-
}
2446-
24472439
let incremental = cg.incremental.as_ref().map(PathBuf::from);
24482440

24492441
let assert_incr_state = parse_assert_incr_state(early_dcx, &unstable_opts.assert_incr_state);

‎compiler/rustc_session/src/errors.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,6 @@ pub fn report_lit_error(
447447
}
448448
}
449449

450-
#[derive(Diagnostic)]
451-
#[diag(session_optimization_fuel_exhausted)]
452-
pub(crate) struct OptimisationFuelExhausted {
453-
pub(crate) msg: String,
454-
}
455-
456450
#[derive(Diagnostic)]
457451
#[diag(session_incompatible_linker_flavor)]
458452
#[note]

‎compiler/rustc_session/src/options.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ mod desc {
393393
pub const parse_collapse_macro_debuginfo: &str = "one of `no`, `external`, or `yes`";
394394
pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
395395
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
396-
pub const parse_optimization_fuel: &str = "crate=integer";
397396
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
398397
pub const parse_instrument_coverage: &str = parse_bool;
399398
pub const parse_coverage_options: &str =
@@ -905,21 +904,6 @@ mod parse {
905904
true
906905
}
907906

908-
pub(crate) fn parse_optimization_fuel(
909-
slot: &mut Option<(String, u64)>,
910-
v: Option<&str>,
911-
) -> bool {
912-
match v {
913-
None => false,
914-
Some(s) => {
915-
let [crate_name, fuel] = *s.split('=').collect::<Vec<_>>() else { return false };
916-
let Ok(fuel) = fuel.parse::<u64>() else { return false };
917-
*slot = Some((crate_name.to_string(), fuel));
918-
true
919-
}
920-
}
921-
}
922-
923907
pub(crate) fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
924908
match v {
925909
None => false,
@@ -1724,8 +1708,6 @@ options! {
17241708
(default: yes)"),
17251709
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
17261710
"force all crates to be `rustc_private` unstable (default: no)"),
1727-
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
1728-
"set the optimization fuel quota for a crate"),
17291711
function_return: FunctionReturn = (FunctionReturn::default(), parse_function_return, [TRACKED],
17301712
"replace returns with jumps to `__x86_return_thunk` (default: `keep`)"),
17311713
function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
@@ -1907,8 +1889,6 @@ options! {
19071889
#[rustc_lint_opt_deny_field_access("use `Session::print_codegen_stats` instead of this field")]
19081890
print_codegen_stats: bool = (false, parse_bool, [UNTRACKED],
19091891
"print codegen statistics (default: no)"),
1910-
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
1911-
"make rustc print the total optimization fuel used by a crate"),
19121892
print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
19131893
"print the LLVM optimization passes being run (default: no)"),
19141894
print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],

‎compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::ops::{Div, Mul};
33
use std::path::{Path, PathBuf};
44
use std::str::FromStr;
55
use std::sync::atomic::AtomicBool;
6-
use std::sync::atomic::Ordering::SeqCst;
76
use std::sync::Arc;
87
use std::{env, fmt, io};
98

@@ -12,7 +11,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
1211
use rustc_data_structures::jobserver::{self, Client};
1312
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
1413
use rustc_data_structures::sync::{
15-
AtomicU64, DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock,
14+
DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock,
1615
};
1716
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
1817
use rustc_errors::codes::*;
@@ -44,13 +43,6 @@ use crate::parse::{add_feature_diagnostics, ParseSess};
4443
use crate::search_paths::{PathKind, SearchPath};
4544
use crate::{errors, filesearch, lint};
4645

47-
struct OptimizationFuel {
48-
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
49-
remaining: u64,
50-
/// We're rejecting all further optimizations.
51-
out_of_fuel: bool,
52-
}
53-
5446
/// The behavior of the CTFE engine when an error occurs with regards to backtraces.
5547
#[derive(Clone, Copy)]
5648
pub enum CtfeBacktrace {
@@ -158,12 +150,6 @@ pub struct Session {
158150
/// Data about code being compiled, gathered during compilation.
159151
pub code_stats: CodeStats,
160152

161-
/// Tracks fuel info if `-zfuel=crate=n` is specified.
162-
optimization_fuel: Lock<OptimizationFuel>,
163-
164-
/// Always set to zero and incremented so that we can print fuel expended by a crate.
165-
pub print_fuel: AtomicU64,
166-
167153
/// Loaded up early on in the initialization of this `Session` to avoid
168154
/// false positives about a job server in our environment.
169155
pub jobserver: Client,
@@ -533,41 +519,6 @@ impl Session {
533519
self.opts.incremental.as_ref().map(|_| self.incr_comp_session_dir())
534520
}
535521

536-
/// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n.
537-
/// This expends fuel if applicable, and records fuel if applicable.
538-
pub fn consider_optimizing(
539-
&self,
540-
get_crate_name: impl Fn() -> Symbol,
541-
msg: impl Fn() -> String,
542-
) -> bool {
543-
let mut ret = true;
544-
if let Some((ref c, _)) = self.opts.unstable_opts.fuel {
545-
if c == get_crate_name().as_str() {
546-
assert_eq!(self.threads(), 1);
547-
let mut fuel = self.optimization_fuel.lock();
548-
ret = fuel.remaining != 0;
549-
if fuel.remaining == 0 && !fuel.out_of_fuel {
550-
if self.dcx().can_emit_warnings() {
551-
// We only call `msg` in case we can actually emit warnings.
552-
// Otherwise, this could cause a `must_produce_diag` ICE
553-
// (issue #79546).
554-
self.dcx().emit_warn(errors::OptimisationFuelExhausted { msg: msg() });
555-
}
556-
fuel.out_of_fuel = true;
557-
} else if fuel.remaining > 0 {
558-
fuel.remaining -= 1;
559-
}
560-
}
561-
}
562-
if let Some(ref c) = self.opts.unstable_opts.print_fuel {
563-
if c == get_crate_name().as_str() {
564-
assert_eq!(self.threads(), 1);
565-
self.print_fuel.fetch_add(1, SeqCst);
566-
}
567-
}
568-
ret
569-
}
570-
571522
/// Is this edition 2015?
572523
pub fn is_rust_2015(&self) -> bool {
573524
self.edition().is_rust_2015()
@@ -1091,12 +1042,6 @@ pub fn build_session(
10911042
Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
10921043
};
10931044

1094-
let optimization_fuel = Lock::new(OptimizationFuel {
1095-
remaining: sopts.unstable_opts.fuel.as_ref().map_or(0, |&(_, i)| i),
1096-
out_of_fuel: false,
1097-
});
1098-
let print_fuel = AtomicU64::new(0);
1099-
11001045
let prof = SelfProfilerRef::new(
11011046
self_profiler,
11021047
sopts.unstable_opts.time_passes.then(|| sopts.unstable_opts.time_passes_format),
@@ -1122,8 +1067,6 @@ pub fn build_session(
11221067
incr_comp_session: RwLock::new(IncrCompSession::NotInitialized),
11231068
prof,
11241069
code_stats: Default::default(),
1125-
optimization_fuel,
1126-
print_fuel,
11271070
jobserver: jobserver::client(),
11281071
lint_store: None,
11291072
registered_lints: false,

‎tests/ui/fuel/optimization-fuel-0.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎tests/ui/fuel/optimization-fuel-0.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎tests/ui/fuel/optimization-fuel-1.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎tests/ui/fuel/optimization-fuel-1.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎tests/ui/fuel/print-fuel.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎tests/ui/fuel/print-fuel.stderr

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎tests/ui/lint/issue-79546-fuel-ice.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.