diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-03 12:09:43 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-03 12:09:43 +0100 |
commit | 2f87ee7f3f9c1efd726774511c9ce02caef73872 (patch) | |
tree | aba0fc8a8b9dcd3456f47ae5cd28fa672a7a6911 /crates/hir_ty/src/infer | |
parent | 8289b96216b5d4ddd0b6cf9feccb7af574d022a8 (diff) | |
parent | c551604b5a0b74a43f5efe567bcbd979daa2f3cc (diff) |
Merge #8310
8310: Rename Ty::interned to Ty::kind r=flodiebold a=flodiebold
... since that's the actual method on Chalk side that matches the signature.
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/coerce.rs | 8 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 12 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/path.rs | 4 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 12 |
5 files changed, 19 insertions, 19 deletions
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 8f7322b36..d887e21a2 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs | |||
@@ -36,7 +36,7 @@ impl<'a> InferenceContext<'a> { | |||
36 | ty1.clone() | 36 | ty1.clone() |
37 | } else { | 37 | } else { |
38 | if let (TyKind::FnDef(..), TyKind::FnDef(..)) = | 38 | if let (TyKind::FnDef(..), TyKind::FnDef(..)) = |
39 | (ty1.interned(&Interner), ty2.interned(&Interner)) | 39 | (ty1.kind(&Interner), ty2.kind(&Interner)) |
40 | { | 40 | { |
41 | cov_mark::hit!(coerce_fn_reification); | 41 | cov_mark::hit!(coerce_fn_reification); |
42 | // Special case: two function types. Try to coerce both to | 42 | // Special case: two function types. Try to coerce both to |
@@ -55,7 +55,7 @@ impl<'a> InferenceContext<'a> { | |||
55 | } | 55 | } |
56 | 56 | ||
57 | fn coerce_inner(&mut self, mut from_ty: Ty, to_ty: &Ty) -> bool { | 57 | fn coerce_inner(&mut self, mut from_ty: Ty, to_ty: &Ty) -> bool { |
58 | match (from_ty.interned(&Interner), to_ty.interned(&Interner)) { | 58 | match (from_ty.kind(&Interner), to_ty.kind(&Interner)) { |
59 | // Never type will make type variable to fallback to Never Type instead of Unknown. | 59 | // Never type will make type variable to fallback to Never Type instead of Unknown. |
60 | (TyKind::Never, TyKind::InferenceVar(tv, TyVariableKind::General)) => { | 60 | (TyKind::Never, TyKind::InferenceVar(tv, TyVariableKind::General)) => { |
61 | self.table.type_variable_table.set_diverging(*tv, true); | 61 | self.table.type_variable_table.set_diverging(*tv, true); |
@@ -73,7 +73,7 @@ impl<'a> InferenceContext<'a> { | |||
73 | } | 73 | } |
74 | 74 | ||
75 | // Pointer weakening and function to pointer | 75 | // Pointer weakening and function to pointer |
76 | match (from_ty.interned_mut(), to_ty.interned(&Interner)) { | 76 | match (from_ty.interned_mut(), to_ty.kind(&Interner)) { |
77 | // `*mut T` -> `*const T` | 77 | // `*mut T` -> `*const T` |
78 | // `&mut T` -> `&T` | 78 | // `&mut T` -> `&T` |
79 | (TyKind::Raw(m1, ..), TyKind::Raw(m2 @ Mutability::Not, ..)) | 79 | (TyKind::Raw(m1, ..), TyKind::Raw(m2 @ Mutability::Not, ..)) |
@@ -111,7 +111,7 @@ impl<'a> InferenceContext<'a> { | |||
111 | } | 111 | } |
112 | 112 | ||
113 | // Auto Deref if cannot coerce | 113 | // Auto Deref if cannot coerce |
114 | match (from_ty.interned(&Interner), to_ty.interned(&Interner)) { | 114 | match (from_ty.kind(&Interner), to_ty.kind(&Interner)) { |
115 | // FIXME: DerefMut | 115 | // FIXME: DerefMut |
116 | (TyKind::Ref(_, st1), TyKind::Ref(_, st2)) => self.unify_autoderef_behind_ref(st1, st2), | 116 | (TyKind::Ref(_, st1), TyKind::Ref(_, st2)) => self.unify_autoderef_behind_ref(st1, st2), |
117 | 117 | ||
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index b99b6cd21..dd3914ec3 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -455,7 +455,7 @@ impl<'a> InferenceContext<'a> { | |||
455 | }) | 455 | }) |
456 | .unwrap_or(true) | 456 | .unwrap_or(true) |
457 | }; | 457 | }; |
458 | match canonicalized.decanonicalize_ty(derefed_ty.value).interned(&Interner) { | 458 | match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) { |
459 | TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| { | 459 | TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| { |
460 | substs | 460 | substs |
461 | .interned(&Interner) | 461 | .interned(&Interner) |
@@ -577,7 +577,7 @@ impl<'a> InferenceContext<'a> { | |||
577 | None => self.err_ty(), | 577 | None => self.err_ty(), |
578 | }, | 578 | }, |
579 | UnaryOp::Neg => { | 579 | UnaryOp::Neg => { |
580 | match inner_ty.interned(&Interner) { | 580 | match inner_ty.kind(&Interner) { |
581 | // Fast path for builtins | 581 | // Fast path for builtins |
582 | TyKind::Scalar(Scalar::Int(_)) | 582 | TyKind::Scalar(Scalar::Int(_)) |
583 | | TyKind::Scalar(Scalar::Uint(_)) | 583 | | TyKind::Scalar(Scalar::Uint(_)) |
@@ -590,7 +590,7 @@ impl<'a> InferenceContext<'a> { | |||
590 | } | 590 | } |
591 | } | 591 | } |
592 | UnaryOp::Not => { | 592 | UnaryOp::Not => { |
593 | match inner_ty.interned(&Interner) { | 593 | match inner_ty.kind(&Interner) { |
594 | // Fast path for builtins | 594 | // Fast path for builtins |
595 | TyKind::Scalar(Scalar::Bool) | 595 | TyKind::Scalar(Scalar::Bool) |
596 | | TyKind::Scalar(Scalar::Int(_)) | 596 | | TyKind::Scalar(Scalar::Int(_)) |
@@ -696,7 +696,7 @@ impl<'a> InferenceContext<'a> { | |||
696 | } | 696 | } |
697 | } | 697 | } |
698 | Expr::Tuple { exprs } => { | 698 | Expr::Tuple { exprs } => { |
699 | let mut tys = match expected.ty.interned(&Interner) { | 699 | let mut tys = match expected.ty.kind(&Interner) { |
700 | TyKind::Tuple(_, substs) => substs | 700 | TyKind::Tuple(_, substs) => substs |
701 | .iter(&Interner) | 701 | .iter(&Interner) |
702 | .map(|a| a.assert_ty_ref(&Interner).clone()) | 702 | .map(|a| a.assert_ty_ref(&Interner).clone()) |
@@ -713,7 +713,7 @@ impl<'a> InferenceContext<'a> { | |||
713 | TyKind::Tuple(tys.len(), Substitution::from_iter(&Interner, tys)).intern(&Interner) | 713 | TyKind::Tuple(tys.len(), Substitution::from_iter(&Interner, tys)).intern(&Interner) |
714 | } | 714 | } |
715 | Expr::Array(array) => { | 715 | Expr::Array(array) => { |
716 | let elem_ty = match expected.ty.interned(&Interner) { | 716 | let elem_ty = match expected.ty.kind(&Interner) { |
717 | TyKind::Array(st) | TyKind::Slice(st) => st.clone(), | 717 | TyKind::Array(st) | TyKind::Slice(st) => st.clone(), |
718 | _ => self.table.new_type_var(), | 718 | _ => self.table.new_type_var(), |
719 | }; | 719 | }; |
@@ -961,7 +961,7 @@ impl<'a> InferenceContext<'a> { | |||
961 | } | 961 | } |
962 | 962 | ||
963 | fn register_obligations_for_call(&mut self, callable_ty: &Ty) { | 963 | fn register_obligations_for_call(&mut self, callable_ty: &Ty) { |
964 | if let TyKind::FnDef(fn_def, parameters) = callable_ty.interned(&Interner) { | 964 | if let TyKind::FnDef(fn_def, parameters) = callable_ty.kind(&Interner) { |
965 | let def: CallableDefId = from_chalk(self.db, *fn_def); | 965 | let def: CallableDefId = from_chalk(self.db, *fn_def); |
966 | let generic_predicates = self.db.generic_predicates(def.into()); | 966 | let generic_predicates = self.db.generic_predicates(def.into()); |
967 | for predicate in generic_predicates.iter() { | 967 | for predicate in generic_predicates.iter() { |
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index f1316415f..10df8d8cb 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -211,7 +211,7 @@ impl<'a> InferenceContext<'a> { | |||
211 | return inner_ty; | 211 | return inner_ty; |
212 | } | 212 | } |
213 | Pat::Slice { prefix, slice, suffix } => { | 213 | Pat::Slice { prefix, slice, suffix } => { |
214 | let (container_ty, elem_ty): (fn(_) -> _, _) = match expected.interned(&Interner) { | 214 | let (container_ty, elem_ty): (fn(_) -> _, _) = match expected.kind(&Interner) { |
215 | TyKind::Array(st) => (TyKind::Array, st.clone()), | 215 | TyKind::Array(st) => (TyKind::Array, st.clone()), |
216 | TyKind::Slice(st) => (TyKind::Slice, st.clone()), | 216 | TyKind::Slice(st) => (TyKind::Slice, st.clone()), |
217 | _ => (TyKind::Slice, self.err_ty()), | 217 | _ => (TyKind::Slice, self.err_ty()), |
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index b96391776..1ba15f737 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs | |||
@@ -147,7 +147,7 @@ impl<'a> InferenceContext<'a> { | |||
147 | remaining_segments_for_ty, | 147 | remaining_segments_for_ty, |
148 | true, | 148 | true, |
149 | ); | 149 | ); |
150 | if let TyKind::Unknown = ty.interned(&Interner) { | 150 | if let TyKind::Unknown = ty.kind(&Interner) { |
151 | return None; | 151 | return None; |
152 | } | 152 | } |
153 | 153 | ||
@@ -212,7 +212,7 @@ impl<'a> InferenceContext<'a> { | |||
212 | name: &Name, | 212 | name: &Name, |
213 | id: ExprOrPatId, | 213 | id: ExprOrPatId, |
214 | ) -> Option<(ValueNs, Option<Substitution>)> { | 214 | ) -> Option<(ValueNs, Option<Substitution>)> { |
215 | if let TyKind::Unknown = ty.interned(&Interner) { | 215 | if let TyKind::Unknown = ty.kind(&Interner) { |
216 | return None; | 216 | return None; |
217 | } | 217 | } |
218 | 218 | ||
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 0efc62e53..d2496db3b 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -49,7 +49,7 @@ impl<'a, 'b> Canonicalizer<'a, 'b> { | |||
49 | 49 | ||
50 | fn do_canonicalize<T: TypeWalk>(&mut self, t: T, binders: DebruijnIndex) -> T { | 50 | fn do_canonicalize<T: TypeWalk>(&mut self, t: T, binders: DebruijnIndex) -> T { |
51 | t.fold_binders( | 51 | t.fold_binders( |
52 | &mut |ty, binders| match ty.interned(&Interner) { | 52 | &mut |ty, binders| match ty.kind(&Interner) { |
53 | &TyKind::InferenceVar(var, kind) => { | 53 | &TyKind::InferenceVar(var, kind) => { |
54 | let inner = var.to_inner(); | 54 | let inner = var.to_inner(); |
55 | if self.var_stack.contains(&inner) { | 55 | if self.var_stack.contains(&inner) { |
@@ -304,7 +304,7 @@ impl InferenceTable { | |||
304 | let ty1 = self.resolve_ty_shallow(ty1); | 304 | let ty1 = self.resolve_ty_shallow(ty1); |
305 | let ty2 = self.resolve_ty_shallow(ty2); | 305 | let ty2 = self.resolve_ty_shallow(ty2); |
306 | if ty1.equals_ctor(&ty2) { | 306 | if ty1.equals_ctor(&ty2) { |
307 | match (ty1.interned(&Interner), ty2.interned(&Interner)) { | 307 | match (ty1.kind(&Interner), ty2.kind(&Interner)) { |
308 | (TyKind::Adt(_, substs1), TyKind::Adt(_, substs2)) | 308 | (TyKind::Adt(_, substs1), TyKind::Adt(_, substs2)) |
309 | | (TyKind::FnDef(_, substs1), TyKind::FnDef(_, substs2)) | 309 | | (TyKind::FnDef(_, substs1), TyKind::FnDef(_, substs2)) |
310 | | ( | 310 | | ( |
@@ -329,7 +329,7 @@ impl InferenceTable { | |||
329 | } | 329 | } |
330 | 330 | ||
331 | pub(super) fn unify_inner_trivial(&mut self, ty1: &Ty, ty2: &Ty, depth: usize) -> bool { | 331 | pub(super) fn unify_inner_trivial(&mut self, ty1: &Ty, ty2: &Ty, depth: usize) -> bool { |
332 | match (ty1.interned(&Interner), ty2.interned(&Interner)) { | 332 | match (ty1.kind(&Interner), ty2.kind(&Interner)) { |
333 | (TyKind::Unknown, _) | (_, TyKind::Unknown) => true, | 333 | (TyKind::Unknown, _) | (_, TyKind::Unknown) => true, |
334 | 334 | ||
335 | (TyKind::Placeholder(p1), TyKind::Placeholder(p2)) if *p1 == *p2 => true, | 335 | (TyKind::Placeholder(p1), TyKind::Placeholder(p2)) if *p1 == *p2 => true, |
@@ -458,7 +458,7 @@ impl InferenceTable { | |||
458 | if i > 0 { | 458 | if i > 0 { |
459 | cov_mark::hit!(type_var_resolves_to_int_var); | 459 | cov_mark::hit!(type_var_resolves_to_int_var); |
460 | } | 460 | } |
461 | match ty.interned(&Interner) { | 461 | match ty.kind(&Interner) { |
462 | TyKind::InferenceVar(tv, _) => { | 462 | TyKind::InferenceVar(tv, _) => { |
463 | let inner = tv.to_inner(); | 463 | let inner = tv.to_inner(); |
464 | match self.var_unification_table.inlined_probe_value(inner).known() { | 464 | match self.var_unification_table.inlined_probe_value(inner).known() { |
@@ -481,7 +481,7 @@ impl InferenceTable { | |||
481 | /// be resolved as far as possible, i.e. contain no type variables with | 481 | /// be resolved as far as possible, i.e. contain no type variables with |
482 | /// known type. | 482 | /// known type. |
483 | fn resolve_ty_as_possible_inner(&mut self, tv_stack: &mut Vec<TypeVarId>, ty: Ty) -> Ty { | 483 | fn resolve_ty_as_possible_inner(&mut self, tv_stack: &mut Vec<TypeVarId>, ty: Ty) -> Ty { |
484 | ty.fold(&mut |ty| match ty.interned(&Interner) { | 484 | ty.fold(&mut |ty| match ty.kind(&Interner) { |
485 | &TyKind::InferenceVar(tv, kind) => { | 485 | &TyKind::InferenceVar(tv, kind) => { |
486 | let inner = tv.to_inner(); | 486 | let inner = tv.to_inner(); |
487 | if tv_stack.contains(&inner) { | 487 | if tv_stack.contains(&inner) { |
@@ -508,7 +508,7 @@ impl InferenceTable { | |||
508 | /// Resolves the type completely; type variables without known type are | 508 | /// Resolves the type completely; type variables without known type are |
509 | /// replaced by TyKind::Unknown. | 509 | /// replaced by TyKind::Unknown. |
510 | fn resolve_ty_completely_inner(&mut self, tv_stack: &mut Vec<TypeVarId>, ty: Ty) -> Ty { | 510 | fn resolve_ty_completely_inner(&mut self, tv_stack: &mut Vec<TypeVarId>, ty: Ty) -> Ty { |
511 | ty.fold(&mut |ty| match ty.interned(&Interner) { | 511 | ty.fold(&mut |ty| match ty.kind(&Interner) { |
512 | &TyKind::InferenceVar(tv, kind) => { | 512 | &TyKind::InferenceVar(tv, kind) => { |
513 | let inner = tv.to_inner(); | 513 | let inner = tv.to_inner(); |
514 | if tv_stack.contains(&inner) { | 514 | if tv_stack.contains(&inner) { |