From 768ee3e47a140e354575154f431421375b0b5203 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 6 Apr 2021 21:09:52 +0200 Subject: Align `InferenceVar` to Chalk --- crates/hir_ty/src/types.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'crates/hir_ty/src/types.rs') diff --git a/crates/hir_ty/src/types.rs b/crates/hir_ty/src/types.rs index 89c0ddd1a..eac1b7900 100644 --- a/crates/hir_ty/src/types.rs +++ b/crates/hir_ty/src/types.rs @@ -11,8 +11,7 @@ use smallvec::SmallVec; use crate::{ AssocTypeId, CanonicalVarKinds, ChalkTraitId, ClosureId, Const, FnDefId, FnSig, ForeignDefId, - InferenceVar, Interner, Lifetime, OpaqueTyId, PlaceholderIndex, TypeWalk, VariableKind, - VariableKinds, + Interner, Lifetime, OpaqueTyId, PlaceholderIndex, TypeWalk, VariableKind, VariableKinds, }; #[derive(Clone, PartialEq, Eq, Debug, Hash)] @@ -524,3 +523,25 @@ pub enum Guidance { /// There's no useful information to feed back to type inference Unknown, } + +/// The kinds of placeholders we need during type inference. There's separate +/// values for general types, and for integer and float variables. The latter +/// two are used for inference of literal values (e.g. `100` could be one of +/// several integer types). +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub struct InferenceVar { + index: u32, +} + +impl From for InferenceVar { + fn from(index: u32) -> InferenceVar { + InferenceVar { index } + } +} + +impl InferenceVar { + /// Gets the underlying index value. + pub fn index(self) -> u32 { + self.index + } +} -- cgit v1.2.3