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:
commit
7c6dca9050
39 changed files with 100 additions and 49 deletions
|
@ -1,4 +1,5 @@
|
|||
use std::any::Any;
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::marker::PhantomData;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
|
@ -1963,7 +1964,7 @@ impl SharedEmitterMain {
|
|||
sess.dcx().abort_if_errors();
|
||||
}
|
||||
Ok(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)) => {
|
||||
assert!(matches!(level, Level::Error | Level::Warning | Level::Note));
|
||||
assert_matches!(level, Level::Error | Level::Warning | Level::Note);
|
||||
let msg = msg.strip_prefix("error: ").unwrap_or(&msg).to_string();
|
||||
let mut err = Diag::<()>::new(sess.dcx(), level, msg);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#![allow(rustc::untranslatable_diagnostic)]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![doc(rust_logo)]
|
||||
#![feature(assert_matches)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(let_chains)]
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use std::assert_matches::assert_matches;
|
||||
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
|
||||
use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout};
|
||||
use rustc_middle::ty::{Instance, Ty};
|
||||
|
@ -254,10 +256,10 @@ pub trait BuilderMethods<'a, 'tcx>:
|
|||
} else {
|
||||
(in_ty, dest_ty)
|
||||
};
|
||||
assert!(matches!(
|
||||
assert_matches!(
|
||||
self.cx().type_kind(float_ty),
|
||||
TypeKind::Half | TypeKind::Float | TypeKind::Double | TypeKind::FP128
|
||||
));
|
||||
);
|
||||
assert_eq!(self.cx().type_kind(int_ty), TypeKind::Integer);
|
||||
|
||||
if let Some(false) = self.cx().sess().opts.unstable_opts.saturating_float_casts {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue