matches!(..)
instead 88 let Some((ip, instruction)) = instructions.next() else {
89 break;
90 };
91 if let InstructionKind::Keyword(Keyword::Include) = instruction.kind { 92 inst_to_remove.push(ip);
93
94 let Some((ip, include)) = instructions.next() else {
matches!(..)
instead530 });
531 }
532 snapshots.push((stack.clone(), Keyword::Do { end_ip: 0 }));
533 } else if let Keyword::If { .. } | Keyword::Elif { .. } = op_type {534 snapshots.push((stack.clone(), Keyword::Do { end_ip: 0 }));
535 } else {
536 return Err(TypecheckError(InvalidLoop)).with_context(|| {
matches!(..)
instead616 .pop()
617 .ok_or(TypecheckError(InvalidEnd))
618 .with_context(|| format!("Invalid end: No stack snapshot available"))?;
619 if let Keyword::Do { .. } = op_type {620 if stack != expected_stack {
621 return Err(TypecheckError(InvalidEnd)).with_context(|| {
622 format!(
matches!(..)
instead634 )
635 });
636 }
637 } else if let Keyword::Else { .. } = op_type {638 if stack != expected_stack {
639 return Err(TypecheckError(InvalidEnd)).with_context(|| {
640 format!(
matches!(..)
instead520 .pop()
521 .ok_or(TypecheckError(InvalidLoop))
522 .with_context(|| format!("Invalid do: No stack snapshot available"))?;
523 if let Keyword::While { .. } = op_type {524 if stack != stack_snapshot {
525 return Err(TypecheckError(InvalidLoop)).with_context(|| {
526 format!(
let
bindings in the form of if-let
and while-let
expressions are unnecessary unless they contain a pattern capture.
Consider using the matches!
macro or testing equality ==
instead. Since the matches!
macro was introduced in 1.42, this issue is raised only if the msrv
flag in your .deepsource.toml
file is set accordingly.
fn main() {
if let Some(1) = foo() {}
if let Bar(_) = bar() {}
}
// or,
enum EnumABC { A(i32), B(u32), C(&'static str) }
fn bar() -> EnumABC { EnumABC::B(10u32) }
fn foo() {
let EnumABC::A(_) = bar() else { return None; }
}
fn main() {
if foo() == Some(1) {}
if matches!(bar(), Bar(_)) {}
}
// or,
enum EnumABC { A(i32), B(u32), C(&'static str) }
fn bar() -> EnumABC { EnumABC::B(10u32) }
fn foo() {
if !matches!(bar(), EnumABC::A(_)) { return None; }
}