pub trait DestructurableAccessorOpInterface: Op {
// Required methods
fn can_rewire(
&self,
ctx: &Context,
value: &DestructurableValueSlot,
used_indices: &mut SmallSet<AttrObj, 8>,
must_be_safely_used: &mut Vec<ValueSlot>,
) -> bool;
fn rewire(
&self,
ctx: &mut Context,
value: &DestructurableValueSlot,
subvalues: &HMap<AttrObj, ValueSlot>,
rewriter: &mut PassRewriter,
) -> DeletionKind;
// Provided method
fn verify(_op: &dyn Op, _ctx: &Context) -> Result<()>
where Self: Sized { ... }
}Expand description
Describes operations that can access a sub-element of a destructurable value.
Required Methods§
Sourcefn can_rewire(
&self,
ctx: &Context,
value: &DestructurableValueSlot,
used_indices: &mut SmallSet<AttrObj, 8>,
must_be_safely_used: &mut Vec<ValueSlot>,
) -> bool
fn can_rewire( &self, ctx: &Context, value: &DestructurableValueSlot, used_indices: &mut SmallSet<AttrObj, 8>, must_be_safely_used: &mut Vec<ValueSlot>, ) -> bool
For a given destructurable value, returns whether this operation can rewire its uses of the value to use the values generated after destructuring. This may involve creating new operations.
This method must also register the indices it will access within the
used_indices set. If the accessor generates new values mapping to
subelements, they must be registered in must_be_safely_used to ensure
they are used in a safe manner.
No IR mutation is allowed in this method.
Sourcefn rewire(
&self,
ctx: &mut Context,
value: &DestructurableValueSlot,
subvalues: &HMap<AttrObj, ValueSlot>,
rewriter: &mut PassRewriter,
) -> DeletionKind
fn rewire( &self, ctx: &mut Context, value: &DestructurableValueSlot, subvalues: &HMap<AttrObj, ValueSlot>, rewriter: &mut PassRewriter, ) -> DeletionKind
Rewires the use of a slot to the generated subvalues, without deleting any operation. Returns whether the accessor should be deleted.
Deletion of operations is not allowed, only the accessor can be scheduled for deletion by returning the appropriate value.
Provided Methods§
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".