1
Fork 0

Rollup merge of #128978 - compiler-errors:assert-matches, r=jieyouxu

Use `assert_matches` around the compiler more

It's a useful assertion, especially since it actually prints out the LHS.
This commit is contained in:
Guillaume Gomez 2024-08-12 17:09:19 +02:00 committed by GitHub
commit 7c6dca9050
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 100 additions and 49 deletions

View file

@ -1,3 +1,4 @@
use std::assert_matches::assert_matches;
use std::fmt;
use arrayvec::ArrayVec;
@ -389,7 +390,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
}
// Newtype vector of array, e.g. #[repr(simd)] struct S([i32; 4]);
(OperandValue::Immediate(llval), Abi::Aggregate { sized: true }) => {
assert!(matches!(self.layout.abi, Abi::Vector { .. }));
assert_matches!(self.layout.abi, Abi::Vector { .. });
let llfield_ty = bx.cx().backend_type(field);

View file

@ -1,3 +1,5 @@
use std::assert_matches::assert_matches;
use arrayvec::ArrayVec;
use rustc_middle::ty::adjustment::PointerCoercion;
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
@ -220,7 +222,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
match operand.val {
OperandValue::Ref(source_place_val) => {
assert_eq!(source_place_val.llextra, None);
assert!(matches!(operand_kind, OperandValueKind::Ref));
assert_matches!(operand_kind, OperandValueKind::Ref);
Some(bx.load_operand(source_place_val.with_type(cast)).val)
}
OperandValue::ZeroSized => {