Replace 'if let' with 'match' in decl_check.rs
This commit is contained in:
parent
559cc97073
commit
66cea8cbaa
@ -171,9 +171,9 @@ fn create_incorrect_case_diagnostic_for_func(
|
||||
|
||||
// 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 @@ fn create_incorrect_case_diagnostic_for_func(
|
||||
fn_src
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let diagnostic = IncorrectCase {
|
||||
@ -359,9 +360,9 @@ fn create_incorrect_case_diagnostic_for_struct(
|
||||
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 @@ fn create_incorrect_case_diagnostic_for_struct(
|
||||
struct_src
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let diagnostic = IncorrectCase {
|
||||
@ -486,9 +488,9 @@ fn create_incorrect_case_diagnostic_for_enum(
|
||||
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 @@ fn create_incorrect_case_diagnostic_for_enum(
|
||||
enum_src
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let diagnostic = IncorrectCase {
|
||||
|
Loading…
Reference in New Issue
Block a user