rustc_const_eval::interpret::validity

Struct ValidityVisitor

Source
struct ValidityVisitor<'rt, 'tcx, M: Machine<'tcx>> {
    path: Vec<PathElem>,
    ref_tracking: Option<&'rt mut RefTracking<MPlaceTy<'tcx, M::Provenance>, Vec<PathElem>>>,
    ctfe_mode: Option<CtfeValidationMode>,
    ecx: &'rt mut InterpCx<'tcx, M>,
    reset_provenance_and_padding: bool,
    data_bytes: Option<RangeSet>,
}

Fields§

§path: Vec<PathElem>

The path may be pushed to, but the part that is present when a function starts must not be changed! visit_fields and visit_array rely on this stack discipline.

§ref_tracking: Option<&'rt mut RefTracking<MPlaceTy<'tcx, M::Provenance>, Vec<PathElem>>>§ctfe_mode: Option<CtfeValidationMode>

None indicates this is not validating for CTFE (but for runtime).

§ecx: &'rt mut InterpCx<'tcx, M>§reset_provenance_and_padding: bool

Whether provenance should be reset outside of pointers (emulating the effect of a typed copy).

§data_bytes: Option<RangeSet>

This tracks which byte ranges in this value contain data; the remaining bytes are padding. The ideal representation here would be pointer-length pairs, but to keep things more compact we only store a (range) set of offsets – the base pointer is the same throughout the entire visit, after all. If this is Some, then reset_provenance_and_padding must be true (but not vice versa: we might not track data vs padding bytes if the operand isn’t stored in memory anyway).

Implementations§

Source§

impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M>

Source

fn aggregate_field_path_elem( &mut self, layout: TyAndLayout<'tcx>, field: usize, ) -> PathElem

Source

fn with_elem<R>( &mut self, elem: PathElem, f: impl FnOnce(&mut Self) -> InterpResult<'tcx, R>, ) -> InterpResult<'tcx, R>

Source

fn read_immediate( &self, val: &PlaceTy<'tcx, M::Provenance>, expected: ExpectedKind, ) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>>

Source

fn read_scalar( &self, val: &PlaceTy<'tcx, M::Provenance>, expected: ExpectedKind, ) -> InterpResult<'tcx, Scalar<M::Provenance>>

Source

fn deref_pointer( &mut self, val: &PlaceTy<'tcx, M::Provenance>, expected: ExpectedKind, ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>>

Source

fn check_wide_ptr_meta( &mut self, meta: MemPlaceMeta<M::Provenance>, pointee: TyAndLayout<'tcx>, ) -> InterpResult<'tcx>

Source

fn check_safe_pointer( &mut self, value: &PlaceTy<'tcx, M::Provenance>, ptr_kind: PointerKind, ) -> InterpResult<'tcx>

Check a reference or Box.

Source

fn try_visit_primitive( &mut self, value: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx, bool>

Check if this is a value of primitive type, and if yes check the validity of the value at that type. Return true if the type is indeed primitive.

Note that not all of these have FieldsShape::Primitive, e.g. wide references.

Source

fn visit_scalar( &mut self, scalar: Scalar<M::Provenance>, scalar_layout: ScalarAbi, ) -> InterpResult<'tcx>

Source

fn in_mutable_memory(&self, val: &PlaceTy<'tcx, M::Provenance>) -> bool

Source

fn add_data_range(&mut self, ptr: Pointer<Option<M::Provenance>>, size: Size)

Add the given pointer-length pair to the “data” range of this visit.

Source

fn add_data_range_place(&mut self, place: &PlaceTy<'tcx, M::Provenance>)

Add the entire given place to the “data” range of this visit.

Source

fn data_range_offset( ecx: &InterpCx<'tcx, M>, place: &PlaceTy<'tcx, M::Provenance>, ) -> Size

Convert a place into the offset it starts at, for the purpose of data_range tracking. Must only be called if data_bytes is Some(_).

Source

fn reset_padding( &mut self, place: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx>

Source

fn union_data_range<'e>( ecx: &'e mut InterpCx<'tcx, M>, layout: TyAndLayout<'tcx>, ) -> Cow<'e, RangeSet>

Computes the data range of this union type: which bytes are inside a field (i.e., not padding.)

Trait Implementations§

Source§

impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt, 'tcx, M>

Source§

type V = PlaceTy<'tcx, <M as Machine<'tcx>>::Provenance>

Source§

fn ecx(&self) -> &InterpCx<'tcx, M>

The visitor must have an InterpCx in it.
Source§

fn read_discriminant( &mut self, val: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx, VariantIdx>

read_discriminant can be hooked for better error messages.
Source§

fn visit_field( &mut self, old_val: &PlaceTy<'tcx, M::Provenance>, field: usize, new_val: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx>

Called each time we recurse down to a field of a “product-like” aggregate (structs, tuples, arrays and the like, but not enums), passing in old (outer) and new (inner) value. This gives the visitor the chance to track the stack of nested fields that we are descending through.
Source§

fn visit_variant( &mut self, old_val: &PlaceTy<'tcx, M::Provenance>, variant_id: VariantIdx, new_val: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx>

Called when recursing into an enum variant. This gives the visitor the chance to track the stack of nested fields that we are descending through.
Source§

fn visit_union( &mut self, val: &PlaceTy<'tcx, M::Provenance>, _fields: NonZero<usize>, ) -> InterpResult<'tcx>

Visits the given value as a union. No automatic recursion can happen here.
Source§

fn visit_box( &mut self, _box_ty: Ty<'tcx>, val: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx>

Visits the given value as the pointer of a Box. There is nothing to recurse into. The type of v will be a raw pointer to T, but this is a field of Box<T> and the pointee type is the actual T. box_ty provides the full type of the Box itself.
Source§

fn visit_value( &mut self, val: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx>

Visits the given value, dispatching as appropriate to more specialized visitors.
Source§

fn aggregate_field_iter( memory_index: &IndexVec<FieldIdx, u32>, ) -> impl Iterator<Item = FieldIdx> + 'static

This function provides the chance to reorder the order in which fields are visited for FieldsShape::Aggregate. Read more
Source§

fn walk_value(&mut self, v: &Self::V) -> InterpResult<'tcx>

Traversal logic; should not be overloaded.

Auto Trait Implementations§

§

impl<'rt, 'tcx, M> DynSend for ValidityVisitor<'rt, 'tcx, M>
where M: DynSend, <M as Machine<'tcx>>::MemoryMap: DynSend, <M as Machine<'tcx>>::ExtraFnVal: DynSend, <M as Machine<'tcx>>::Provenance: DynSend,

§

impl<'rt, 'tcx, M> DynSync for ValidityVisitor<'rt, 'tcx, M>
where M: DynSync, <M as Machine<'tcx>>::MemoryMap: DynSync, <M as Machine<'tcx>>::ExtraFnVal: DynSync, <M as Machine<'tcx>>::Provenance: DynSync,

§

impl<'rt, 'tcx, M> Freeze for ValidityVisitor<'rt, 'tcx, M>

§

impl<'rt, 'tcx, M> !RefUnwindSafe for ValidityVisitor<'rt, 'tcx, M>

§

impl<'rt, 'tcx, M> !Send for ValidityVisitor<'rt, 'tcx, M>

§

impl<'rt, 'tcx, M> !Sync for ValidityVisitor<'rt, 'tcx, M>

§

impl<'rt, 'tcx, M> Unpin for ValidityVisitor<'rt, 'tcx, M>

§

impl<'rt, 'tcx, M> !UnwindSafe for ValidityVisitor<'rt, 'tcx, M>

Blanket Implementations§

Source§

impl<T> Aligned for T

Source§

const ALIGN: Alignment

Alignment of Self.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P> IntoQueryParam<P> for P

Source§

impl<T> MaybeResult<T> for T

Source§

type Error = !

Source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

Source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

Source§

fn upcast(self, interner: I) -> U

Source§

impl<I, T> UpcastFrom<I, T> for T

Source§

fn upcast_from(from: T, _tcx: I) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

Source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 72 bytes