]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_type_ir/src/lib.rs
Rollup merge of #91150 - dtolnay:qpath, r=davidtwco
[rust.git] / compiler / rustc_type_ir / src / lib.rs
1 #![feature(min_specialization)]
2
3 #[macro_use]
4 extern crate bitflags;
5 #[macro_use]
6 extern crate rustc_macros;
7
8 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
9 use rustc_data_structures::unify::{EqUnifyValue, UnifyKey};
10 use std::fmt;
11 use std::mem::discriminant;
12
13 bitflags! {
14     /// Flags that we track on types. These flags are propagated upwards
15     /// through the type during type construction, so that we can quickly check
16     /// whether the type has various kinds of types in it without recursing
17     /// over the type itself.
18     pub struct TypeFlags: u32 {
19         // Does this have parameters? Used to determine whether substitution is
20         // required.
21         /// Does this have `Param`?
22         const HAS_TY_PARAM                = 1 << 0;
23         /// Does this have `ReEarlyBound`?
24         const HAS_RE_PARAM                = 1 << 1;
25         /// Does this have `ConstKind::Param`?
26         const HAS_CT_PARAM                = 1 << 2;
27
28         const NEEDS_SUBST                 = TypeFlags::HAS_TY_PARAM.bits
29                                           | TypeFlags::HAS_RE_PARAM.bits
30                                           | TypeFlags::HAS_CT_PARAM.bits;
31
32         /// Does this have `Infer`?
33         const HAS_TY_INFER                = 1 << 3;
34         /// Does this have `ReVar`?
35         const HAS_RE_INFER                = 1 << 4;
36         /// Does this have `ConstKind::Infer`?
37         const HAS_CT_INFER                = 1 << 5;
38
39         /// Does this have inference variables? Used to determine whether
40         /// inference is required.
41         const NEEDS_INFER                 = TypeFlags::HAS_TY_INFER.bits
42                                           | TypeFlags::HAS_RE_INFER.bits
43                                           | TypeFlags::HAS_CT_INFER.bits;
44
45         /// Does this have `Placeholder`?
46         const HAS_TY_PLACEHOLDER          = 1 << 6;
47         /// Does this have `RePlaceholder`?
48         const HAS_RE_PLACEHOLDER          = 1 << 7;
49         /// Does this have `ConstKind::Placeholder`?
50         const HAS_CT_PLACEHOLDER          = 1 << 8;
51
52         /// `true` if there are "names" of regions and so forth
53         /// that are local to a particular fn/inferctxt
54         const HAS_FREE_LOCAL_REGIONS      = 1 << 9;
55
56         /// `true` if there are "names" of types and regions and so forth
57         /// that are local to a particular fn
58         const HAS_FREE_LOCAL_NAMES        = TypeFlags::HAS_TY_PARAM.bits
59                                           | TypeFlags::HAS_CT_PARAM.bits
60                                           | TypeFlags::HAS_TY_INFER.bits
61                                           | TypeFlags::HAS_CT_INFER.bits
62                                           | TypeFlags::HAS_TY_PLACEHOLDER.bits
63                                           | TypeFlags::HAS_CT_PLACEHOLDER.bits
64                                           // We consider 'freshened' types and constants
65                                           // to depend on a particular fn.
66                                           // The freshening process throws away information,
67                                           // which can make things unsuitable for use in a global
68                                           // cache. Note that there is no 'fresh lifetime' flag -
69                                           // freshening replaces all lifetimes with `ReErased`,
70                                           // which is different from how types/const are freshened.
71                                           | TypeFlags::HAS_TY_FRESH.bits
72                                           | TypeFlags::HAS_CT_FRESH.bits
73                                           | TypeFlags::HAS_FREE_LOCAL_REGIONS.bits;
74
75         /// Does this have `Projection`?
76         const HAS_TY_PROJECTION           = 1 << 10;
77         /// Does this have `Opaque`?
78         const HAS_TY_OPAQUE               = 1 << 11;
79         /// Does this have `ConstKind::Unevaluated`?
80         const HAS_CT_PROJECTION           = 1 << 12;
81
82         /// Could this type be normalized further?
83         const HAS_PROJECTION              = TypeFlags::HAS_TY_PROJECTION.bits
84                                           | TypeFlags::HAS_TY_OPAQUE.bits
85                                           | TypeFlags::HAS_CT_PROJECTION.bits;
86
87         /// Is an error type/const reachable?
88         const HAS_ERROR                   = 1 << 13;
89
90         /// Does this have any region that "appears free" in the type?
91         /// Basically anything but `ReLateBound` and `ReErased`.
92         const HAS_FREE_REGIONS            = 1 << 14;
93
94         /// Does this have any `ReLateBound` regions? Used to check
95         /// if a global bound is safe to evaluate.
96         const HAS_RE_LATE_BOUND           = 1 << 15;
97
98         /// Does this have any `ReErased` regions?
99         const HAS_RE_ERASED               = 1 << 16;
100
101         /// Does this value have parameters/placeholders/inference variables which could be
102         /// replaced later, in a way that would change the results of `impl` specialization?
103         const STILL_FURTHER_SPECIALIZABLE = 1 << 17;
104
105         /// Does this value have `InferTy::FreshTy/FreshIntTy/FreshFloatTy`?
106         const HAS_TY_FRESH                = 1 << 18;
107
108         /// Does this value have `InferConst::Fresh`?
109         const HAS_CT_FRESH                = 1 << 19;
110     }
111 }
112
113 rustc_index::newtype_index! {
114     /// A [De Bruijn index][dbi] is a standard means of representing
115     /// regions (and perhaps later types) in a higher-ranked setting. In
116     /// particular, imagine a type like this:
117     ///
118     ///     for<'a> fn(for<'b> fn(&'b isize, &'a isize), &'a char)
119     ///     ^          ^            |          |           |
120     ///     |          |            |          |           |
121     ///     |          +------------+ 0        |           |
122     ///     |                                  |           |
123     ///     +----------------------------------+ 1         |
124     ///     |                                              |
125     ///     +----------------------------------------------+ 0
126     ///
127     /// In this type, there are two binders (the outer fn and the inner
128     /// fn). We need to be able to determine, for any given region, which
129     /// fn type it is bound by, the inner or the outer one. There are
130     /// various ways you can do this, but a De Bruijn index is one of the
131     /// more convenient and has some nice properties. The basic idea is to
132     /// count the number of binders, inside out. Some examples should help
133     /// clarify what I mean.
134     ///
135     /// Let's start with the reference type `&'b isize` that is the first
136     /// argument to the inner function. This region `'b` is assigned a De
137     /// Bruijn index of 0, meaning "the innermost binder" (in this case, a
138     /// fn). The region `'a` that appears in the second argument type (`&'a
139     /// isize`) would then be assigned a De Bruijn index of 1, meaning "the
140     /// second-innermost binder". (These indices are written on the arrows
141     /// in the diagram).
142     ///
143     /// What is interesting is that De Bruijn index attached to a particular
144     /// variable will vary depending on where it appears. For example,
145     /// the final type `&'a char` also refers to the region `'a` declared on
146     /// the outermost fn. But this time, this reference is not nested within
147     /// any other binders (i.e., it is not an argument to the inner fn, but
148     /// rather the outer one). Therefore, in this case, it is assigned a
149     /// De Bruijn index of 0, because the innermost binder in that location
150     /// is the outer fn.
151     ///
152     /// [dbi]: https://en.wikipedia.org/wiki/De_Bruijn_index
153     pub struct DebruijnIndex {
154         DEBUG_FORMAT = "DebruijnIndex({})",
155         const INNERMOST = 0,
156     }
157 }
158
159 impl DebruijnIndex {
160     /// Returns the resulting index when this value is moved into
161     /// `amount` number of new binders. So, e.g., if you had
162     ///
163     ///    for<'a> fn(&'a x)
164     ///
165     /// and you wanted to change it to
166     ///
167     ///    for<'a> fn(for<'b> fn(&'a x))
168     ///
169     /// you would need to shift the index for `'a` into a new binder.
170     #[must_use]
171     pub fn shifted_in(self, amount: u32) -> DebruijnIndex {
172         DebruijnIndex::from_u32(self.as_u32() + amount)
173     }
174
175     /// Update this index in place by shifting it "in" through
176     /// `amount` number of binders.
177     pub fn shift_in(&mut self, amount: u32) {
178         *self = self.shifted_in(amount);
179     }
180
181     /// Returns the resulting index when this value is moved out from
182     /// `amount` number of new binders.
183     #[must_use]
184     pub fn shifted_out(self, amount: u32) -> DebruijnIndex {
185         DebruijnIndex::from_u32(self.as_u32() - amount)
186     }
187
188     /// Update in place by shifting out from `amount` binders.
189     pub fn shift_out(&mut self, amount: u32) {
190         *self = self.shifted_out(amount);
191     }
192
193     /// Adjusts any De Bruijn indices so as to make `to_binder` the
194     /// innermost binder. That is, if we have something bound at `to_binder`,
195     /// it will now be bound at INNERMOST. This is an appropriate thing to do
196     /// when moving a region out from inside binders:
197     ///
198     /// ```
199     ///             for<'a>   fn(for<'b>   for<'c>   fn(&'a u32), _)
200     /// // Binder:  D3           D2        D1            ^^
201     /// ```
202     ///
203     /// Here, the region `'a` would have the De Bruijn index D3,
204     /// because it is the bound 3 binders out. However, if we wanted
205     /// to refer to that region `'a` in the second argument (the `_`),
206     /// those two binders would not be in scope. In that case, we
207     /// might invoke `shift_out_to_binder(D3)`. This would adjust the
208     /// De Bruijn index of `'a` to D1 (the innermost binder).
209     ///
210     /// If we invoke `shift_out_to_binder` and the region is in fact
211     /// bound by one of the binders we are shifting out of, that is an
212     /// error (and should fail an assertion failure).
213     pub fn shifted_out_to_binder(self, to_binder: DebruijnIndex) -> Self {
214         self.shifted_out(to_binder.as_u32() - INNERMOST.as_u32())
215     }
216 }
217
218 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
219 #[derive(Encodable, Decodable)]
220 pub enum IntTy {
221     Isize,
222     I8,
223     I16,
224     I32,
225     I64,
226     I128,
227 }
228
229 impl IntTy {
230     pub fn name_str(&self) -> &'static str {
231         match *self {
232             IntTy::Isize => "isize",
233             IntTy::I8 => "i8",
234             IntTy::I16 => "i16",
235             IntTy::I32 => "i32",
236             IntTy::I64 => "i64",
237             IntTy::I128 => "i128",
238         }
239     }
240
241     pub fn bit_width(&self) -> Option<u64> {
242         Some(match *self {
243             IntTy::Isize => return None,
244             IntTy::I8 => 8,
245             IntTy::I16 => 16,
246             IntTy::I32 => 32,
247             IntTy::I64 => 64,
248             IntTy::I128 => 128,
249         })
250     }
251
252     pub fn normalize(&self, target_width: u32) -> Self {
253         match self {
254             IntTy::Isize => match target_width {
255                 16 => IntTy::I16,
256                 32 => IntTy::I32,
257                 64 => IntTy::I64,
258                 _ => unreachable!(),
259             },
260             _ => *self,
261         }
262     }
263 }
264
265 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Debug)]
266 #[derive(Encodable, Decodable)]
267 pub enum UintTy {
268     Usize,
269     U8,
270     U16,
271     U32,
272     U64,
273     U128,
274 }
275
276 impl UintTy {
277     pub fn name_str(&self) -> &'static str {
278         match *self {
279             UintTy::Usize => "usize",
280             UintTy::U8 => "u8",
281             UintTy::U16 => "u16",
282             UintTy::U32 => "u32",
283             UintTy::U64 => "u64",
284             UintTy::U128 => "u128",
285         }
286     }
287
288     pub fn bit_width(&self) -> Option<u64> {
289         Some(match *self {
290             UintTy::Usize => return None,
291             UintTy::U8 => 8,
292             UintTy::U16 => 16,
293             UintTy::U32 => 32,
294             UintTy::U64 => 64,
295             UintTy::U128 => 128,
296         })
297     }
298
299     pub fn normalize(&self, target_width: u32) -> Self {
300         match self {
301             UintTy::Usize => match target_width {
302                 16 => UintTy::U16,
303                 32 => UintTy::U32,
304                 64 => UintTy::U64,
305                 _ => unreachable!(),
306             },
307             _ => *self,
308         }
309     }
310 }
311
312 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
313 #[derive(Encodable, Decodable)]
314 pub enum FloatTy {
315     F32,
316     F64,
317 }
318
319 impl FloatTy {
320     pub fn name_str(self) -> &'static str {
321         match self {
322             FloatTy::F32 => "f32",
323             FloatTy::F64 => "f64",
324         }
325     }
326
327     pub fn bit_width(self) -> u64 {
328         match self {
329             FloatTy::F32 => 32,
330             FloatTy::F64 => 64,
331         }
332     }
333 }
334
335 #[derive(Clone, Copy, PartialEq, Eq)]
336 pub enum IntVarValue {
337     IntType(IntTy),
338     UintType(UintTy),
339 }
340
341 #[derive(Clone, Copy, PartialEq, Eq)]
342 pub struct FloatVarValue(pub FloatTy);
343
344 rustc_index::newtype_index! {
345     /// A **ty**pe **v**ariable **ID**.
346     pub struct TyVid {
347         DEBUG_FORMAT = "_#{}t"
348     }
349 }
350
351 /// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
352 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
353 pub struct IntVid {
354     pub index: u32,
355 }
356
357 /// An **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
358 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
359 pub struct FloatVid {
360     pub index: u32,
361 }
362
363 /// A placeholder for a type that hasn't been inferred yet.
364 ///
365 /// E.g., if we have an empty array (`[]`), then we create a fresh
366 /// type variable for the element type since we won't know until it's
367 /// used what the element type is supposed to be.
368 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
369 pub enum InferTy {
370     /// A type variable.
371     TyVar(TyVid),
372     /// An integral type variable (`{integer}`).
373     ///
374     /// These are created when the compiler sees an integer literal like
375     /// `1` that could be several different types (`u8`, `i32`, `u32`, etc.).
376     /// We don't know until it's used what type it's supposed to be, so
377     /// we create a fresh type variable.
378     IntVar(IntVid),
379     /// A floating-point type variable (`{float}`).
380     ///
381     /// These are created when the compiler sees an float literal like
382     /// `1.0` that could be either an `f32` or an `f64`.
383     /// We don't know until it's used what type it's supposed to be, so
384     /// we create a fresh type variable.
385     FloatVar(FloatVid),
386
387     /// A [`FreshTy`][Self::FreshTy] is one that is generated as a replacement
388     /// for an unbound type variable. This is convenient for caching etc. See
389     /// `rustc_infer::infer::freshen` for more details.
390     ///
391     /// Compare with [`TyVar`][Self::TyVar].
392     FreshTy(u32),
393     /// Like [`FreshTy`][Self::FreshTy], but as a replacement for [`IntVar`][Self::IntVar].
394     FreshIntTy(u32),
395     /// Like [`FreshTy`][Self::FreshTy], but as a replacement for [`FloatVar`][Self::FloatVar].
396     FreshFloatTy(u32),
397 }
398
399 /// Raw `TyVid` are used as the unification key for `sub_relations`;
400 /// they carry no values.
401 impl UnifyKey for TyVid {
402     type Value = ();
403     fn index(&self) -> u32 {
404         self.as_u32()
405     }
406     fn from_index(i: u32) -> TyVid {
407         TyVid::from_u32(i)
408     }
409     fn tag() -> &'static str {
410         "TyVid"
411     }
412 }
413
414 impl EqUnifyValue for IntVarValue {}
415
416 impl UnifyKey for IntVid {
417     type Value = Option<IntVarValue>;
418     #[inline] // make this function eligible for inlining - it is quite hot.
419     fn index(&self) -> u32 {
420         self.index
421     }
422     fn from_index(i: u32) -> IntVid {
423         IntVid { index: i }
424     }
425     fn tag() -> &'static str {
426         "IntVid"
427     }
428 }
429
430 impl EqUnifyValue for FloatVarValue {}
431
432 impl UnifyKey for FloatVid {
433     type Value = Option<FloatVarValue>;
434     fn index(&self) -> u32 {
435         self.index
436     }
437     fn from_index(i: u32) -> FloatVid {
438         FloatVid { index: i }
439     }
440     fn tag() -> &'static str {
441         "FloatVid"
442     }
443 }
444
445 #[derive(Copy, Clone, PartialEq, Decodable, Encodable, Hash)]
446 pub enum Variance {
447     Covariant,     // T<A> <: T<B> iff A <: B -- e.g., function return type
448     Invariant,     // T<A> <: T<B> iff B == A -- e.g., type of mutable cell
449     Contravariant, // T<A> <: T<B> iff B <: A -- e.g., function param type
450     Bivariant,     // T<A> <: T<B>            -- e.g., unused type parameter
451 }
452
453 impl Variance {
454     /// `a.xform(b)` combines the variance of a context with the
455     /// variance of a type with the following meaning. If we are in a
456     /// context with variance `a`, and we encounter a type argument in
457     /// a position with variance `b`, then `a.xform(b)` is the new
458     /// variance with which the argument appears.
459     ///
460     /// Example 1:
461     ///
462     ///     *mut Vec<i32>
463     ///
464     /// Here, the "ambient" variance starts as covariant. `*mut T` is
465     /// invariant with respect to `T`, so the variance in which the
466     /// `Vec<i32>` appears is `Covariant.xform(Invariant)`, which
467     /// yields `Invariant`. Now, the type `Vec<T>` is covariant with
468     /// respect to its type argument `T`, and hence the variance of
469     /// the `i32` here is `Invariant.xform(Covariant)`, which results
470     /// (again) in `Invariant`.
471     ///
472     /// Example 2:
473     ///
474     ///     fn(*const Vec<i32>, *mut Vec<i32)
475     ///
476     /// The ambient variance is covariant. A `fn` type is
477     /// contravariant with respect to its parameters, so the variance
478     /// within which both pointer types appear is
479     /// `Covariant.xform(Contravariant)`, or `Contravariant`. `*const
480     /// T` is covariant with respect to `T`, so the variance within
481     /// which the first `Vec<i32>` appears is
482     /// `Contravariant.xform(Covariant)` or `Contravariant`. The same
483     /// is true for its `i32` argument. In the `*mut T` case, the
484     /// variance of `Vec<i32>` is `Contravariant.xform(Invariant)`,
485     /// and hence the outermost type is `Invariant` with respect to
486     /// `Vec<i32>` (and its `i32` argument).
487     ///
488     /// Source: Figure 1 of "Taming the Wildcards:
489     /// Combining Definition- and Use-Site Variance" published in PLDI'11.
490     pub fn xform(self, v: Variance) -> Variance {
491         match (self, v) {
492             // Figure 1, column 1.
493             (Variance::Covariant, Variance::Covariant) => Variance::Covariant,
494             (Variance::Covariant, Variance::Contravariant) => Variance::Contravariant,
495             (Variance::Covariant, Variance::Invariant) => Variance::Invariant,
496             (Variance::Covariant, Variance::Bivariant) => Variance::Bivariant,
497
498             // Figure 1, column 2.
499             (Variance::Contravariant, Variance::Covariant) => Variance::Contravariant,
500             (Variance::Contravariant, Variance::Contravariant) => Variance::Covariant,
501             (Variance::Contravariant, Variance::Invariant) => Variance::Invariant,
502             (Variance::Contravariant, Variance::Bivariant) => Variance::Bivariant,
503
504             // Figure 1, column 3.
505             (Variance::Invariant, _) => Variance::Invariant,
506
507             // Figure 1, column 4.
508             (Variance::Bivariant, _) => Variance::Bivariant,
509         }
510     }
511 }
512
513 impl<CTX> HashStable<CTX> for DebruijnIndex {
514     fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
515         self.as_u32().hash_stable(ctx, hasher);
516     }
517 }
518
519 impl<CTX> HashStable<CTX> for IntTy {
520     fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
521         discriminant(self).hash_stable(ctx, hasher);
522     }
523 }
524
525 impl<CTX> HashStable<CTX> for UintTy {
526     fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
527         discriminant(self).hash_stable(ctx, hasher);
528     }
529 }
530
531 impl<CTX> HashStable<CTX> for FloatTy {
532     fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
533         discriminant(self).hash_stable(ctx, hasher);
534     }
535 }
536
537 impl<CTX> HashStable<CTX> for InferTy {
538     fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
539         use InferTy::*;
540         discriminant(self).hash_stable(ctx, hasher);
541         match self {
542             TyVar(v) => v.as_u32().hash_stable(ctx, hasher),
543             IntVar(v) => v.index.hash_stable(ctx, hasher),
544             FloatVar(v) => v.index.hash_stable(ctx, hasher),
545             FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(ctx, hasher),
546         }
547     }
548 }
549
550 impl<CTX> HashStable<CTX> for Variance {
551     fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
552         discriminant(self).hash_stable(ctx, hasher);
553     }
554 }
555
556 impl fmt::Debug for IntVarValue {
557     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
558         match *self {
559             IntVarValue::IntType(ref v) => v.fmt(f),
560             IntVarValue::UintType(ref v) => v.fmt(f),
561         }
562     }
563 }
564
565 impl fmt::Debug for FloatVarValue {
566     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
567         self.0.fmt(f)
568     }
569 }
570
571 impl fmt::Debug for IntVid {
572     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
573         write!(f, "_#{}i", self.index)
574     }
575 }
576
577 impl fmt::Debug for FloatVid {
578     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
579         write!(f, "_#{}f", self.index)
580     }
581 }
582
583 impl fmt::Debug for InferTy {
584     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
585         use InferTy::*;
586         match *self {
587             TyVar(ref v) => v.fmt(f),
588             IntVar(ref v) => v.fmt(f),
589             FloatVar(ref v) => v.fmt(f),
590             FreshTy(v) => write!(f, "FreshTy({:?})", v),
591             FreshIntTy(v) => write!(f, "FreshIntTy({:?})", v),
592             FreshFloatTy(v) => write!(f, "FreshFloatTy({:?})", v),
593         }
594     }
595 }
596
597 impl fmt::Debug for Variance {
598     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
599         f.write_str(match *self {
600             Variance::Covariant => "+",
601             Variance::Contravariant => "-",
602             Variance::Invariant => "o",
603             Variance::Bivariant => "*",
604         })
605     }
606 }
607
608 impl fmt::Display for InferTy {
609     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
610         use InferTy::*;
611         match *self {
612             TyVar(_) => write!(f, "_"),
613             IntVar(_) => write!(f, "{}", "{integer}"),
614             FloatVar(_) => write!(f, "{}", "{float}"),
615             FreshTy(v) => write!(f, "FreshTy({})", v),
616             FreshIntTy(v) => write!(f, "FreshIntTy({})", v),
617             FreshFloatTy(v) => write!(f, "FreshFloatTy({})", v),
618         }
619     }
620 }