|
3 | 3 |
|
4 | 4 | use rustc_index::IndexVec;
|
5 | 5 | use rustc_middle::mir::interpret::InterpResult;
|
6 |
| -use rustc_middle::ty; |
| 6 | +use rustc_middle::ty::{self, Ty}; |
7 | 7 | use rustc_target::abi::FieldIdx;
|
8 | 8 | use rustc_target::abi::{FieldsShape, VariantIdx, Variants};
|
9 | 9 |
|
@@ -47,10 +47,10 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
|
47 | 47 | Ok(())
|
48 | 48 | }
|
49 | 49 | /// Visits the given value as the pointer of a `Box`. There is nothing to recurse into.
|
50 |
| - /// The type of `v` will be a raw pointer, but this is a field of `Box<T>` and the |
51 |
| - /// pointee type is the actual `T`. |
| 50 | + /// The type of `v` will be a raw pointer to `T`, but this is a field of `Box<T>` and the |
| 51 | + /// pointee type is the actual `T`. `box_ty` provides the full type of the `Box` itself. |
52 | 52 | #[inline(always)]
|
53 |
| - fn visit_box(&mut self, _v: &Self::V) -> InterpResult<'tcx> { |
| 53 | + fn visit_box(&mut self, _box_ty: Ty<'tcx>, _v: &Self::V) -> InterpResult<'tcx> { |
54 | 54 | Ok(())
|
55 | 55 | }
|
56 | 56 |
|
@@ -144,7 +144,7 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
|
144 | 144 | assert_eq!(nonnull_ptr.layout().fields.count(), 1);
|
145 | 145 | let raw_ptr = self.ecx().project_field(&nonnull_ptr, 0)?; // the actual raw ptr
|
146 | 146 | // ... whose only field finally is a raw ptr we can dereference.
|
147 |
| - self.visit_box(&raw_ptr)?; |
| 147 | + self.visit_box(ty, &raw_ptr)?; |
148 | 148 |
|
149 | 149 | // The second `Box` field is the allocator, which we recursively check for validity
|
150 | 150 | // like in regular structs.
|
|
0 commit comments