aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Aleksanov <[email protected]>2020-10-08 06:40:30 +0100
committerIgor Aleksanov <[email protected]>2020-10-12 09:05:00 +0100
commit66cea8cbaa3320653e760e7b4ce839e055976acf (patch)
tree51866a4cdb1d3df848eee301a8b56782566b0f6d
parent559cc970732d80e3ec624c20da4f8aac219d6b2e (diff)
Replace 'if let' with 'match' in decl_check.rs
-rw-r--r--crates/hir_ty/src/diagnostics/decl_check.rs63
1 files changed, 33 insertions, 30 deletions
diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs
index 901ccc94f..1f9386b75 100644
--- a/crates/hir_ty/src/diagnostics/decl_check.rs
+++ b/crates/hir_ty/src/diagnostics/decl_check.rs
@@ -171,16 +171,17 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
171 171
172 // 1. Diagnostic for function name. 172 // 1. Diagnostic for function name.
173 if let Some(replacement) = fn_name_replacement { 173 if let Some(replacement) = fn_name_replacement {
174 let ast_ptr = if let Some(name) = fn_src.value.name() { 174 let ast_ptr = match fn_src.value.name() {
175 name 175 Some(name) => name,
176 } else { 176 None => {
177 // We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic. 177 // We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic.
178 log::error!( 178 log::error!(
179 "Replacement ({:?}) was generated for a function without a name: {:?}", 179 "Replacement ({:?}) was generated for a function without a name: {:?}",
180 replacement, 180 replacement,
181 fn_src 181 fn_src
182 ); 182 );
183 return; 183 return;
184 }
184 }; 185 };
185 186
186 let diagnostic = IncorrectCase { 187 let diagnostic = IncorrectCase {
@@ -359,16 +360,17 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
359 let struct_src = struct_loc.source(db.upcast()); 360 let struct_src = struct_loc.source(db.upcast());
360 361
361 if let Some(replacement) = struct_name_replacement { 362 if let Some(replacement) = struct_name_replacement {
362 let ast_ptr = if let Some(name) = struct_src.value.name() { 363 let ast_ptr = match struct_src.value.name() {
363 name 364 Some(name) => name,
364 } else { 365 None => {
365 // We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic. 366 // We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic.
366 log::error!( 367 log::error!(
367 "Replacement ({:?}) was generated for a structure without a name: {:?}", 368 "Replacement ({:?}) was generated for a structure without a name: {:?}",
368 replacement, 369 replacement,
369 struct_src 370 struct_src
370 ); 371 );
371 return; 372 return;
373 }
372 }; 374 };
373 375
374 let diagnostic = IncorrectCase { 376 let diagnostic = IncorrectCase {
@@ -486,16 +488,17 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
486 let enum_src = enum_loc.source(db.upcast()); 488 let enum_src = enum_loc.source(db.upcast());
487 489
488 if let Some(replacement) = enum_name_replacement { 490 if let Some(replacement) = enum_name_replacement {
489 let ast_ptr = if let Some(name) = enum_src.value.name() { 491 let ast_ptr = match enum_src.value.name() {
490 name 492 Some(name) => name,
491 } else { 493 None => {
492 // We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic. 494 // We don't want rust-analyzer to panic over this, but it is definitely some kind of error in the logic.
493 log::error!( 495 log::error!(
494 "Replacement ({:?}) was generated for a enum without a name: {:?}", 496 "Replacement ({:?}) was generated for a enum without a name: {:?}",
495 replacement, 497 replacement,
496 enum_src 498 enum_src
497 ); 499 );
498 return; 500 return;
501 }
499 }; 502 };
500 503
501 let diagnostic = IncorrectCase { 504 let diagnostic = IncorrectCase {