mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-10 17:07:36 +00:00
renaming err to err_unsup
This commit is contained in:
parent
b60a336e86
commit
fc5df1dfbf
@ -244,7 +244,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
|
|||||||
Ok(&self.get_bytes(cx, ptr, size_with_null)?[..size])
|
Ok(&self.get_bytes(cx, ptr, size_with_null)?[..size])
|
||||||
}
|
}
|
||||||
// This includes the case where `offset` is out-of-bounds to begin with.
|
// This includes the case where `offset` is out-of-bounds to begin with.
|
||||||
None => throw_err!(UnterminatedCString(ptr.erase_tag())),
|
None => throw_err_unsup!(UnterminatedCString(ptr.erase_tag())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
|
|||||||
if self.relocations(cx, ptr, size).is_empty() {
|
if self.relocations(cx, ptr, size).is_empty() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
throw_err!(ReadPointerAsBytes)
|
throw_err_unsup!(ReadPointerAsBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,7 +516,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
|
|||||||
self.undef_mask.is_range_defined(
|
self.undef_mask.is_range_defined(
|
||||||
ptr.offset,
|
ptr.offset,
|
||||||
ptr.offset + size,
|
ptr.offset + size,
|
||||||
).or_else(|idx| throw_err!(ReadUndefBytes(idx)))
|
).or_else(|idx| throw_err_unsup!(ReadUndefBytes(idx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mark_definedness(
|
pub fn mark_definedness(
|
||||||
|
@ -184,8 +184,8 @@ pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'
|
|||||||
/// Packages the kind of error we got from the const code interpreter
|
/// Packages the kind of error we got from the const code interpreter
|
||||||
/// up with a Rust-level backtrace of where the error occured.
|
/// up with a Rust-level backtrace of where the error occured.
|
||||||
/// Thsese should always be constructed by calling `.into()` on
|
/// Thsese should always be constructed by calling `.into()` on
|
||||||
/// a `InterpError`. In `librustc_mir::interpret`, we have the `throw_err!`
|
/// a `InterpError`. In `librustc_mir::interpret`, we have `throw_err_*`
|
||||||
/// macro for this.
|
/// macros for this.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct InterpErrorInfo<'tcx> {
|
pub struct InterpErrorInfo<'tcx> {
|
||||||
pub kind: InterpError<'tcx>,
|
pub kind: InterpError<'tcx>,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! An interpreter for MIR used in CTFE and by miri
|
//! An interpreter for MIR used in CTFE and by miri
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! throw_err {
|
macro_rules! throw_err_unsup {
|
||||||
($($tt:tt)*) => {
|
($($tt:tt)*) => {
|
||||||
Err($crate::mir::interpret::InterpError::Unsupported(
|
Err($crate::mir::interpret::InterpError::Unsupported(
|
||||||
$crate::mir::interpret::UnsupportedOpInfo::$($tt)*
|
$crate::mir::interpret::UnsupportedOpInfo::$($tt)*
|
||||||
@ -55,7 +55,7 @@ macro_rules! err_inval {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! err {
|
macro_rules! err_unsup {
|
||||||
($($tt:tt)*) => {
|
($($tt:tt)*) => {
|
||||||
$crate::mir::interpret::InterpError::Unsupported(
|
$crate::mir::interpret::InterpError::Unsupported(
|
||||||
$crate::mir::interpret::UnsupportedOpInfo::$($tt)*
|
$crate::mir::interpret::UnsupportedOpInfo::$($tt)*
|
||||||
|
@ -196,7 +196,7 @@ impl<'tcx, Tag> Pointer<Tag> {
|
|||||||
msg: CheckInAllocMsg,
|
msg: CheckInAllocMsg,
|
||||||
) -> InterpResult<'tcx, ()> {
|
) -> InterpResult<'tcx, ()> {
|
||||||
if self.offset > allocation_size {
|
if self.offset > allocation_size {
|
||||||
throw_err!(PointerOutOfBounds { ptr: self.erase_tag(), msg, allocation_size })
|
throw_err_unsup!(PointerOutOfBounds { ptr: self.erase_tag(), msg, allocation_size })
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ impl<'tcx, Tag> Scalar<Tag> {
|
|||||||
Scalar::check_data(data, size);
|
Scalar::check_data(data, size);
|
||||||
Ok(data)
|
Ok(data)
|
||||||
}
|
}
|
||||||
Scalar::Ptr(_) => throw_err!(ReadPointerAsBytes),
|
Scalar::Ptr(_) => throw_err_unsup!(ReadPointerAsBytes),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,8 +373,8 @@ impl<'tcx, Tag> Scalar<Tag> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_ptr(self) -> InterpResult<'tcx, Pointer<Tag>> {
|
pub fn to_ptr(self) -> InterpResult<'tcx, Pointer<Tag>> {
|
||||||
match self {
|
match self {
|
||||||
Scalar::Raw { data: 0, .. } => throw_err!(InvalidNullPointerUsage),
|
Scalar::Raw { data: 0, .. } => throw_err_unsup!(InvalidNullPointerUsage),
|
||||||
Scalar::Raw { .. } => throw_err!(ReadBytesAsPointer),
|
Scalar::Raw { .. } => throw_err_unsup!(ReadBytesAsPointer),
|
||||||
Scalar::Ptr(p) => Ok(p),
|
Scalar::Ptr(p) => Ok(p),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,7 +406,7 @@ impl<'tcx, Tag> Scalar<Tag> {
|
|||||||
match self {
|
match self {
|
||||||
Scalar::Raw { data: 0, size: 1 } => Ok(false),
|
Scalar::Raw { data: 0, size: 1 } => Ok(false),
|
||||||
Scalar::Raw { data: 1, size: 1 } => Ok(true),
|
Scalar::Raw { data: 1, size: 1 } => Ok(true),
|
||||||
_ => throw_err!(InvalidBool),
|
_ => throw_err_unsup!(InvalidBool),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ impl<'tcx, Tag> Scalar<Tag> {
|
|||||||
let val = self.to_u32()?;
|
let val = self.to_u32()?;
|
||||||
match ::std::char::from_u32(val) {
|
match ::std::char::from_u32(val) {
|
||||||
Some(c) => Ok(c),
|
Some(c) => Ok(c),
|
||||||
None => throw_err!(InvalidChar(val as u128)),
|
None => throw_err_unsup!(InvalidChar(val as u128)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,7 +537,7 @@ impl<'tcx, Tag> ScalarMaybeUndef<Tag> {
|
|||||||
pub fn not_undef(self) -> InterpResult<'static, Scalar<Tag>> {
|
pub fn not_undef(self) -> InterpResult<'static, Scalar<Tag>> {
|
||||||
match self {
|
match self {
|
||||||
ScalarMaybeUndef::Scalar(scalar) => Ok(scalar),
|
ScalarMaybeUndef::Scalar(scalar) => Ok(scalar),
|
||||||
ScalarMaybeUndef::Undef => throw_err!(ReadUndefBytes(Size::from_bytes(0))),
|
ScalarMaybeUndef::Undef => throw_err_unsup!(ReadUndefBytes(Size::from_bytes(0))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +352,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
|||||||
ecx.goto_block(ret)?; // fully evaluated and done
|
ecx.goto_block(ret)?; // fully evaluated and done
|
||||||
Ok(None)
|
Ok(None)
|
||||||
} else {
|
} else {
|
||||||
throw_err!(MachineError(format!("calling non-const function `{}`", instance)))
|
throw_err_unsup!(
|
||||||
|
MachineError(format!("calling non-const function `{}`", instance))
|
||||||
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,7 +414,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
|||||||
_tcx: TyCtxt<'tcx>,
|
_tcx: TyCtxt<'tcx>,
|
||||||
_def_id: DefId,
|
_def_id: DefId,
|
||||||
) -> InterpResult<'tcx, Cow<'tcx, Allocation<Self::PointerTag>>> {
|
) -> InterpResult<'tcx, Cow<'tcx, Allocation<Self::PointerTag>>> {
|
||||||
throw_err!(ReadForeignStatic)
|
throw_err_unsup!(ReadForeignStatic)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -199,7 +199,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Casts to bool are not permitted by rustc, no need to handle them here.
|
// Casts to bool are not permitted by rustc, no need to handle them here.
|
||||||
_ => throw_err!(Unimplemented(format!("int to {:?} cast", dest_layout.ty))),
|
_ => throw_err_unsup!(Unimplemented(format!("int to {:?} cast", dest_layout.ty))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ pub enum LocalValue<Tag=(), Id=AllocId> {
|
|||||||
impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
|
impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
|
||||||
pub fn access(&self) -> InterpResult<'tcx, Operand<Tag>> {
|
pub fn access(&self) -> InterpResult<'tcx, Operand<Tag>> {
|
||||||
match self.value {
|
match self.value {
|
||||||
LocalValue::Dead => throw_err!(DeadLocal),
|
LocalValue::Dead => throw_err_unsup!(DeadLocal),
|
||||||
LocalValue::Uninitialized =>
|
LocalValue::Uninitialized =>
|
||||||
bug!("The type checker should prevent reading from a never-written local"),
|
bug!("The type checker should prevent reading from a never-written local"),
|
||||||
LocalValue::Live(val) => Ok(val),
|
LocalValue::Live(val) => Ok(val),
|
||||||
@ -148,7 +148,7 @@ impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
) -> InterpResult<'tcx, Result<&mut LocalValue<Tag>, MemPlace<Tag>>> {
|
) -> InterpResult<'tcx, Result<&mut LocalValue<Tag>, MemPlace<Tag>>> {
|
||||||
match self.value {
|
match self.value {
|
||||||
LocalValue::Dead => throw_err!(DeadLocal),
|
LocalValue::Dead => throw_err_unsup!(DeadLocal),
|
||||||
LocalValue::Live(Operand::Indirect(mplace)) => Ok(Err(mplace)),
|
LocalValue::Live(Operand::Indirect(mplace)) => Ok(Err(mplace)),
|
||||||
ref mut local @ LocalValue::Live(Operand::Immediate(_)) |
|
ref mut local @ LocalValue::Live(Operand::Immediate(_)) |
|
||||||
ref mut local @ LocalValue::Uninitialized => {
|
ref mut local @ LocalValue::Uninitialized => {
|
||||||
@ -346,7 +346,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
ty::InstanceDef::Item(def_id) => if self.tcx.is_mir_available(did) {
|
ty::InstanceDef::Item(def_id) => if self.tcx.is_mir_available(did) {
|
||||||
Ok(self.tcx.optimized_mir(did))
|
Ok(self.tcx.optimized_mir(did))
|
||||||
} else {
|
} else {
|
||||||
throw_err!(NoMirFor(self.tcx.def_path_str(def_id)))
|
throw_err_unsup!(NoMirFor(self.tcx.def_path_str(def_id)))
|
||||||
},
|
},
|
||||||
_ => Ok(self.tcx.instance_mir(instance)),
|
_ => Ok(self.tcx.instance_mir(instance)),
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ pub fn intern_const_alloc_recursive(
|
|||||||
}
|
}
|
||||||
} else if ecx.memory().dead_alloc_map.contains_key(&alloc_id) {
|
} else if ecx.memory().dead_alloc_map.contains_key(&alloc_id) {
|
||||||
// dangling pointer
|
// dangling pointer
|
||||||
return throw_err!(
|
return throw_err_unsup!(
|
||||||
ValidationFailure("encountered dangling pointer in final constant".into())
|
ValidationFailure("encountered dangling pointer in final constant".into())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
};
|
};
|
||||||
let out_val = if intrinsic_name.ends_with("_nonzero") {
|
let out_val = if intrinsic_name.ends_with("_nonzero") {
|
||||||
if bits == 0 {
|
if bits == 0 {
|
||||||
return throw_err!(Intrinsic(format!("{} called on 0", intrinsic_name)));
|
return throw_err_unsup!(
|
||||||
|
Intrinsic(format!("{} called on 0", intrinsic_name))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
numeric_intrinsic(intrinsic_name.trim_end_matches("_nonzero"), bits, kind)?
|
numeric_intrinsic(intrinsic_name.trim_end_matches("_nonzero"), bits, kind)?
|
||||||
} else {
|
} else {
|
||||||
@ -190,7 +192,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
if overflowed {
|
if overflowed {
|
||||||
let layout = self.layout_of(substs.type_at(0))?;
|
let layout = self.layout_of(substs.type_at(0))?;
|
||||||
let r_val = r.to_scalar()?.to_bits(layout.size)?;
|
let r_val = r.to_scalar()?.to_bits(layout.size)?;
|
||||||
return throw_err!(Intrinsic(
|
return throw_err_unsup!(Intrinsic(
|
||||||
format!("Overflowing shift by {} in {}", r_val, intrinsic_name),
|
format!("Overflowing shift by {} in {}", r_val, intrinsic_name),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -251,6 +251,6 @@ pub trait Machine<'mir, 'tcx>: Sized {
|
|||||||
_mem: &Memory<'mir, 'tcx, Self>,
|
_mem: &Memory<'mir, 'tcx, Self>,
|
||||||
_ptr: Pointer<Self::PointerTag>,
|
_ptr: Pointer<Self::PointerTag>,
|
||||||
) -> InterpResult<'tcx, u64> {
|
) -> InterpResult<'tcx, u64> {
|
||||||
throw_err!(ReadPointerAsBytes)
|
throw_err_unsup!(ReadPointerAsBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ impl<'tcx, Other> FnVal<'tcx, Other> {
|
|||||||
match self {
|
match self {
|
||||||
FnVal::Instance(instance) =>
|
FnVal::Instance(instance) =>
|
||||||
Ok(instance),
|
Ok(instance),
|
||||||
FnVal::Other(_) => throw_err!(MachineError(format!(
|
FnVal::Other(_) => throw_err_unsup!(MachineError(format!(
|
||||||
"Expected instance function pointer, got 'other' pointer"
|
"Expected instance function pointer, got 'other' pointer"
|
||||||
))),
|
))),
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
kind: MemoryKind<M::MemoryKinds>,
|
kind: MemoryKind<M::MemoryKinds>,
|
||||||
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
|
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
|
||||||
if ptr.offset.bytes() != 0 {
|
if ptr.offset.bytes() != 0 {
|
||||||
return throw_err!(ReallocateNonBasePtr);
|
return throw_err_unsup!(ReallocateNonBasePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For simplicities' sake, we implement reallocate as "alloc, copy, dealloc".
|
// For simplicities' sake, we implement reallocate as "alloc, copy, dealloc".
|
||||||
@ -243,7 +243,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
trace!("deallocating: {}", ptr.alloc_id);
|
trace!("deallocating: {}", ptr.alloc_id);
|
||||||
|
|
||||||
if ptr.offset.bytes() != 0 {
|
if ptr.offset.bytes() != 0 {
|
||||||
return throw_err!(DeallocateNonBasePtr);
|
return throw_err_unsup!(DeallocateNonBasePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
let (alloc_kind, mut alloc) = match self.alloc_map.remove(&ptr.alloc_id) {
|
let (alloc_kind, mut alloc) = match self.alloc_map.remove(&ptr.alloc_id) {
|
||||||
@ -251,22 +251,22 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
None => {
|
None => {
|
||||||
// Deallocating static memory -- always an error
|
// Deallocating static memory -- always an error
|
||||||
return match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
|
return match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
|
||||||
Some(GlobalAlloc::Function(..)) => throw_err!(DeallocatedWrongMemoryKind(
|
Some(GlobalAlloc::Function(..)) => throw_err_unsup!(DeallocatedWrongMemoryKind(
|
||||||
"function".to_string(),
|
"function".to_string(),
|
||||||
format!("{:?}", kind),
|
format!("{:?}", kind),
|
||||||
)),
|
)),
|
||||||
Some(GlobalAlloc::Static(..)) |
|
Some(GlobalAlloc::Static(..)) |
|
||||||
Some(GlobalAlloc::Memory(..)) => throw_err!(DeallocatedWrongMemoryKind(
|
Some(GlobalAlloc::Memory(..)) => throw_err_unsup!(DeallocatedWrongMemoryKind(
|
||||||
"static".to_string(),
|
"static".to_string(),
|
||||||
format!("{:?}", kind),
|
format!("{:?}", kind),
|
||||||
)),
|
)),
|
||||||
None => throw_err!(DoubleFree)
|
None => throw_err_unsup!(DoubleFree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if alloc_kind != kind {
|
if alloc_kind != kind {
|
||||||
return throw_err!(DeallocatedWrongMemoryKind(
|
return throw_err_unsup!(DeallocatedWrongMemoryKind(
|
||||||
format!("{:?}", alloc_kind),
|
format!("{:?}", alloc_kind),
|
||||||
format!("{:?}", kind),
|
format!("{:?}", kind),
|
||||||
));
|
));
|
||||||
@ -274,7 +274,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
if let Some((size, align)) = old_size_and_align {
|
if let Some((size, align)) = old_size_and_align {
|
||||||
if size.bytes() != alloc.bytes.len() as u64 || align != alloc.align {
|
if size.bytes() != alloc.bytes.len() as u64 || align != alloc.align {
|
||||||
let bytes = Size::from_bytes(alloc.bytes.len() as u64);
|
let bytes = Size::from_bytes(alloc.bytes.len() as u64);
|
||||||
return throw_err!(IncorrectAllocationInformation(size, bytes, align, alloc.align));
|
return throw_err_unsup!(
|
||||||
|
IncorrectAllocationInformation(size, bytes, align, alloc.align)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +321,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
} else {
|
} else {
|
||||||
// The biggest power of two through which `offset` is divisible.
|
// The biggest power of two through which `offset` is divisible.
|
||||||
let offset_pow2 = 1 << offset.trailing_zeros();
|
let offset_pow2 = 1 << offset.trailing_zeros();
|
||||||
throw_err!(AlignmentCheckFailed {
|
throw_err_unsup!(AlignmentCheckFailed {
|
||||||
has: Align::from_bytes(offset_pow2).unwrap(),
|
has: Align::from_bytes(offset_pow2).unwrap(),
|
||||||
required: align,
|
required: align,
|
||||||
})
|
})
|
||||||
@ -341,7 +343,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
assert!(size.bytes() == 0);
|
assert!(size.bytes() == 0);
|
||||||
// Must be non-NULL and aligned.
|
// Must be non-NULL and aligned.
|
||||||
if bits == 0 {
|
if bits == 0 {
|
||||||
return throw_err!(InvalidNullPointerUsage);
|
return throw_err_unsup!(InvalidNullPointerUsage);
|
||||||
}
|
}
|
||||||
check_offset_align(bits, align)?;
|
check_offset_align(bits, align)?;
|
||||||
None
|
None
|
||||||
@ -362,7 +364,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
// got picked we might be aligned even if this check fails.
|
// got picked we might be aligned even if this check fails.
|
||||||
// We instead have to fall back to converting to an integer and checking
|
// We instead have to fall back to converting to an integer and checking
|
||||||
// the "real" alignment.
|
// the "real" alignment.
|
||||||
return throw_err!(AlignmentCheckFailed {
|
return throw_err_unsup!(AlignmentCheckFailed {
|
||||||
has: alloc_align,
|
has: alloc_align,
|
||||||
required: align,
|
required: align,
|
||||||
});
|
});
|
||||||
@ -413,9 +415,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
Some(GlobalAlloc::Memory(mem)) =>
|
Some(GlobalAlloc::Memory(mem)) =>
|
||||||
Cow::Borrowed(mem),
|
Cow::Borrowed(mem),
|
||||||
Some(GlobalAlloc::Function(..)) =>
|
Some(GlobalAlloc::Function(..)) =>
|
||||||
return throw_err!(DerefFunctionPointer),
|
return throw_err_unsup!(DerefFunctionPointer),
|
||||||
None =>
|
None =>
|
||||||
return throw_err!(DanglingPointerDeref),
|
return throw_err_unsup!(DanglingPointerDeref),
|
||||||
Some(GlobalAlloc::Static(def_id)) => {
|
Some(GlobalAlloc::Static(def_id)) => {
|
||||||
// We got a "lazy" static that has not been computed yet.
|
// We got a "lazy" static that has not been computed yet.
|
||||||
if tcx.is_foreign_item(def_id) {
|
if tcx.is_foreign_item(def_id) {
|
||||||
@ -505,11 +507,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
// to give us a cheap reference.
|
// to give us a cheap reference.
|
||||||
let alloc = Self::get_static_alloc(memory_extra, tcx, id)?;
|
let alloc = Self::get_static_alloc(memory_extra, tcx, id)?;
|
||||||
if alloc.mutability == Mutability::Immutable {
|
if alloc.mutability == Mutability::Immutable {
|
||||||
return throw_err!(ModifiedConstantMemory);
|
return throw_err_unsup!(ModifiedConstantMemory);
|
||||||
}
|
}
|
||||||
match M::STATIC_KIND {
|
match M::STATIC_KIND {
|
||||||
Some(kind) => Ok((MemoryKind::Machine(kind), alloc.into_owned())),
|
Some(kind) => Ok((MemoryKind::Machine(kind), alloc.into_owned())),
|
||||||
None => throw_err!(ModifiedStatic),
|
None => throw_err_unsup!(ModifiedStatic),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Unpack the error type manually because type inference doesn't
|
// Unpack the error type manually because type inference doesn't
|
||||||
@ -519,7 +521,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
Ok(a) => {
|
Ok(a) => {
|
||||||
let a = &mut a.1;
|
let a = &mut a.1;
|
||||||
if a.mutability == Mutability::Immutable {
|
if a.mutability == Mutability::Immutable {
|
||||||
return throw_err!(ModifiedConstantMemory);
|
return throw_err_unsup!(ModifiedConstantMemory);
|
||||||
}
|
}
|
||||||
Ok(a)
|
Ok(a)
|
||||||
}
|
}
|
||||||
@ -548,7 +550,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
if let Ok(_) = self.get_fn_alloc(id) {
|
if let Ok(_) = self.get_fn_alloc(id) {
|
||||||
return if let AllocCheck::Dereferencable = liveness {
|
return if let AllocCheck::Dereferencable = liveness {
|
||||||
// The caller requested no function pointers.
|
// The caller requested no function pointers.
|
||||||
throw_err!(DerefFunctionPointer)
|
throw_err_unsup!(DerefFunctionPointer)
|
||||||
} else {
|
} else {
|
||||||
Ok((Size::ZERO, Align::from_bytes(1).unwrap()))
|
Ok((Size::ZERO, Align::from_bytes(1).unwrap()))
|
||||||
};
|
};
|
||||||
@ -579,7 +581,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
.expect("deallocated pointers should all be recorded in \
|
.expect("deallocated pointers should all be recorded in \
|
||||||
`dead_alloc_map`"))
|
`dead_alloc_map`"))
|
||||||
} else {
|
} else {
|
||||||
throw_err!(DanglingPointerDeref)
|
throw_err_unsup!(DanglingPointerDeref)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -591,7 +593,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
} else {
|
} else {
|
||||||
match self.tcx.alloc_map.lock().get(id) {
|
match self.tcx.alloc_map.lock().get(id) {
|
||||||
Some(GlobalAlloc::Function(instance)) => Ok(FnVal::Instance(instance)),
|
Some(GlobalAlloc::Function(instance)) => Ok(FnVal::Instance(instance)),
|
||||||
_ => throw_err!(ExecuteMemory),
|
_ => throw_err_unsup!(ExecuteMemory),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -602,7 +604,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
) -> InterpResult<'tcx, FnVal<'tcx, M::ExtraFnVal>> {
|
) -> InterpResult<'tcx, FnVal<'tcx, M::ExtraFnVal>> {
|
||||||
let ptr = self.force_ptr(ptr)?; // We definitely need a pointer value.
|
let ptr = self.force_ptr(ptr)?; // We definitely need a pointer value.
|
||||||
if ptr.offset.bytes() != 0 {
|
if ptr.offset.bytes() != 0 {
|
||||||
return throw_err!(InvalidFunctionPointer);
|
return throw_err_unsup!(InvalidFunctionPointer);
|
||||||
}
|
}
|
||||||
self.get_fn_alloc(ptr.alloc_id)
|
self.get_fn_alloc(ptr.alloc_id)
|
||||||
}
|
}
|
||||||
@ -837,7 +839,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||||||
if (src.offset <= dest.offset && src.offset + size > dest.offset) ||
|
if (src.offset <= dest.offset && src.offset + size > dest.offset) ||
|
||||||
(dest.offset <= src.offset && dest.offset + size > src.offset)
|
(dest.offset <= src.offset && dest.offset + size > src.offset)
|
||||||
{
|
{
|
||||||
return throw_err!(Intrinsic(
|
return throw_err_unsup!(Intrinsic(
|
||||||
"copy_nonoverlapping called on overlapping ranges".to_string(),
|
"copy_nonoverlapping called on overlapping ranges".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
mir_place.iterate(|place_base, place_projection| {
|
mir_place.iterate(|place_base, place_projection| {
|
||||||
let mut op = match place_base {
|
let mut op = match place_base {
|
||||||
PlaceBase::Local(mir::RETURN_PLACE) =>
|
PlaceBase::Local(mir::RETURN_PLACE) =>
|
||||||
return throw_err!(ReadFromReturnPointer),
|
return throw_err_unsup!(ReadFromReturnPointer),
|
||||||
PlaceBase::Local(local) => {
|
PlaceBase::Local(local) => {
|
||||||
// Do not use the layout passed in as argument if the base we are looking at
|
// Do not use the layout passed in as argument if the base we are looking at
|
||||||
// here is not the entire place.
|
// here is not the entire place.
|
||||||
@ -610,7 +610,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
let bits_discr = match raw_discr.to_bits(discr_val.layout.size) {
|
let bits_discr = match raw_discr.to_bits(discr_val.layout.size) {
|
||||||
Ok(raw_discr) => raw_discr,
|
Ok(raw_discr) => raw_discr,
|
||||||
Err(_) =>
|
Err(_) =>
|
||||||
return throw_err!(InvalidDiscriminant(raw_discr.erase_tag())),
|
return throw_err_unsup!(InvalidDiscriminant(raw_discr.erase_tag())),
|
||||||
};
|
};
|
||||||
let real_discr = if discr_val.layout.ty.is_signed() {
|
let real_discr = if discr_val.layout.ty.is_signed() {
|
||||||
// going from layout tag type to typeck discriminant type
|
// going from layout tag type to typeck discriminant type
|
||||||
@ -637,7 +637,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
.find(|(_, var)| var.val == real_discr),
|
.find(|(_, var)| var.val == real_discr),
|
||||||
_ => bug!("tagged layout for non-adt non-generator"),
|
_ => bug!("tagged layout for non-adt non-generator"),
|
||||||
}.ok_or_else(
|
}.ok_or_else(
|
||||||
|| err!(InvalidDiscriminant(raw_discr.erase_tag()))
|
|| err_unsup!(InvalidDiscriminant(raw_discr.erase_tag()))
|
||||||
)?;
|
)?;
|
||||||
(real_discr, index.0)
|
(real_discr, index.0)
|
||||||
},
|
},
|
||||||
@ -657,7 +657,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
let ptr_valid = niche_start == 0 && variants_start == variants_end &&
|
let ptr_valid = niche_start == 0 && variants_start == variants_end &&
|
||||||
!self.memory.ptr_may_be_null(ptr);
|
!self.memory.ptr_may_be_null(ptr);
|
||||||
if !ptr_valid {
|
if !ptr_valid {
|
||||||
return throw_err!(InvalidDiscriminant(raw_discr.erase_tag().into()));
|
return throw_err_unsup!(
|
||||||
|
InvalidDiscriminant(raw_discr.erase_tag().into())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
(dataful_variant.as_u32() as u128, dataful_variant)
|
(dataful_variant.as_u32() as u128, dataful_variant)
|
||||||
},
|
},
|
||||||
|
@ -155,7 +155,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
r,
|
r,
|
||||||
right_layout.ty
|
right_layout.ty
|
||||||
);
|
);
|
||||||
return throw_err!(Unimplemented(msg));
|
return throw_err_unsup!(Unimplemented(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operations that need special treatment for signed integers
|
// Operations that need special treatment for signed integers
|
||||||
@ -250,7 +250,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
r,
|
r,
|
||||||
right_layout.ty,
|
right_layout.ty,
|
||||||
);
|
);
|
||||||
return throw_err!(Unimplemented(msg));
|
return throw_err_unsup!(Unimplemented(msg));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ where
|
|||||||
.layout_of(self.monomorphize(self.frame().body.return_ty())?)?,
|
.layout_of(self.monomorphize(self.frame().body.return_ty())?)?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => return throw_err!(InvalidNullPointerUsage),
|
None => return throw_err_unsup!(InvalidNullPointerUsage),
|
||||||
},
|
},
|
||||||
PlaceBase::Local(local) => PlaceTy {
|
PlaceBase::Local(local) => PlaceTy {
|
||||||
// This works even for dead/uninitialized locals; we check further when writing
|
// This works even for dead/uninitialized locals; we check further when writing
|
||||||
|
@ -121,7 +121,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
// size of MIR constantly.
|
// size of MIR constantly.
|
||||||
Nop => {}
|
Nop => {}
|
||||||
|
|
||||||
InlineAsm { .. } => return throw_err!(InlineAsm),
|
InlineAsm { .. } => return throw_err_unsup!(InlineAsm),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.stack[frame_idx].stmt += 1;
|
self.stack[frame_idx].stmt += 1;
|
||||||
|
@ -89,7 +89,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
let msg = format!("can't handle callee of type {:?}", func.layout.ty);
|
let msg = format!("can't handle callee of type {:?}", func.layout.ty);
|
||||||
return throw_err!(Unimplemented(msg));
|
return throw_err_unsup!(Unimplemented(msg));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let args = self.eval_operands(args)?;
|
let args = self.eval_operands(args)?;
|
||||||
@ -220,13 +220,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let caller_arg = caller_arg.next()
|
let caller_arg = caller_arg.next()
|
||||||
.ok_or_else(|| err!(FunctionArgCountMismatch)) ?;
|
.ok_or_else(|| err_unsup!(FunctionArgCountMismatch)) ?;
|
||||||
if rust_abi {
|
if rust_abi {
|
||||||
debug_assert!(!caller_arg.layout.is_zst(), "ZSTs must have been already filtered out");
|
debug_assert!(!caller_arg.layout.is_zst(), "ZSTs must have been already filtered out");
|
||||||
}
|
}
|
||||||
// Now, check
|
// Now, check
|
||||||
if !Self::check_argument_compat(rust_abi, caller_arg.layout, callee_arg.layout) {
|
if !Self::check_argument_compat(rust_abi, caller_arg.layout, callee_arg.layout) {
|
||||||
return throw_err!(FunctionArgMismatch(caller_arg.layout.ty, callee_arg.layout.ty));
|
return throw_err_unsup!(
|
||||||
|
FunctionArgMismatch(caller_arg.layout.ty, callee_arg.layout.ty)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// We allow some transmutes here
|
// We allow some transmutes here
|
||||||
self.copy_op_transmute(caller_arg, callee_arg)
|
self.copy_op_transmute(caller_arg, callee_arg)
|
||||||
@ -254,7 +256,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
match instance.def {
|
match instance.def {
|
||||||
ty::InstanceDef::Intrinsic(..) => {
|
ty::InstanceDef::Intrinsic(..) => {
|
||||||
if caller_abi != Abi::RustIntrinsic {
|
if caller_abi != Abi::RustIntrinsic {
|
||||||
return throw_err!(FunctionAbiMismatch(caller_abi, Abi::RustIntrinsic));
|
return throw_err_unsup!(FunctionAbiMismatch(caller_abi, Abi::RustIntrinsic));
|
||||||
}
|
}
|
||||||
// The intrinsic itself cannot diverge, so if we got here without a return
|
// The intrinsic itself cannot diverge, so if we got here without a return
|
||||||
// place... (can happen e.g., for transmute returning `!`)
|
// place... (can happen e.g., for transmute returning `!`)
|
||||||
@ -295,7 +297,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
abi,
|
abi,
|
||||||
};
|
};
|
||||||
if normalize_abi(caller_abi) != normalize_abi(callee_abi) {
|
if normalize_abi(caller_abi) != normalize_abi(callee_abi) {
|
||||||
return throw_err!(FunctionAbiMismatch(caller_abi, callee_abi));
|
return throw_err_unsup!(FunctionAbiMismatch(caller_abi, callee_abi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +392,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
// Now we should have no more caller args
|
// Now we should have no more caller args
|
||||||
if caller_iter.next().is_some() {
|
if caller_iter.next().is_some() {
|
||||||
trace!("Caller has passed too many args");
|
trace!("Caller has passed too many args");
|
||||||
return throw_err!(FunctionArgCountMismatch);
|
return throw_err_unsup!(FunctionArgCountMismatch);
|
||||||
}
|
}
|
||||||
// Don't forget to check the return type!
|
// Don't forget to check the return type!
|
||||||
if let Some(caller_ret) = dest {
|
if let Some(caller_ret) = dest {
|
||||||
@ -402,7 +404,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
caller_ret.layout,
|
caller_ret.layout,
|
||||||
callee_ret.layout,
|
callee_ret.layout,
|
||||||
) {
|
) {
|
||||||
return throw_err!(
|
return throw_err_unsup!(
|
||||||
FunctionRetMismatch(caller_ret.layout.ty, callee_ret.layout.ty)
|
FunctionRetMismatch(caller_ret.layout.ty, callee_ret.layout.ty)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -410,7 +412,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
let local = mir::RETURN_PLACE;
|
let local = mir::RETURN_PLACE;
|
||||||
let ty = self.frame().body.local_decls[local].ty;
|
let ty = self.frame().body.local_decls[local].ty;
|
||||||
if !self.tcx.is_ty_uninhabited_from_any_module(ty) {
|
if !self.tcx.is_ty_uninhabited_from_any_module(ty) {
|
||||||
return throw_err!(FunctionRetMismatch(self.tcx.types.never, ty));
|
return throw_err_unsup!(FunctionRetMismatch(self.tcx.types.never, ty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -22,7 +22,7 @@ macro_rules! validation_failure {
|
|||||||
} else {
|
} else {
|
||||||
format!(" at {}", where_)
|
format!(" at {}", where_)
|
||||||
};
|
};
|
||||||
throw_err!(ValidationFailure(format!(
|
throw_err_unsup!(ValidationFailure(format!(
|
||||||
"encountered {}{}, but expected {}",
|
"encountered {}{}, but expected {}",
|
||||||
$what, where_, $details,
|
$what, where_, $details,
|
||||||
)))
|
)))
|
||||||
@ -34,7 +34,7 @@ macro_rules! validation_failure {
|
|||||||
} else {
|
} else {
|
||||||
format!(" at {}", where_)
|
format!(" at {}", where_)
|
||||||
};
|
};
|
||||||
throw_err!(ValidationFailure(format!(
|
throw_err_unsup!(ValidationFailure(format!(
|
||||||
"encountered {}{}",
|
"encountered {}{}",
|
||||||
$what, where_,
|
$what, where_,
|
||||||
)))
|
)))
|
||||||
|
Loading…
Reference in New Issue
Block a user