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