Skip to content

Commit f1d273c

Browse files
committed
Replace some _ == _ || _ == _s with matches!(_, _ | _)s
1 parent 4d75f61 commit f1d273c

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

compiler/rustc_const_eval/src/transform/validate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
754754
// FIXME(JakobDegen) The validator should check that `self.mir_phase <
755755
// DropsLowered`. However, this causes ICEs with generation of drop shims, which
756756
// seem to fail to set their `MirPhase` correctly.
757-
if *kind == RetagKind::Raw || *kind == RetagKind::TwoPhase {
757+
if matches!(kind, RetagKind::Raw | RetagKind::TwoPhase) {
758758
self.fail(location, format!("explicit `{:?}` is forbidden", kind));
759759
}
760760
}

compiler/rustc_errors/src/styled_buffer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl StyledBuffer {
142142
pub fn set_style(&mut self, line: usize, col: usize, style: Style, overwrite: bool) {
143143
if let Some(ref mut line) = self.lines.get_mut(line) {
144144
if let Some(StyledChar { style: s, .. }) = line.get_mut(col) {
145-
if overwrite || *s == Style::NoStyle || *s == Style::Quotation {
145+
if overwrite || matches!(s, Style::NoStyle | Style::Quotation) {
146146
*s = style;
147147
}
148148
}

compiler/rustc_expand/src/mbe/macro_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl TtParser {
503503
mp.push_match(metavar_idx, seq_depth, MatchedSeq(vec![]));
504504
}
505505

506-
if op == KleeneOp::ZeroOrMore || op == KleeneOp::ZeroOrOne {
506+
if matches!(op, KleeneOp::ZeroOrMore | KleeneOp::ZeroOrOne) {
507507
// Try zero matches of this sequence, by skipping over it.
508508
self.cur_mps.push(MatcherPos {
509509
idx: idx_first_after,

compiler/rustc_metadata/src/native_libs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'tcx> Collector<'tcx> {
107107
return;
108108
};
109109

110-
if abi == Abi::Rust || abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic {
110+
if matches!(abi, Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic) {
111111
return;
112112
}
113113

compiler/rustc_mir_transform/src/const_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
527527
let r = self.use_ecx(|this| this.ecx.read_immediate(&this.ecx.eval_operand(right, None)?));
528528
let l = self.use_ecx(|this| this.ecx.read_immediate(&this.ecx.eval_operand(left, None)?));
529529
// Check for exceeding shifts *even if* we cannot evaluate the LHS.
530-
if op == BinOp::Shr || op == BinOp::Shl {
530+
if matches!(op, BinOp::Shr | BinOp::Shl) {
531531
let r = r.clone()?;
532532
// We need the type of the LHS. We cannot use `place_layout` as that is the type
533533
// of the result, which for checked binops is not the same!

compiler/rustc_mir_transform/src/const_prop_lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
368368
this.ecx.read_immediate(&this.ecx.eval_operand(left, None)?)
369369
});
370370
// Check for exceeding shifts *even if* we cannot evaluate the LHS.
371-
if op == BinOp::Shr || op == BinOp::Shl {
371+
if matches!(op, BinOp::Shr | BinOp::Shl) {
372372
let r = r.clone()?;
373373
// We need the type of the LHS. We cannot use `place_layout` as that is the type
374374
// of the result, which for checked binops is not the same!

compiler/rustc_passes/src/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
125125
if let Some((depr, span)) = &depr {
126126
is_deprecated = true;
127127

128-
if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited {
128+
if matches!(kind, AnnotationKind::Prohibited | AnnotationKind::DeprecationProhibited) {
129129
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
130130
self.tcx.emit_spanned_lint(
131131
USELESS_DEPRECATED,

0 commit comments

Comments
 (0)