aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/types.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/types.rs')
-rw-r--r--crates/hir_ty/src/types.rs25
1 files changed, 23 insertions, 2 deletions
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;
11 11
12use crate::{ 12use crate::{
13 AssocTypeId, CanonicalVarKinds, ChalkTraitId, ClosureId, Const, FnDefId, FnSig, ForeignDefId, 13 AssocTypeId, CanonicalVarKinds, ChalkTraitId, ClosureId, Const, FnDefId, FnSig, ForeignDefId,
14 InferenceVar, Interner, Lifetime, OpaqueTyId, PlaceholderIndex, TypeWalk, VariableKind, 14 Interner, Lifetime, OpaqueTyId, PlaceholderIndex, TypeWalk, VariableKind, VariableKinds,
15 VariableKinds,
16}; 15};
17 16
18#[derive(Clone, PartialEq, Eq, Debug, Hash)] 17#[derive(Clone, PartialEq, Eq, Debug, Hash)]
@@ -524,3 +523,25 @@ pub enum Guidance {
524 /// There's no useful information to feed back to type inference 523 /// There's no useful information to feed back to type inference
525 Unknown, 524 Unknown,
526} 525}
526
527/// The kinds of placeholders we need during type inference. There's separate
528/// values for general types, and for integer and float variables. The latter
529/// two are used for inference of literal values (e.g. `100` could be one of
530/// several integer types).
531#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
532pub struct InferenceVar {
533 index: u32,
534}
535
536impl From<u32> for InferenceVar {
537 fn from(index: u32) -> InferenceVar {
538 InferenceVar { index }
539 }
540}
541
542impl InferenceVar {
543 /// Gets the underlying index value.
544 pub fn index(self) -> u32 {
545 self.index
546 }
547}