aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
authorIgor Aleksanov <[email protected]>2020-10-08 07:27:38 +0100
committerIgor Aleksanov <[email protected]>2020-10-12 09:05:00 +0100
commitfb0ab9f7456018ff0bac628e05366f976c5af1a7 (patch)
tree681abdb0ab856c42a586d8851c9708a7ec6f8b88 /crates/hir_ty/src
parent66cea8cbaa3320653e760e7b4ce839e055976acf (diff)
Keep SyntaxNodePtr::range private
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/diagnostics.rs4
-rw-r--r--crates/hir_ty/src/diagnostics/decl_check.rs13
2 files changed, 13 insertions, 4 deletions
diff --git a/crates/hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs
index f2e06495e..dfe98571e 100644
--- a/crates/hir_ty/src/diagnostics.rs
+++ b/crates/hir_ty/src/diagnostics.rs
@@ -267,7 +267,7 @@ impl fmt::Display for CaseType {
267#[derive(Debug)] 267#[derive(Debug)]
268pub struct IncorrectCase { 268pub struct IncorrectCase {
269 pub file: HirFileId, 269 pub file: HirFileId,
270 pub ident: SyntaxNodePtr, 270 pub ident: AstPtr<ast::Name>,
271 pub expected_case: CaseType, 271 pub expected_case: CaseType,
272 pub ident_type: String, 272 pub ident_type: String,
273 pub ident_text: String, 273 pub ident_text: String,
@@ -290,7 +290,7 @@ impl Diagnostic for IncorrectCase {
290 } 290 }
291 291
292 fn display_source(&self) -> InFile<SyntaxNodePtr> { 292 fn display_source(&self) -> InFile<SyntaxNodePtr> {
293 InFile::new(self.file, self.ident.clone()) 293 InFile::new(self.file, self.ident.clone().into())
294 } 294 }
295 295
296 fn as_any(&self) -> &(dyn Any + Send + 'static) { 296 fn as_any(&self) -> &(dyn Any + Send + 'static) {
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 => {