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
|
@ -468,7 +468,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
|
||||
if let ty::RawPtr(_, _) | ty::FnPtr(..) = lhs_ty.kind() {
|
||||
// Raw and fn pointer operations are not allowed inside consts and thus not promotable.
|
||||
assert!(matches!(
|
||||
assert_matches!(
|
||||
op,
|
||||
BinOp::Eq
|
||||
| BinOp::Ne
|
||||
|
@ -477,7 +477,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
|||
| BinOp::Ge
|
||||
| BinOp::Gt
|
||||
| BinOp::Offset
|
||||
));
|
||||
);
|
||||
return Err(Unpromotable);
|
||||
}
|
||||
|
||||
|
|
|
@ -996,7 +996,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
|
|||
/// }
|
||||
/// ```
|
||||
fn build_fn_ptr_addr_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -> Body<'tcx> {
|
||||
assert!(matches!(self_ty.kind(), ty::FnPtr(..)), "expected fn ptr, found {self_ty}");
|
||||
assert_matches!(self_ty.kind(), ty::FnPtr(..), "expected fn ptr, found {self_ty}");
|
||||
let span = tcx.def_span(def_id);
|
||||
let Some(sig) = tcx.fn_sig(def_id).instantiate(tcx, &[self_ty.into()]).no_bound_vars() else {
|
||||
span_bug!(span, "FnPtr::addr with bound vars for `{self_ty}`");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue