Replace 'if let' with 'match' in decl_check.rs
@@ -171,9 +171,9 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
// 1. Diagnostic for function name.
if let Some(replacement) = fn_name_replacement {
- let ast_ptr = if let Some(name) = fn_src.value.name() {
- name
- } else {
+ let ast_ptr = match fn_src.value.name() {
+ Some(name) => name,
+ None => {
// We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic.
log::error!(
"Replacement ({:?}) was generated for a function without a name: {:?}",
@@ -181,6 +181,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
fn_src
);
return;
+ }
};
let diagnostic = IncorrectCase {
@@ -359,9 +360,9 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
let struct_src = struct_loc.source(db.upcast());
if let Some(replacement) = struct_name_replacement {
- let ast_ptr = if let Some(name) = struct_src.value.name() {
- name
- } else {
+ let ast_ptr = match struct_src.value.name() {
+ Some(name) => name,
+ None => {
// We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic.
log::error!(
"Replacement ({:?}) was generated for a structure without a name: {:?}",
@@ -369,6 +370,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
struct_src
);
return;
+ }
};
let diagnostic = IncorrectCase {
@@ -486,9 +488,9 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
let enum_src = enum_loc.source(db.upcast());
if let Some(replacement) = enum_name_replacement {
- let ast_ptr = if let Some(name) = enum_src.value.name() {
- name
- } else {
+ let ast_ptr = match enum_src.value.name() {
+ Some(name) => name,
+ None => {
// We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic.
log::error!(
"Replacement ({:?}) was generated for a enum without a name: {:?}",
@@ -496,6 +498,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
enum_src
);
return;
+ }
};
let diagnostic = IncorrectCase {
