Skip to content

Commit 7618163

Browse files
committed
Add comments and remove unnecessary code
1 parent f9982ea commit 7618163

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

compiler/rustc_const_eval/src/const_eval/machine.rs

-5
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
561561
throw_unsup_format!("pointer arithmetic or comparison is not supported at compile-time");
562562
}
563563

564-
// Not used here, but used by Miri (see `src/tools/miri/src/machine.rs`).
565-
fn before_terminator(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
566-
Ok(())
567-
}
568-
569564
fn increment_const_eval_counter(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
570565
// The step limit has already been hit in a previous call to `increment_const_eval_counter`.
571566
if ecx.machine.steps_remaining == 0 {

compiler/rustc_middle/src/mir/syntax.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,7 @@ pub enum StatementKind<'tcx> {
286286
/// This is permitted for both generators and ADTs. This does not necessarily write to the
287287
/// entire place; instead, it writes to the minimum set of bytes as required by the layout for
288288
/// the type.
289-
SetDiscriminant {
290-
place: Box<Place<'tcx>>,
291-
variant_index: VariantIdx,
292-
},
289+
SetDiscriminant { place: Box<Place<'tcx>>, variant_index: VariantIdx },
293290

294291
/// Deinitializes the place.
295292
///
@@ -358,6 +355,10 @@ pub enum StatementKind<'tcx> {
358355
/// This avoids adding a new block and a terminator for simple intrinsics.
359356
Intrinsic(Box<NonDivergingIntrinsic<'tcx>>),
360357

358+
/// Instructs the const eval interpreter to increment a counter; this counter is used to track
359+
/// how many steps the interpreter has taken. It is used to prevent the user from writing const
360+
/// code that runs for too long or infinitely. Other than in the const eval interpreter, this
361+
/// is a no-op.
361362
ConstEvalCounter,
362363

363364
/// No-op. Useful for deleting instructions without affecting statement indices.

compiler/rustc_mir_transform/src/ctfe_limit.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! A pass that inserts the `ConstEvalCounter` instruction into any blocks that have a back edge
2+
//! (thus indicating there is a loop in the CFG), or whose terminator is a function call.
13
use crate::MirPass;
24

35
use rustc_middle::mir::{

0 commit comments

Comments
 (0)