@@ -16,6 +16,8 @@ use rustc_span::Span;
16
16
use rustc_span:: def_id:: DefId ;
17
17
use rustc_target:: callconv:: FnAbi ;
18
18
19
+ use crate :: interpret:: util:: EnteredTraceSpan ;
20
+
19
21
use super :: {
20
22
AllocBytes , AllocId , AllocKind , AllocRange , Allocation , CTFE_ALLOC_SALT , ConstAllocation ,
21
23
CtfeProvenance , FnArg , Frame , ImmTy , InterpCx , InterpResult , MPlaceTy , MemoryKind ,
@@ -147,12 +149,6 @@ pub trait Machine<'tcx>: Sized {
147
149
/// already been checked before.
148
150
const ALL_CONSTS_ARE_PRECHECKED : bool = true ;
149
151
150
- /// Determines whether rustc_const_eval functions that make use of the [Machine] should make
151
- /// tracing calls (to the `tracing` library). By default this is `false`, meaning the tracing
152
- /// calls will supposedly be optimized out. This flag is set to `true` inside Miri, to allow
153
- /// tracing the interpretation steps, among other things.
154
- const TRACING_ENABLED : bool = false ;
155
-
156
152
/// Whether memory accesses should be alignment-checked.
157
153
fn enforce_alignment ( ecx : & InterpCx < ' tcx , Self > ) -> bool ;
158
154
@@ -634,6 +630,14 @@ pub trait Machine<'tcx>: Sized {
634
630
/// Compute the value passed to the constructors of the `AllocBytes` type for
635
631
/// abstract machine allocations.
636
632
fn get_default_alloc_params ( & self ) -> <Self :: Bytes as AllocBytes >:: AllocParams ;
633
+
634
+ /// Allows enabling/disabling tracing calls from within `rustc_const_eval` at compile time, by
635
+ /// delegating the entering of [tracing::Span]s to implementors of the [Machine] trait. The
636
+ /// default implementation corresponds to tracing being disabled, meaning the tracing calls will
637
+ /// supposedly be optimized out completely. To enable tracing, override this trait method and
638
+ /// return `span.entered()`. Also see [crate::enter_trace_span].
639
+ #[ must_use]
640
+ fn enter_trace_span ( _span : tracing:: Span ) -> impl EnteredTraceSpan { ( ) }
637
641
}
638
642
639
643
/// A lot of the flexibility above is just needed for `Miri`, but all "compile-time" machines
0 commit comments