Skip to content

Commit d2f050d

Browse files
committed
Fix lint
1 parent 46657d3 commit d2f050d

File tree

8 files changed

+35
-48
lines changed

8 files changed

+35
-48
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
930930
return;
931931
};
932932

933-
let param = match find_param_with_region(tcx, self.mir_def_id(), f, o) {
934-
Some(param) => param,
935-
None => return,
933+
let Some(param) = find_param_with_region(tcx, self.mir_def_id(), f, o) else {
934+
return;
936935
};
937936
debug!(?param);
938937

compiler/rustc_borrowck/src/polonius/legacy/accesses.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ impl<'a, 'tcx> Visitor<'tcx> for AccessFactsExtractor<'a, 'tcx> {
6767
match context {
6868
PlaceContext::NonMutatingUse(_)
6969
| PlaceContext::MutatingUse(MutatingUseContext::Borrow) => {
70-
let path = match self.move_data.rev_lookup.find(place.as_ref()) {
71-
LookupResult::Exact(path) | LookupResult::Parent(Some(path)) => path,
72-
_ => {
73-
// There's no path access to emit.
74-
return;
75-
}
70+
let (LookupResult::Exact(path) | LookupResult::Parent(Some(path))) =
71+
self.move_data.rev_lookup.find(place.as_ref())
72+
else {
73+
// There's no path access to emit.
74+
return;
7675
};
7776
debug!("AccessFactsExtractor - emit path access ({path:?}, {location:?})");
7877
self.facts.path_accessed_at_base.push((path, self.location_to_index(location)));

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,15 +1551,15 @@ fn const_param_default<'tcx>(
15511551
tcx: TyCtxt<'tcx>,
15521552
def_id: LocalDefId,
15531553
) -> ty::EarlyBinder<'tcx, Const<'tcx>> {
1554-
let default_ct = match tcx.hir_node_by_def_id(def_id) {
1555-
hir::Node::GenericParam(hir::GenericParam {
1556-
kind: hir::GenericParamKind::Const { default: Some(ct), .. },
1557-
..
1558-
}) => ct,
1559-
_ => span_bug!(
1554+
let hir::Node::GenericParam(hir::GenericParam {
1555+
kind: hir::GenericParamKind::Const { default: Some(default_ct), .. },
1556+
..
1557+
}) = tcx.hir_node_by_def_id(def_id)
1558+
else {
1559+
span_bug!(
15601560
tcx.def_span(def_id),
15611561
"`const_param_default` expected a generic parameter with a constant"
1562-
),
1562+
)
15631563
};
15641564
let icx = ItemCtxt::new(tcx, def_id);
15651565
let identity_args = ty::GenericArgs::identity_for_item(tcx, def_id);

compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
763763
&self,
764764
err: &mut Diag<'_, impl EmissionGuarantee>,
765765
) {
766-
let trait_ = match self.tcx.trait_of_assoc(self.def_id) {
767-
Some(def_id) => def_id,
768-
None => return,
766+
let Some(trait_) = self.tcx.trait_of_assoc(self.def_id) else {
767+
return;
769768
};
770769

771770
// Skip suggestion when the associated function is itself generic, it is unclear

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,19 +1561,15 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
15611561
base_place: PlaceWithHirId<'tcx>,
15621562
) -> Result<PlaceWithHirId<'tcx>, Cx::Error> {
15631563
let base_curr_ty = base_place.place.ty();
1564-
let deref_ty = match self
1564+
let Some(deref_ty) = self
15651565
.cx
15661566
.structurally_resolve_type(self.cx.tcx().hir_span(base_place.hir_id), base_curr_ty)
15671567
.builtin_deref(true)
1568-
{
1569-
Some(ty) => ty,
1570-
None => {
1571-
debug!("explicit deref of non-derefable type: {:?}", base_curr_ty);
1572-
return Err(self.cx.report_bug(
1573-
self.cx.tcx().hir_span(node),
1574-
"explicit deref of non-derefable type",
1575-
));
1576-
}
1568+
else {
1569+
debug!("explicit deref of non-derefable type: {:?}", base_curr_ty);
1570+
return Err(self
1571+
.cx
1572+
.report_bug(self.cx.tcx().hir_span(node), "explicit deref of non-derefable type"));
15771573
};
15781574
let mut projections = base_place.place.projections;
15791575
projections.push(Projection { kind: ProjectionKind::Deref, ty: deref_ty });

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,9 +2405,7 @@ fn typetree_from_ty_impl_inner<'tcx>(
24052405
}
24062406

24072407
if ty.is_ref() || ty.is_raw_ptr() || ty.is_box() {
2408-
let inner_ty = if let Some(inner) = ty.builtin_deref(true) {
2409-
inner
2410-
} else {
2408+
let Some(inner_ty) = ty.builtin_deref(true) else {
24112409
return TypeTree::new();
24122410
};
24132411

compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,17 +445,15 @@ where
445445
goal_kind: ty::ClosureKind,
446446
) -> Result<Candidate<I>, NoSolution> {
447447
let cx = ecx.cx();
448-
let tupled_inputs_and_output =
449-
match structural_traits::extract_tupled_inputs_and_output_from_callable(
448+
let Some(tupled_inputs_and_output) =
449+
structural_traits::extract_tupled_inputs_and_output_from_callable(
450450
cx,
451451
goal.predicate.self_ty(),
452452
goal_kind,
453-
)? {
454-
Some(tupled_inputs_and_output) => tupled_inputs_and_output,
455-
None => {
456-
return ecx.forced_ambiguity(MaybeCause::Ambiguity);
457-
}
458-
};
453+
)?
454+
else {
455+
return ecx.forced_ambiguity(MaybeCause::Ambiguity);
456+
};
459457
let (inputs, output) = ecx.instantiate_binder_with_infer(tupled_inputs_and_output);
460458

461459
// A built-in `Fn` impl only holds if the output is sized.

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,17 +360,15 @@ where
360360
}
361361

362362
let cx = ecx.cx();
363-
let tupled_inputs_and_output =
364-
match structural_traits::extract_tupled_inputs_and_output_from_callable(
363+
let Some(tupled_inputs_and_output) =
364+
structural_traits::extract_tupled_inputs_and_output_from_callable(
365365
cx,
366366
goal.predicate.self_ty(),
367367
goal_kind,
368-
)? {
369-
Some(a) => a,
370-
None => {
371-
return ecx.forced_ambiguity(MaybeCause::Ambiguity);
372-
}
373-
};
368+
)?
369+
else {
370+
return ecx.forced_ambiguity(MaybeCause::Ambiguity);
371+
};
374372
let (inputs, output) = ecx.instantiate_binder_with_infer(tupled_inputs_and_output);
375373

376374
// A built-in `Fn` impl only holds if the output is sized.

0 commit comments

Comments
 (0)