aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics/decl_check.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/diagnostics/decl_check.rs')
-rw-r--r--crates/hir_ty/src/diagnostics/decl_check.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs
index 1f9386b75..f987636fe 100644
--- a/crates/hir_ty/src/diagnostics/decl_check.rs
+++ b/crates/hir_ty/src/diagnostics/decl_check.rs
@@ -213,12 +213,21 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
213 for param_to_rename in fn_param_replacements { 213 for param_to_rename in fn_param_replacements {
214 // We assume that parameters in replacement are in the same order as in the 214 // We assume that parameters in replacement are in the same order as in the
215 // actual params list, but just some of them (ones that named correctly) are skipped. 215 // actual params list, but just some of them (ones that named correctly) are skipped.
216 let ast_ptr = loop { 216 let ast_ptr: ast::Name = loop {
217 match fn_params_iter.next() { 217 match fn_params_iter.next() {
218 Some(element) 218 Some(element)
219 if pat_equals_to_name(element.pat(), &param_to_rename.current_name) => 219 if pat_equals_to_name(element.pat(), &param_to_rename.current_name) =>
220 { 220 {
221 break element.pat().unwrap() 221 if let ast::Pat::IdentPat(pat) = element.pat().unwrap() {
222 break pat.name().unwrap();
223 } else {
224 // This is critical. If we consider this parameter the expected one,
225 // it **must** have a name.
226 panic!(
227 "Pattern {:?} equals to expected replacement {:?}, but has no name",
228 element, param_to_rename
229 );
230 }
222 } 231 }
223 Some(_) => {} 232 Some(_) => {}
224 None => { 233 None => {