feat: WIP
This commit is contained in:
@@ -22,10 +22,15 @@ impl<'ctx, 'bump> DowngradeCtx<'ctx, 'bump> {
|
||||
|
||||
impl DowngradeCtx<'_, '_> {
|
||||
fn get_ir(&self, id: ExprId) -> &RefCell<Hir> {
|
||||
// SAFETY: The `ExprId` is guaranteed to be valid and correspond to an expression
|
||||
// allocated within this context, making the raw index access safe.
|
||||
let idx = unsafe { id.raw() } - self.ctx.lirs.len() - self.ctx.hirs.len();
|
||||
if cfg!(debug_assertions) {
|
||||
self.irs.get(idx).unwrap()
|
||||
} else {
|
||||
// SAFETY: The index calculation is guarded by the logic that creates `ExprId`s,
|
||||
// ensuring it's always within the bounds of the `irs` vector in release builds.
|
||||
// The debug build's `unwrap()` serves as a runtime check for this invariant.
|
||||
unsafe { self.irs.get_unchecked(idx) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user