Skip to content

Commit 4102e73

Browse files
authored
Rollup merge of rust-lang#145249 - Stypox:_span-to-_trace, r=joshtriplett
Rename entered trace span variables from `_span` to `_trace` This PR just changes the name of `EnteredTraceSpan` variables used to automatically close tracing spans when going out of scope. This renaming was needed because `_span` could possibly be confused with the `Span` type in rustc, so I used `_trace` as suggested in rust-lang#144727 (comment).
2 parents 0ad15fd + cd4676c commit 4102e73

File tree

8 files changed

+31
-31
lines changed

8 files changed

+31
-31
lines changed

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
346346
destination: &PlaceTy<'tcx, M::Provenance>,
347347
mut cont: ReturnContinuation,
348348
) -> InterpResult<'tcx> {
349-
let _span = enter_trace_span!(M, step::init_stack_frame, %instance, tracing_separate_thread = Empty);
349+
let _trace = enter_trace_span!(M, step::init_stack_frame, %instance, tracing_separate_thread = Empty);
350350

351351
// Compute callee information.
352352
// FIXME: for variadic support, do we have to somehow determine callee's extra_args?
@@ -527,7 +527,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
527527
target: Option<mir::BasicBlock>,
528528
unwind: mir::UnwindAction,
529529
) -> InterpResult<'tcx> {
530-
let _span =
530+
let _trace =
531531
enter_trace_span!(M, step::init_fn_call, tracing_separate_thread = Empty, ?fn_val)
532532
.or_if_tracing_disabled(|| trace!("init_fn_call: {:#?}", fn_val));
533533

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
113113
/// See [LayoutOf::layout_of] for the original documentation.
114114
#[inline(always)]
115115
pub fn layout_of(&self, ty: Ty<'tcx>) -> <Self as LayoutOfHelpers<'tcx>>::LayoutOfResult {
116-
let _span = enter_trace_span!(M, layouting::layout_of, ty = ?ty.kind());
116+
let _trace = enter_trace_span!(M, layouting::layout_of, ty = ?ty.kind());
117117
LayoutOf::layout_of(self, ty)
118118
}
119119

@@ -126,7 +126,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
126126
sig: ty::PolyFnSig<'tcx>,
127127
extra_args: &'tcx ty::List<Ty<'tcx>>,
128128
) -> <Self as FnAbiOfHelpers<'tcx>>::FnAbiOfResult {
129-
let _span = enter_trace_span!(M, layouting::fn_abi_of_fn_ptr, ?sig, ?extra_args);
129+
let _trace = enter_trace_span!(M, layouting::fn_abi_of_fn_ptr, ?sig, ?extra_args);
130130
FnAbiOf::fn_abi_of_fn_ptr(self, sig, extra_args)
131131
}
132132

@@ -139,7 +139,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
139139
instance: ty::Instance<'tcx>,
140140
extra_args: &'tcx ty::List<Ty<'tcx>>,
141141
) -> <Self as FnAbiOfHelpers<'tcx>>::FnAbiOfResult {
142-
let _span = enter_trace_span!(M, layouting::fn_abi_of_instance, ?instance, ?extra_args);
142+
let _trace = enter_trace_span!(M, layouting::fn_abi_of_instance, ?instance, ?extra_args);
143143
FnAbiOf::fn_abi_of_instance(self, instance, extra_args)
144144
}
145145
}
@@ -322,7 +322,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
322322
frame: &Frame<'tcx, M::Provenance, M::FrameExtra>,
323323
value: T,
324324
) -> Result<T, ErrorHandled> {
325-
let _span = enter_trace_span!(
325+
let _trace = enter_trace_span!(
326326
M,
327327
"instantiate_from_frame_and_normalize_erasing_regions",
328328
"{}",

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
773773
mir_place: mir::Place<'tcx>,
774774
layout: Option<TyAndLayout<'tcx>>,
775775
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
776-
let _span = enter_trace_span!(
776+
let _trace = enter_trace_span!(
777777
M,
778778
step::eval_place_to_op,
779779
?mir_place,
@@ -823,7 +823,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
823823
mir_op: &mir::Operand<'tcx>,
824824
layout: Option<TyAndLayout<'tcx>>,
825825
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
826-
let _span =
826+
let _trace =
827827
enter_trace_span!(M, step::eval_operand, ?mir_op, tracing_separate_thread = Empty);
828828

829829
use rustc_middle::mir::Operand::*;

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ where
526526
&self,
527527
mir_place: mir::Place<'tcx>,
528528
) -> InterpResult<'tcx, PlaceTy<'tcx, M::Provenance>> {
529-
let _span =
529+
let _trace =
530530
enter_trace_span!(M, step::eval_place, ?mir_place, tracing_separate_thread = Empty);
531531

532532
let mut place = self.local_to_place(mir_place.local)?;

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
7676
///
7777
/// This does NOT move the statement counter forward, the caller has to do that!
7878
pub fn eval_statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
79-
let _span = enter_trace_span!(
79+
let _trace = enter_trace_span!(
8080
M,
8181
step::eval_statement,
8282
stmt = ?stmt.kind,
@@ -465,7 +465,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
465465
}
466466

467467
fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> InterpResult<'tcx> {
468-
let _span = enter_trace_span!(
468+
let _trace = enter_trace_span!(
469469
M,
470470
step::eval_terminator,
471471
terminator = ?terminator.kind,

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ impl EnteredTraceSpan for tracing::span::EnteredSpan {
8585
/// # let my_debug_var = String::new();
8686
/// // logs a span named "hello" with a field named "arg" of value 42 (works only because
8787
/// // 42 implements the tracing::Value trait, otherwise use one of the options below)
88-
/// let _span = enter_trace_span!(M, "hello", arg = 42);
88+
/// let _trace = enter_trace_span!(M, "hello", arg = 42);
8989
/// // logs a field called "my_display_var" using the Display implementation
90-
/// let _span = enter_trace_span!(M, "hello", %my_display_var);
90+
/// let _trace = enter_trace_span!(M, "hello", %my_display_var);
9191
/// // logs a field called "my_debug_var" using the Debug implementation
92-
/// let _span = enter_trace_span!(M, "hello", ?my_debug_var);
92+
/// let _trace = enter_trace_span!(M, "hello", ?my_debug_var);
9393
/// ```
9494
///
9595
/// ### `NAME::SUBNAME` syntax
@@ -107,8 +107,8 @@ impl EnteredTraceSpan for tracing::span::EnteredSpan {
107107
/// # use rustc_const_eval::enter_trace_span;
108108
/// # type M = rustc_const_eval::const_eval::CompileTimeMachine<'static>;
109109
/// // for example, the first will expand to the second
110-
/// let _span = enter_trace_span!(M, borrow_tracker::on_stack_pop, /* ... */);
111-
/// let _span = enter_trace_span!(M, "borrow_tracker", borrow_tracker = "on_stack_pop", /* ... */);
110+
/// let _trace = enter_trace_span!(M, borrow_tracker::on_stack_pop, /* ... */);
111+
/// let _trace = enter_trace_span!(M, "borrow_tracker", borrow_tracker = "on_stack_pop", /* ... */);
112112
/// ```
113113
///
114114
/// ### `tracing_separate_thread` parameter
@@ -124,7 +124,7 @@ impl EnteredTraceSpan for tracing::span::EnteredSpan {
124124
/// ```rust
125125
/// # use rustc_const_eval::enter_trace_span;
126126
/// # type M = rustc_const_eval::const_eval::CompileTimeMachine<'static>;
127-
/// let _span = enter_trace_span!(M, step::eval_statement, tracing_separate_thread = tracing::field::Empty);
127+
/// let _trace = enter_trace_span!(M, step::eval_statement, tracing_separate_thread = tracing::field::Empty);
128128
/// ```
129129
///
130130
/// ### Executing something else when tracing is disabled
@@ -136,7 +136,7 @@ impl EnteredTraceSpan for tracing::span::EnteredSpan {
136136
/// # use rustc_const_eval::enter_trace_span;
137137
/// # use rustc_const_eval::interpret::EnteredTraceSpan;
138138
/// # type M = rustc_const_eval::const_eval::CompileTimeMachine<'static>;
139-
/// let _span = enter_trace_span!(M, step::eval_statement)
139+
/// let _trace = enter_trace_span!(M, step::eval_statement)
140140
/// .or_if_tracing_disabled(|| tracing::info!("eval_statement"));
141141
/// ```
142142
#[macro_export]

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
14151415
recursive: bool,
14161416
reset_provenance_and_padding: bool,
14171417
) -> InterpResult<'tcx> {
1418-
let _span = enter_trace_span!(
1418+
let _trace = enter_trace_span!(
14191419
M,
14201420
"validate_operand",
14211421
"recursive={recursive}, reset_provenance_and_padding={reset_provenance_and_padding}, val={val:?}"

src/tools/miri/src/borrow_tracker/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl GlobalStateInner {
260260
kind: MemoryKind,
261261
machine: &MiriMachine<'_>,
262262
) -> AllocState {
263-
let _span = enter_trace_span!(borrow_tracker::new_allocation, ?id, ?alloc_size, ?kind);
263+
let _trace = enter_trace_span!(borrow_tracker::new_allocation, ?id, ?alloc_size, ?kind);
264264
match self.borrow_tracker_method {
265265
BorrowTrackerMethod::StackedBorrows =>
266266
AllocState::StackedBorrows(Box::new(RefCell::new(Stacks::new_allocation(
@@ -281,7 +281,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
281281
kind: RetagKind,
282282
val: &ImmTy<'tcx>,
283283
) -> InterpResult<'tcx, ImmTy<'tcx>> {
284-
let _span = enter_trace_span!(borrow_tracker::retag_ptr_value, ?kind, ?val.layout);
284+
let _trace = enter_trace_span!(borrow_tracker::retag_ptr_value, ?kind, ?val.layout);
285285
let this = self.eval_context_mut();
286286
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
287287
match method {
@@ -295,7 +295,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
295295
kind: RetagKind,
296296
place: &PlaceTy<'tcx>,
297297
) -> InterpResult<'tcx> {
298-
let _span = enter_trace_span!(borrow_tracker::retag_place_contents, ?kind, ?place);
298+
let _trace = enter_trace_span!(borrow_tracker::retag_place_contents, ?kind, ?place);
299299
let this = self.eval_context_mut();
300300
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
301301
match method {
@@ -305,7 +305,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
305305
}
306306

307307
fn protect_place(&mut self, place: &MPlaceTy<'tcx>) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
308-
let _span = enter_trace_span!(borrow_tracker::protect_place, ?place);
308+
let _trace = enter_trace_span!(borrow_tracker::protect_place, ?place);
309309
let this = self.eval_context_mut();
310310
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
311311
match method {
@@ -315,7 +315,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
315315
}
316316

317317
fn expose_tag(&self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> {
318-
let _span =
318+
let _trace =
319319
enter_trace_span!(borrow_tracker::expose_tag, alloc_id = alloc_id.0, tag = tag.0);
320320
let this = self.eval_context_ref();
321321
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
@@ -360,7 +360,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
360360
&self,
361361
frame: &Frame<'tcx, Provenance, FrameExtra<'tcx>>,
362362
) -> InterpResult<'tcx> {
363-
let _span = enter_trace_span!(borrow_tracker::on_stack_pop);
363+
let _trace = enter_trace_span!(borrow_tracker::on_stack_pop);
364364
let this = self.eval_context_ref();
365365
let borrow_tracker = this.machine.borrow_tracker.as_ref().unwrap();
366366
// The body of this loop needs `borrow_tracker` immutably
@@ -438,7 +438,7 @@ impl AllocState {
438438
range: AllocRange,
439439
machine: &MiriMachine<'tcx>,
440440
) -> InterpResult<'tcx> {
441-
let _span = enter_trace_span!(borrow_tracker::before_memory_read, alloc_id = alloc_id.0);
441+
let _trace = enter_trace_span!(borrow_tracker::before_memory_read, alloc_id = alloc_id.0);
442442
match self {
443443
AllocState::StackedBorrows(sb) =>
444444
sb.borrow_mut().before_memory_read(alloc_id, prov_extra, range, machine),
@@ -460,7 +460,7 @@ impl AllocState {
460460
range: AllocRange,
461461
machine: &MiriMachine<'tcx>,
462462
) -> InterpResult<'tcx> {
463-
let _span = enter_trace_span!(borrow_tracker::before_memory_write, alloc_id = alloc_id.0);
463+
let _trace = enter_trace_span!(borrow_tracker::before_memory_write, alloc_id = alloc_id.0);
464464
match self {
465465
AllocState::StackedBorrows(sb) =>
466466
sb.get_mut().before_memory_write(alloc_id, prov_extra, range, machine),
@@ -482,7 +482,7 @@ impl AllocState {
482482
size: Size,
483483
machine: &MiriMachine<'tcx>,
484484
) -> InterpResult<'tcx> {
485-
let _span =
485+
let _trace =
486486
enter_trace_span!(borrow_tracker::before_memory_deallocation, alloc_id = alloc_id.0);
487487
match self {
488488
AllocState::StackedBorrows(sb) =>
@@ -493,7 +493,7 @@ impl AllocState {
493493
}
494494

495495
pub fn remove_unreachable_tags(&self, tags: &FxHashSet<BorTag>) {
496-
let _span = enter_trace_span!(borrow_tracker::remove_unreachable_tags);
496+
let _trace = enter_trace_span!(borrow_tracker::remove_unreachable_tags);
497497
match self {
498498
AllocState::StackedBorrows(sb) => sb.borrow_mut().remove_unreachable_tags(tags),
499499
AllocState::TreeBorrows(tb) => tb.borrow_mut().remove_unreachable_tags(tags),
@@ -508,7 +508,7 @@ impl AllocState {
508508
tag: BorTag,
509509
alloc_id: AllocId, // diagnostics
510510
) -> InterpResult<'tcx> {
511-
let _span = enter_trace_span!(
511+
let _trace = enter_trace_span!(
512512
borrow_tracker::release_protector,
513513
alloc_id = alloc_id.0,
514514
tag = tag.0
@@ -523,7 +523,7 @@ impl AllocState {
523523

524524
impl VisitProvenance for AllocState {
525525
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
526-
let _span = enter_trace_span!(borrow_tracker::visit_provenance);
526+
let _trace = enter_trace_span!(borrow_tracker::visit_provenance);
527527
match self {
528528
AllocState::StackedBorrows(sb) => sb.visit_provenance(visit),
529529
AllocState::TreeBorrows(tb) => tb.visit_provenance(visit),

0 commit comments

Comments
 (0)