Skip to content

Commit e78e835

Browse files
committed
Slim down tuple_field_access_types
1 parent 70b3c35 commit e78e835

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/infer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ pub struct InferenceResult<'db> {
487487
/// Whenever a tuple field expression access a tuple field, we allocate a tuple id in
488488
/// [`InferenceContext`] and store the tuples substitution there. This map is the reverse of
489489
/// that which allows us to resolve a [`TupleFieldId`]s type.
490-
tuple_field_access_types: FxHashMap<TupleId, Tys<'db>>,
490+
#[update(unsafe(with(crate::utils::unsafe_update_eq /* thinvec is technically update */)))]
491+
tuple_field_access_types: ThinVec<Tys<'db>>,
491492

492493
#[update(unsafe(with(crate::utils::unsafe_update_eq /* expr id is technically update */)))]
493494
pub(crate) type_of_expr: ArenaMap<ExprId, Ty<'db>>,
@@ -685,7 +686,7 @@ impl<'db> InferenceResult<'db> {
685686
}
686687

687688
pub fn tuple_field_access_type(&self, id: TupleId) -> Tys<'db> {
688-
self.tuple_field_access_types[&id]
689+
self.tuple_field_access_types[id.0 as usize]
689690
}
690691

691692
pub fn pat_adjustment(&self, id: PatId) -> Option<&[Ty<'db>]> {
@@ -1148,9 +1149,8 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
11481149
pat_adjustments.shrink_to_fit();
11491150
result.tuple_field_access_types = tuple_field_accesses_rev
11501151
.into_iter()
1151-
.enumerate()
1152-
.map(|(idx, subst)| (TupleId(idx as u32), table.resolve_completely(subst)))
1153-
.inspect(|(_, subst)| {
1152+
.map(|subst| table.resolve_completely(subst))
1153+
.inspect(|subst| {
11541154
*has_errors = *has_errors || subst.iter().any(|ty| ty.references_non_lt_error());
11551155
})
11561156
.collect();

src/tools/rust-analyzer/crates/hir/src/semantics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ impl<'db> SemanticsImpl<'db> {
17801780
let (body, source_map) = self.db.body_with_source_map(def);
17811781
let infer = InferenceResult::for_body(self.db, def);
17821782
let mut res = FxHashSet::default();
1783-
unsafe_operations_for_body(self.db, &infer, def, &body, &mut |node| {
1783+
unsafe_operations_for_body(self.db, infer, def, &body, &mut |node| {
17841784
if let Ok(node) = source_map.expr_or_pat_syntax(node) {
17851785
res.insert(node);
17861786
}
@@ -1799,7 +1799,7 @@ impl<'db> SemanticsImpl<'db> {
17991799
return Vec::new();
18001800
};
18011801
let mut res = Vec::default();
1802-
unsafe_operations(self.db, &infer, def, &body, block, &mut |node, _| {
1802+
unsafe_operations(self.db, infer, def, &body, block, &mut |node, _| {
18031803
if let Ok(node) = source_map.expr_or_pat_syntax(node) {
18041804
res.push(node);
18051805
}

0 commit comments

Comments
 (0)