diff --git a/fathom/src/env.rs b/fathom/src/env.rs index 62d12934c..07039deae 100644 --- a/fathom/src/env.rs +++ b/fathom/src/env.rs @@ -17,7 +17,8 @@ //! and [`SliceEnv`], but when we need to copy environments often, we use a //! [`SharedEnv`] to increase the amount of sharing at the expense of locality. -use std::{fmt, ops::Add}; +use std::fmt; +use std::ops::Add; /// Underlying variable representation. type RawVar = u16; @@ -133,6 +134,13 @@ pub fn levels() -> impl Iterator { #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct EnvLen(RawVar); +impl Add for EnvLen { + type Output = Self; + fn add(self, rhs: Index) -> Self::Output { + Self(self.0 + rhs.0) // FIXME: check overflow? + } +} + impl EnvLen { /// Construct a new, empty environment. pub fn new() -> EnvLen {