diff options
Diffstat (limited to 'crates/hir_ty/src/diagnostics')
-rw-r--r-- | crates/hir_ty/src/diagnostics/decl_check.rs | 18 | ||||
-rw-r--r-- | crates/hir_ty/src/diagnostics/expr.rs | 18 | ||||
-rw-r--r-- | crates/hir_ty/src/diagnostics/unsafe_check.rs | 2 |
3 files changed, 19 insertions, 19 deletions
diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs index 982ad5b9e..bfe239793 100644 --- a/crates/hir_ty/src/diagnostics/decl_check.rs +++ b/crates/hir_ty/src/diagnostics/decl_check.rs | |||
@@ -203,7 +203,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
203 | let diagnostic = IncorrectCase { | 203 | let diagnostic = IncorrectCase { |
204 | file: fn_src.file_id, | 204 | file: fn_src.file_id, |
205 | ident_type: IdentType::Function, | 205 | ident_type: IdentType::Function, |
206 | ident: AstPtr::new(&ast_ptr).into(), | 206 | ident: AstPtr::new(&ast_ptr), |
207 | expected_case: replacement.expected_case, | 207 | expected_case: replacement.expected_case, |
208 | ident_text: replacement.current_name.to_string(), | 208 | ident_text: replacement.current_name.to_string(), |
209 | suggested_text: replacement.suggested_text, | 209 | suggested_text: replacement.suggested_text, |
@@ -261,7 +261,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
261 | let diagnostic = IncorrectCase { | 261 | let diagnostic = IncorrectCase { |
262 | file: fn_src.file_id, | 262 | file: fn_src.file_id, |
263 | ident_type: IdentType::Argument, | 263 | ident_type: IdentType::Argument, |
264 | ident: AstPtr::new(&ast_ptr).into(), | 264 | ident: AstPtr::new(&ast_ptr), |
265 | expected_case: param_to_rename.expected_case, | 265 | expected_case: param_to_rename.expected_case, |
266 | ident_text: param_to_rename.current_name.to_string(), | 266 | ident_text: param_to_rename.current_name.to_string(), |
267 | suggested_text: param_to_rename.suggested_text, | 267 | suggested_text: param_to_rename.suggested_text, |
@@ -313,7 +313,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
313 | let diagnostic = IncorrectCase { | 313 | let diagnostic = IncorrectCase { |
314 | file: source_ptr.file_id, | 314 | file: source_ptr.file_id, |
315 | ident_type: IdentType::Variable, | 315 | ident_type: IdentType::Variable, |
316 | ident: AstPtr::new(&name_ast).into(), | 316 | ident: AstPtr::new(&name_ast), |
317 | expected_case: replacement.expected_case, | 317 | expected_case: replacement.expected_case, |
318 | ident_text: replacement.current_name.to_string(), | 318 | ident_text: replacement.current_name.to_string(), |
319 | suggested_text: replacement.suggested_text, | 319 | suggested_text: replacement.suggested_text, |
@@ -403,7 +403,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
403 | let diagnostic = IncorrectCase { | 403 | let diagnostic = IncorrectCase { |
404 | file: struct_src.file_id, | 404 | file: struct_src.file_id, |
405 | ident_type: IdentType::Structure, | 405 | ident_type: IdentType::Structure, |
406 | ident: AstPtr::new(&ast_ptr).into(), | 406 | ident: AstPtr::new(&ast_ptr), |
407 | expected_case: replacement.expected_case, | 407 | expected_case: replacement.expected_case, |
408 | ident_text: replacement.current_name.to_string(), | 408 | ident_text: replacement.current_name.to_string(), |
409 | suggested_text: replacement.suggested_text, | 409 | suggested_text: replacement.suggested_text, |
@@ -448,7 +448,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
448 | let diagnostic = IncorrectCase { | 448 | let diagnostic = IncorrectCase { |
449 | file: struct_src.file_id, | 449 | file: struct_src.file_id, |
450 | ident_type: IdentType::Field, | 450 | ident_type: IdentType::Field, |
451 | ident: AstPtr::new(&ast_ptr).into(), | 451 | ident: AstPtr::new(&ast_ptr), |
452 | expected_case: field_to_rename.expected_case, | 452 | expected_case: field_to_rename.expected_case, |
453 | ident_text: field_to_rename.current_name.to_string(), | 453 | ident_text: field_to_rename.current_name.to_string(), |
454 | suggested_text: field_to_rename.suggested_text, | 454 | suggested_text: field_to_rename.suggested_text, |
@@ -527,7 +527,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
527 | let diagnostic = IncorrectCase { | 527 | let diagnostic = IncorrectCase { |
528 | file: enum_src.file_id, | 528 | file: enum_src.file_id, |
529 | ident_type: IdentType::Enum, | 529 | ident_type: IdentType::Enum, |
530 | ident: AstPtr::new(&ast_ptr).into(), | 530 | ident: AstPtr::new(&ast_ptr), |
531 | expected_case: replacement.expected_case, | 531 | expected_case: replacement.expected_case, |
532 | ident_text: replacement.current_name.to_string(), | 532 | ident_text: replacement.current_name.to_string(), |
533 | suggested_text: replacement.suggested_text, | 533 | suggested_text: replacement.suggested_text, |
@@ -572,7 +572,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
572 | let diagnostic = IncorrectCase { | 572 | let diagnostic = IncorrectCase { |
573 | file: enum_src.file_id, | 573 | file: enum_src.file_id, |
574 | ident_type: IdentType::Variant, | 574 | ident_type: IdentType::Variant, |
575 | ident: AstPtr::new(&ast_ptr).into(), | 575 | ident: AstPtr::new(&ast_ptr), |
576 | expected_case: variant_to_rename.expected_case, | 576 | expected_case: variant_to_rename.expected_case, |
577 | ident_text: variant_to_rename.current_name.to_string(), | 577 | ident_text: variant_to_rename.current_name.to_string(), |
578 | suggested_text: variant_to_rename.suggested_text, | 578 | suggested_text: variant_to_rename.suggested_text, |
@@ -617,7 +617,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
617 | let diagnostic = IncorrectCase { | 617 | let diagnostic = IncorrectCase { |
618 | file: const_src.file_id, | 618 | file: const_src.file_id, |
619 | ident_type: IdentType::Constant, | 619 | ident_type: IdentType::Constant, |
620 | ident: AstPtr::new(&ast_ptr).into(), | 620 | ident: AstPtr::new(&ast_ptr), |
621 | expected_case: replacement.expected_case, | 621 | expected_case: replacement.expected_case, |
622 | ident_text: replacement.current_name.to_string(), | 622 | ident_text: replacement.current_name.to_string(), |
623 | suggested_text: replacement.suggested_text, | 623 | suggested_text: replacement.suggested_text, |
@@ -665,7 +665,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
665 | let diagnostic = IncorrectCase { | 665 | let diagnostic = IncorrectCase { |
666 | file: static_src.file_id, | 666 | file: static_src.file_id, |
667 | ident_type: IdentType::StaticVariable, | 667 | ident_type: IdentType::StaticVariable, |
668 | ident: AstPtr::new(&ast_ptr).into(), | 668 | ident: AstPtr::new(&ast_ptr), |
669 | expected_case: replacement.expected_case, | 669 | expected_case: replacement.expected_case, |
670 | ident_text: replacement.current_name.to_string(), | 670 | ident_text: replacement.current_name.to_string(), |
671 | suggested_text: replacement.suggested_text, | 671 | suggested_text: replacement.suggested_text, |
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index b2bfd68d4..71b2cade0 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs | |||
@@ -44,7 +44,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
44 | pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) { | 44 | pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) { |
45 | self.check_for_filter_map_next(db); | 45 | self.check_for_filter_map_next(db); |
46 | 46 | ||
47 | let body = db.body(self.owner.into()); | 47 | let body = db.body(self.owner); |
48 | 48 | ||
49 | for (id, expr) in body.exprs.iter() { | 49 | for (id, expr) in body.exprs.iter() { |
50 | if let Some((variant_def, missed_fields, true)) = | 50 | if let Some((variant_def, missed_fields, true)) = |
@@ -98,7 +98,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
98 | missed_fields: Vec<LocalFieldId>, | 98 | missed_fields: Vec<LocalFieldId>, |
99 | ) { | 99 | ) { |
100 | // XXX: only look at source_map if we do have missing fields | 100 | // XXX: only look at source_map if we do have missing fields |
101 | let (_, source_map) = db.body_with_source_map(self.owner.into()); | 101 | let (_, source_map) = db.body_with_source_map(self.owner); |
102 | 102 | ||
103 | if let Ok(source_ptr) = source_map.expr_syntax(id) { | 103 | if let Ok(source_ptr) = source_map.expr_syntax(id) { |
104 | let root = source_ptr.file_syntax(db.upcast()); | 104 | let root = source_ptr.file_syntax(db.upcast()); |
@@ -128,7 +128,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
128 | missed_fields: Vec<LocalFieldId>, | 128 | missed_fields: Vec<LocalFieldId>, |
129 | ) { | 129 | ) { |
130 | // XXX: only look at source_map if we do have missing fields | 130 | // XXX: only look at source_map if we do have missing fields |
131 | let (_, source_map) = db.body_with_source_map(self.owner.into()); | 131 | let (_, source_map) = db.body_with_source_map(self.owner); |
132 | 132 | ||
133 | if let Ok(source_ptr) = source_map.pat_syntax(id) { | 133 | if let Ok(source_ptr) = source_map.pat_syntax(id) { |
134 | if let Some(expr) = source_ptr.value.as_ref().left() { | 134 | if let Some(expr) = source_ptr.value.as_ref().left() { |
@@ -175,7 +175,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
175 | }; | 175 | }; |
176 | 176 | ||
177 | // Search function body for instances of .filter_map(..).next() | 177 | // Search function body for instances of .filter_map(..).next() |
178 | let body = db.body(self.owner.into()); | 178 | let body = db.body(self.owner); |
179 | let mut prev = None; | 179 | let mut prev = None; |
180 | for (id, expr) in body.exprs.iter() { | 180 | for (id, expr) in body.exprs.iter() { |
181 | if let Expr::MethodCall { receiver, .. } = expr { | 181 | if let Expr::MethodCall { receiver, .. } = expr { |
@@ -192,7 +192,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
192 | if function_id == *next_function_id { | 192 | if function_id == *next_function_id { |
193 | if let Some(filter_map_id) = prev { | 193 | if let Some(filter_map_id) = prev { |
194 | if *receiver == filter_map_id { | 194 | if *receiver == filter_map_id { |
195 | let (_, source_map) = db.body_with_source_map(self.owner.into()); | 195 | let (_, source_map) = db.body_with_source_map(self.owner); |
196 | if let Ok(next_source_ptr) = source_map.expr_syntax(id) { | 196 | if let Ok(next_source_ptr) = source_map.expr_syntax(id) { |
197 | self.sink.push(ReplaceFilterMapNextWithFindMap { | 197 | self.sink.push(ReplaceFilterMapNextWithFindMap { |
198 | file: next_source_ptr.file_id, | 198 | file: next_source_ptr.file_id, |
@@ -262,7 +262,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
262 | let mut arg_count = args.len(); | 262 | let mut arg_count = args.len(); |
263 | 263 | ||
264 | if arg_count != param_count { | 264 | if arg_count != param_count { |
265 | let (_, source_map) = db.body_with_source_map(self.owner.into()); | 265 | let (_, source_map) = db.body_with_source_map(self.owner); |
266 | if let Ok(source_ptr) = source_map.expr_syntax(call_id) { | 266 | if let Ok(source_ptr) = source_map.expr_syntax(call_id) { |
267 | if is_method_call { | 267 | if is_method_call { |
268 | param_count -= 1; | 268 | param_count -= 1; |
@@ -287,7 +287,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
287 | infer: Arc<InferenceResult>, | 287 | infer: Arc<InferenceResult>, |
288 | ) { | 288 | ) { |
289 | let (body, source_map): (Arc<Body>, Arc<BodySourceMap>) = | 289 | let (body, source_map): (Arc<Body>, Arc<BodySourceMap>) = |
290 | db.body_with_source_map(self.owner.into()); | 290 | db.body_with_source_map(self.owner); |
291 | 291 | ||
292 | let match_expr_ty = if infer.type_of_expr[match_expr].is_unknown() { | 292 | let match_expr_ty = if infer.type_of_expr[match_expr].is_unknown() { |
293 | return; | 293 | return; |
@@ -393,7 +393,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
393 | }; | 393 | }; |
394 | 394 | ||
395 | if params.len() > 0 && params[0] == mismatch.actual { | 395 | if params.len() > 0 && params[0] == mismatch.actual { |
396 | let (_, source_map) = db.body_with_source_map(self.owner.into()); | 396 | let (_, source_map) = db.body_with_source_map(self.owner); |
397 | 397 | ||
398 | if let Ok(source_ptr) = source_map.expr_syntax(id) { | 398 | if let Ok(source_ptr) = source_map.expr_syntax(id) { |
399 | self.sink.push(MissingOkOrSomeInTailExpr { | 399 | self.sink.push(MissingOkOrSomeInTailExpr { |
@@ -425,7 +425,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | 427 | ||
428 | let (_, source_map) = db.body_with_source_map(self.owner.into()); | 428 | let (_, source_map) = db.body_with_source_map(self.owner); |
429 | 429 | ||
430 | if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) { | 430 | if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) { |
431 | self.sink | 431 | self.sink |
diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs index 44a7e5506..1f49a4909 100644 --- a/crates/hir_ty/src/diagnostics/unsafe_check.rs +++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs | |||
@@ -29,7 +29,7 @@ impl<'a, 'b> UnsafeValidator<'a, 'b> { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) { | 31 | pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) { |
32 | let def = self.owner.into(); | 32 | let def = self.owner; |
33 | let unsafe_expressions = unsafe_expressions(db, self.infer.as_ref(), def); | 33 | let unsafe_expressions = unsafe_expressions(db, self.infer.as_ref(), def); |
34 | let is_unsafe = match self.owner { | 34 | let is_unsafe = match self.owner { |
35 | DefWithBodyId::FunctionId(it) => db.function_data(it).qualifier.is_unsafe, | 35 | DefWithBodyId::FunctionId(it) => db.function_data(it).qualifier.is_unsafe, |