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 7fa021a

Browse files
committedNov 26, 2024
Remove -Zfuel.
1 parent f2abf82 commit 7fa021a

26 files changed

+19
-281
lines changed
 

‎compiler/rustc_driver_impl/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,6 @@ fn run_compiler(
472472
linker.link(sess, codegen_backend)?
473473
}
474474

475-
if let Some(fuel) = sess.opts.unstable_opts.print_fuel.as_deref() {
476-
eprintln!("Fuel used by {}: {}", fuel, sess.print_fuel.load(Ordering::SeqCst));
477-
}
478-
479475
Ok(())
480476
})
481477
}

‎compiler/rustc_interface/src/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,6 @@ fn test_unstable_options_tracking_hash() {
784784
tracked!(flatten_format_args, false);
785785
tracked!(fmt_debug, FmtDebug::Shallow);
786786
tracked!(force_unstable_if_unmarked, true);
787-
tracked!(fuel, Some(("abc".to_string(), 99)));
788787
tracked!(function_return, FunctionReturn::ThunkExtern);
789788
tracked!(function_sections, Some(false));
790789
tracked!(human_readable_cgu_names, true);
@@ -830,7 +829,6 @@ fn test_unstable_options_tracking_hash() {
830829
tracked!(plt, Some(true));
831830
tracked!(polonius, Polonius::Legacy);
832831
tracked!(precise_enum_drop_elaboration, false);
833-
tracked!(print_fuel, Some("abc".to_string()));
834832
tracked!(profile_sample_use, Some(PathBuf::from("abc")));
835833
tracked!(profiler_runtime, "abc".to_string());
836834
tracked!(regparm, Some(3));

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,10 +1566,6 @@ impl<'tcx> TyCtxt<'tcx> {
15661566
}
15671567
}
15681568

1569-
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {
1570-
self.sess.consider_optimizing(|| self.crate_name(LOCAL_CRATE), msg)
1571-
}
1572-
15731569
/// Obtain all lang items of this crate and all dependencies (recursively)
15741570
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
15751571
self.get_lang_items(())

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,10 +1558,7 @@ impl<'tcx> TyCtxt<'tcx> {
15581558
let is_box = self.is_lang_item(did.to_def_id(), LangItem::OwnedBox);
15591559

15601560
// This is here instead of layout because the choice must make it into metadata.
1561-
if is_box
1562-
|| !self
1563-
.consider_optimizing(|| format!("Reorder fields of {:?}", self.def_path_str(did)))
1564-
{
1561+
if is_box {
15651562
flags.insert(ReprFlags::IS_LINEAR);
15661563
}
15671564

‎compiler/rustc_mir_transform/src/dest_prop.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,6 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
217217
else {
218218
continue;
219219
};
220-
if !tcx.consider_optimizing(|| {
221-
format!("{} round {}", tcx.def_path_str(def_id), round_count)
222-
}) {
223-
break;
224-
}
225220

226221
// Replace `src` by `dest` everywhere.
227222
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
@@ -108,10 +108,6 @@ impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch {
108108
let parent = BasicBlock::from_usize(i);
109109
let Some(opt_data) = evaluate_candidate(tcx, body, parent) else { continue };
110110

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

117113
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.typing_env,

‎compiler/rustc_mir_transform/src/instsimplify.rs

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use rustc_middle::bug;
77
use rustc_middle::mir::*;
88
use rustc_middle::ty::layout::ValidityRequirement;
99
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, layout};
10-
use rustc_span::sym;
1110
use rustc_span::symbol::Symbol;
11+
use rustc_span::{DUMMY_SP, sym};
1212

1313
use crate::simplify::simplify_duplicate_switch_targets;
1414
use crate::take_array;
@@ -43,12 +43,12 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify {
4343
match statement.kind {
4444
StatementKind::Assign(box (_place, ref mut rvalue)) => {
4545
if !preserve_ub_checks {
46-
ctx.simplify_ub_check(&statement.source_info, rvalue);
46+
ctx.simplify_ub_check(rvalue);
4747
}
48-
ctx.simplify_bool_cmp(&statement.source_info, rvalue);
49-
ctx.simplify_ref_deref(&statement.source_info, rvalue);
50-
ctx.simplify_len(&statement.source_info, rvalue);
51-
ctx.simplify_ptr_aggregate(&statement.source_info, rvalue);
48+
ctx.simplify_bool_cmp(rvalue);
49+
ctx.simplify_ref_deref(rvalue);
50+
ctx.simplify_len(rvalue);
51+
ctx.simplify_ptr_aggregate(rvalue);
5252
ctx.simplify_cast(rvalue);
5353
}
5454
_ => {}
@@ -70,23 +70,8 @@ struct InstSimplifyContext<'a, 'tcx> {
7070
}
7171

7272
impl<'tcx> InstSimplifyContext<'_, 'tcx> {
73-
fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
74-
self.should_simplify_custom(source_info, "Rvalue", rvalue)
75-
}
76-
77-
fn should_simplify_custom(
78-
&self,
79-
source_info: &SourceInfo,
80-
label: &str,
81-
value: impl std::fmt::Debug,
82-
) -> bool {
83-
self.tcx.consider_optimizing(|| {
84-
format!("InstSimplify - {label}: {value:?} SourceInfo: {source_info:?}")
85-
})
86-
}
87-
8873
/// Transform boolean comparisons into logical operations.
89-
fn simplify_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
74+
fn simplify_bool_cmp(&self, rvalue: &mut Rvalue<'tcx>) {
9075
match rvalue {
9176
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
9277
let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
@@ -117,9 +102,7 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
117102
_ => None,
118103
};
119104

120-
if let Some(new) = new
121-
&& self.should_simplify(source_info, rvalue)
122-
{
105+
if let Some(new) = new {
123106
*rvalue = new;
124107
}
125108
}
@@ -134,17 +117,13 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
134117
}
135118

136119
/// Transform `&(*a)` ==> `a`.
137-
fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
120+
fn simplify_ref_deref(&self, rvalue: &mut Rvalue<'tcx>) {
138121
if let Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) = rvalue {
139122
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
140123
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
141124
return;
142125
}
143126

144-
if !self.should_simplify(source_info, rvalue) {
145-
return;
146-
}
147-
148127
*rvalue = Rvalue::Use(Operand::Copy(Place {
149128
local: base.local,
150129
projection: self.tcx.mk_place_elems(base.projection),
@@ -154,36 +133,24 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
154133
}
155134

156135
/// Transform `Len([_; N])` ==> `N`.
157-
fn simplify_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
136+
fn simplify_len(&self, rvalue: &mut Rvalue<'tcx>) {
158137
if let Rvalue::Len(ref place) = *rvalue {
159138
let place_ty = place.ty(self.local_decls, self.tcx).ty;
160139
if let ty::Array(_, len) = *place_ty.kind() {
161-
if !self.should_simplify(source_info, rvalue) {
162-
return;
163-
}
164-
165140
let const_ = Const::from_ty_const(len, self.tcx.types.usize, self.tcx);
166-
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
141+
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
167142
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
168143
}
169144
}
170145
}
171146

172147
/// Transform `Aggregate(RawPtr, [p, ()])` ==> `Cast(PtrToPtr, p)`.
173-
fn simplify_ptr_aggregate(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
148+
fn simplify_ptr_aggregate(&self, rvalue: &mut Rvalue<'tcx>) {
174149
if let Rvalue::Aggregate(box AggregateKind::RawPtr(pointee_ty, mutability), fields) = rvalue
175150
{
176151
let meta_ty = fields.raw[1].ty(self.local_decls, self.tcx);
177152
if meta_ty.is_unit() {
178153
// The mutable borrows we're holding prevent printing `rvalue` here
179-
if !self.should_simplify_custom(
180-
source_info,
181-
"Aggregate::RawPtr",
182-
(&pointee_ty, *mutability, &fields),
183-
) {
184-
return;
185-
}
186-
187154
let mut fields = std::mem::take(fields);
188155
let _meta = fields.pop().unwrap();
189156
let data = fields.pop().unwrap();
@@ -193,10 +160,10 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
193160
}
194161
}
195162

196-
fn simplify_ub_check(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
163+
fn simplify_ub_check(&self, rvalue: &mut Rvalue<'tcx>) {
197164
if let Rvalue::NullaryOp(NullOp::UbChecks, _) = *rvalue {
198165
let const_ = Const::from_bool(self.tcx, self.tcx.sess.ub_checks());
199-
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
166+
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
200167
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
201168
}
202169
}
@@ -284,16 +251,6 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
284251
return;
285252
}
286253

287-
if !self.tcx.consider_optimizing(|| {
288-
format!(
289-
"InstSimplify - Call: {:?} SourceInfo: {:?}",
290-
(fn_def_id, fn_args),
291-
terminator.source_info
292-
)
293-
}) {
294-
return;
295-
}
296-
297254
let Ok([arg]) = take_array(args) else { return };
298255
let Some(arg_place) = arg.node.place() else { return };
299256

‎compiler/rustc_mir_transform/src/match_branches.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ impl<'tcx> crate::MirPass<'tcx> for MatchBranchSimplification {
1818
}
1919

2020
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
21-
let def_id = body.source.def_id();
2221
let typing_env = body.typing_env(tcx);
2322
let mut should_cleanup = false;
2423
for i in 0..body.basic_blocks.len() {
2524
let bbs = &*body.basic_blocks;
2625
let bb_idx = BasicBlock::from_usize(i);
27-
if !tcx.consider_optimizing(|| format!("MatchBranchSimplification {def_id:?} ")) {
28-
continue;
29-
}
30-
3126
match bbs[bb_idx].terminator().kind {
3227
TerminatorKind::SwitchInt {
3328
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> crate::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> crate::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
@@ -45,10 +45,6 @@ impl<'tcx> crate::MirPass<'tcx> for RenameReturnPlace {
4545
return;
4646
};
4747

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

‎compiler/rustc_mir_transform/src/remove_unneeded_drops.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ impl<'tcx> crate::MirPass<'tcx> for RemoveUnneededDrops {
2626
if ty.ty.needs_drop(tcx, typing_env) {
2727
continue;
2828
}
29-
if !tcx.consider_optimizing(|| {
30-
format!("RemoveUnneededDrops {:?}", body.source.def_id())
31-
}) {
32-
continue;
33-
}
3429
debug!("SUCCESS: replacing `drop` with goto({:?})", target);
3530
terminator.kind = TerminatorKind::Goto { target };
3631
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> crate::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 typing_env = body.typing_env(tcx);
2521
let local_decls = &body.local_decls;
2622
let mut replacer = Replacer { tcx, typing_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
@@ -43,12 +43,6 @@ impl crate::MirPass<'_> for UnreachablePropagation {
4343
}
4444
}
4545

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

5448
// 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
@@ -84,8 +84,6 @@ session_not_supported = not supported
8484
8585
session_octal_float_literal_not_supported = octal float literal is not supported
8686
87-
session_optimization_fuel_exhausted = optimization-fuel-exhausted: {$msg}
88-
8987
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist
9088
9189
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
@@ -2356,14 +2356,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
23562356
early_dcx.early_warn(format!("number of threads was capped at {}", parse::MAX_THREADS_CAP));
23572357
}
23582358

2359-
let fuel = unstable_opts.fuel.is_some() || unstable_opts.print_fuel.is_some();
2360-
if fuel && unstable_opts.threads > 1 {
2361-
early_dcx.early_fatal("optimization fuel is incompatible with multiple threads");
2362-
}
2363-
if fuel && cg.incremental.is_some() {
2364-
early_dcx.early_fatal("optimization fuel is incompatible with incremental compilation");
2365-
}
2366-
23672359
let incremental = cg.incremental.as_ref().map(PathBuf::from);
23682360

23692361
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
@@ -463,12 +463,6 @@ pub fn report_lit_error(
463463
}
464464
}
465465

466-
#[derive(Diagnostic)]
467-
#[diag(session_optimization_fuel_exhausted)]
468-
pub(crate) struct OptimisationFuelExhausted {
469-
pub(crate) msg: String,
470-
}
471-
472466
#[derive(Diagnostic)]
473467
#[diag(session_incompatible_linker_flavor)]
474468
#[note]

‎compiler/rustc_session/src/options.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ mod desc {
394394
pub(crate) const parse_collapse_macro_debuginfo: &str = "one of `no`, `external`, or `yes`";
395395
pub(crate) const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
396396
pub(crate) const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
397-
pub(crate) const parse_optimization_fuel: &str = "crate=integer";
398397
pub(crate) const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
399398
pub(crate) const parse_instrument_coverage: &str = parse_bool;
400399
pub(crate) const parse_coverage_options: &str =
@@ -948,21 +947,6 @@ pub mod parse {
948947
true
949948
}
950949

951-
pub(crate) fn parse_optimization_fuel(
952-
slot: &mut Option<(String, u64)>,
953-
v: Option<&str>,
954-
) -> bool {
955-
match v {
956-
None => false,
957-
Some(s) => {
958-
let [crate_name, fuel] = *s.split('=').collect::<Vec<_>>() else { return false };
959-
let Ok(fuel) = fuel.parse::<u64>() else { return false };
960-
*slot = Some((crate_name.to_string(), fuel));
961-
true
962-
}
963-
}
964-
}
965-
966950
pub(crate) fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
967951
match v {
968952
None => false,
@@ -1794,8 +1778,6 @@ options! {
17941778
`shallow` prints only type names, `none` prints nothing and disables `{:?}`. (default: `full`)"),
17951779
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
17961780
"force all crates to be `rustc_private` unstable (default: no)"),
1797-
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
1798-
"set the optimization fuel quota for a crate"),
17991781
function_return: FunctionReturn = (FunctionReturn::default(), parse_function_return, [TRACKED],
18001782
"replace returns with jumps to `__x86_return_thunk` (default: `keep`)"),
18011783
function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
@@ -1978,8 +1960,6 @@ options! {
19781960
#[rustc_lint_opt_deny_field_access("use `Session::print_codegen_stats` instead of this field")]
19791961
print_codegen_stats: bool = (false, parse_bool, [UNTRACKED],
19801962
"print codegen statistics (default: no)"),
1981-
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
1982-
"make rustc print the total optimization fuel used by a crate"),
19831963
print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
19841964
"print the LLVM optimization passes being run (default: no)"),
19851965
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
@@ -4,15 +4,14 @@ use std::path::{Path, PathBuf};
44
use std::str::FromStr;
55
use std::sync::Arc;
66
use std::sync::atomic::AtomicBool;
7-
use std::sync::atomic::Ordering::SeqCst;
87
use std::{env, fmt, io};
98

109
use rustc_data_structures::flock;
1110
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::*;
@@ -49,13 +48,6 @@ use crate::parse::{ParseSess, add_feature_diagnostics};
4948
use crate::search_paths::SearchPath;
5049
use crate::{errors, filesearch, lint};
5150

52-
struct OptimizationFuel {
53-
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
54-
remaining: u64,
55-
/// We're rejecting all further optimizations.
56-
out_of_fuel: bool,
57-
}
58-
5951
/// The behavior of the CTFE engine when an error occurs with regards to backtraces.
6052
#[derive(Clone, Copy)]
6153
pub enum CtfeBacktrace {
@@ -163,12 +155,6 @@ pub struct Session {
163155
/// Data about code being compiled, gathered during compilation.
164156
pub code_stats: CodeStats,
165157

166-
/// Tracks fuel info if `-zfuel=crate=n` is specified.
167-
optimization_fuel: Lock<OptimizationFuel>,
168-
169-
/// Always set to zero and incremented so that we can print fuel expended by a crate.
170-
pub print_fuel: AtomicU64,
171-
172158
/// Loaded up early on in the initialization of this `Session` to avoid
173159
/// false positives about a job server in our environment.
174160
pub jobserver: Client,
@@ -532,41 +518,6 @@ impl Session {
532518
self.opts.incremental.as_ref().map(|_| self.incr_comp_session_dir())
533519
}
534520

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

1100-
let optimization_fuel = Lock::new(OptimizationFuel {
1101-
remaining: sopts.unstable_opts.fuel.as_ref().map_or(0, |&(_, i)| i),
1102-
out_of_fuel: false,
1103-
});
1104-
let print_fuel = AtomicU64::new(0);
1105-
11061051
let prof = SelfProfilerRef::new(
11071052
self_profiler,
11081053
sopts.unstable_opts.time_passes.then(|| sopts.unstable_opts.time_passes_format),
@@ -1130,8 +1075,6 @@ pub fn build_session(
11301075
incr_comp_session: RwLock::new(IncrCompSession::NotInitialized),
11311076
prof,
11321077
code_stats: Default::default(),
1133-
optimization_fuel,
1134-
print_fuel,
11351078
jobserver: jobserver::client(),
11361079
lint_store: None,
11371080
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.