diff options
author | Lukas Wirth <[email protected]> | 2021-01-28 18:06:33 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-01-28 18:08:55 +0000 |
commit | 426ad8e165aeb70a3d12b8bc870cb0c57a308bc7 (patch) | |
tree | d40c9d6ed4a234a0d3a56d14f64f97b8bf7fdf8b /crates/hir_ty/src/diagnostics | |
parent | f421ee672253499b8ca8d1badf98db42525a5216 (diff) |
Classify function calls as functions when shadowed by types
Diffstat (limited to 'crates/hir_ty/src/diagnostics')
-rw-r--r-- | crates/hir_ty/src/diagnostics/unsafe_check.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs index 6dc862826..9c506112d 100644 --- a/crates/hir_ty/src/diagnostics/unsafe_check.rs +++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs | |||
@@ -12,8 +12,7 @@ use hir_def::{ | |||
12 | use hir_expand::diagnostics::DiagnosticSink; | 12 | use hir_expand::diagnostics::DiagnosticSink; |
13 | 13 | ||
14 | use crate::{ | 14 | use crate::{ |
15 | db::HirDatabase, diagnostics::MissingUnsafe, lower::CallableDefId, ApplicationTy, | 15 | db::HirDatabase, diagnostics::MissingUnsafe, ApplicationTy, InferenceResult, Ty, TypeCtor, |
16 | InferenceResult, Ty, TypeCtor, | ||
17 | }; | 16 | }; |
18 | 17 | ||
19 | pub(super) struct UnsafeValidator<'a, 'b: 'a> { | 18 | pub(super) struct UnsafeValidator<'a, 'b: 'a> { |
@@ -87,13 +86,8 @@ fn walk_unsafe( | |||
87 | ) { | 86 | ) { |
88 | let expr = &body.exprs[current]; | 87 | let expr = &body.exprs[current]; |
89 | match expr { | 88 | match expr { |
90 | Expr::Call { callee, .. } => { | 89 | &Expr::Call { callee, .. } => { |
91 | let ty = &infer[*callee]; | 90 | if let Some(func) = infer[callee].as_fn_def() { |
92 | if let &Ty::Apply(ApplicationTy { | ||
93 | ctor: TypeCtor::FnDef(CallableDefId::FunctionId(func)), | ||
94 | .. | ||
95 | }) = ty | ||
96 | { | ||
97 | if db.function_data(func).is_unsafe { | 91 | if db.function_data(func).is_unsafe { |
98 | unsafe_exprs.push(UnsafeExpr { expr: current, inside_unsafe_block }); | 92 | unsafe_exprs.push(UnsafeExpr { expr: current, inside_unsafe_block }); |
99 | } | 93 | } |