Skip to content

Commit fcb4cf5

Browse files
committed
avoid repeating the Provenance parameter everywhere
1 parent 79c30b6 commit fcb4cf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+585
-709
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
281281
fn retag_ptr_value(
282282
&mut self,
283283
kind: RetagKind,
284-
val: &ImmTy<'tcx, Provenance>,
285-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
284+
val: &ImmTy<'tcx>,
285+
) -> InterpResult<'tcx, ImmTy<'tcx>> {
286286
let this = self.eval_context_mut();
287287
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
288288
match method {
@@ -294,7 +294,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
294294
fn retag_place_contents(
295295
&mut self,
296296
kind: RetagKind,
297-
place: &PlaceTy<'tcx, Provenance>,
297+
place: &PlaceTy<'tcx>,
298298
) -> InterpResult<'tcx> {
299299
let this = self.eval_context_mut();
300300
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
@@ -304,10 +304,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
304304
}
305305
}
306306

307-
fn protect_place(
308-
&mut self,
309-
place: &MPlaceTy<'tcx, Provenance>,
310-
) -> InterpResult<'tcx, MPlaceTy<'tcx, Provenance>> {
307+
fn protect_place(&mut self, place: &MPlaceTy<'tcx>) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
311308
let this = self.eval_context_mut();
312309
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
313310
match method {

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
587587
/// Returns the provenance that should be used henceforth.
588588
fn sb_reborrow(
589589
&mut self,
590-
place: &MPlaceTy<'tcx, Provenance>,
590+
place: &MPlaceTy<'tcx>,
591591
size: Size,
592592
new_perm: NewPermission,
593593
new_tag: BorTag,
@@ -809,10 +809,10 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
809809

810810
fn sb_retag_place(
811811
&mut self,
812-
place: &MPlaceTy<'tcx, Provenance>,
812+
place: &MPlaceTy<'tcx>,
813813
new_perm: NewPermission,
814814
info: RetagInfo, // diagnostics info about this retag
815-
) -> InterpResult<'tcx, MPlaceTy<'tcx, Provenance>> {
815+
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
816816
let this = self.eval_context_mut();
817817
let size = this.size_and_align_of_mplace(place)?.map(|(size, _)| size);
818818
// FIXME: If we cannot determine the size (because the unsized tail is an `extern type`),
@@ -839,10 +839,10 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
839839
/// `kind` indicates what kind of reference is being created.
840840
fn sb_retag_reference(
841841
&mut self,
842-
val: &ImmTy<'tcx, Provenance>,
842+
val: &ImmTy<'tcx>,
843843
new_perm: NewPermission,
844844
info: RetagInfo, // diagnostics info about this retag
845-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
845+
) -> InterpResult<'tcx, ImmTy<'tcx>> {
846846
let this = self.eval_context_mut();
847847
let place = this.ref_to_mplace(val)?;
848848
let new_place = this.sb_retag_place(&place, new_perm, info)?;
@@ -855,8 +855,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
855855
fn sb_retag_ptr_value(
856856
&mut self,
857857
kind: RetagKind,
858-
val: &ImmTy<'tcx, Provenance>,
859-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
858+
val: &ImmTy<'tcx>,
859+
) -> InterpResult<'tcx, ImmTy<'tcx>> {
860860
let this = self.eval_context_mut();
861861
let new_perm = NewPermission::from_ref_ty(val.layout.ty, kind, this);
862862
let cause = match kind {
@@ -870,7 +870,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
870870
fn sb_retag_place_contents(
871871
&mut self,
872872
kind: RetagKind,
873-
place: &PlaceTy<'tcx, Provenance>,
873+
place: &PlaceTy<'tcx>,
874874
) -> InterpResult<'tcx> {
875875
let this = self.eval_context_mut();
876876
let retag_fields = this.machine.borrow_tracker.as_mut().unwrap().get_mut().retag_fields;
@@ -895,7 +895,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
895895
#[inline(always)] // yes this helps in our benchmarks
896896
fn retag_ptr_inplace(
897897
&mut self,
898-
place: &PlaceTy<'tcx, Provenance>,
898+
place: &PlaceTy<'tcx>,
899899
new_perm: NewPermission,
900900
) -> InterpResult<'tcx> {
901901
let val = self.ecx.read_immediate(&self.ecx.place_to_op(place)?)?;
@@ -909,18 +909,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
909909
}
910910
}
911911
impl<'ecx, 'tcx> ValueVisitor<'tcx, MiriMachine<'tcx>> for RetagVisitor<'ecx, 'tcx> {
912-
type V = PlaceTy<'tcx, Provenance>;
912+
type V = PlaceTy<'tcx>;
913913

914914
#[inline(always)]
915915
fn ecx(&self) -> &MiriInterpCx<'tcx> {
916916
self.ecx
917917
}
918918

919-
fn visit_box(
920-
&mut self,
921-
box_ty: Ty<'tcx>,
922-
place: &PlaceTy<'tcx, Provenance>,
923-
) -> InterpResult<'tcx> {
919+
fn visit_box(&mut self, box_ty: Ty<'tcx>, place: &PlaceTy<'tcx>) -> InterpResult<'tcx> {
924920
// Only boxes for the global allocator get any special treatment.
925921
if box_ty.is_box_global(*self.ecx.tcx) {
926922
// Boxes get a weak protectors, since they may be deallocated.
@@ -930,7 +926,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
930926
Ok(())
931927
}
932928

933-
fn visit_value(&mut self, place: &PlaceTy<'tcx, Provenance>) -> InterpResult<'tcx> {
929+
fn visit_value(&mut self, place: &PlaceTy<'tcx>) -> InterpResult<'tcx> {
934930
// If this place is smaller than a pointer, we know that it can't contain any
935931
// pointers we need to retag, so we can stop recursion early.
936932
// This optimization is crucial for ZSTs, because they can contain way more fields
@@ -984,10 +980,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
984980
/// call.
985981
///
986982
/// This is used to ensure soundness of in-place function argument/return passing.
987-
fn sb_protect_place(
988-
&mut self,
989-
place: &MPlaceTy<'tcx, Provenance>,
990-
) -> InterpResult<'tcx, MPlaceTy<'tcx, Provenance>> {
983+
fn sb_protect_place(&mut self, place: &MPlaceTy<'tcx>) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
991984
let this = self.eval_context_mut();
992985

993986
// Retag it. With protection! That is the entire point.

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

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
195195
/// Returns the provenance that should be used henceforth.
196196
fn tb_reborrow(
197197
&mut self,
198-
place: &MPlaceTy<'tcx, Provenance>, // parent tag extracted from here
198+
place: &MPlaceTy<'tcx>, // parent tag extracted from here
199199
ptr_size: Size,
200200
new_perm: NewPermission,
201201
new_tag: BorTag,
@@ -327,9 +327,9 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
327327

328328
fn tb_retag_place(
329329
&mut self,
330-
place: &MPlaceTy<'tcx, Provenance>,
330+
place: &MPlaceTy<'tcx>,
331331
new_perm: NewPermission,
332-
) -> InterpResult<'tcx, MPlaceTy<'tcx, Provenance>> {
332+
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
333333
let this = self.eval_context_mut();
334334

335335
// Determine the size of the reborrow.
@@ -366,9 +366,9 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
366366
/// Retags an individual pointer, returning the retagged version.
367367
fn tb_retag_reference(
368368
&mut self,
369-
val: &ImmTy<'tcx, Provenance>,
369+
val: &ImmTy<'tcx>,
370370
new_perm: NewPermission,
371-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
371+
) -> InterpResult<'tcx, ImmTy<'tcx>> {
372372
let this = self.eval_context_mut();
373373
let place = this.ref_to_mplace(val)?;
374374
let new_place = this.tb_retag_place(&place, new_perm)?;
@@ -383,8 +383,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
383383
fn tb_retag_ptr_value(
384384
&mut self,
385385
kind: RetagKind,
386-
val: &ImmTy<'tcx, Provenance>,
387-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
386+
val: &ImmTy<'tcx>,
387+
) -> InterpResult<'tcx, ImmTy<'tcx>> {
388388
let this = self.eval_context_mut();
389389
let new_perm = match val.layout.ty.kind() {
390390
&ty::Ref(_, pointee, mutability) =>
@@ -402,7 +402,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
402402
fn tb_retag_place_contents(
403403
&mut self,
404404
kind: RetagKind,
405-
place: &PlaceTy<'tcx, Provenance>,
405+
place: &PlaceTy<'tcx>,
406406
) -> InterpResult<'tcx> {
407407
let this = self.eval_context_mut();
408408
let options = this.machine.borrow_tracker.as_mut().unwrap().get_mut();
@@ -423,7 +423,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
423423
#[inline(always)] // yes this helps in our benchmarks
424424
fn retag_ptr_inplace(
425425
&mut self,
426-
place: &PlaceTy<'tcx, Provenance>,
426+
place: &PlaceTy<'tcx>,
427427
new_perm: Option<NewPermission>,
428428
) -> InterpResult<'tcx> {
429429
if let Some(new_perm) = new_perm {
@@ -435,7 +435,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
435435
}
436436
}
437437
impl<'ecx, 'tcx> ValueVisitor<'tcx, MiriMachine<'tcx>> for RetagVisitor<'ecx, 'tcx> {
438-
type V = PlaceTy<'tcx, Provenance>;
438+
type V = PlaceTy<'tcx>;
439439

440440
#[inline(always)]
441441
fn ecx(&self) -> &MiriInterpCx<'tcx> {
@@ -445,11 +445,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
445445
/// Regardless of how `Unique` is handled, Boxes are always reborrowed.
446446
/// When `Unique` is also reborrowed, then it behaves exactly like `Box`
447447
/// except for the fact that `Box` has a non-zero-sized reborrow.
448-
fn visit_box(
449-
&mut self,
450-
box_ty: Ty<'tcx>,
451-
place: &PlaceTy<'tcx, Provenance>,
452-
) -> InterpResult<'tcx> {
448+
fn visit_box(&mut self, box_ty: Ty<'tcx>, place: &PlaceTy<'tcx>) -> InterpResult<'tcx> {
453449
// Only boxes for the global allocator get any special treatment.
454450
if box_ty.is_box_global(*self.ecx.tcx) {
455451
let new_perm = NewPermission::from_unique_ty(
@@ -463,7 +459,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
463459
Ok(())
464460
}
465461

466-
fn visit_value(&mut self, place: &PlaceTy<'tcx, Provenance>) -> InterpResult<'tcx> {
462+
fn visit_value(&mut self, place: &PlaceTy<'tcx>) -> InterpResult<'tcx> {
467463
// If this place is smaller than a pointer, we know that it can't contain any
468464
// pointers we need to retag, so we can stop recursion early.
469465
// This optimization is crucial for ZSTs, because they can contain way more fields
@@ -526,10 +522,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
526522
/// call.
527523
///
528524
/// This is used to ensure soundness of in-place function argument/return passing.
529-
fn tb_protect_place(
530-
&mut self,
531-
place: &MPlaceTy<'tcx, Provenance>,
532-
) -> InterpResult<'tcx, MPlaceTy<'tcx, Provenance>> {
525+
fn tb_protect_place(&mut self, place: &MPlaceTy<'tcx>) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
533526
let this = self.eval_context_mut();
534527

535528
// Retag it. With protection! That is the entire point.
@@ -604,8 +597,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
604597
/// and output can be used by `retag_ptr_inplace`.
605598
fn inner_ptr_of_unique<'tcx>(
606599
ecx: &MiriInterpCx<'tcx>,
607-
place: &PlaceTy<'tcx, Provenance>,
608-
) -> InterpResult<'tcx, PlaceTy<'tcx, Provenance>> {
600+
place: &PlaceTy<'tcx>,
601+
) -> InterpResult<'tcx, PlaceTy<'tcx>> {
609602
// Follows the same layout as `interpret/visitor.rs:walk_value` for `Box` in
610603
// `rustc_const_eval`, just with one fewer layer.
611604
// Here we have a `Unique(NonNull(*mut), PhantomData)`

src/tools/miri/src/concurrency/data_race.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,9 @@ pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> {
606606
/// Perform an atomic read operation at the memory location.
607607
fn read_scalar_atomic(
608608
&self,
609-
place: &MPlaceTy<'tcx, Provenance>,
609+
place: &MPlaceTy<'tcx>,
610610
atomic: AtomicReadOrd,
611-
) -> InterpResult<'tcx, Scalar<Provenance>> {
611+
) -> InterpResult<'tcx, Scalar> {
612612
let this = self.eval_context_ref();
613613
this.atomic_access_check(place, AtomicAccessType::Load(atomic))?;
614614
// This will read from the last store in the modification order of this location. In case
@@ -625,8 +625,8 @@ pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> {
625625
/// Perform an atomic write operation at the memory location.
626626
fn write_scalar_atomic(
627627
&mut self,
628-
val: Scalar<Provenance>,
629-
dest: &MPlaceTy<'tcx, Provenance>,
628+
val: Scalar,
629+
dest: &MPlaceTy<'tcx>,
630630
atomic: AtomicWriteOrd,
631631
) -> InterpResult<'tcx> {
632632
let this = self.eval_context_mut();
@@ -645,12 +645,12 @@ pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> {
645645
/// Perform an atomic RMW operation on a memory location.
646646
fn atomic_rmw_op_immediate(
647647
&mut self,
648-
place: &MPlaceTy<'tcx, Provenance>,
649-
rhs: &ImmTy<'tcx, Provenance>,
648+
place: &MPlaceTy<'tcx>,
649+
rhs: &ImmTy<'tcx>,
650650
op: mir::BinOp,
651651
not: bool,
652652
atomic: AtomicRwOrd,
653-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
653+
) -> InterpResult<'tcx, ImmTy<'tcx>> {
654654
let this = self.eval_context_mut();
655655
this.atomic_access_check(place, AtomicAccessType::Rmw)?;
656656

@@ -670,10 +670,10 @@ pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> {
670670
/// scalar value, the old value is returned.
671671
fn atomic_exchange_scalar(
672672
&mut self,
673-
place: &MPlaceTy<'tcx, Provenance>,
674-
new: Scalar<Provenance>,
673+
place: &MPlaceTy<'tcx>,
674+
new: Scalar,
675675
atomic: AtomicRwOrd,
676-
) -> InterpResult<'tcx, Scalar<Provenance>> {
676+
) -> InterpResult<'tcx, Scalar> {
677677
let this = self.eval_context_mut();
678678
this.atomic_access_check(place, AtomicAccessType::Rmw)?;
679679

@@ -690,11 +690,11 @@ pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> {
690690
/// scalar value, the old value is returned.
691691
fn atomic_min_max_scalar(
692692
&mut self,
693-
place: &MPlaceTy<'tcx, Provenance>,
694-
rhs: ImmTy<'tcx, Provenance>,
693+
place: &MPlaceTy<'tcx>,
694+
rhs: ImmTy<'tcx>,
695695
min: bool,
696696
atomic: AtomicRwOrd,
697-
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
697+
) -> InterpResult<'tcx, ImmTy<'tcx>> {
698698
let this = self.eval_context_mut();
699699
this.atomic_access_check(place, AtomicAccessType::Rmw)?;
700700

@@ -726,9 +726,9 @@ pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> {
726726
/// identical.
727727
fn atomic_compare_exchange_scalar(
728728
&mut self,
729-
place: &MPlaceTy<'tcx, Provenance>,
730-
expect_old: &ImmTy<'tcx, Provenance>,
731-
new: Scalar<Provenance>,
729+
place: &MPlaceTy<'tcx>,
730+
expect_old: &ImmTy<'tcx>,
731+
new: Scalar,
732732
success: AtomicRwOrd,
733733
fail: AtomicReadOrd,
734734
can_fail_spuriously: bool,
@@ -1163,7 +1163,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
11631163
/// Checks that an atomic access is legal at the given place.
11641164
fn atomic_access_check(
11651165
&self,
1166-
place: &MPlaceTy<'tcx, Provenance>,
1166+
place: &MPlaceTy<'tcx>,
11671167
access_type: AtomicAccessType,
11681168
) -> InterpResult<'tcx> {
11691169
let this = self.eval_context_ref();
@@ -1219,7 +1219,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
12191219
/// associated memory-place and on the current thread.
12201220
fn validate_atomic_load(
12211221
&self,
1222-
place: &MPlaceTy<'tcx, Provenance>,
1222+
place: &MPlaceTy<'tcx>,
12231223
atomic: AtomicReadOrd,
12241224
) -> InterpResult<'tcx> {
12251225
let this = self.eval_context_ref();
@@ -1241,7 +1241,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
12411241
/// associated memory-place and on the current thread.
12421242
fn validate_atomic_store(
12431243
&mut self,
1244-
place: &MPlaceTy<'tcx, Provenance>,
1244+
place: &MPlaceTy<'tcx>,
12451245
atomic: AtomicWriteOrd,
12461246
) -> InterpResult<'tcx> {
12471247
let this = self.eval_context_mut();
@@ -1263,7 +1263,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
12631263
/// at the associated memory place and on the current thread.
12641264
fn validate_atomic_rmw(
12651265
&mut self,
1266-
place: &MPlaceTy<'tcx, Provenance>,
1266+
place: &MPlaceTy<'tcx>,
12671267
atomic: AtomicRwOrd,
12681268
) -> InterpResult<'tcx> {
12691269
use AtomicRwOrd::*;
@@ -1292,7 +1292,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
12921292
/// Generic atomic operation implementation
12931293
fn validate_atomic_op<A: Debug + Copy>(
12941294
&self,
1295-
place: &MPlaceTy<'tcx, Provenance>,
1295+
place: &MPlaceTy<'tcx>,
12961296
atomic: A,
12971297
access: AccessType,
12981298
mut op: impl FnMut(

src/tools/miri/src/concurrency/init_once.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
5151
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5252
fn init_once_get_or_create_id(
5353
&mut self,
54-
lock_op: &OpTy<'tcx, Provenance>,
54+
lock_op: &OpTy<'tcx>,
5555
lock_layout: TyAndLayout<'tcx>,
5656
offset: u64,
5757
) -> InterpResult<'tcx, InitOnceId> {

0 commit comments

Comments
 (0)