-impl<'a, 'tcx> Lift<'tcx> for ConstEvalErr<'a> {
- type Lifted = ConstEvalErr<'tcx>;
- fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
- tcx.lift(&self.error).map(|error| {
- ConstEvalErr {
- span: self.span,
- stacktrace: self.stacktrace.clone(),
- error,
- }
- })
- }
-}
-
-impl<'a, 'tcx> Lift<'tcx> for interpret::EvalError<'a> {
- type Lifted = interpret::EvalError<'tcx>;
- fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
- Some(interpret::EvalError {
- kind: tcx.lift(&self.kind)?,
- })
- }
-}
-
-impl<'a, 'tcx, O: Lift<'tcx>> Lift<'tcx> for interpret::EvalErrorKind<'a, O> {
- type Lifted = interpret::EvalErrorKind<'tcx, <O as Lift<'tcx>>::Lifted>;
- fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
- use ::mir::interpret::EvalErrorKind::*;
- Some(match *self {
- MachineError(ref err) => MachineError(err.clone()),
- FunctionAbiMismatch(a, b) => FunctionAbiMismatch(a, b),
- FunctionArgMismatch(a, b) => FunctionArgMismatch(
- tcx.lift(&a)?,
- tcx.lift(&b)?,
- ),
- FunctionRetMismatch(a, b) => FunctionRetMismatch(
- tcx.lift(&a)?,
- tcx.lift(&b)?,
- ),
- FunctionArgCountMismatch => FunctionArgCountMismatch,
- NoMirFor(ref s) => NoMirFor(s.clone()),
- UnterminatedCString(ptr) => UnterminatedCString(ptr),
- DanglingPointerDeref => DanglingPointerDeref,
- DoubleFree => DoubleFree,
- InvalidMemoryAccess => InvalidMemoryAccess,
- InvalidFunctionPointer => InvalidFunctionPointer,
- InvalidBool => InvalidBool,
- InvalidDiscriminant(val) => InvalidDiscriminant(val),
- PointerOutOfBounds {
- ptr,
- access,
- allocation_size,
- } => PointerOutOfBounds { ptr, access, allocation_size },
- InvalidNullPointerUsage => InvalidNullPointerUsage,
- ReadPointerAsBytes => ReadPointerAsBytes,
- ReadBytesAsPointer => ReadBytesAsPointer,
- ReadForeignStatic => ReadForeignStatic,
- InvalidPointerMath => InvalidPointerMath,
- ReadUndefBytes(offset) => ReadUndefBytes(offset),
- DeadLocal => DeadLocal,
- InvalidBoolOp(bop) => InvalidBoolOp(bop),
- Unimplemented(ref s) => Unimplemented(s.clone()),
- DerefFunctionPointer => DerefFunctionPointer,
- ExecuteMemory => ExecuteMemory,
- BoundsCheck { ref len, ref index } => BoundsCheck {
- len: tcx.lift(len)?,
- index: tcx.lift(index)?,
- },
- Intrinsic(ref s) => Intrinsic(s.clone()),
- InvalidChar(c) => InvalidChar(c),
- StackFrameLimitReached => StackFrameLimitReached,
- OutOfTls => OutOfTls,
- TlsOutOfBounds => TlsOutOfBounds,
- AbiViolation(ref s) => AbiViolation(s.clone()),
- AlignmentCheckFailed {
- required,
- has,
- } => AlignmentCheckFailed { required, has },
- MemoryLockViolation {
- ptr,
- len,
- frame,
- access,
- ref lock,
- } => MemoryLockViolation { ptr, len, frame, access, lock: lock.clone() },
- MemoryAcquireConflict {
- ptr,
- len,
- kind,
- ref lock,
- } => MemoryAcquireConflict { ptr, len, kind, lock: lock.clone() },
- InvalidMemoryLockRelease {
- ptr,
- len,
- frame,
- ref lock,
- } => InvalidMemoryLockRelease { ptr, len, frame, lock: lock.clone() },
- DeallocatedLockedMemory {
- ptr,
- ref lock,
- } => DeallocatedLockedMemory { ptr, lock: lock.clone() },
- ValidationFailure(ref s) => ValidationFailure(s.clone()),
- CalledClosureAsFunction => CalledClosureAsFunction,
- VtableForArgumentlessMethod => VtableForArgumentlessMethod,
- ModifiedConstantMemory => ModifiedConstantMemory,
- AssumptionNotHeld => AssumptionNotHeld,
- InlineAsm => InlineAsm,
- TypeNotPrimitive(ty) => TypeNotPrimitive(tcx.lift(&ty)?),
- ReallocatedWrongMemoryKind(ref a, ref b) => {
- ReallocatedWrongMemoryKind(a.clone(), b.clone())
- },
- DeallocatedWrongMemoryKind(ref a, ref b) => {
- DeallocatedWrongMemoryKind(a.clone(), b.clone())
- },
- ReallocateNonBasePtr => ReallocateNonBasePtr,
- DeallocateNonBasePtr => DeallocateNonBasePtr,
- IncorrectAllocationInformation(a, b, c, d) => {
- IncorrectAllocationInformation(a, b, c, d)
- },
- Layout(lay) => Layout(tcx.lift(&lay)?),
- HeapAllocZeroBytes => HeapAllocZeroBytes,
- HeapAllocNonPowerOfTwoAlignment(n) => HeapAllocNonPowerOfTwoAlignment(n),
- Unreachable => Unreachable,
- Panic { ref msg, ref file, line, col } => Panic {
- msg: msg.clone(),
- file: file.clone(),
- line, col,
- },
- ReadFromReturnPointer => ReadFromReturnPointer,
- PathNotFound(ref v) => PathNotFound(v.clone()),
- UnimplementedTraitSelection => UnimplementedTraitSelection,
- TypeckError => TypeckError,
- TooGeneric => TooGeneric,
- CheckMatchError => CheckMatchError,
- ReferencedConstant(ref err) => ReferencedConstant(tcx.lift(&**err)?.into()),
- OverflowNeg => OverflowNeg,
- Overflow(op) => Overflow(op),
- DivisionByZero => DivisionByZero,
- RemainderByZero => RemainderByZero,
- GeneratorResumedAfterReturn => GeneratorResumedAfterReturn,
- GeneratorResumedAfterPanic => GeneratorResumedAfterPanic,
- InfiniteLoop => InfiniteLoop,
- })
- }
-}
-
-impl<'a, 'tcx> Lift<'tcx> for ty::layout::LayoutError<'a> {
- type Lifted = ty::layout::LayoutError<'tcx>;
- fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
- match *self {
- ty::layout::LayoutError::Unknown(ref ty) => {
- tcx.lift(ty).map(ty::layout::LayoutError::Unknown)
- }
- ty::layout::LayoutError::SizeOverflow(ref ty) => {
- tcx.lift(ty).map(ty::layout::LayoutError::SizeOverflow)
- }
- }
- }
-}
-