Skip to main content

## Erasable

# Trait Erasable

Source

    pub trait Erasable: Copy {
        type Storage: Copy;
    }

Expand description

Trait for types that can be erased into `Erased<Self>`.

Erasing and unerasing values is performed by `erase_val` and `restore_val`.

FIXME: This whole trait could potentially be replaced by `T: Copy` and the storage type `[u8; size_of::<T>()]` when support for that is more mature.

## Required Associated Types§

Source

#### type Storage: Copy

Storage type to used for erased values of this type. Should be `[u8; N]`, where N is equal to `size_of::<Self>`.

`ErasedData` wraps this storage type in `MaybeUninit` to ensure that transmutes to/from erased storage are well-defined.

## Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

## Implementations on Foreign Types§

Source§

### impl Erasable for &OsStr

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for AllocatorKind

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for CrateType

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for DefKind

Source§

#### type Storage = [u8; 3]

Source§

### impl Erasable for Constness

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for CoroutineKind

Source§

#### type Storage = [u8; 2]

Source§

### impl Erasable for Defaultness

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for IsAsync

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for MaybeOwner<'_>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for OpaqueTyOrigin<DefId>

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for LangItem

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for LintExpectationId

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for EntryFnType

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for OptLevel

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for SymbolManglingVersion

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for CrateDepKind

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for LinkagePreference

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for PanicStrategy

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Option<&OsStr>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Option<(ConstValue, Ty<'_>)>

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for Option<(DefId, EntryFnType)>

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for Option<AllocatorKind>

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Option<DefKind>

Source§

#### type Storage = [u8; 3]

Source§

### impl Erasable for Option<CoroutineKind>

Source§

#### type Storage = [u8; 2]

Source§

### impl Erasable for Option<PanicStrategy>

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Option<ImplTraitInTraitData>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Option<usize>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Option<FieldIdx>

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for Option<Align>

Source§

#### type Storage = [u8; 2]

Source§

### impl Erasable for Option<Svh>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Option<ConstStability>

Source§

#### type Storage = [u8; 28]

Source§

### impl Erasable for Option<DefaultBodyStability>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Option<Stability>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Option<HirId>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<CrateNum>

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for Option<DefId>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<LocalDefId>

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for Option<Span>

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for Option<DeprecationEntry>

Source§

#### type Storage = [u8; 28]

Source§

### impl Erasable for Option<DestructuredConstant<'_>>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Option<AsyncDestructor>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<Destructor>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<IntrinsicDef>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Option<ScalarInt>

Source§

#### type Storage = [u8; 17]

Source§

### impl Erasable for Option<EarlyBinder<'_, Ty<'_>>>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Result<&TokenStream, ()>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Result<&List<Ty<'_>>, AlwaysRequiresDrop>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Result<(&[Spanned<MonoItem<'_>>], &[Spanned<MonoItem<'_>>]), NormalizationErrorInMono>

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for Result<ConstValue, ErrorHandled>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Result<EvaluationResult, OverflowError>

Source§

#### type Storage = [u8; 2]

Source§

### impl Erasable for Result<Option<Instance<'_>>, ErrorGuaranteed>

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for Result<Option<EarlyBinder<'_, Const<'_>>>, ErrorGuaranteed>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<bool, &LayoutError<'_>>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<(), ErrorGuaranteed>

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Result<(), NoSolution>

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Result<TyAndLayout<'_, Ty<'_>>, &LayoutError<'_>>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Result<ConstAlloc<'_>, ErrorHandled>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Result<CoerceUnsizedInfo, ErrorGuaranteed>

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for Result<GenericArg<'_>, NoSolution>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Result<EarlyBinder<'_, Ty<'_>>, CyclePlaceholder>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for bool

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for u32

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for ()

Source§

#### type Storage = [u8; 0]

Source§

### impl Erasable for usize

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ReprOptions

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Svh

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Deprecation

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for EiiDecl

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for EiiImpl

Source§

#### type Storage = [u8; 44]

Source§

### impl Erasable for DefKey

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Upvar

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ConstStability

Source§

#### type Storage = [u8; 28]

Source§

### impl Erasable for DefaultBodyStability

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Stability

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for HirId

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ItemLocalId

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for OwnerId

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for FiniteBitSet<u32>

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for ExternCrate

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for Limits

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for CrateNum

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for DefId

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for DefIndex

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for DefPathHash

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for LocalDefId

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for LocalModDefId

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for ExpnHash

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for ExpnId

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Span

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ErrorGuaranteed

Source§

#### type Storage = [u8; 0]

Source§

### impl Erasable for Ident

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for Symbol

Source§

#### type Storage = [u8; 4]

Source§

### impl<I: Idx, T> Erasable for &IndexSlice<I, T>

Source§

#### type Storage = [u8; 16]

Source§

### impl<T0> Erasable for (&T0, Result<(), ErrorGuaranteed>)

Source§

#### type Storage = [u8; 16]

Source§

### impl<T0> Erasable for (QueryResult<'_>, &T0)

Source§

#### type Storage = [u8; 48]

Source§

### impl<T0, T1> Erasable for (&[T0], &[T1])

Source§

#### type Storage = [u8; 32]

Source§

### impl<T0, T1> Erasable for (&T0, &[T1])

Source§

#### type Storage = [u8; 24]

Source§

### impl<T0, T1> Erasable for (&T0, &T1)

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for &[T]

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for Option<&[T]>

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for Option<&T>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T> Erasable for Result<&[T], ErrorGuaranteed>

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for Result<&[T], NoSolution>

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for Result<(&T, ExprId), ErrorGuaranteed>

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for Result<&T, &FnAbiError<'_>>

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for Result<&T, CodegenObligationError>

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for Result<&T, ErrorGuaranteed>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T> Erasable for Result<&T, NoSolution>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T> Erasable for &T

Source§

#### type Storage = [u8; 8]

## Implementors§

Source§

### impl Erasable for Linkage

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for ObjectLifetimeDefault

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ResolvedArg

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for ConstValue

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for ErrorHandled

Source§

#### type Storage = [u8; 12]

Source§

### impl Erasable for CodegenObligationError

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for WellFormedLoc

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for EvaluationResult

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for OverflowError

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for AnonConstKind

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for AssocContainer

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Asyncness

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for ImplPolarity

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Representability

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Variance

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for Visibility<DefId>

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for SanitizerFnAttrs

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for DeducedParamAttrs

Source§

#### type Storage = [u8; 1]

Source§

### impl Erasable for SymbolExportInfo

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for DeprecationEntry

Source§

#### type Storage = [u8; 28]

Source§

### impl Erasable for AllocId

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for CtfeProvenance

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ConstQualifs

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for ExprId

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for NoSolution

Source§

#### type Storage = [u8; 0]

Source§

### impl Erasable for CoerceUnsizedInfo

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for AssocItem

Source§

#### type Storage = [u8; 32]

Source§

### impl Erasable for AsyncDestructor

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for Destructor

Source§

#### type Storage = [u8; 8]

Source§

### impl Erasable for ImplTraitHeader<'_>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for UnusedGenericParams

Source§

#### type Storage = [u8; 4]

Source§

### impl Erasable for AlwaysRequiresDrop

Source§

#### type Storage = [u8; 0]

Source§

### impl Erasable for EvalToValTreeResult<'_>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for SimplifiedType

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Binder<'_, &List<Ty<'_>>>

Source§

#### type Storage = [u8; 16]

Source§

### impl Erasable for Binder<'_, CoroutineWitnessTypes<TyCtxt<'_>>>

Source§

#### type Storage = [u8; 24]

Source§

### impl Erasable for Binder<'_, FnSig<'_>>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for ExportedSymbol<'tcx>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for rustc_middle::mir::Const<'tcx>

Source§

#### type Storage = [u8; 40]

Source§

### impl<'tcx> Erasable for InstanceKind<'tcx>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for InhabitedPredicate<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for FnAbiError<'tcx>

Source§

#### type Storage = [u8; 32]

Source§

### impl<'tcx> Erasable for LayoutError<'tcx>

Source§

#### type Storage = [u8; 32]

Source§

### impl<'tcx> Erasable for VtblEntry<'tcx>

Source§

#### type Storage = [u8; 32]

Source§

### impl<'tcx> Erasable for GlobalId<'tcx>

Source§

#### type Storage = [u8; 40]

Source§

### impl<'tcx> Erasable for LitToConstInput<'tcx>

Source§

#### type Storage = [u8; 40]

Source§

### impl<'tcx> Erasable for MonoItemPartitions<'tcx>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for ConstAlloc<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for DestructuredConstant<'tcx>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for MethodAutoderefStepsResult<'tcx>

Source§

#### type Storage = [u8; 32]

Source§

### impl<'tcx> Erasable for AscribeUserType<'tcx>

Source§

#### type Storage = [u8; 48]

Source§

### impl<'tcx> Erasable for Eq<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for ProvePredicate<'tcx>

Source§

#### type Storage = [u8; 8]

Source§

### impl<'tcx> Erasable for Subtype<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for AdtDef<'tcx>

Source§

#### type Storage = [u8; 8]

Source§

### impl<'tcx> Erasable for ClosureTypeInfo<'tcx>

Source§

#### type Storage = [u8; 56]

Source§

### impl<'tcx> Erasable for rustc_middle::ty::Const<'tcx>

Source§

#### type Storage = [u8; 8]

Source§

### impl<'tcx> Erasable for ConstConditions<'tcx>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for DestructuredAdtConst<'tcx>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for GenericArg<'tcx>

Source§

#### type Storage = [u8; 8]

Source§

### impl<'tcx> Erasable for GenericPredicates<'tcx>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for Instance<'tcx>

Source§

#### type Storage = [u8; 32]

Source§

### impl<'tcx> Erasable for ParamEnv<'tcx>

Source§

#### type Storage = [u8; 8]

Source§

### impl<'tcx> Erasable for Predicate<'tcx>

Source§

#### type Storage = [u8; 8]

Source§

### impl<'tcx> Erasable for SymbolName<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for Ty<'tcx>

Source§

#### type Storage = [u8; 8]

Source§

### impl<'tcx> Erasable for TypingEnv<'tcx>

Source§

#### type Storage = [u8; 24]

Source§

### impl<'tcx> Erasable for ValTree<'tcx>

Source§

#### type Storage = [u8; 8]

Source§

### impl<'tcx> Erasable for EvalStaticInitializerRawResult<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for AliasTy<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for BoundVariableKind<'tcx>

Source§

#### type Storage = [u8; 12]

Source§

### impl<'tcx> Erasable for ClauseKind<'tcx>

Source§

#### type Storage = [u8; 32]

Source§

### impl<'tcx> Erasable for ExistentialTraitRef<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for FnSig<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for TraitRef<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<'tcx> Erasable for UnevaluatedConst<'tcx>

Source§

#### type Storage = [u8; 16]

Source§

### impl<T> Erasable for &List<T>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T> Erasable for &ListWithCachedTypeInfo<T>

Source§

#### type Storage = [u8; 8]

Source§

### impl<T: Erasable> Erasable for EarlyBinder<'_, T>

Source§

#### type Storage = <T as Erasable>::Storage