Rollup merge of #80344 - matthiaskrgr:matches, r=Dylan-DPC
use matches!() macro in more places
This commit is contained in:
commit
c51172f38a
33 changed files with 137 additions and 266 deletions
|
@ -35,10 +35,7 @@ pub enum AutoTraitResult<A> {
|
|||
#[allow(dead_code)]
|
||||
impl<A> AutoTraitResult<A> {
|
||||
fn is_auto(&self) -> bool {
|
||||
match *self {
|
||||
AutoTraitResult::PositiveImpl(_) | AutoTraitResult::NegativeImpl => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, AutoTraitResult::PositiveImpl(_) | AutoTraitResult::NegativeImpl)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,10 +598,7 @@ impl AutoTraitFinder<'tcx> {
|
|||
}
|
||||
|
||||
fn is_self_referential_projection(&self, p: ty::PolyProjectionPredicate<'_>) -> bool {
|
||||
match *p.ty().skip_binder().kind() {
|
||||
ty::Projection(proj) if proj == p.skip_binder().projection_ty => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*p.ty().skip_binder().kind(), ty::Projection(proj) if proj == p.skip_binder().projection_ty)
|
||||
}
|
||||
|
||||
fn evaluate_nested_obligations(
|
||||
|
|
|
@ -193,10 +193,8 @@ fn overlap_within_probe(
|
|||
let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes();
|
||||
debug!("overlap: intercrate_ambiguity_causes={:#?}", intercrate_ambiguity_causes);
|
||||
|
||||
let involves_placeholder = match selcx.infcx().region_constraints_added_in_snapshot(snapshot) {
|
||||
Some(true) => true,
|
||||
_ => false,
|
||||
};
|
||||
let involves_placeholder =
|
||||
matches!(selcx.infcx().region_constraints_added_in_snapshot(snapshot), Some(true));
|
||||
|
||||
Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder })
|
||||
}
|
||||
|
|
|
@ -861,10 +861,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
let args_str = |arguments: &[ArgKind], other: &[ArgKind]| {
|
||||
let arg_length = arguments.len();
|
||||
let distinct = match &other[..] {
|
||||
&[ArgKind::Tuple(..)] => true,
|
||||
_ => false,
|
||||
};
|
||||
let distinct = matches!(other, &[ArgKind::Tuple(..)]);
|
||||
match (arg_length, arguments.get(0)) {
|
||||
(1, Some(&ArgKind::Tuple(_, ref fields))) => {
|
||||
format!("a single {}-tuple as argument", fields.len())
|
||||
|
@ -1201,12 +1198,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
normalized_ty, data.ty
|
||||
);
|
||||
|
||||
let is_normalized_ty_expected = match &obligation.cause.code {
|
||||
ObligationCauseCode::ItemObligation(_)
|
||||
let is_normalized_ty_expected = !matches!(obligation.cause.code, ObligationCauseCode::ItemObligation(_)
|
||||
| ObligationCauseCode::BindingObligation(_, _)
|
||||
| ObligationCauseCode::ObjectCastObligation(_) => false,
|
||||
_ => true,
|
||||
};
|
||||
| ObligationCauseCode::ObjectCastObligation(_));
|
||||
|
||||
if let Err(error) = self.at(&obligation.cause, obligation.param_env).eq_exp(
|
||||
is_normalized_ty_expected,
|
||||
|
|
|
@ -323,9 +323,8 @@ pub fn normalize_param_env_or_error<'tcx>(
|
|||
// This works fairly well because trait matching does not actually care about param-env
|
||||
// TypeOutlives predicates - these are normally used by regionck.
|
||||
let outlives_predicates: Vec<_> = predicates
|
||||
.drain_filter(|predicate| match predicate.skip_binders() {
|
||||
ty::PredicateAtom::TypeOutlives(..) => true,
|
||||
_ => false,
|
||||
.drain_filter(|predicate| {
|
||||
matches!(predicate.skip_binders(), ty::PredicateAtom::TypeOutlives(..))
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue