@@ -153,6 +153,34 @@ pub enum IntRange {
153153
154154/// Type information relevant to Rust but generally not relevant to the SMT encoding.
155155/// This information is relevant for resolving traits.
156+ ///
157+ /// A `TypDecoration` can be applied to a type (via `TypX::Decorate`) to represent
158+ /// a different type that has the same encoding at the SMT level.
159+ /// For example, `u64` is represented in VIR as `Int(IntRange::U(64))`
160+ /// while `Box<u64>` is represented in VIR as `Decorate(Box, Int(IntRange::U(64)))`.
161+ /// Since the VIR types differ only in the "decoration", we know they are represented
162+ /// by the same SMT sort (air's Int type, in this case).
163+ /// Many functions (e.g., HasType) that depend on a type can be written
164+ /// to only depend on the "base type" (i.e., the type minus the decoration).
165+ ///
166+ /// Furthermore, many functions can be elided entirely because they are simply the identity
167+ /// operation, e.g., `Box::new` takes a `T` to a `Box<T>`; but since these types are
168+ /// equivalent up to decoration, they are represented the same in SMT, and it happens the
169+ /// function is the identity function.
170+ ///
171+ /// However, decorations are not totally irrelevant. They are still significant for resolving
172+ /// traits (e.g., `u64` and `Box<u64>` might implement the same trait in different ways).
173+ ///
174+ /// In some places, the decoration of a Typ cannot be considered meaningful due to these
175+ /// implicit 'identity' coercions:
176+ /// - `expr.typ`
177+ /// - `place.typ`
178+ /// - `pattern.typ`
179+ /// - `exp.typ` (SST nodes)
180+ /// But in other places, types must be exactly correct, *including* decoration:
181+ /// - type arguments for a Call
182+ /// - `pattern_binding.typ` (type of a local variable declaration)
183+ /// - Most places where `Typ` is given as an explicit field of a node
156184#[ derive(
157185 Debug ,
158186 Serialize ,
@@ -170,8 +198,10 @@ pub enum TypDecoration {
170198 /// &T
171199 Ref ,
172200 /// &mut T
201+ /// For new-mut-ref, don't use this; use TypX::MutRef instead
173202 MutRef ,
174203 /// Box<T>
204+ /// This is complicated due to the Allocator type argument; see `TypDecorationArg`.
175205 Box ,
176206 /// Rc<T>
177207 Rc ,
0 commit comments