Use assert_matches around the compiler
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
//! Manages calling a concrete function (with known MIR body) with argument passing,
|
||||
//! and returning the return value to the caller.
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::borrow::Cow;
|
||||
|
||||
use either::{Left, Right};
|
||||
@@ -557,7 +558,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
unwind,
|
||||
)? {
|
||||
assert!(!self.tcx.intrinsic(fallback.def_id()).unwrap().must_be_overridden);
|
||||
assert!(matches!(fallback.def, ty::InstanceKind::Item(_)));
|
||||
assert_matches!(fallback.def, ty::InstanceKind::Item(_));
|
||||
return self.init_fn_call(
|
||||
FnVal::Instance(fallback),
|
||||
(caller_abi, caller_fn_abi),
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//! looking at their MIR. Intrinsics/functions supported here are shared by CTFE
|
||||
//! and miri.
|
||||
|
||||
use std::assert_matches::assert_matches;
|
||||
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::mir::{self, BinOp, ConstValue, NonDivergingIntrinsic};
|
||||
use rustc_middle::ty::layout::{LayoutOf as _, TyAndLayout, ValidityRequirement};
|
||||
@@ -510,7 +512,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
dest: &MPlaceTy<'tcx, M::Provenance>,
|
||||
) -> InterpResult<'tcx> {
|
||||
assert_eq!(a.layout.ty, b.layout.ty);
|
||||
assert!(matches!(a.layout.ty.kind(), ty::Int(..) | ty::Uint(..)));
|
||||
assert_matches!(a.layout.ty.kind(), ty::Int(..) | ty::Uint(..));
|
||||
|
||||
// Performs an exact division, resulting in undefined behavior where
|
||||
// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`.
|
||||
@@ -536,8 +538,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
r: &ImmTy<'tcx, M::Provenance>,
|
||||
) -> InterpResult<'tcx, Scalar<M::Provenance>> {
|
||||
assert_eq!(l.layout.ty, r.layout.ty);
|
||||
assert!(matches!(l.layout.ty.kind(), ty::Int(..) | ty::Uint(..)));
|
||||
assert!(matches!(mir_op, BinOp::Add | BinOp::Sub));
|
||||
assert_matches!(l.layout.ty.kind(), ty::Int(..) | ty::Uint(..));
|
||||
assert_matches!(mir_op, BinOp::Add | BinOp::Sub);
|
||||
|
||||
let (val, overflowed) =
|
||||
self.binary_op(mir_op.wrapping_to_overflowing().unwrap(), l, r)?.to_scalar_pair();
|
||||
|
||||
@@ -342,7 +342,7 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
|
||||
}
|
||||
// extract fields from types with `ScalarPair` ABI
|
||||
(Immediate::ScalarPair(a_val, b_val), Abi::ScalarPair(a, b)) => {
|
||||
assert!(matches!(layout.abi, Abi::Scalar(..)));
|
||||
assert_matches!(layout.abi, Abi::Scalar(..));
|
||||
Immediate::from(if offset.bytes() == 0 {
|
||||
debug_assert_eq!(layout.size, a.size(cx));
|
||||
a_val
|
||||
|
||||
Reference in New Issue
Block a user