From fb0ab9f7456018ff0bac628e05366f976c5af1a7 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Thu, 8 Oct 2020 09:27:38 +0300 Subject: Keep SyntaxNodePtr::range private --- crates/hir_ty/src/diagnostics/decl_check.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'crates/hir_ty/src/diagnostics') 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> { for param_to_rename in fn_param_replacements { // We assume that parameters in replacement are in the same order as in the // actual params list, but just some of them (ones that named correctly) are skipped. - let ast_ptr = loop { + let ast_ptr: ast::Name = loop { match fn_params_iter.next() { Some(element) if pat_equals_to_name(element.pat(), ¶m_to_rename.current_name) => { - break element.pat().unwrap() + if let ast::Pat::IdentPat(pat) = element.pat().unwrap() { + break pat.name().unwrap(); + } else { + // This is critical. If we consider this parameter the expected one, + // it **must** have a name. + panic!( + "Pattern {:?} equals to expected replacement {:?}, but has no name", + element, param_to_rename + ); + } } Some(_) => {} None => { -- cgit v1.2.3