File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1431,3 +1431,25 @@ impl ToU64 for usize {
1431
1431
self . try_into ( ) . unwrap ( )
1432
1432
}
1433
1433
}
1434
+
1435
+ /// This struct is needed to enforce `#[must_use]` on values produced by [enter_trace_span] even
1436
+ /// when the "tracing" feature is not enabled.
1437
+ #[ must_use]
1438
+ pub struct MaybeEnteredSpan {
1439
+ #[ cfg( feature = "tracing" ) ]
1440
+ pub _entered_span : tracing:: span:: EnteredSpan ,
1441
+ }
1442
+
1443
+ /// Enters a [tracing::info_span] only if the "tracing" feature is enabled, otherwise does nothing.
1444
+ /// This is like [rustc_const_eval::enter_trace_span] except that it does not depend on the
1445
+ /// [Machine] trait to check if tracing is enabled, because from the Miri codebase we can directly
1446
+ /// check whether the "tracing" feature is enabled, unlike from the rustc_const_eval codebase.
1447
+ #[ macro_export]
1448
+ macro_rules! enter_trace_span {
1449
+ ( $( $tt: tt) * ) => {
1450
+ $crate:: helpers:: MaybeEnteredSpan {
1451
+ #[ cfg( feature = "tracing" ) ]
1452
+ _entered_span: tracing:: info_span!( $( $tt) * ) . entered( )
1453
+ }
1454
+ }
1455
+ }
You can’t perform that action at this time.
0 commit comments