aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--crates/hir/Cargo.toml1
-rw-r--r--crates/hir/src/lib.rs7
-rw-r--r--crates/hir_ty/src/diagnostics/unsafe_check.rs5
4 files changed, 8 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock
index e1d2a74f0..0ffc91548 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -482,6 +482,7 @@ dependencies = [
482 "hir_ty", 482 "hir_ty",
483 "itertools", 483 "itertools",
484 "log", 484 "log",
485 "once_cell",
485 "profile", 486 "profile",
486 "rustc-hash", 487 "rustc-hash",
487 "smallvec", 488 "smallvec",
diff --git a/crates/hir/Cargo.toml b/crates/hir/Cargo.toml
index 560b15238..7c148fd40 100644
--- a/crates/hir/Cargo.toml
+++ b/crates/hir/Cargo.toml
@@ -16,6 +16,7 @@ either = "1.5.3"
16arrayvec = "0.7" 16arrayvec = "0.7"
17itertools = "0.10.0" 17itertools = "0.10.0"
18smallvec = "1.4.0" 18smallvec = "1.4.0"
19once_cell = "1"
19 20
20stdx = { path = "../stdx", version = "0.0.0" } 21stdx = { path = "../stdx", version = "0.0.0" }
21syntax = { path = "../syntax", version = "0.0.0" } 22syntax = { path = "../syntax", version = "0.0.0" }
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index a21a9da21..8804e63c5 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -73,6 +73,7 @@ use hir_ty::{
73}; 73};
74use itertools::Itertools; 74use itertools::Itertools;
75use nameres::diagnostics::DefDiagnosticKind; 75use nameres::diagnostics::DefDiagnosticKind;
76use once_cell::unsync::Lazy;
76use rustc_hash::FxHashSet; 77use rustc_hash::FxHashSet;
77use stdx::{format_to, impl_from}; 78use stdx::{format_to, impl_from};
78use syntax::{ 79use syntax::{
@@ -1044,7 +1045,7 @@ impl Function {
1044 } 1045 }
1045 1046
1046 let infer = db.infer(self.id.into()); 1047 let infer = db.infer(self.id.into());
1047 let (_, source_map) = db.body_with_source_map(self.id.into()); 1048 let source_map = Lazy::new(|| db.body_with_source_map(self.id.into()).1);
1048 for d in &infer.diagnostics { 1049 for d in &infer.diagnostics {
1049 match d { 1050 match d {
1050 hir_ty::InferenceDiagnostic::NoSuchField { expr } => { 1051 hir_ty::InferenceDiagnostic::NoSuchField { expr } => {
@@ -1061,13 +1062,13 @@ impl Function {
1061 } 1062 }
1062 1063
1063 for expr in hir_ty::diagnostics::missing_unsafe(db, self.id.into()) { 1064 for expr in hir_ty::diagnostics::missing_unsafe(db, self.id.into()) {
1064 match source_map.as_ref().expr_syntax(expr) { 1065 match source_map.expr_syntax(expr) {
1065 Ok(in_file) => { 1066 Ok(in_file) => {
1066 sink.push(MissingUnsafe { file: in_file.file_id, expr: in_file.value }) 1067 sink.push(MissingUnsafe { file: in_file.file_id, expr: in_file.value })
1067 } 1068 }
1068 Err(SyntheticSyntax) => { 1069 Err(SyntheticSyntax) => {
1069 // FIXME: The `expr` was desugared, report or assert that 1070 // FIXME: The `expr` was desugared, report or assert that
1070 // this dosen't happen. 1071 // this doesn't happen.
1071 } 1072 }
1072 } 1073 }
1073 } 1074 }
diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs
index a4054cef9..777f347b8 100644
--- a/crates/hir_ty/src/diagnostics/unsafe_check.rs
+++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs
@@ -13,7 +13,6 @@ use crate::{db::HirDatabase, InferenceResult, Interner, TyExt, TyKind};
13pub fn missing_unsafe(db: &dyn HirDatabase, def: DefWithBodyId) -> Vec<ExprId> { 13pub fn missing_unsafe(db: &dyn HirDatabase, def: DefWithBodyId) -> Vec<ExprId> {
14 let infer = db.infer(def); 14 let infer = db.infer(def);
15 15
16 // let unsafe_expressions = ;
17 let is_unsafe = match def { 16 let is_unsafe = match def {
18 DefWithBodyId::FunctionId(it) => db.function_data(it).is_unsafe(), 17 DefWithBodyId::FunctionId(it) => db.function_data(it).is_unsafe(),
19 DefWithBodyId::StaticId(_) | DefWithBodyId::ConstId(_) => false, 18 DefWithBodyId::StaticId(_) | DefWithBodyId::ConstId(_) => false,
@@ -29,12 +28,12 @@ pub fn missing_unsafe(db: &dyn HirDatabase, def: DefWithBodyId) -> Vec<ExprId> {
29 .collect() 28 .collect()
30} 29}
31 30
32pub(crate) struct UnsafeExpr { 31struct UnsafeExpr {
33 pub(crate) expr: ExprId, 32 pub(crate) expr: ExprId,
34 pub(crate) inside_unsafe_block: bool, 33 pub(crate) inside_unsafe_block: bool,
35} 34}
36 35
37pub(crate) fn unsafe_expressions( 36fn unsafe_expressions(
38 db: &dyn HirDatabase, 37 db: &dyn HirDatabase,
39 infer: &InferenceResult, 38 infer: &InferenceResult,
40 def: DefWithBodyId, 39 def: DefWithBodyId,