diff options
Diffstat (limited to 'compiler/rustc_borrowck/src')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs | 25 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/mod.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/move_errors.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/lib.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/region_infer/mod.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 76 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/universal_regions.rs | 5 | 
8 files changed, 57 insertions, 92 deletions
| diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index fce5ed0ef42..6988fbf8336 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -2071,11 +2071,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ) = rvalue { for operand in operands { - let assigned_from = match operand { - Operand::Copy(assigned_from) | Operand::Move(assigned_from) => { - assigned_from - } - _ => continue, + let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) = operand else { + continue; }; debug!( "annotate_argument_and_return_for_borrow: assigned_from={:?}", @@ -2083,10 +2080,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); // Find the local from the operand. - let assigned_from_local = match assigned_from.local_or_deref_local() - { - Some(local) => local, - None => continue, + let Some(assigned_from_local) = assigned_from.local_or_deref_local() else { + continue; }; if assigned_from_local != target { @@ -2138,10 +2133,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); // Find the local from the rvalue. - let assigned_from_local = match assigned_from.local_or_deref_local() { - Some(local) => local, - None => continue, - }; + let Some(assigned_from_local) = assigned_from.local_or_deref_local() else { continue }; debug!( "annotate_argument_and_return_for_borrow: \ assigned_from_local={:?}", @@ -2189,11 +2181,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { assigned_to, args ); for operand in args { - let assigned_from = match operand { - Operand::Copy(assigned_from) | Operand::Move(assigned_from) => { - assigned_from - } - _ => continue, + let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) = operand else { + continue; }; debug!( "annotate_argument_and_return_for_borrow: assigned_from={:?}", diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index db8268c8e2e..b1e5a211cf1 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -650,13 +650,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // The only kind of statement that we care about is assignments... if let StatementKind::Assign(box (place, rvalue)) = &stmt.kind { - let into = match place.local_or_deref_local() { - Some(into) => into, - None => { - // Continue at the next location. - queue.push(current_location.successor_within_block()); - continue; - } + let Some(into) = place.local_or_deref_local() else { + // Continue at the next location. + queue.push(current_location.successor_within_block()); + continue; }; match rvalue { diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 73b0d398285..5f533ddcb82 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -444,10 +444,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { debug!("borrowed_content_source: init={:?}", init); // We're only interested in statements that initialized a value, not the // initializations from arguments. - let loc = match init.location { - InitLocation::Statement(stmt) => stmt, - _ => continue, - }; + let InitLocation::Statement(loc) = init.location else { continue }; let bbd = &self.body[loc.block]; let is_terminator = bbd.statements.len() == loc.statement_index; @@ -787,9 +784,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ) -> UseSpans<'tcx> { use self::UseSpans::*; - let stmt = match self.body[location.block].statements.get(location.statement_index) { - Some(stmt) => stmt, - None => return OtherUse(self.body.source_info(location).span), + let Some(stmt) = self.body[location.block].statements.get(location.statement_index) else { + return OtherUse(self.body.source_info(location).span); }; debug!("move_spans: moved_place={:?} location={:?} stmt={:?}", moved_place, location, stmt); diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index cc6566882ad..d4f238ff71f 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -188,10 +188,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } // Error with the pattern LookupResult::Exact(_) => { - let mpi = match self.move_data.rev_lookup.find(move_from.as_ref()) { - LookupResult::Parent(Some(mpi)) => mpi, + let LookupResult::Parent(Some(mpi)) = self.move_data.rev_lookup.find(move_from.as_ref()) else { // move_from should be a projection from match_place. - _ => unreachable!("Probably not unreachable..."), + unreachable!("Probably not unreachable..."); }; for ge in &mut *grouped_errors { if let GroupedMoveError::MovesFromValue { diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 459b03b0fad..719862e67c8 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1914,10 +1914,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // without going over a Deref. let mut shortest_uninit_seen = None; for prefix in this.prefixes(base, PrefixSet::Shallow) { - let mpi = match this.move_path_for_place(prefix) { - Some(mpi) => mpi, - None => continue, - }; + let Some(mpi) = this.move_path_for_place(prefix) else { continue }; if maybe_uninits.contains(mpi) { debug!( diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index abd6a15334c..b99fb00599e 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -913,9 +913,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { let TypeTest { generic_kind, lower_bound, locations, verify_bound: _ } = type_test; let generic_ty = generic_kind.to_ty(tcx); - let subject = match self.try_promote_type_test_subject(infcx, generic_ty) { - Some(s) => s, - None => return false, + let Some(subject) = self.try_promote_type_test_subject(infcx, generic_ty) else { + return false; }; // For each region outlived by lower_bound find a non-local, @@ -1623,15 +1622,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { // If we have some bound universal region `'a`, then the only // elements it can contain is itself -- we don't know anything // else about it! - let error_element = match { + let Some(error_element) = ({ self.scc_values.elements_contained_in(longer_fr_scc).find(|element| match element { RegionElement::Location(_) => true, RegionElement::RootUniversalRegion(_) => true, RegionElement::PlaceholderRegion(placeholder1) => placeholder != *placeholder1, }) - } { - Some(v) => v, - None => return, + }) else { + return; }; debug!("check_bound_universal_region: error_element = {:?}", error_element); diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 46924f50d2e..8c4d81aaf52 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -810,13 +810,12 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { ty::Adt(adt_def, substs) => (&adt_def.variants[variant_index], substs), ty::Generator(def_id, substs, _) => { let mut variants = substs.as_generator().state_tys(def_id, tcx); - let mut variant = match variants.nth(variant_index.into()) { - Some(v) => v, - None => bug!( + let Some(mut variant) = variants.nth(variant_index.into()) else { + bug!( "variant_index of generator out of range: {:?}/{:?}", variant_index, substs.as_generator().state_tys(def_id, tcx).count() - ), + ); }; return match variant.nth(field.index()) { Some(ty) => Ok(ty), @@ -2178,35 +2177,29 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } CastKind::Pointer(PointerCast::MutToConstPointer) => { - let ty_from = match op.ty(body, tcx).kind() { - ty::RawPtr(ty::TypeAndMut { - ty: ty_from, - mutbl: hir::Mutability::Mut, - }) => ty_from, - _ => { - span_mirbug!( - self, - rvalue, - "unexpected base type for cast {:?}", - ty, - ); - return; - } + let ty::RawPtr(ty::TypeAndMut { + ty: ty_from, + mutbl: hir::Mutability::Mut, + }) = op.ty(body, tcx).kind() else { + span_mirbug!( + self, + rvalue, + "unexpected base type for cast {:?}", + ty, + ); + return; }; - let ty_to = match ty.kind() { - ty::RawPtr(ty::TypeAndMut { - ty: ty_to, - mutbl: hir::Mutability::Not, - }) => ty_to, - _ => { - span_mirbug!( - self, - rvalue, - "unexpected target type for cast {:?}", - ty, - ); - return; - } + let ty::RawPtr(ty::TypeAndMut { + ty: ty_to, + mutbl: hir::Mutability::Not, + }) = ty.kind() else { + span_mirbug!( + self, + rvalue, + "unexpected target type for cast {:?}", + ty, + ); + return; }; if let Err(terr) = self.sub_types( *ty_from, @@ -2238,17 +2231,14 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { _ => None, }; - let (ty_elem, ty_mut) = match opt_ty_elem_mut { - Some(ty_elem_mut) => ty_elem_mut, - None => { - span_mirbug!( - self, - rvalue, - "ArrayToPointer cast from unexpected type {:?}", - ty_from, - ); - return; - } + let Some((ty_elem, ty_mut)) = opt_ty_elem_mut else { + span_mirbug!( + self, + rvalue, + "ArrayToPointer cast from unexpected type {:?}", + ty_from, + ); + return; }; let (ty_to, ty_to_mut) = match ty.kind() { diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 72de3805467..33e65439fd7 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -641,9 +641,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { let (&output, tuplized_inputs) = inputs_and_output.skip_binder().split_last().unwrap(); assert_eq!(tuplized_inputs.len(), 1, "multiple closure inputs"); - let inputs = match tuplized_inputs[0].kind() { - ty::Tuple(inputs) => inputs, - _ => bug!("closure inputs not a tuple: {:?}", tuplized_inputs[0]), + let ty::Tuple(inputs) = tuplized_inputs[0].kind() else { + bug!("closure inputs not a tuple: {:?}", tuplized_inputs[0]); }; ty::Binder::bind_with_vars( | 
