charon_lib/ast/
expressions.rs

1//! Implements expressions: paths, operands, rvalues, lvalues
2
3use crate::ast::*;
4use derive_generic_visitor::{Drive, DriveMut};
5use macros::{EnumAsGetters, EnumIsA, EnumToGetters, VariantIndexArity, VariantName};
6use serde::{Deserialize, Serialize};
7use std::vec::Vec;
8
9#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Drive, DriveMut)]
10pub struct Place {
11    pub kind: PlaceKind,
12    pub ty: Ty,
13}
14
15#[derive(
16    Debug,
17    PartialEq,
18    Eq,
19    Clone,
20    EnumIsA,
21    EnumAsGetters,
22    EnumToGetters,
23    Serialize,
24    Deserialize,
25    Drive,
26    DriveMut,
27)]
28#[charon::variants_prefix("Place")]
29pub enum PlaceKind {
30    Local(LocalId),
31    Projection(Box<Place>, ProjectionElem),
32}
33
34/// Note that we don't have the equivalent of "downcasts".
35/// Downcasts are actually necessary, for instance when initializing enumeration
36/// values: the value is initially `Bottom`, and we need a way of knowing the
37/// variant.
38/// For example:
39/// `((_0 as Right).0: T2) = move _1;`
40/// In MIR, downcasts always happen before field projections: in our internal
41/// language, we thus merge downcasts and field projections.
42#[derive(
43    Debug,
44    PartialEq,
45    Eq,
46    Clone,
47    EnumIsA,
48    EnumAsGetters,
49    EnumToGetters,
50    VariantName,
51    Serialize,
52    Deserialize,
53    Drive,
54    DriveMut,
55)]
56pub enum ProjectionElem {
57    /// Dereference a shared/mutable reference, a box, or a raw pointer.
58    Deref,
59    /// Projection from ADTs (variants, structures).
60    /// We allow projections to be used as left-values and right-values.
61    /// We should never have projections to fields of symbolic variants (they
62    /// should have been expanded before through a match).
63    Field(FieldProjKind, FieldId),
64    /// MIR imposes that the argument to an index projection be a local variable, meaning
65    /// that even constant indices into arrays are let-bound as separate variables.
66    /// We **eliminate** this variant in a micro-pass for LLBC.
67    #[charon::rename("ProjIndex")]
68    Index {
69        offset: Box<Operand>,
70        #[drive(skip)]
71        from_end: bool,
72    },
73    /// Take a subslice of a slice or array. If `from_end` is `true` this is
74    /// `slice[from..slice.len() - to]`, otherwise this is `slice[from..to]`.
75    /// We **eliminate** this variant in a micro-pass for LLBC.
76    Subslice {
77        from: Box<Operand>,
78        to: Box<Operand>,
79        #[drive(skip)]
80        from_end: bool,
81    },
82}
83
84#[derive(
85    Debug,
86    PartialEq,
87    Eq,
88    Copy,
89    Clone,
90    EnumIsA,
91    EnumAsGetters,
92    Serialize,
93    Deserialize,
94    Drive,
95    DriveMut,
96)]
97#[charon::variants_prefix("Proj")]
98pub enum FieldProjKind {
99    Adt(TypeDeclId, Option<VariantId>),
100    /// If we project from a tuple, the projection kind gives the arity of the tuple.
101    #[drive(skip)]
102    Tuple(usize),
103}
104
105#[derive(
106    Debug,
107    PartialEq,
108    Eq,
109    Copy,
110    Clone,
111    EnumIsA,
112    EnumAsGetters,
113    Serialize,
114    Deserialize,
115    Drive,
116    DriveMut,
117)]
118#[charon::variants_prefix("B")]
119pub enum BorrowKind {
120    Shared,
121    Mut,
122    /// See <https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/mir/enum.MutBorrowKind.html#variant.TwoPhaseBorrow>
123    /// and <https://rustc-dev-guide.rust-lang.org/borrow_check/two_phase_borrows.html>
124    TwoPhaseMut,
125    /// Those are typically introduced when using guards in matches, to make sure guards don't
126    /// change the variant of an enum value while me match over it.
127    ///
128    /// See <https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/mir/enum.FakeBorrowKind.html#variant.Shallow>.
129    Shallow,
130    /// Data must be immutable but not aliasable. In other words you can't mutate the data but you
131    /// can mutate *through it*, e.g. if it points to a `&mut T`. This is only used in closure
132    /// captures, e.g.
133    /// ```rust,ignore
134    /// let mut z = 3;
135    /// let x: &mut isize = &mut z;
136    /// let y = || *x += 5;
137    /// ```
138    /// Here the captured variable can't be `&mut &mut x` since the `x` binding is not mutable, yet
139    /// we must be able to mutate what it points to.
140    ///
141    /// See <https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/mir/enum.MutBorrowKind.html#variant.ClosureCapture>.
142    UniqueImmutable,
143}
144
145/// Unary operation
146#[derive(
147    Debug, PartialEq, Eq, Clone, EnumIsA, VariantName, Serialize, Deserialize, Drive, DriveMut,
148)]
149#[charon::rename("Unop")]
150pub enum UnOp {
151    Not,
152    /// This can overflow. In practice, rust introduces an assert before
153    /// (in debug mode) to check that it is not equal to the minimum integer
154    /// value (for the proper type).
155    Neg,
156    /// Retreive the metadata part of a fat pointer. For slices, this retreives their length.
157    PtrMetadata,
158    /// Casts are rvalues in MIR, but we treat them as unops.
159    Cast(CastKind),
160    /// Coercion from array (i.e., [T; N]) to slice.
161    ///
162    /// **Remark:** We introduce this unop when translating from MIR, **then transform**
163    /// it to a function call in a micro pass. The type and the scalar value are not
164    /// *necessary* as we can retrieve them from the context, but storing them here is
165    /// very useful. The [RefKind] argument states whethere we operate on a mutable
166    /// or a shared borrow to an array.
167    ArrayToSlice(RefKind, Ty, ConstGeneric),
168}
169
170/// Nullary operation
171#[derive(
172    Debug, PartialEq, Eq, Clone, EnumIsA, VariantName, Serialize, Deserialize, Drive, DriveMut,
173)]
174#[charon::rename("Nullop")]
175pub enum NullOp {
176    SizeOf,
177    AlignOf,
178    #[drive(skip)]
179    OffsetOf(Vec<(usize, FieldId)>),
180    UbChecks,
181}
182
183/// For all the variants: the first type gives the source type, the second one gives
184/// the destination type.
185#[derive(
186    Debug, PartialEq, Eq, Clone, EnumIsA, VariantName, Serialize, Deserialize, Drive, DriveMut,
187)]
188#[charon::variants_prefix("Cast")]
189pub enum CastKind {
190    /// Conversion between types in `{Integer, Bool}`
191    /// Remark: for now we don't support conversions with Char.
192    Scalar(LiteralTy, LiteralTy),
193    RawPtr(Ty, Ty),
194    FnPtr(Ty, Ty),
195    /// [Unsize coercion](https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html). This is
196    /// either `[T; N]` -> `[T]` or `T: Trait` -> `dyn Trait` coercions, behind a pointer
197    /// (reference, `Box`, or other type that implements `CoerceUnsized`).
198    ///
199    /// The special case of `&[T; N]` -> `&[T]` coercion is caught by `UnOp::ArrayToSlice`.
200    Unsize(Ty, Ty),
201    /// Reinterprets the bits of a value of one type as another type, i.e. exactly what
202    /// [`std::mem::transmute`] does.
203    Transmute(Ty, Ty),
204}
205
206/// Binary operations.
207#[derive(
208    Debug, PartialEq, Eq, Copy, Clone, EnumIsA, VariantName, Serialize, Deserialize, Drive, DriveMut,
209)]
210#[charon::rename("Binop")]
211pub enum BinOp {
212    BitXor,
213    BitAnd,
214    BitOr,
215    Eq,
216    Lt,
217    Le,
218    Ne,
219    Ge,
220    Gt,
221    /// Fails if the divisor is 0, or if the operation is `int::MIN / -1`.
222    Div,
223    /// Fails if the divisor is 0, or if the operation is `int::MIN % -1`.
224    Rem,
225    /// Fails on overflow.
226    /// Not present in MIR: this is introduced by the `remove_dynamic_checks` pass.
227    Add,
228    /// Fails on overflow.
229    /// Not present in MIR: this is introduced by the `remove_dynamic_checks` pass.
230    Sub,
231    /// Fails on overflow.
232    /// Not present in MIR: this is introduced by the `remove_dynamic_checks` pass.
233    Mul,
234    /// Wraps on overflow.
235    WrappingAdd,
236    /// Wraps on overflow.
237    WrappingSub,
238    /// Wraps on overflow.
239    WrappingMul,
240    /// Returns `(result, did_overflow)`, where `result` is the result of the operation with
241    /// wrapping semantics, and `did_overflow` is a boolean that indicates whether the operation
242    /// overflowed. This operation does not fail.
243    CheckedAdd,
244    /// Like `CheckedAdd`.
245    CheckedSub,
246    /// Like `CheckedAdd`.
247    CheckedMul,
248    /// Fails if the shift is bigger than the bit-size of the type.
249    Shl,
250    /// Fails if the shift is bigger than the bit-size of the type.
251    Shr,
252    /// `BinOp(Offset, ptr, n)` for `ptr` a pointer to type `T` offsets `ptr` by `n * size_of::<T>()`.
253    Offset,
254    /// `BinOp(Cmp, a, b)` returns `-1u8` if `a < b`, `0u8` if `a == b`, and `1u8` if `a > b`.
255    Cmp,
256}
257
258#[derive(
259    Debug,
260    PartialEq,
261    Eq,
262    Clone,
263    EnumIsA,
264    EnumToGetters,
265    EnumAsGetters,
266    VariantName,
267    Serialize,
268    Deserialize,
269    Drive,
270    DriveMut,
271)]
272pub enum Operand {
273    Copy(Place),
274    Move(Place),
275    /// Constant value (including constant and static variables)
276    #[charon::rename("Constant")]
277    Const(Box<ConstantExpr>),
278}
279
280/// A function identifier. See [crate::ullbc_ast::Terminator]
281#[derive(
282    Debug,
283    Clone,
284    PartialEq,
285    Eq,
286    Hash,
287    EnumIsA,
288    EnumAsGetters,
289    VariantName,
290    Serialize,
291    Deserialize,
292    Drive,
293    DriveMut,
294)]
295#[charon::variants_prefix("F")]
296pub enum FunId {
297    /// A "regular" function (function local to the crate, external function
298    /// not treated as a primitive one).
299    Regular(FunDeclId),
300    /// A primitive function, coming from a standard library (for instance:
301    /// `alloc::boxed::Box::new`).
302    /// TODO: rename to "Primitive"
303    #[charon::rename("FBuiltin")]
304    Builtin(BuiltinFunId),
305}
306
307/// An built-in function identifier, identifying a function coming from a
308/// standard library.
309#[derive(
310    Debug,
311    Clone,
312    Copy,
313    PartialEq,
314    Eq,
315    Hash,
316    EnumIsA,
317    EnumAsGetters,
318    VariantName,
319    Serialize,
320    Deserialize,
321    Drive,
322    DriveMut,
323)]
324pub enum BuiltinFunId {
325    /// `alloc::boxed::Box::new`
326    BoxNew,
327    /// Cast an array as a slice.
328    ///
329    /// Converted from [UnOp::ArrayToSlice]
330    ArrayToSliceShared,
331    /// Cast an array as a slice.
332    ///
333    /// Converted from [UnOp::ArrayToSlice]
334    ArrayToSliceMut,
335    /// `repeat(n, x)` returns an array where `x` has been replicated `n` times.
336    ///
337    /// We introduce this when desugaring the `ArrayRepeat` rvalue.
338    ArrayRepeat,
339    /// Converted from indexing `ProjectionElem`s. The signature depends on the parameters. It
340    /// could look like:
341    /// - `fn ArrayIndexShared<T,N>(&[T;N], usize) -> &T`
342    /// - `fn SliceIndexShared<T>(&[T], usize) -> &T`
343    /// - `fn ArraySubSliceShared<T,N>(&[T;N], usize, usize) -> &[T]`
344    /// - `fn SliceSubSliceMut<T>(&mut [T], usize, usize) -> &mut [T]`
345    /// - etc
346    Index(BuiltinIndexOp),
347    /// Build a raw pointer, from a data pointer and metadata. The metadata can be unit, if
348    /// building a thin pointer.
349    ///
350    /// Converted from [AggregateKind::RawPtr]
351    PtrFromParts(RefKind),
352}
353
354/// One of 8 built-in indexing operations.
355#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Drive, DriveMut)]
356pub struct BuiltinIndexOp {
357    /// Whether this is a slice or array.
358    #[drive(skip)]
359    pub is_array: bool,
360    /// Whether we're indexing mutably or not. Determines the type ofreference of the input and
361    /// output.
362    pub mutability: RefKind,
363    /// Whether we're indexing a single element or a subrange. If `true`, the function takes
364    /// two indices and the output is a slice; otherwise, the function take one index and the
365    /// output is a reference to a single element.
366    #[drive(skip)]
367    pub is_range: bool,
368}
369
370/// Reference to a function declaration or builtin function.
371#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Drive, DriveMut)]
372pub struct MaybeBuiltinFunDeclRef {
373    #[charon::rename("fun_decl_id")]
374    pub id: FunId,
375    #[charon::rename("fun_decl_generics")]
376    pub generics: BoxedArgs,
377}
378
379/// Reference to a trait method.
380#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Drive, DriveMut)]
381pub struct TraitMethodRef {
382    pub trait_ref: TraitRef,
383    pub name: TraitItemName,
384    pub generics: BoxedArgs,
385    /// Reference to the method declaration; can be derived from the trait_ref, provided here for
386    /// convenience. The generic args are for the method, not for this function.
387    pub method_decl_id: FunDeclId,
388}
389
390#[derive(Debug, Clone, PartialEq, Eq, EnumAsGetters, Serialize, Deserialize, Drive, DriveMut)]
391pub enum FunIdOrTraitMethodRef {
392    #[charon::rename("FunId")]
393    Fun(FunId),
394    /// If a trait: the reference to the trait and the id of the trait method.
395    /// The fun decl id is not really necessary - we put it here for convenience
396    /// purposes.
397    #[charon::rename("TraitMethod")]
398    Trait(TraitRef, TraitItemName, FunDeclId),
399}
400
401#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Drive, DriveMut)]
402pub struct FnPtr {
403    pub func: Box<FunIdOrTraitMethodRef>,
404    pub generics: BoxedArgs,
405}
406
407/// A constant expression.
408///
409/// Only the [`RawConstantExpr::Literal`] and [`RawConstantExpr::Var`]
410/// cases are left in the final LLBC.
411///
412/// The other cases come from a straight translation from the MIR:
413///
414/// [`RawConstantExpr::Adt`] case:
415/// It is a bit annoying, but rustc treats some ADT and tuple instances as
416/// constants when generating MIR:
417/// - an enumeration with one variant and no fields is a constant.
418/// - a structure with no field is a constant.
419/// - sometimes, Rust stores the initialization of an ADT as a constant
420///   (if all the fields are constant) rather than as an aggregated value
421/// We later desugar those to regular ADTs, see [regularize_constant_adts.rs].
422///
423/// [`RawConstantExpr::Global`] case: access to a global variable. We later desugar it to
424/// a separate statement.
425///
426/// [`RawConstantExpr::Ref`] case: reference to a constant value. We later desugar it to a separate
427/// statement.
428///
429/// [`RawConstantExpr::FnPtr`] case: a function pointer (to a top-level function).
430///
431/// Remark:
432/// MIR seems to forbid more complex expressions like paths. For instance,
433/// reading the constant `a.b` is translated to `{ _1 = const a; _2 = (_1.0) }`.
434#[derive(
435    Debug,
436    PartialEq,
437    Eq,
438    Clone,
439    VariantName,
440    EnumIsA,
441    EnumAsGetters,
442    Serialize,
443    Deserialize,
444    Drive,
445    DriveMut,
446)]
447#[charon::variants_prefix("C")]
448pub enum RawConstantExpr {
449    Literal(Literal),
450    ///
451    /// In most situations:
452    /// Enumeration with one variant with no fields, structure with
453    /// no fields, unit (encoded as a 0-tuple).
454    ///
455    /// Less frequently: arbitrary ADT values.
456    ///
457    /// We eliminate this case in a micro-pass.
458    #[charon::opaque]
459    Adt(Option<VariantId>, Vec<ConstantExpr>),
460    #[charon::opaque]
461    Array(Vec<ConstantExpr>),
462    /// The value is a top-level constant/static.
463    ///
464    /// We eliminate this case in a micro-pass.
465    ///
466    /// Remark: constants can actually have generic parameters.
467    /// ```text
468    /// struct V<const N: usize, T> {
469    ///   x: [T; N],
470    /// }
471    ///
472    /// impl<const N: usize, T> V<N, T> {
473    ///   const LEN: usize = N; // This has generics <N, T>
474    /// }
475    ///
476    /// fn use_v<const N: usize, T>(v: V<N, T>) {
477    ///   let l = V::<N, T>::LEN; // We need to provided a substitution here
478    /// }
479    /// ```
480    #[charon::opaque]
481    Global(GlobalDeclRef),
482    ///
483    /// A trait constant.
484    ///
485    /// Ex.:
486    /// ```text
487    /// impl Foo for Bar {
488    ///   const C : usize = 32; // <-
489    /// }
490    /// ```
491    ///
492    /// Remark: trait constants can not be used in types, they are necessarily
493    /// values.
494    TraitConst(TraitRef, TraitItemName),
495    /// A shared reference to a constant value.
496    ///
497    /// We eliminate this case in a micro-pass.
498    #[charon::opaque]
499    Ref(Box<ConstantExpr>),
500    /// A pointer to a mutable static.
501    ///
502    /// We eliminate this case in a micro-pass.
503    #[charon::opaque]
504    Ptr(RefKind, Box<ConstantExpr>),
505    /// A const generic var
506    Var(ConstGenericDbVar),
507    /// Function pointer
508    FnPtr(FnPtr),
509    /// Raw memory value obtained from constant evaluation. Used when a more structured
510    /// representation isn't possible (e.g. for unions) or just isn't implemented yet.
511    #[drive(skip)]
512    RawMemory(Vec<u8>),
513    /// A constant expression that Charon still doesn't handle, along with the reason why.
514    #[drive(skip)]
515    Opaque(String),
516}
517
518#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Drive, DriveMut)]
519pub struct ConstantExpr {
520    pub value: RawConstantExpr,
521    pub ty: Ty,
522}
523
524/// TODO: we could factor out [Rvalue] and function calls (for LLBC, not ULLBC).
525/// We can also factor out the unops, binops with the function calls.
526/// TODO: move the aggregate kind to operands
527/// TODO: we should prefix the type variants with "R" or "Rv", this would avoid collisions
528#[derive(
529    Debug, Clone, EnumToGetters, EnumAsGetters, EnumIsA, Serialize, Deserialize, Drive, DriveMut,
530)]
531pub enum Rvalue {
532    /// Lifts an operand as an rvalue.
533    Use(Operand),
534    /// Takes a reference to the given place.
535    #[charon::rename("RvRef")]
536    Ref(Place, BorrowKind),
537    /// Takes a raw pointer with the given mutability to the given place. This is generated by
538    /// pointer casts like `&v as *const _` or raw borrow expressions like `&raw const v.`
539    RawPtr(Place, RefKind),
540    /// Binary operations (note that we merge "checked" and "unchecked" binops)
541    BinaryOp(BinOp, Operand, Operand),
542    /// Unary operation (e.g. not, neg)
543    UnaryOp(UnOp, Operand),
544    /// Nullary operation (e.g. `size_of`)
545    NullaryOp(NullOp, Ty),
546    /// Discriminant (for enumerations).
547    /// Note that discriminant values have type isize. We also store the identifier
548    /// of the type from which we read the discriminant.
549    ///
550    /// This case is filtered in [crate::transform::remove_read_discriminant]
551    Discriminant(Place, TypeDeclId),
552    /// Creates an aggregate value, like a tuple, a struct or an enum:
553    /// ```text
554    /// l = List::Cons { value:x, tail:tl };
555    /// ```
556    /// Note that in some MIR passes (like optimized MIR), aggregate values are
557    /// decomposed, like below:
558    /// ```text
559    /// (l as List::Cons).value = x;
560    /// (l as List::Cons).tail = tl;
561    /// ```
562    /// Because we may want to plug our translation mechanism at various
563    /// places, we need to take both into accounts in the translation and in
564    /// our semantics. Aggregate value initialization is easy, you might want
565    /// to have a look at expansion of `Bottom` values for explanations about the
566    /// other case.
567    ///
568    /// Remark: in case of closures, the aggregated value groups the closure id
569    /// together with its state.
570    Aggregate(AggregateKind, Vec<Operand>),
571    /// Copy the value of the referenced global.
572    /// Not present in MIR; introduced in [simplify_constants.rs].
573    Global(GlobalDeclRef),
574    /// Reference the value of the global. This has type `&T` or `*mut T` depending on desired
575    /// mutability.
576    /// Not present in MIR; introduced in [simplify_constants.rs].
577    GlobalRef(GlobalDeclRef, RefKind),
578    /// Length of a memory location. The run-time length of e.g. a vector or a slice is
579    /// represented differently (but pretty-prints the same, FIXME).
580    /// Should be seen as a function of signature:
581    /// - `fn<T;N>(&[T;N]) -> usize`
582    /// - `fn<T>(&[T]) -> usize`
583    ///
584    /// We store the type argument and the const generic (the latter only for arrays).
585    ///
586    /// `Len` is automatically introduced by rustc, notably for the bound checks:
587    /// we eliminate it together with the bounds checks whenever possible.
588    /// There are however occurrences that we don't eliminate (yet).
589    /// For instance, for the following Rust code:
590    /// ```text
591    /// fn slice_pattern_4(x: &[()]) {
592    ///     match x {
593    ///         [_named] => (),
594    ///         _ => (),
595    ///     }
596    /// }
597    /// ```
598    /// rustc introduces a check that the length of the slice is exactly equal
599    /// to 1 and that we preserve.
600    Len(Place, Ty, Option<ConstGeneric>),
601    /// `Repeat(x, n)` creates an array where `x` is copied `n` times.
602    ///
603    /// We translate this to a function call for LLBC.
604    Repeat(Operand, Ty, ConstGeneric),
605    /// Transmutes a `*mut u8` (obtained from `malloc`) into shallow-initialized `Box<T>`. This
606    /// only appears as part of lowering `Box::new()` in some cases. We reconstruct the original
607    /// `Box::new()` call, but sometimes may fail to do so, leaking the expression.
608    ShallowInitBox(Operand, Ty),
609}
610
611/// An aggregated ADT.
612///
613/// Note that ADTs are desaggregated at some point in MIR. For instance, if
614/// we have in Rust:
615/// ```ignore
616///   let ls = Cons(hd, tl);
617/// ```
618///
619/// In MIR we have (yes, the discriminant update happens *at the end* for some
620/// reason):
621/// ```text
622///   (ls as Cons).0 = move hd;
623///   (ls as Cons).1 = move tl;
624///   discriminant(ls) = 0; // assuming `Cons` is the variant of index 0
625/// ```
626///
627/// Rem.: in the Aeneas semantics, both cases are handled (in case of desaggregated
628/// initialization, `ls` is initialized to `⊥`, then this `⊥` is expanded to
629/// `Cons (⊥, ⊥)` upon the first assignment, at which point we can initialize
630/// the field 0, etc.).
631#[derive(Debug, Clone, VariantIndexArity, Serialize, Deserialize, Drive, DriveMut)]
632#[charon::variants_prefix("Aggregated")]
633pub enum AggregateKind {
634    /// A struct, enum or union aggregate. The `VariantId`, if present, indicates this is an enum
635    /// and the aggregate uses that variant. The `FieldId`, if present, indicates this is a union
636    /// and the aggregate writes into that field. Otherwise this is a struct.
637    Adt(TypeDeclRef, Option<VariantId>, Option<FieldId>),
638    /// We don't put this with the ADT cas because this is the only built-in type
639    /// with aggregates, and it is a primitive type. In particular, it makes
640    /// sense to treat it differently because it has a variable number of fields.
641    Array(Ty, ConstGeneric),
642    /// Construct a raw pointer from a pointer value, and its metadata (can be unit, if building
643    /// a thin pointer). The type is the type of the pointee.
644    /// We lower this to a builtin function call for LLBC in [crate::transform::ops_to_function_calls].
645    RawPtr(Ty, RefKind),
646}