Skip to content

Commit bb08a4d

Browse files
committed
Make Miri's enter_trace_span! call const_eval's
1 parent e1f674c commit bb08a4d

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ impl EnteredTraceSpan for tracing::span::EnteredSpan {}
114114
/// ```
115115
#[macro_export]
116116
macro_rules! enter_trace_span {
117-
($machine:ident, $name:ident :: $subname:ident $($tt:tt)*) => {{
117+
($machine:ty, $name:ident :: $subname:ident $($tt:tt)*) => {
118118
$crate::enter_trace_span!($machine, stringify!($name), $name = %stringify!($subname) $($tt)*)
119-
}};
119+
};
120120

121-
($machine:ident, $($tt:tt)*) => {
121+
($machine:ty, $($tt:tt)*) => {
122122
<$machine as $crate::interpret::Machine>::enter_trace_span(|| tracing::info_span!($($tt)*))
123-
}
123+
};
124124
}

src/tools/miri/src/helpers.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,29 +1245,14 @@ impl ToU64 for usize {
12451245
}
12461246
}
12471247

1248-
/// This struct is needed to enforce `#[must_use]` on values produced by [enter_trace_span] even
1249-
/// when the "tracing" feature is not enabled.
1250-
#[must_use]
1251-
pub struct MaybeEnteredTraceSpan {
1252-
#[cfg(feature = "tracing")]
1253-
pub _entered_span: tracing::span::EnteredSpan,
1254-
}
1255-
12561248
/// Enters a [tracing::info_span] only if the "tracing" feature is enabled, otherwise does nothing.
1257-
/// This is like [rustc_const_eval::enter_trace_span] except that it does not depend on the
1258-
/// [Machine] trait to check if tracing is enabled, because from the Miri codebase we can directly
1259-
/// check whether the "tracing" feature is enabled, unlike from the rustc_const_eval codebase.
1249+
/// This calls [rustc_const_eval::enter_trace_span] with [MiriMachine] as the first argument, which
1250+
/// will in turn call [MiriMachine::enter_trace_span], which takes care of determining at compile
1251+
/// time whether to trace or not (and supposedly the call is compiled out if tracing is disabled).
12601252
/// Look at [rustc_const_eval::enter_trace_span] for complete documentation, examples and tips.
12611253
#[macro_export]
12621254
macro_rules! enter_trace_span {
1263-
($name:ident :: $subname:ident $($tt:tt)*) => {{
1264-
$crate::enter_trace_span!(stringify!($name), $name = %stringify!($subname) $($tt)*)
1265-
}};
1266-
12671255
($($tt:tt)*) => {
1268-
$crate::MaybeEnteredTraceSpan {
1269-
#[cfg(feature = "tracing")]
1270-
_entered_span: tracing::info_span!($($tt)*).entered()
1271-
}
1256+
rustc_const_eval::enter_trace_span!($crate::MiriMachine<'static>, $($tt)*)
12721257
};
12731258
}

src/tools/miri/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ pub use crate::eval::{
143143
AlignmentCheck, BacktraceStyle, IsolatedOp, MiriConfig, MiriEntryFnType, RejectOpWith,
144144
ValidationMode, create_ecx, eval_entry,
145145
};
146-
pub use crate::helpers::{
147-
AccessKind, EvalContextExt as _, MaybeEnteredTraceSpan, ToU64 as _, ToUsize as _,
148-
};
146+
pub use crate::helpers::{AccessKind, EvalContextExt as _, ToU64 as _, ToUsize as _};
149147
pub use crate::intrinsics::EvalContextExt as _;
150148
pub use crate::machine::{
151149
AllocExtra, DynMachineCallback, FrameExtra, MachineCallback, MemoryKind, MiriInterpCx,

0 commit comments

Comments
 (0)