Skip to content

Commit a654914

Browse files
committed
feat: added utility resolve_hir_index in LoweredStructTypeContainer
1 parent 17a2cef commit a654914

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

compiler/compiler_typing/src/structs.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ pub struct LoweredStructTypeContainer {
2424
pub functions: IndexStorage<usize>
2525
}
2626

27+
impl LoweredStructTypeContainer {
28+
29+
/// Resolves the given `HIR` field index into the corresponding `MIR` field index if said one has changed.
30+
pub fn resolve_hir_index(&self, ind: usize) -> usize {
31+
if self.hir_mir_indexes.contains_key(&ind) {
32+
return self.hir_mir_indexes[&ind];
33+
}
34+
35+
return ind;
36+
}
37+
38+
}
39+
2740
impl SizedType for RawStructTypeContainer {
2841
fn get_size(&self, t: &Type, compacted_size: bool, storage: &TypeStorage) -> usize {
2942
let mut size = 0;

0 commit comments

Comments
 (0)