diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-12 15:50:37 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-12 15:50:37 +0100 |
commit | 10ca6b286c6f763f0d2a44bc551139f64549938e (patch) | |
tree | fcf4b661c6f656229e1e598ae3798705780ead39 /crates/hir | |
parent | f9e67d692d915b326bd20a4c487039ade377029b (diff) | |
parent | 6f0141a14026827edfe4ef046013001acd22d94d (diff) |
Merge #9231
9231: minor: optimize r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 7 |
2 files changed, 5 insertions, 3 deletions
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" | |||
16 | arrayvec = "0.7" | 16 | arrayvec = "0.7" |
17 | itertools = "0.10.0" | 17 | itertools = "0.10.0" |
18 | smallvec = "1.4.0" | 18 | smallvec = "1.4.0" |
19 | once_cell = "1" | ||
19 | 20 | ||
20 | stdx = { path = "../stdx", version = "0.0.0" } | 21 | stdx = { path = "../stdx", version = "0.0.0" } |
21 | syntax = { path = "../syntax", version = "0.0.0" } | 22 | syntax = { 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 | }; |
74 | use itertools::Itertools; | 74 | use itertools::Itertools; |
75 | use nameres::diagnostics::DefDiagnosticKind; | 75 | use nameres::diagnostics::DefDiagnosticKind; |
76 | use once_cell::unsync::Lazy; | ||
76 | use rustc_hash::FxHashSet; | 77 | use rustc_hash::FxHashSet; |
77 | use stdx::{format_to, impl_from}; | 78 | use stdx::{format_to, impl_from}; |
78 | use syntax::{ | 79 | use 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 | } |