diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-16 16:42:58 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-16 16:42:58 +0000 |
commit | adcc89137d3feea8f19fad461bbde6f4bce048e5 (patch) | |
tree | 160af959553ce57fdfcbc0a6c79bafcc3611aeea /crates/ra_hir_ty/src/expr.rs | |
parent | 648df02953a6ebf87a5876668eceba208687e8a7 (diff) | |
parent | 9faea2364dee4fbc9391ad233c570b70256ef002 (diff) |
Merge #3584
3584: Switch to dynamic dispatch r=matklad a=matklad
Benches are in https://github.com/rust-analyzer/rust-analyzer/issues/1987#issuecomment-598807185
TL;DR:
* 33% faster release build
* slightly worse/same perf
* no changes for debug build
* slightly smaller binary
cc @flodiebold I genuinely don't know if it is a good idea or not.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/expr.rs')
-rw-r--r-- | crates/ra_hir_ty/src/expr.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index d8cdf5266..b7b476b4c 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs | |||
@@ -46,7 +46,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
46 | ExprValidator { func, infer, sink } | 46 | ExprValidator { func, infer, sink } |
47 | } | 47 | } |
48 | 48 | ||
49 | pub fn validate_body(&mut self, db: &impl HirDatabase) { | 49 | pub fn validate_body(&mut self, db: &dyn HirDatabase) { |
50 | let body = db.body(self.func.into()); | 50 | let body = db.body(self.func.into()); |
51 | 51 | ||
52 | for e in body.exprs.iter() { | 52 | for e in body.exprs.iter() { |
@@ -67,7 +67,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
67 | _path: &Option<Path>, | 67 | _path: &Option<Path>, |
68 | fields: &[RecordLitField], | 68 | fields: &[RecordLitField], |
69 | spread: Option<ExprId>, | 69 | spread: Option<ExprId>, |
70 | db: &impl HirDatabase, | 70 | db: &dyn HirDatabase, |
71 | ) { | 71 | ) { |
72 | if spread.is_some() { | 72 | if spread.is_some() { |
73 | return; | 73 | return; |
@@ -80,7 +80,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | let variant_data = variant_data(db, variant_def); | 83 | let variant_data = variant_data(db.upcast(), variant_def); |
84 | 84 | ||
85 | let lit_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect(); | 85 | let lit_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect(); |
86 | let missed_fields: Vec<Name> = variant_data | 86 | let missed_fields: Vec<Name> = variant_data |
@@ -102,7 +102,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
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 | if let Some(expr) = source_ptr.value.left() { | 104 | if let Some(expr) = source_ptr.value.left() { |
105 | let root = source_ptr.file_syntax(db); | 105 | let root = source_ptr.file_syntax(db.upcast()); |
106 | if let ast::Expr::RecordLit(record_lit) = expr.to_node(&root) { | 106 | if let ast::Expr::RecordLit(record_lit) = expr.to_node(&root) { |
107 | if let Some(field_list) = record_lit.record_field_list() { | 107 | if let Some(field_list) = record_lit.record_field_list() { |
108 | self.sink.push(MissingFields { | 108 | self.sink.push(MissingFields { |
@@ -116,12 +116,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | fn validate_results_in_tail_expr( | 119 | fn validate_results_in_tail_expr(&mut self, body_id: ExprId, id: ExprId, db: &dyn HirDatabase) { |
120 | &mut self, | ||
121 | body_id: ExprId, | ||
122 | id: ExprId, | ||
123 | db: &impl HirDatabase, | ||
124 | ) { | ||
125 | // the mismatch will be on the whole block currently | 120 | // the mismatch will be on the whole block currently |
126 | let mismatch = match self.infer.type_mismatch_for_expr(body_id) { | 121 | let mismatch = match self.infer.type_mismatch_for_expr(body_id) { |
127 | Some(m) => m, | 122 | Some(m) => m, |
@@ -130,8 +125,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
130 | 125 | ||
131 | let std_result_path = path![std::result::Result]; | 126 | let std_result_path = path![std::result::Result]; |
132 | 127 | ||
133 | let resolver = self.func.resolver(db); | 128 | let resolver = self.func.resolver(db.upcast()); |
134 | let std_result_enum = match resolver.resolve_known_enum(db, &std_result_path) { | 129 | let std_result_enum = match resolver.resolve_known_enum(db.upcast(), &std_result_path) { |
135 | Some(it) => it, | 130 | Some(it) => it, |
136 | _ => return, | 131 | _ => return, |
137 | }; | 132 | }; |