@@ -1245,43 +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.
1260- ///
1261- /// In addition to the syntax accepted by [tracing::span!], this macro optionally allows passing
1262- /// the span name (i.e. the first macro argument) in the form `NAME::SUBNAME` (without quotes) to
1263- /// indicate that the span has name "NAME" (usually the name of the component) and has an additional
1264- /// more specific name "SUBNAME" (usually the function name). The latter is passed to the [tracing]
1265- /// infrastructure as a span field with the name "NAME". This allows not being distracted by
1266- /// subnames when looking at the trace in <https://ui.perfetto.dev>, but when deeper introspection
1267- /// is needed within a component, it's still possible to view the subnames directly in the UI by
1268- /// selecting a span, clicking on the "NAME" argument on the right, and clicking on "Visualize
1269- /// argument values".
1270- /// ```rust
1271- /// // for example, the first will expand to the second
1272- /// enter_trace_span!(borrow_tracker::on_stack_pop, /* ... */)
1273- /// enter_trace_span!("borrow_tracker", borrow_tracker = "on_stack_pop", /* ... */)
1274- /// ```
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).
1252+ /// Look at [rustc_const_eval::enter_trace_span] for complete documentation, examples and tips.
12751253#[ macro_export]
12761254macro_rules! enter_trace_span {
1277- ( $name: ident :: $subname: ident $( $tt: tt) * ) => { {
1278- enter_trace_span!( stringify!( $name) , $name = %stringify!( $subname) $( $tt) * )
1279- } } ;
1280-
12811255 ( $( $tt: tt) * ) => {
1282- $crate:: MaybeEnteredTraceSpan {
1283- #[ cfg( feature = "tracing" ) ]
1284- _entered_span: tracing:: info_span!( $( $tt) * ) . entered( )
1285- }
1256+ rustc_const_eval:: enter_trace_span!( $crate:: MiriMachine <' static >, $( $tt) * )
12861257 } ;
12871258}
0 commit comments