X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_typeck%2Fsrc%2Fcheck%2Fcoercion.rs;h=b011fb8804d3ded91d169e5a3dcf37a84450bb33;hb=c1aa85475cf5623caf50f7ef3b62903bb084e518;hp=be7ac006926a9fc5201b24f41f59681b166c3949;hpb=576afec73a15e918ab6d1e85ba7d8dd6fb1626d3;p=rust.git diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index be7ac006926..b011fb8804d 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -429,13 +429,10 @@ fn coerce_borrowed_pointer( // (e.g., in example above, the failure from relating `Vec` // to the target type), since that should be the least // confusing. - let InferOk { value: ty, mut obligations } = match found { - Some(d) => d, - None => { - let err = first_error.expect("coerce_borrowed_pointer had no error"); - debug!("coerce_borrowed_pointer: failed with err = {:?}", err); - return Err(err); - } + let Some(InferOk { value: ty, mut obligations }) = found else { + let err = first_error.expect("coerce_borrowed_pointer had no error"); + debug!("coerce_borrowed_pointer: failed with err = {:?}", err); + return Err(err); }; if ty == a && mt_a.mutbl == hir::Mutability::Not && autoderef.step_count() == 1 { @@ -461,9 +458,8 @@ fn coerce_borrowed_pointer( // Now apply the autoref. We have to extract the region out of // the final ref type we got. - let r_borrow = match ty.kind() { - ty::Ref(r_borrow, _, _) => r_borrow, - _ => span_bug!(span, "expected a ref type, got {:?}", ty), + let ty::Ref(r_borrow, _, _) = ty.kind() else { + span_bug!(span, "expected a ref type, got {:?}", ty); }; let mutbl = match mutbl_b { hir::Mutability::Not => AutoBorrowMutability::Not, @@ -944,9 +940,8 @@ pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool { // We don't ever need two-phase here since we throw out the result of the coercion let coerce = Coerce::new(self, cause, AllowTwoPhase::No); self.probe(|_| { - let ok = match coerce.coerce(source, target) { - Ok(ok) => ok, - _ => return false, + let Ok(ok) = coerce.coerce(source, target) else { + return false; }; let mut fcx = traits::FulfillmentContext::new_in_snapshot(); fcx.register_predicate_obligations(self, ok.obligations);